MCPcopy Create free account
hub / github.com/PenguLoader/PenguLoader / MainWindow

Class MainWindow

loader/MainWindow.xaml.cs:11–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9namespace PenguLoader
10{
11 public partial class MainWindow : Window
12 {
13 public static MainWindow Instance { get; private set; }
14
15 public MainWindow()
16 {
17 Instance = this;
18 InitializeComponent();
19 ShowInTaskbar = true;
20 WindowStyle = WindowStyle.SingleBorderWindow;
21 Loaded += WindowLoaded;
22 }
23
24 private void WindowLoaded(object sender, RoutedEventArgs e)
25 {
26 Loaded -= WindowLoaded;
27
28 Topmost = true;
29 Show();
30 Topmost = false;
31
32 GC.Collect();
33 Updater.CheckUpdate();
34 }
35
36 private void ThemeButtonClick(object sender, RoutedEventArgs e)
37 {
38 var tm = ThemeManager.Current;
39 var isLight = tm.ApplicationTheme == null
40 ? tm.ActualApplicationTheme == ApplicationTheme.Light
41 : tm.ApplicationTheme == ApplicationTheme.Light;
42
43 tm.ApplicationTheme = isLight
44 ? ApplicationTheme.Dark
45 : ApplicationTheme.Light;
46 }
47
48 protected override void OnSourceInitialized(EventArgs e)
49 {
50 base.OnSourceInitialized(e);
51
52 var hwnd = new WindowInteropHelper(this).EnsureHandle();
53 var source = HwndSource.FromHwnd(hwnd);
54 source.AddHook(new HwndSourceHook(WndProc));
55 }
56
57 private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wp, IntPtr lp, ref bool handled)
58 {
59 if (msg == Native.WM_SHOWME)
60 {
61 if (WindowState == WindowState.Minimized)
62 WindowState = WindowState.Normal;
63
64 if (!IsVisible)
65 Show();
66
67 Activate();
68 handled = true;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected