public void AddNewSwitchProfile(SwitchProfile.SwitchType switchType, string windowTitle, int monitorToSwitchTo, int delay) { profiles.Add(new SwitchProfile(switchType, windowTitle, monitorToSwitchTo, delay)); }
private void RefreshSummaryText(SwitchProfile profile) { lblSummary.Text = ""; lblSummary.Text += "The currently selected rule will "; if(profile.Type == SwitchProfile.SwitchType.SWITCH_WINDOW) { lblSummary.Text += "move the window \""; lblSummary.Text += profile.WindowTitle + "\" to Monitor " + (profile.MonitorToSwitchTo + 1) + " - " + DisplaySwitcher.GetInstance().GetDeviceName(profile.MonitorToSwitchTo); lblSummary.Text += " and make it emulate full screen, whenever the window is opened."; } else { lblSummary.Text += "make Monitor " + (profile.MonitorToSwitchTo + 1) + " - \"" + DisplaySwitcher.GetInstance().GetDeviceName(profile.MonitorToSwitchTo); lblSummary.Text += "\" the primary monitor when \"" + profile.WindowTitle + "\" opens. When the window \"" + profile.WindowTitle + "\" closes, "; lblSummary.Text += "the primary monitor will be reset after a " + profile.Delay + " ms delay."; } }
public void UpdateSwitchProfile(int index, SwitchProfile.SwitchType switchType, string windowTitle, int monitorToSwitchTo, int delay) { profiles[index] = new SwitchProfile(switchType, windowTitle, monitorToSwitchTo, delay); }
void CreateDisplaySwitchThread(WinHookEventArgs e, SwitchProfile p) { switch (e.type) { case (Interop.ShellEvents.HSHELL_WINDOWCREATED): { Thread switchMon; WriteDebugMessage("Window Created. SwitchType: " + p.Type.ToString()); switch (p.Type) { case (SwitchProfile.SwitchType.SWITCH_MONITOR): { DisplaySwitcher.GetInstance().RefreshPrimaryDisplay(); switchMon = new System.Threading.Thread(() => DisplaySwitcher.GetInstance().SetPrimaryDisplay(p.MonitorToSwitchTo)); switchMon.Start(); break; } case (SwitchProfile.SwitchType.SWITCH_WINDOW): { switchMon = new System.Threading.Thread(() => MoveWindow(p.WindowTitle, p.MonitorToSwitchTo)); switchMon.Start(); break; } } break; } case (Interop.ShellEvents.HSHELL_WINDOWDESTROYED): { if (p.Type == SwitchProfile.SwitchType.SWITCH_MONITOR) { Thread processSwitch = new System.Threading.Thread(() => DelayedSwitch(p.Delay, DisplaySwitcher.GetInstance().PrimaryMonitor)); processSwitch.Start(); } break; } } }