示例#1
0
 private void Add()
 {
     using (ItemDialog dialog = new ItemDialog())
     {
         DialogResult result = dialog.ShowDialog();
         if (result == DialogResult.OK)
         {
             manager.AddStartupItem(dialog.Item);
             PopulateListView(new List <StartupItem>(manager.GetItems()));
             UpdateUI();
         }
     }
 }
示例#2
0
        private void Edit()
        {
            if (listViewItems.SelectedIndices.Count == 0)
            {
                return;
            }

            // Get the selected index - first is fine as multi-select is off
            int index = listViewItems.SelectedIndices[0];

            StartupItem item = manager.GetItems().ElementAt(index);

            using (ItemDialog dialog = new ItemDialog(item))
            {
                DialogResult result = dialog.ShowDialog();
                if (result == DialogResult.OK)
                {
                    manager.EditStartupItem(item, dialog.Item);
                    PopulateListView(new List <StartupItem>(manager.GetItems()));
                    UpdateUI();
                }
            }
        }