예제 #1
0
        private void btnAddApp_Click(object sender, EventArgs e)
        {
            using (var frm = new EditAppForm(Controller.IntentStore))
            {
                var result = frm.ShowDialog();

                if (result != DialogResult.OK)
                {
                    return;
                }

                var    appPath = frm.AppPath;
                ExeApp found;

                if (Controller.IntentStore.TryGetExeApp(appPath, out found))
                {
                    HighlightAppInList(found);
                }
                else
                {
                    var app = new OrderableExeApp()
                    {
                        ExecutablePath = appPath, Name = frm.AppName, Order = 1
                    };

                    AddAppToList(app);
                    HighlightAppInList(app);
                    Controller.IntentStore.Add(app);
                }
            }
        }
예제 #2
0
        private void EditSelectedApp()
        {
            if (listApps.SelectedIndices.Count != 1 || listApps.SelectedIndices[0] == 0)
            {
                return;
            }

            var sel   = listApps.SelectedItems[0];
            var found = (OrderableExeApp)Controller.IntentStore.GetExeApp((listApps.SelectedItems[0].Tag as ExeApp).ExecutablePath);

            using (var frm = new EditAppForm(found, Controller.IntentStore))
            {
                var ret = frm.ShowDialog();

                if (ret == DialogResult.OK)
                {
                    if (frm.AppPath.Equals(found.ExecutablePath))
                    {
                        found.Name = frm.AppName;

                        sel.Text = found.Name;

                        if (!found.AppExists())
                        {
                            sel.Text += "(不存在)";
                        }

                        labelAppName.Text = sel.Text;
                    }
                    else
                    {
                        ExeApp existed;
                        if (Controller.IntentStore.TryGetExeApp(frm.AppPath, out existed))
                        {
                            HighlightAppInList(existed);
                        }
                        else
                        {
                            RemoveSelectedAppFromList();

                            Controller.IntentStore.Remove(found.ExecutablePath);

                            found.ExecutablePath = frm.AppPath;
                            found.Name           = frm.AppName;

                            Controller.IntentStore.Add(found);

                            AddAppToList(found);
                        }
                    }
                }
            }
        }
예제 #3
0
        private void EditSelectedApp()
        {
            if (listApps.SelectedIndices.Count != 1 || listApps.SelectedIndices[0] == 0)
            {
                return;
            }

            var sel = listApps.SelectedItems[0];
            var found = (OrderableExeApp) Controller.IntentStore.GetExeApp((listApps.SelectedItems[0].Tag as ExeApp).ExecutablePath);

            using (var frm = new EditAppForm(found, Controller.IntentStore))
            {
                var ret = frm.ShowDialog();

                if (ret == DialogResult.OK)
                {
                    if (frm.AppPath.Equals(found.ExecutablePath))
                    {
                        found.Name = frm.AppName;

                        sel.Text = found.Name;

                        if (!found.AppExists()) sel.Text += "(不存在)";

                        labelAppName.Text = sel.Text;
                    }
                    else
                    {
                        ExeApp existed;
                        if (Controller.IntentStore.TryGetExeApp(frm.AppPath, out existed))
                        {
                            HighlightAppInList(existed);
                        }
                        else
                        {
                            RemoveSelectedAppFromList();

                            Controller.IntentStore.Remove(found.ExecutablePath);

                            found.ExecutablePath = frm.AppPath;
                            found.Name = frm.AppName;

                            Controller.IntentStore.Add(found);

                            AddAppToList(found);
                        }


                    }
                }


            }
        }
예제 #4
0
        private void btnAddApp_Click(object sender, EventArgs e)
        {
            using (var frm = new EditAppForm(Controller.IntentStore))
            {
                var result = frm.ShowDialog();

                if (result != DialogResult.OK) return;

                var appPath = frm.AppPath;
                ExeApp found;

                if (Controller.IntentStore.TryGetExeApp(appPath, out found))
                {
                    HighlightAppInList(found);
                }
                else
                {
                    var app = new OrderableExeApp() { ExecutablePath = appPath, Name = frm.AppName, Order = 1}; 
                    
                    AddAppToList(app);
                    HighlightAppInList(app);
                    Controller.IntentStore.Add(app);
                }
            }
        }