BetterExplorer.MainWindow.LoadInitialWindowPositionAndState C# (CSharp) Method

LoadInitialWindowPositionAndState() private method

Loads initial position of the main window
private LoadInitialWindowPositionAndState ( ) : void
return void
    private void LoadInitialWindowPositionAndState() {
      RegistryKey rk = Registry.CurrentUser;
      RegistryKey rks = rk.OpenSubKey(@"Software\BExplorer", false);

      if (rks == null) return;

      this.Width = Convert.ToDouble(rks.GetValue("LastWindowWidth", "640"));
      this.Height = Convert.ToDouble(rks.GetValue("LastWindowHeight", "480"));

      var location = new System.Drawing.Point();
      try {
        location = new System.Drawing.Point(Convert.ToInt32(rks.GetValue("LastWindowPosLeft", "0")), Convert.ToInt32(rks.GetValue("LastWindowPosTop", "0")));
      } catch { }

      if (location != null) {
        this.Left = location.X;
        this.Top = location.Y;
      }

      switch (Convert.ToInt32(rks.GetValue("LastWindowState"))) {
        case 2:
          this.WindowState = WindowState.Maximized;
          break;
        case 1:
          this.WindowState = WindowState.Minimized;
          break;
        case 0:
          this.WindowState = WindowState.Normal;
          break;
        default:
          this.WindowState = WindowState.Maximized;
          break;
      }

      int isGlassOnRibonMinimized = (int)rks.GetValue("RibbonMinimizedGlass", 1);
      this.IsGlassOnRibonMinimized = isGlassOnRibonMinimized == 1;
      chkRibbonMinimizedGlass.IsChecked = this.IsGlassOnRibonMinimized;

      TheRibbon.IsMinimized = Convert.ToBoolean(rks.GetValue("IsRibonMinimized", false));

      //CommandPrompt window size
      this.CommandPromptWinHeight = Convert.ToDouble(rks.GetValue("CmdWinHeight", 100));
      rCommandPrompt.Height = new GridLength(this.CommandPromptWinHeight);

      if ((int)rks.GetValue("IsConsoleShown", 0) == 1) {
        rCommandPrompt.MinHeight = 100;
        rCommandPrompt.Height = new GridLength(this.CommandPromptWinHeight);
        spCommandPrompt.Height = GridLength.Auto;
      } else {
        rCommandPrompt.MinHeight = 0;
        rCommandPrompt.Height = new GridLength(0);
        spCommandPrompt.Height = new GridLength(0);
      }

      rks.Close();
    }
MainWindow