NOTICE: Significant community changes coming soon
The header menu and the home page on our community will be changing soon. Get more information HERE.
Absent Member.
Absent Member.
908 views

System Parameters get/set

Hi!
I will get and set System Parameters like this in c#:

            this.Top = Properties.Settings.Default.Top;
            this.Left = Properties.Settings.Default.Left;
            this.Height = Properties.Settings.Default.Height;
            this.Width = Properties.Settings.Default.Width;
            this.Closing += MainWindow_Closing;

            // Bildschirmgröße anpassen falls zu klein!
            HOEHE = Convert.ToInt32(System.Windows.SystemParameters.PrimaryScreenHeight);
            BREITE = Convert.ToInt32(System.Windows.SystemParameters.PrimaryScreenWidth);

            if (BREITE < 1200)
            {
                this.Width = SystemParameters.PrimaryScreenWidth;
                this.MaxWidth = SystemParameters.PrimaryScreenWidth;
                this.WindowState = WindowState.Maximized;
            }

            if (HOEHE < 800)
            {
                this.Height = SystemParameters.PrimaryScreenHeight;
                this.MaxHeight = SystemParameters.PrimaryScreenHeight;
                this.WindowState = WindowState.Maximized;
            }

...

        private void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (WindowState == WindowState.Maximized)
            {
                Properties.Settings.Default.Top = RestoreBounds.Top;
                Properties.Settings.Default.Left = RestoreBounds.Left;
                Properties.Settings.Default.Height = RestoreBounds.Height;
                Properties.Settings.Default.Width = RestoreBounds.Width;
            }
            else
            {
                Properties.Settings.Default.Top = this.Top;
                Properties.Settings.Default.Left = this.Left;
                Properties.Settings.Default.Height = this.Height;
                Properties.Settings.Default.Width = this.Width;
            }
            Properties.Settings.Default.Save();
        }

Have anypne an idea for this?

Best Regards

Bernd

Best Regards

Bernd Riemke

0 Likes
1 Reply
Highlighted
Micro Focus Expert
Micro Focus Expert

Hi Bernd,

Something like the following:

 
           set self::Top to type Properties.Settings::Default::Top
           set self::Left to type Properties.Settings::Default::Left
           set self::Height to type Properties.Settings::Default::Height
           set self::Width to type Properties.Settings::Default::Width
           attach method MainWindow_Closing to  self::Closing
           *> Bildschirmgröße anpassen falls zu klein!
           declare HOEHE = type Convert::ToInt32(type System.Windows.SystemParameters::PrimaryScreenHeight)
           declare BREITE = type Convert::ToInt32(type System.Windows.SystemParameters::PrimaryScreenWidth)
           if (BREITE < 1200)
              set self::Width = type SystemParameters::PrimaryScreenWidth
              set self::MaxWidth = type SystemParameters::PrimaryScreenWidth
              set self::WindowState = type WindowState::Maximized
           end-if
           if (HOEHE < 800)
              set self::Height = type SystemParameters::PrimaryScreenHeight
              set self::MaxHeight = type SystemParameters::PrimaryScreenHeight
              set self::WindowState = type WindowState::Maximized
           end-if.
...
       end method.

       method-id MainWindow_Closing.
       procedure division using by value sender as object e as type System.ComponentModel.CancelEventArgs.
       
           if WindowState = type WindowState::Maximized
              set type Properties.Settings::Default::Top = self::RestoreBounds::Top
              set type Properties.Settings::Default::Left = self::RestoreBounds::Left
              set type Properties.Settings::Default::Height = self::RestoreBounds::Height
              set type Properties.Settings::Default::Width = self::RestoreBounds::Width
            else
              set type Properties.Settings::Default::Top = self::Top
              set type Properties.Settings::Default::Left = self::Left
              set type Properties.Settings::Default::Height = self::Height
              set type Properties.Settings::Default::Width = self::Width
            end-if
            invoke type Properties.Settings::Default::Save.

       end method.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.