-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainWindow.xaml.cs
More file actions
55 lines (46 loc) · 1.79 KB
/
Copy pathMainWindow.xaml.cs
File metadata and controls
55 lines (46 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System;
using System.Windows;
using System.Windows.Input;
namespace CoreX
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
this.MouseLeftButtonDown += (s, e) =>
{
if (e.ButtonState == MouseButtonState.Pressed)
DragMove();
};
}
private void SwitchTheme_Click(object sender, RoutedEventArgs e)
{
if (Application.Current.Resources.MergedDictionaries.Count == 0)
{
Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary()
{
Source = new Uri("Themes/LightTheme.xaml", UriKind.Relative)
});
}
var currentTheme = Application.Current.Resources.MergedDictionaries[0].Source.ToString();
var newTheme = currentTheme.Contains("LightTheme")
? new Uri("Themes/DarkTheme.xaml", UriKind.Relative)
: new Uri("Themes/LightTheme.xaml", UriKind.Relative);
Application.Current.Resources.MergedDictionaries.Clear();
Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = newTheme });
var newIconPath = currentTheme.Contains("LightTheme")
? "Assets/light.png"
: "Assets/dark.png";
ThemeIcon.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(newIconPath, UriKind.Relative));
}
private void Minimize_Click(object sender, RoutedEventArgs e)
{
this.WindowState = WindowState.Minimized;
}
private void CloseButton_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
}
}