Пример #1
0
        private void SkinsComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ClearValue(TitlebarHeightProperty);
            MainTabControl.Margin = new Thickness(0);
            MainTabControl.ClearValue(TabControl.BackgroundProperty);

            if (SkinsComboBox.SelectedIndex == 0)
            {
                Application.Current.Resources.MergedDictionaries[0].Source = new Uri("/Mechanism.Wpf.Styles.Shale;component/Themes/Shale.xaml", UriKind.Relative);
                TitlebarHeight = 61;
            }
            if (SkinsComboBox.SelectedIndex == 1)
            {
                Application.Current.Resources.MergedDictionaries[0].Source = new Uri("/Mechanism.Wpf.Styles.Plex;component/Themes/Plex.xaml", UriKind.Relative);
            }
            else if (SkinsComboBox.SelectedIndex == 2)
            {
                Application.Current.Resources.MergedDictionaries[0].Source = new Uri("/Mechanism.Wpf.Styles.EDNA;component/Themes/EDNA.xaml", UriKind.Relative);
                MainTabControl.Margin = new Thickness(15);
            }
            else if (SkinsComboBox.SelectedIndex == 4)
            {
                Application.Current.Resources.MergedDictionaries[0].Source = new Uri("/PresentationFramework.Classic, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, ProcessorArchitecture=MSIL;component/themes/classic.xaml", UriKind.Relative);
                Application.Current.Resources.MergedDictionaries[1].Source = new Uri("/Mechanism.Wpf.Core;component/Themes/Generic.xaml", UriKind.Relative);
                MainTabControl.Background = SystemColors.ActiveBorderBrush;
            }
            else if (SkinsComboBox.SelectedIndex == 5)
            {
                Application.Current.Resources.MergedDictionaries[0].Source = new Uri("/PresentationFramework.Luna, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, ProcessorArchitecture=MSIL;component/themes/luna.normalcolor.xaml", UriKind.Relative);
                Application.Current.Resources.MergedDictionaries[1].Source = new Uri("/Mechanism.Wpf.Core;component/Themes/Luna.NormalColor.xaml", UriKind.Relative);
            }
            else if (SkinsComboBox.SelectedIndex == 6)
            {
                Application.Current.Resources.MergedDictionaries[0].Source = new Uri("/PresentationFramework.Luna, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, ProcessorArchitecture=MSIL;component/themes/luna.homestead.xaml", UriKind.Relative);
                Application.Current.Resources.MergedDictionaries[1].Source = new Uri("/Mechanism.Wpf.Core;component/Themes/Luna.Homestead.xaml", UriKind.Relative);
            }
            else if (SkinsComboBox.SelectedIndex == 7)
            {
                Application.Current.Resources.MergedDictionaries[0].Source = new Uri("/PresentationFramework.Luna, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, ProcessorArchitecture=MSIL;component/themes/luna.metallic.xaml", UriKind.Relative);
                Application.Current.Resources.MergedDictionaries[1].Source = new Uri("/Mechanism.Wpf.Core;component/Themes/Luna.Metallic.xaml", UriKind.Relative);
            }
            else if (SkinsComboBox.SelectedIndex == 7)
            {
                Application.Current.Resources.MergedDictionaries[0].Source = new Uri("/PresentationFramework.Luna, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, ProcessorArchitecture=MSIL;component/themes/luna.metallic.xaml", UriKind.Relative);
                Application.Current.Resources.MergedDictionaries[1].Source = new Uri("/Mechanism.Wpf.Core;component/Themes/Luna.Metallic.xaml", UriKind.Relative);
            }
            else if (SkinsComboBox.SelectedIndex == 8)
            {
                Application.Current.Resources.MergedDictionaries[0].Source = new Uri("/PresentationFramework.Royale, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, ProcessorArchitecture=MSIL;component/themes/royale.normalcolor.xaml", UriKind.Relative);
                Application.Current.Resources.MergedDictionaries[1].Source = new Uri("/Mechanism.Wpf.Core;component/Themes/Royale.NormalColor.xaml", UriKind.Relative);
            }
            else if (SkinsComboBox.SelectedIndex == 9)
            {
                Application.Current.Resources.MergedDictionaries[0].Source = new Uri("/PresentationFramework.Aero, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, ProcessorArchitecture=MSIL;component/themes/aero.normalcolor.xaml", UriKind.Relative);
                Application.Current.Resources.MergedDictionaries[1].Source = new Uri("/Mechanism.Wpf.Core;component/Themes/Aero.NormalColor.xaml", UriKind.Relative);
            }
            else if (SkinsComboBox.SelectedIndex == 10)
            {
                Application.Current.Resources.MergedDictionaries[0].Source = new Uri("/PresentationFramework.Aero2, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, ProcessorArchitecture=MSIL;component/themes/aero2.normalcolor.xaml", UriKind.Relative);
                Application.Current.Resources.MergedDictionaries[1].Source = new Uri("/Mechanism.Wpf.Core;component/Themes/Aero2.NormalColor.xaml", UriKind.Relative);
            }
            else if (SkinsComboBox.SelectedIndex == 11)
            {
                Application.Current.Resources.MergedDictionaries[0].Source = new Uri("/PresentationFramework.AeroLite, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, ProcessorArchitecture=MSIL;component/themes/aerolite.normalcolor.xaml", UriKind.Relative);
                Application.Current.Resources.MergedDictionaries[1].Source = new Uri("/Mechanism.Wpf.Core;component/Themes/Generic.xaml", UriKind.Relative);
            }

            if ((SkinsComboBox.SelectedIndex >= 13) && (SkinsComboBox.SelectedItem is ComboBoxItem item) && (item.Tag is string uri))
            {
                string[] uris = uri.Split("?".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                for (int i = 0; i < uris.Length; i++)
                {
                    if (i < Application.Current.Resources.MergedDictionaries.Count)
                    {
                        Application.Current.Resources.MergedDictionaries[i].Source = new Uri(uris[i], UriKind.RelativeOrAbsolute);
                    }
                    else
                    {
                        Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary()
                        {
                            Source = new Uri(uris[i], UriKind.RelativeOrAbsolute)
                        });
                    }
                }
            }

            //Enable/disable Reveal test tab as needed
            if (SkinsComboBox.SelectedIndex == 1)
            {
                RevealTestTabItem.IsEnabled = true;
            }
            else
            {
                RevealTestTabItem.IsEnabled = false;
            }

            if (SkinsComboBox.SelectedIndex != 2)
            {
                MainTabControl.ClearValue(TabControl.MarginProperty);
            }

            if (LightsToggleSwitch.IsChecked.Value)
            {
                LightsToggleSwitch_Checked(LightsToggleSwitch, null);
            }
            else
            {
                LightsToggleSwitch_Unchecked(LightsToggleSwitch, null);
            }
        }