BetterExplorer.MainWindow.MainWindow C# (CSharp) Method

MainWindow() public method

public MainWindow ( ) : System
return System
    public MainWindow() {
      this.Badges = this.LoadBadgesData();
      this.DataContext = this;

      this.LVItemsColorCol = new ObservableCollectionEx<LVItemColor>();
      this.CommandBindings.AddRange(new[]
      {
            new CommandBinding(AppCommands.RoutedNavigateBack, leftNavBut_Click),
            new CommandBinding(AppCommands.RoutedNavigateFF, rightNavBut_Click),
            new CommandBinding(AppCommands.RoutedNavigateUp, btnUpLevel_Click),
            new CommandBinding(AppCommands.RoutedGotoSearch, GoToSearchBox),
            new CommandBinding(AppCommands.RoutedNewTab, (sender, e) => tcMain.NewTab()),
            new CommandBinding(AppCommands.RoutedEnterInBreadCrumbCombo, (sender, e) => { this._ShellListView.IsFocusAllowed = false; this.bcbc.SetInputState(); }),
            new CommandBinding(AppCommands.RoutedChangeTab, (sender, e) => {
                int selIndex = tcMain.SelectedIndex == tcMain.Items.Count - 1 ? 0 : tcMain.SelectedIndex + 1;
                tcMain.SelectedItem = tcMain.Items[selIndex];
            }),
            new CommandBinding(AppCommands.RoutedCloseTab, (sender, e) => {
                if (tcMain.SelectedIndex == 0 && tcMain.Items.Count == 1) {
                    Close();
                    return;
                }

                int CurSelIndex = tcMain.SelectedIndex;
                tcMain.SelectedItem = tcMain.SelectedIndex == 0 ? tcMain.Items[1] : tcMain.Items[CurSelIndex - 1];
                tcMain.Items.RemoveAt(CurSelIndex);
            })
        });

      RegistryKey rk = Registry.CurrentUser;
      RegistryKey rks = rk.OpenSubKey(@"Software\BExplorer", true);

      // loads current Ribbon color theme
      try {
        var Color = Convert.ToString(rks.GetValue("CurrentTheme", "Blue"));
        switch (Color) {
          case "Blue":
          case "Silver":
          case "Black":
          case "Green":
            ChangeRibbonTheme(Color);
            break;
          case "Metro":
            //ChangeRibbonTheme(Color, true);
            //Do nothing since Metro should be already loaded in App.Startup
            break;
          default:
            ChangeRibbonTheme("Blue");
            break;
        }
      } catch (Exception ex) {
        MessageBox.Show($"An error occurred while trying to load the theme data from the Registry. \n\r \n\r{ex.Message}\n\r \n\rPlease let us know of this issue at http://bugs.gainedge.org/public/betterexplorer", "RibbonTheme Error - " + ex.ToString());
      }

      // loads current UI language (uses en-US if default)
      try {
        //load current UI language in case there is no specified registry value
        var loc = Convert.ToString(rks.GetValue("Locale", ":null:")) == ":null:" ? Thread.CurrentThread.CurrentUICulture.Name : Convert.ToString(rks.GetValue("Locale", ":null:"));
        ((App)Application.Current).SelectCulture(loc, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\BExplorer\\translation.xaml");
      } catch (Exception ex) {
        MessageBox.Show($"An error occurred while trying to load the locale data from the Registry. \n\r \n\r{ex.Message}\n\r \n\rPlease let us know of this issue at http://bugs.gainedge.org/public/betterexplorer", "Locale Load Error - " + ex);
      }

      // gets values from registry to be applied after initialization
      string lohc = Convert.ToString(rks.GetValue("Locale", ":null:"));
      double sbw = Convert.ToDouble(rks.GetValue("SearchBarWidth", "220"));
      string tabba = Convert.ToString(rks.GetValue("TabBarAlignment", "top"));
	  //bool rtlset = Convert.ToString(rks.GetValue("RTLMode", "notset")) != "notset";
	  string RTLMode = Convert.ToString(rks.GetValue("RTLMode", "notset"));
	  
	  rks.Close();
      rk.Close();


      //Main Initialization routine
      InitializeComponent();

      // sets up ComboBox to select the current UI language
      this.TranslationComboBox.SelectedItem = this.TranslationComboBox.Items.OfType<TranslationComboBoxItem>().FirstOrDefault(x => x.LocaleCode == lohc);

      if (RTLMode == "notset") {
		RTLMode = (this.TranslationComboBox.SelectedItem as TranslationComboBoxItem).UsesRTL.ToString();
      }

      this.SearchBarColumn.Width = new GridLength(sbw);

      // prepares RTL mode
      FlowDirection = RTLMode.ToLower() == "true" ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;

      // sets tab bar alignment
      if (tabba == "top")
        TabbaTop.IsChecked = true;
      else if (tabba == "bottom")
        TabbaBottom.IsChecked = true;
      else
        TabbaTop.IsChecked = true;

      // allows user to change language
    }
MainWindow