public void Initialize(LayoutType tabType, string name) { _name = name; TabType = tabType; if (TabType == LayoutType.Layout) { NewTabBtnVisibility = Visibility.Collapsed; RemoveTabBtnVisibility = Visibility.Visible; SelectedApps = new List <AppInfo>(GridSize.CellCount); for (int i = 0; i < GridSize.CellCount; i++) { SelectedApps.Add(AppInfo.GetEmptyAppInfo()); } } else if (tabType == LayoutType.CreateNewTab) //new tab button - should not be serialized { NewTabBtnVisibility = Visibility.Visible; RemoveTabBtnVisibility = Visibility.Collapsed; } else if (TabType == LayoutType.Serializable) { //tabs config from serialization NewTabBtnVisibility = Visibility.Collapsed; RemoveTabBtnVisibility = Visibility.Visible; TabType = LayoutType.Layout; //loaded from serialization } }
private void UpdateUI() { if (HasSelection) { //btnRun.ToolTip = "Open " + SelectedApp.ProcessName; //btnRun.IsEnabled = File.Exists(SelectedApp.ProcessPath); mnuRun.IsEnabled = File.Exists(SelectedApp.ProcessPath); mnuMinimize.IsEnabled = SelectedApp.IsActive; mnuRestore.IsEnabled = SelectedApp.IsActive; DisplayConfiguration[Row, Col] = SelectedApp; } else { //btnRun.ToolTip = ""; //btnRun.IsEnabled = false; mnuRun.IsEnabled = false; mnuMinimize.IsEnabled = false; mnuRestore.IsEnabled = false; imagePreview.Source = null; txtInfo.Content = "? Select Window ?"; DisplayConfiguration[Row, Col] = AppInfo.GetEmptyAppInfo(); } }
public void UpdateApps(GridSizeData newGridSize) { if (SelectedApps.Count == _gridSize.CellCount) { if (newGridSize.Rows != _gridSize.Rows || newGridSize.Cols != _gridSize.Cols) { //init List <AppInfo> list = new List <AppInfo>(); for (int i = 0; i < newGridSize.CellCount; i++) { list.Add(AppInfo.GetEmptyAppInfo()); } //smart copy for (int row = 0; row < _gridSize.Rows; row++) //copy maximum possible settings { for (int col = 0; col < _gridSize.Cols; col++) { if (row < newGridSize.Rows && col < newGridSize.Cols) { int index = newGridSize.Pos(row, col); list[index] = this[row, col]; } } } SelectedApps = list; } } else if (SelectedApps.Count > 0) { List <AppInfo> list = new List <AppInfo>(); for (int i = 0; i < newGridSize.CellCount; i++) { list.Add(AppInfo.GetEmptyAppInfo()); } //smart copy for (int row = 0; row < _gridSize.Rows; row++) //copy maximum possible settings { for (int col = 0; col < _gridSize.Cols; col++) { if (row < newGridSize.Rows && col < newGridSize.Cols) { int index = newGridSize.Pos(row, col); if (index < SelectedApps.Count) { list[index] = SelectedApps[index]; } } } } SelectedApps = list; } _gridSize = newGridSize; }
private AppInfo FindAppInCombo(AppInfo a) { foreach (AppInfo item in cmbApps.Items) { if (a.Title == item.Title) { return(item); } } return(AppInfo.GetEmptyAppInfo()); }
public AppInfo this[int row, int col] { get { return(SelectedApps[GridSize.Pos(row, col)]); } set { AppInfo info = value; if (info == null) { info = AppInfo.GetEmptyAppInfo(); } int pos = GridSize.Pos(row, col); SelectedApps[pos] = info; SelectedApps[pos].Row = row; SelectedApps[pos].Col = col; } }
public static List <AppInfo> GetAppsWithUI() { List <AppInfo> apps = new List <AppInfo>(); apps.AddRange(EnumOpenWindows.GetOpenWindows().Select(w => new AppInfo(w))); apps.Sort((a1, a2) => string.Compare(a1.ProcessName, a2.ProcessName, true)); apps.Insert(0, AppInfo.GetEmptyAppInfo()); //Process[] processes = Process.GetProcesses(); //List<Process> pp = processes.Where(p => !string.IsNullOrEmpty(p.MainWindowTitle)).ToList(); //pp = processes.Where(p => p.MainWindowHandle != IntPtr.Zero).ToList(); //foreach (Process p in pp) // apps.Add(new AppInfo(p)); return(apps); //new ObservableCollection<AppInfo>(apps); }