private void InitializeFormFromSettings() { if (this.FormState == FormInitState.Initialized) { return; } this.SetHiddenWindowsView(Runtime.Instance.Settings.CurrentView); this.statusStrip1.Visible = !Runtime.Instance.Settings.HideStatusbar; this.statusStrip1.VisibleChanged += (s, e) => Runtime.Instance.Settings.HideStatusbar = !this.statusStrip1.Visible; Runtime.Instance.Settings.LastState.SetFormState(this); this.Shown += (s, e) => { Runtime.Instance.Store.All(item => { WindowInfo window; if (WindowInfo.TryFind(item, out window) && Runtime.Instance.WindowManager.Register(item.Handle)) { if (item.IsPasswordProtected) { window.Lock(this.UnlockWindow); } if (item.IsHidden) { window.Hide(); } item.RegisterHandlers(window); } }); this.SetToolbarIcons(); this.SetToolbarText(); this.hiddenWindows_SelectedIndexChanged(s, e); if (!Program.IsConfigured) { this.openConfigurationForm_Click(this, EventArgs.Empty); } }; Runtime.Instance.WindowManager.Registered += this.Store_Added; Runtime.Instance.WindowManager.UnRegistered += this.Store_Removed; Runtime.Instance.WindowManager.WindowHidden += (s, e) => this.Notification?.Invoke(this, new NotificationEventArgs("Window Hidden", $"The window '{e.Window.Title}' has been hidden.", NotificationType.General)); Runtime.Instance.WindowManager.WindowShown += (s, e) => this.Notification?.Invoke(this, new NotificationEventArgs("Window Restored", $"The window '{e.Window.Title}' has been restored.", NotificationType.General)); Runtime.Instance.WindowManager.WindowPinned += (s, e) => this.Notification?.Invoke(this, new NotificationEventArgs("Window Pinned", $"The window '{e.Window.Title}' has been pinned.", NotificationType.Info)); Runtime.Instance.WindowManager.WindowUnpinned += (s, e) => this.Notification?.Invoke(this, new NotificationEventArgs("Window Unpinned", $"The window '{e.Window.Title}' has been unpinned.", NotificationType.Info)); this.FormState = FormInitState.Initialized; }
private void InitializeFormHandlers() { if (this.FormState == FormInitState.Initialized) { return; } this.FormState = FormInitState.Initializing; GlobalHotKeyManager.RegisterAll(this.Handle); this.FormClosing += this.Form1_FormClosing; this.hiddenWindows.SelectedIndexChanged += (s, e) => this.Invoke(() => this.show.Enabled = this.hiddenWindows.SelectedItems.Count != 0); this.HiddenWindowsChanged += this.OnHiddenWindowsChanged; this.VisibleChanged += (s, e) => this.Invoke(() => this.notifyIcon.Visible = !this.Visible); }
public FormInitializeEventArgs(FormInitState state) : base() { this.State = state; }
private void InitializeFormHandlers() { if (this.initializing == FormInitState.Initialized) return; this.initializing = FormInitState.Initializing; ExternalReferences.MainHandle = this.Handle; ExternalReferences.RegisterAll(); this.FormClosing += this.Form1_FormClosing; this.hiddenWindows.SelectedIndexChanged += (s, e) => { this.DoInvoke(() => this.show.Enabled = this.hiddenWindows.SelectedItems.Count != 0); }; this.HiddenWindowsChanged += this.OnHiddenWindowsChanged; this.VisibleChanged += (s, e) => { this.DoInvoke(() => this.notifyIcon.Visible = !this.Visible); }; }
private void InitializeFormFromSettings() { if (this.initializing == FormInitState.Initialized) return; this.SetHiddenWindowsView(Runtime.Instance.Settings.CurrentView); this.statusStrip1.Visible = !Runtime.Instance.Settings.HideStatusbar; this.statusStrip1.VisibleChanged += (s, e) => Runtime.Instance.Settings.HideStatusbar = !this.statusStrip1.Visible; Runtime.Instance.Settings.LastState.SetFormState(this); if (Runtime.Instance.Settings.StartInTaskBar) this.Shown += (s, e) => this.MinimizeToTray(); this.Shown += (s, e) => { Runtime.Instance.Store.All(item => { WindowInfo window = WindowInfo.Find(item); if (window.IsValid && Runtime.Instance.WindowManager.Register(item.Handle)) { if (item.IsPasswordProtected) window.Lock(this.UnlockWindow); if (item.IsHidden) window.Hide(); item.RegisterHandlers(window); } }); this.hiddenWindows_SelectedIndexChanged(s, e); this.SetToolbarText(); if (!Program.IsConfigured) this.openConfigurationForm_Click(this, EventArgs.Empty); }; Runtime.Instance.WindowManager.Registered += this.Store_Added; Runtime.Instance.WindowManager.UnRegistered += this.Store_Removed; this.initializing = FormInitState.Initialized; }