private string _lastPresence; // we resend this if the state changes internal MainController(bool isLeague) { _trayIcon = new NotifyIcon { Icon = Resources.deceive, Visible = true, BalloonTipTitle = StartupHandler.DeceiveTitle, BalloonTipText = "Deceive is currently masking your status. Right-Click the tray icon for more options." }; _trayIcon.ShowBalloonTip(5000); // Create overlay and start following the LCU with it. if (isLeague) { var process = Process.GetProcessesByName("LeagueClientUx").First(); _overlay = new LCUOverlay(); _overlay.Show(); _follower = new WindowFollower(_overlay, process); _follower.StartFollowing(); } LoadStatus(); UpdateUI(); }
private async void CreateOverlay() { while (true) { var process = Process.GetProcessesByName("LeagueClientUx").FirstOrDefault(); if (process == null) { await Task.Delay(5000); continue; } _overlay = new LCUOverlay(); _overlay.Show(); _follower = new WindowFollower(_overlay, process); _follower.StartFollowing(); return; } }
private void UpdateUI() { var aboutMenuItem = new MenuItem(StartupHandler.DeceiveTitle) { Enabled = false }; var enabledMenuItem = new MenuItem("Enabled", (a, e) => { _enabled = !_enabled; UpdateStatus(_enabled ? _status : "chat"); UpdateUI(); }) { Checked = _enabled }; var overlayMenuItem = new MenuItem("Show status overlay", (a, e) => { if (_overlay == null) { CreateOverlay(); } else { _follower.Dispose(); _overlay.Close(); _overlay = null; } UpdateUI(); }) { Checked = _overlay != null }; var mucMenuItem = new MenuItem("Enable lobby chat", (a, e) => { _connectToMuc = !_connectToMuc; UpdateUI(); }) { Checked = _connectToMuc }; var offlineStatus = new MenuItem("Offline", (a, e) => { UpdateStatus(_status = "offline"); _enabled = true; UpdateUI(); }) { Checked = _status.Equals("offline") }; var mobileStatus = new MenuItem("Mobile", (a, e) => { UpdateStatus(_status = "mobile"); _enabled = true; UpdateUI(); }) { Checked = _status.Equals("mobile") }; var typeMenuItem = new MenuItem("Status Type", new[] { offlineStatus, mobileStatus }); var quitMenuItem = new MenuItem("Quit", (a, b) => { var result = MessageBox.Show( "Are you sure you want to stop Deceive? This will also stop League if it is running.", StartupHandler.DeceiveTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1 ); if (result != DialogResult.Yes) { return; } Utils.KillClients(); SaveStatus(); Application.Exit(); }); _trayIcon.ContextMenu = new ContextMenu(new[] { aboutMenuItem, enabledMenuItem, typeMenuItem, overlayMenuItem, mucMenuItem, quitMenuItem }); _overlay?.UpdateStatus(_status, _enabled); }