private void MainWindow_Load(object sender, EventArgs e) { ConfigPanel.Visible = false; if (!IsAdmin()) { DialogResult res = MetroMessageBox.Show(this, $"\nGenshinOverlay must be started as Administrator.", "Genshin Overlay - Error", MessageBoxButtons.OK, Theme, MessageBoxDefaultButton.Button1, 135); if (res == DialogResult.OK) { Environment.Exit(0); } } Config.Load(); Theme = (MetroThemeStyle)Config.ConfigTheme; MStyleManager.Theme = (MetroThemeStyle)Config.ConfigTheme; OverlayWindow = new OverlayWindow(); WinHook = new WindowHook(Config.ProcessName); WinHook.WindowHandleChanged += WinHook_WindowHandleChanged; KeyHook = new KeyboardHook(new List <Keys>() { Keys.E }); KeyHook.KeyUp += KeyHook_KeyUp; if (Config.CooldownTextLocation == Point.Empty || Config.PartyNumLocations["4 #1"] == Point.Empty) { ConfigureOverlayMessage.Visible = true; ConfigureOverlayButton.Location = new Point(ConfigureOverlayButton.Location.X, ConfigureOverlayButton.Location.Y + 20); } else { ConfigureOverlayMessage.Visible = false; } Activate(); FocusMe(); }
private void MainWindow_Load(object sender, EventArgs e) { if (!IsAdmin()) { DialogResult res = MetroMessageBox.Show(this, $"\nGenshinOverlay must be started as Administrator.", "Genshin Overlay - Error", MessageBoxButtons.OK, MessageBoxIcon.Error, 135); if (res == DialogResult.OK) { Environment.Exit(0); } } Config.Load(); Theme = (MetroThemeStyle)Config.ConfigTheme; MStyleManager.Theme = (MetroThemeStyle)Config.ConfigTheme; OverlayWindow = new OverlayWindow(); WinHook = new WindowHook(Config.ProcessName); WinHook.WindowHandleChanged += WinHook_WindowHandleChanged; KeyHook = new KeyboardHook(new List <Keys>() { Keys.E }); KeyHook.KeyUp += KeyHook_KeyUp; Controller = new Controller(UserIndex.One); if (Controller.IsConnected) { new Thread(() => { while (true) { Thread.Sleep(100); ControllerStateOld = ControllerStateNew; ControllerStateNew = Controller.GetState(); if (OverlayWindow.GenshinHandle == IntPtr.Zero) { continue; } if (Config.CooldownTextLocation == Point.Empty || Config.PartyNumLocations["4 #1"] == Point.Empty) { continue; } if (ControllerStateOld.Gamepad.RightTrigger < ControllerStateNew.Gamepad.RightTrigger) { SkillKeyPressed(); } } }).Start(); } if (Config.CooldownTextLocation == Point.Empty || Config.PartyNumLocations["4 #1"] == Point.Empty) { // ConfigureOverlayMessage.Visible = true; // ConfigureOverlayButton.Location = new Point(ConfigureOverlayButton.Location.X, ConfigureOverlayButton.Location.Y + 20); } else { // ConfigureOverlayMessage.Visible = false; } Activate(); FocusMe(); }