private void UnsetAsCurrent() { if (CurrentForeground == this) { CurrentForeground = null; } }
public static ControlledWindow Capture(string processName, Action action, bool maximize = true) { var prevProcesses = Process.GetProcessesByName(processName); var prevTitleMap = GetProcessTitleMap(prevProcesses); action(); var processes = Process.GetProcessesByName(processName); var titleMap = GetProcessTitleMap(processes); var diff = DiffMap(prevTitleMap, titleMap).ToArray(); if (diff.Length == 1) { var proc = Process.GetProcessById(diff[0]); var w = new ControlledWindow { Process = proc, ProcessPath = proc.StartInfo.FileName, Arguments = proc.StartInfo.Arguments, MaximizeOnStartup = maximize, Status = Statuses.WindowValid }; w.SwitchToThisWindow(); return(w); } return(null); }
private void SetAsCurrent() { CurrentForeground = this; }