/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

  1. using System;
  2. using System.Collections;
  3. using System.Reflection;
  4. using System.Windows;
  5. using System.Windows.Input;
  6. namespace MetroDemo
  7. {
  8. public partial class MainWindow
  9. {
  10. public MainWindow()
  11. {
  12. InitializeComponent();
  13. }
  14. private void WindowMouseDown(object sender, MouseButtonEventArgs e)
  15. {
  16. if (e.RightButton != MouseButtonState.Pressed && e.MiddleButton != MouseButtonState.Pressed)
  17. DragMove();
  18. }
  19. private void BtnMinClick(object sender, RoutedEventArgs e)
  20. {
  21. WindowState = WindowState.Minimized;
  22. }
  23. private void BtnCloseClick(object sender, RoutedEventArgs e)
  24. {
  25. Application.Current.Shutdown();
  26. }
  27. private void BtnMaxClick(object sender, RoutedEventArgs e)
  28. {
  29. WindowState = WindowState == WindowState.Normal ? WindowState.Maximized : WindowState.Normal;
  30. }
  31. private void MiDarkRed(object sender, RoutedEventArgs e)
  32. {
  33. var redRd = new ResourceDictionary();
  34. var darkRd = new ResourceDictionary();
  35. redRd.Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/Red.xaml");
  36. darkRd.Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseDark.xaml");
  37. ApplyResourceDictionary(redRd);
  38. ApplyResourceDictionary(darkRd);
  39. }
  40. private void MiLightGreen(object sender, RoutedEventArgs e)
  41. {
  42. var greenRd = new ResourceDictionary();
  43. var lightRd = new ResourceDictionary();
  44. greenRd.Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/Green.xaml");
  45. lightRd.Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml");
  46. ApplyResourceDictionary(greenRd);
  47. ApplyResourceDictionary(lightRd);
  48. }
  49. private void ApplyResourceDictionary(ResourceDictionary rd)
  50. {
  51. foreach (DictionaryEntry r in rd)
  52. {
  53. if (Resources.Contains(r.Key))
  54. Resources.Remove(r.Key);
  55. Resources.Add(r.Key, r.Value);
  56. }
  57. }
  58. private void Button_Click(object sender, RoutedEventArgs e)
  59. {
  60. pb.IsIndeterminate = !pb.IsIndeterminate;
  61. }
  62. private void MiLightRed(object sender, RoutedEventArgs e)
  63. {
  64. var accentRd = new ResourceDictionary();
  65. var themeRd = new ResourceDictionary();
  66. accentRd.Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/Red.xaml");
  67. themeRd.Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml");
  68. ApplyResourceDictionary(accentRd);
  69. ApplyResourceDictionary(themeRd);
  70. }
  71. private void MiLightBlue(object sender, RoutedEventArgs e)
  72. {
  73. var accentRd = new ResourceDictionary();
  74. var themeRd = new ResourceDictionary();
  75. accentRd.Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml");
  76. themeRd.Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml");
  77. ApplyResourceDictionary(accentRd);
  78. ApplyResourceDictionary(themeRd);
  79. }
  80. private void MiLightPurple(object sender, RoutedEventArgs e)
  81. {
  82. var accentRd = new ResourceDictionary();
  83. var themeRd = new ResourceDictionary();
  84. accentRd.Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/Purple.xaml");
  85. themeRd.Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml");
  86. ApplyResourceDictionary(accentRd);
  87. ApplyResourceDictionary(themeRd);
  88. }
  89. private void MiDarkBlue(object sender, RoutedEventArgs e)
  90. {
  91. var accentRd = new ResourceDictionary();
  92. var themeRd = new ResourceDictionary();
  93. accentRd.Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml");
  94. themeRd.Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseDark.xaml");
  95. ApplyResourceDictionary(accentRd);
  96. ApplyResourceDictionary(themeRd);
  97. }
  98. private void MiDarkGreen(object sender, RoutedEventArgs e)
  99. {
  100. var accentRd = new ResourceDictionary();
  101. var themeRd = new ResourceDictionary();
  102. accentRd.Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/Green.xaml");
  103. themeRd.Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseDark.xaml");
  104. ApplyResourceDictionary(accentRd);
  105. ApplyResourceDictionary(themeRd);
  106. }
  107. private void MiDarkPurple(object sender, RoutedEventArgs e)
  108. {
  109. var accentRd = new ResourceDictionary();
  110. var themeRd = new ResourceDictionary();
  111. accentRd.Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/Purple.xaml");
  112. themeRd.Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseDark.xaml");
  113. ApplyResourceDictionary(accentRd);
  114. ApplyResourceDictionary(themeRd);
  115. }
  116. }
  117. }