/// <summary> /// Gets a list of active windows sorted on the /// indcated sort order /// </summary> /// <param name="order">sort order</param> /// <returns>sorted list</returns> private List <EnumWindows.WindowInfo> getWindowList(SortOrder order) { var processName = FilterByProcessName.Trim(); var windowList = EnumWindows.Enumerate(); if (!String.IsNullOrEmpty(processName)) { var filteredList = new List <EnumWindows.WindowInfo>(); for (int ii = 0; ii < windowList.Count; ii++) { var process = WindowActivityMonitor.GetProcessForWindow(windowList[ii].Handle); if (String.Compare(process.ProcessName, FilterByProcessName, true) == 0) { filteredList.Add(windowList[ii]); } } windowList = filteredList; } var sortedList = sortWindowList(windowList, order); if (String.IsNullOrEmpty(processName)) { IntPtr desktopHWnd = User32Interop.GetDesktopWindow(); if (desktopHWnd != null) { sortedList.Insert(0, new EnumWindows.WindowInfo(desktopHWnd, R.GetString("ShowDesktop"))); } } return(sortedList); }
/// <summary> /// Form has been loaded /// </summary> private void TaskSwitcherForm_Load(object sender, EventArgs e) { Log.Debug(); dtlp.Show(); _dialogCommon.OnLoad(); subscribeToEvents(); var windowList = EnumWindows.Enumerate(); if (!String.IsNullOrEmpty(FilterProcessName)) { List <EnumWindows.WindowInfo> filteredList = new List <EnumWindows.WindowInfo>(); for (int ii = 0; ii < windowList.Count; ii++) { Process process = WindowActivityMonitor.GetProcessForWindow(windowList[ii].Handle); if (String.Compare(process.ProcessName, FilterProcessName, true) == 0) { filteredList.Add(windowList[ii]); } } windowList = filteredList; } else { Log.Debug("list count=" + windowList.Count); IntPtr desktopHWnd = User32Interop.GetDesktopWindow(); Log.Debug("desktopHWnd=" + desktopHWnd.ToString()); if (desktopHWnd != null) { windowList.Insert(0, new EnumWindows.WindowInfo(desktopHWnd, "Show Desktop")); } } PopulateTLP(windowList); Windows.SetWindowPosition(this, Windows.WindowPosition.CenterScreen); _dialogCommon.GetAnimationManager().Start(_dialogCommon.GetRootWidget()); Log.Debug("returning"); }