private static void UndockFromPanel(ref SystemWindow systemWindow) { systemWindow.UndockFromPanel(); if (Settings.Instance.EnableLogger) Logger.Debug("(MainForm - UndockFromPanel) Maximizing window after undocking."); systemWindow.Maximize(); systemWindow = null; }
private void DockToPanel(SystemWindow systemWindow, PanelEnum panel) { if (Settings.Instance.EnableLogger) Logger.Debug("(MainForm - DockToPanel) Docking window: {0}.", systemWindow.FullName); if (Settings.Instance.EnableLogger) Logger.Debug("(MainForm - DockToPanel) Maximizing window."); if (systemWindow.Parent != null && systemWindow.Parent.IsMinimized) { if (Settings.Instance.EnableLogger) Logger.Debug("(MainForm - DockToPanel) Maximizing parent for Delphi applications."); systemWindow.Parent.Restore(); } else { systemWindow.Restore(); } systemWindow.Maximize(); switch (panel) { case PanelEnum.First: if (Settings.Instance.EnableLogger) Logger.Debug("(MainForm - DockToPanel) Docking first window: {0}.", systemWindow.FullName); systemWindow.DockToPanel(splitContainerApps.Panel1); if (_firstEventAssigned == false) { splitContainerApps.Panel1.SizeChanged += systemWindow.PanelSizeChanged; _firstEventAssigned = true; } break; case PanelEnum.Second: if (Settings.Instance.EnableLogger) Logger.Debug("(MainForm - DockToPanel) Docking second window: {0}.", systemWindow.FullName); systemWindow.DockToPanel(splitContainerApps.Panel2); if (_secondEventAssigned == false) { splitContainerApps.Panel2.SizeChanged += systemWindow.PanelSizeChanged; _secondEventAssigned = true; } break; } systemWindow.PanelSizeChanged(panel == PanelEnum.First ? splitContainerApps.Panel1 : splitContainerApps.Panel2, new EventArgs()); if (Settings.Instance.EnableLogger) Logger.Debug("(MainForm - DockToPanel) Docking windows ends."); }
private void DockingSavedWindows(Window window, PanelEnum panelEnum) { if (window == null) return; var w = new SystemWindow(window.ClassName, window.Title); if (Settings.Instance.EnableLogger) Logger.Debug("(MainForm - DockingSavedWindows) Window exists: {0}", w.Exists); if (!w.Exists) return; DockToPanel(w, panelEnum); switch (panelEnum) { case PanelEnum.First: _firstWindow = w; break; case PanelEnum.Second: _secondWindow = w; break; } }
public ApplicationList(SystemWindow firstWindow, SystemWindow secondWindow) { InitializeComponent(); if (Settings.Instance.EnableLogger) Logger.Debug("(ApplicationList - Constructor) Loading form."); FirstWindow = firstWindow; SecondWindow = secondWindow; labelDockedApp1.Text = FirstWindow == null ? "(pusto)" : FirstWindow.FullName; labelDockedApp2.Text = SecondWindow == null ? "(pusto)" : SecondWindow.FullName; if (Settings.Instance.EnableLogger) { Logger.Debug("(ApplicationList - Constructor) Previously docked first window: {0}.", labelDockedApp1.Text); Logger.Debug("(ApplicationList - Constructor) Previously docked second window: {0}.", labelDockedApp2.Text); } listBoxOfApps.ValueMember = "Hwnd"; listBoxOfApps.DisplayMember = "FullName"; }
private void ToolStripMenuItemApplicationListClick(object sender, EventArgs e) { if (Settings.Instance.EnableLogger) Logger.Debug("(MainForm - ToolStripMenuItemApplicationListClick) Application menu click."); var appsList = new ApplicationList(_firstWindow, _secondWindow); if (appsList.ShowDialog() != DialogResult.OK) return; if (Settings.Instance.EnableLogger) Logger.Debug("(MainForm - ToolStripMenuItemApplicationListClick) Saving configuration."); Settings.Instance.Save(ConvertToPercentage(splitContainerApps.SplitterDistance, splitContainerApps.Width)); _firstWindow = appsList.FirstWindow; _secondWindow = appsList.SecondWindow; if (Settings.Instance.EnableLogger) { Logger.Debug("(MainForm - ToolStripMenuItemApplicationListClick) Selected first window: {0}", _firstWindow == null ? "(empty)" : _firstWindow.FullName); Logger.Debug("(MainForm - ToolStripMenuItemApplicationListClick) Selected second window: {0}", _secondWindow == null ? "(empty)" : _secondWindow.FullName); } if (_firstWindow != null) { DockToPanel(_firstWindow, PanelEnum.First); } if (_secondWindow != null) { DockToPanel(_secondWindow, PanelEnum.Second); } }
private void ButtonCleanDockClick(object sender, EventArgs e) { if (Settings.Instance.EnableLogger) Logger.Debug("(ApplicationList - ButtonCleanDockClick) Clean dockings click."); if (FirstWindow != null && FirstWindow.Docked) { FirstWindow.UndockFromPanel(); } if (SecondWindow != null && SecondWindow.Docked) { SecondWindow.UndockFromPanel(); } FirstWindow = SecondWindow = null; labelDockedApp1.Text = labelDockedApp2.Text = @"(pusto)"; }
private void SetProcessAndLabel(Control label, PanelEnum panelEnum) { if (listBoxOfApps.SelectedItem == null) return; var selectedItem = (SystemWindow)listBoxOfApps.SelectedItem; if (Settings.Instance.EnableLogger) Logger.Debug("(ApplicationList - SetProcessAndLabel) Preparing app to dock ({0})", selectedItem.FullName); switch (panelEnum) { case PanelEnum.First: if (!selectedItem.Equals(SecondWindow)) { FirstWindow = (SystemWindow)listBoxOfApps.SelectedItem; label.Text = FirstWindow.FullName; } break; case PanelEnum.Second: if (!selectedItem.Equals(FirstWindow)) { SecondWindow = (SystemWindow)listBoxOfApps.SelectedItem; label.Text = SecondWindow.FullName; } break; } }