Skip to main content

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

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

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.