コード例 #1
0
        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
            }
        }
コード例 #2
0
        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();
            }
        }
コード例 #3
0
        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;
        }
コード例 #4
0
 private AppInfo FindAppInCombo(AppInfo a)
 {
     foreach (AppInfo item in cmbApps.Items)
     {
         if (a.Title == item.Title)
         {
             return(item);
         }
     }
     return(AppInfo.GetEmptyAppInfo());
 }
コード例 #5
0
        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;
            }
        }
コード例 #6
0
        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);
        }