PageRenderTime 138ms CodeModel.GetById 76ms app.highlight 4ms RepoModel.GetById 57ms app.codeStats 0ms

/MetroDemo/MainWindow.xaml.cs

https://bitbucket.org/aeoth/mahapps.metro/
C# | 160 lines | 117 code | 43 blank | 0 comment | 6 complexity | 5dc4f6e186d4ce2683bdcb632d088292 MD5 | raw file
  1using System;
  2using System.Collections;
  3using System.Reflection;
  4using System.Windows;
  5using System.Windows.Input;
  6
  7namespace MetroDemo
  8{
  9    public partial class MainWindow
 10    {
 11        public MainWindow()
 12        {
 13            InitializeComponent();
 14        }
 15
 16        private void WindowMouseDown(object sender, MouseButtonEventArgs e)
 17        {
 18            if (e.RightButton != MouseButtonState.Pressed && e.MiddleButton != MouseButtonState.Pressed)
 19                DragMove();
 20        }
 21
 22        private void BtnMinClick(object sender, RoutedEventArgs e)
 23        {
 24            WindowState = WindowState.Minimized;
 25        }
 26
 27        private void BtnCloseClick(object sender, RoutedEventArgs e)
 28        {
 29            Application.Current.Shutdown();
 30        }
 31
 32        private void BtnMaxClick(object sender, RoutedEventArgs e)
 33        {
 34            WindowState = WindowState == WindowState.Normal ? WindowState.Maximized : WindowState.Normal;
 35        }
 36
 37
 38        private void MiDarkRed(object sender, RoutedEventArgs e)
 39        {
 40            var redRd = new ResourceDictionary();
 41            var darkRd = new ResourceDictionary();
 42
 43            redRd.Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/Red.xaml");
 44            darkRd.Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseDark.xaml");
 45
 46
 47            ApplyResourceDictionary(redRd);
 48            ApplyResourceDictionary(darkRd);
 49            
 50
 51        }
 52
 53        private void MiLightGreen(object sender, RoutedEventArgs e)
 54        {
 55            var greenRd = new ResourceDictionary();
 56            var lightRd = new ResourceDictionary();
 57
 58            greenRd.Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/Green.xaml");
 59            lightRd.Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml");
 60
 61
 62            ApplyResourceDictionary(greenRd);
 63            ApplyResourceDictionary(lightRd);
 64        }
 65
 66        private void ApplyResourceDictionary(ResourceDictionary rd)
 67        {
 68            foreach (DictionaryEntry r in rd)
 69            {
 70                if (Resources.Contains(r.Key))
 71                    Resources.Remove(r.Key);
 72
 73                Resources.Add(r.Key, r.Value);
 74            }
 75        }
 76
 77        private void Button_Click(object sender, RoutedEventArgs e)
 78        {
 79            pb.IsIndeterminate = !pb.IsIndeterminate;
 80        }
 81
 82        private void MiLightRed(object sender, RoutedEventArgs e)
 83        {
 84            var accentRd = new ResourceDictionary();
 85            var themeRd = new ResourceDictionary();
 86
 87            accentRd.Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/Red.xaml");
 88            themeRd.Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml");
 89
 90
 91            ApplyResourceDictionary(accentRd);
 92            ApplyResourceDictionary(themeRd);
 93        }
 94
 95        private void MiLightBlue(object sender, RoutedEventArgs e)
 96        {
 97            var accentRd = new ResourceDictionary();
 98            var themeRd = new ResourceDictionary();
 99
100            accentRd.Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml");
101            themeRd.Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml");
102
103
104            ApplyResourceDictionary(accentRd);
105            ApplyResourceDictionary(themeRd);
106        }
107
108        private void MiLightPurple(object sender, RoutedEventArgs e)
109        {
110            var accentRd = new ResourceDictionary();
111            var themeRd = new ResourceDictionary();
112
113            accentRd.Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/Purple.xaml");
114            themeRd.Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml");
115
116
117            ApplyResourceDictionary(accentRd);
118            ApplyResourceDictionary(themeRd);
119        }
120
121        private void MiDarkBlue(object sender, RoutedEventArgs e)
122        {
123            var accentRd = new ResourceDictionary();
124            var themeRd = new ResourceDictionary();
125
126            accentRd.Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml");
127            themeRd.Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseDark.xaml");
128
129
130            ApplyResourceDictionary(accentRd);
131            ApplyResourceDictionary(themeRd);
132        }
133
134        private void MiDarkGreen(object sender, RoutedEventArgs e)
135        {
136            var accentRd = new ResourceDictionary();
137            var themeRd = new ResourceDictionary();
138
139            accentRd.Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/Green.xaml");
140            themeRd.Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseDark.xaml");
141
142
143            ApplyResourceDictionary(accentRd);
144            ApplyResourceDictionary(themeRd);
145        }
146
147        private void MiDarkPurple(object sender, RoutedEventArgs e)
148        {
149            var accentRd = new ResourceDictionary();
150            var themeRd = new ResourceDictionary();
151
152            accentRd.Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/Purple.xaml");
153            themeRd.Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseDark.xaml");
154
155
156            ApplyResourceDictionary(accentRd);
157            ApplyResourceDictionary(themeRd);
158        }
159    }
160}