void AppEdit() { var group_name = comboBox_Group.Text; if (listView_Apps.SelectedItems.Count > 0) { var item = listView_Apps.SelectedItems[0]; var app_name = item.Text; var app = GetAppObject(group_name, app_name); var Form = new AppEditorForm(); Form.ConfigData = app; var result = Form.ShowDialog(); if (result == DialogResult.OK) { app = Form.ConfigData; // // Add to UI // item.SubItems[0].Text = app.Name; item.SubItems[1].Text = app.Target; item.SubItems[2].Text = app.Args; } } else { MessageBox.Show("SelectedItems not found", "ERROR"); } }
void AppAdd() { dynamic app = new ExpandoObject(); var group_name = comboBox_Group.Text; if (listView_Apps.SelectedItems.Count > 0) { var item = listView_Apps.SelectedItems[0]; var app_name = item.Text; app = GetAppObject(group_name, app_name); app = DeepCopy(app); } var Form = new AppEditorForm(); Form.ConfigData = app; var result = Form.ShowDialog(); if (result == DialogResult.OK) { app = Form.ConfigData; var match_item = listView_Apps.FindItemWithText(app.Name); if (match_item == null) // Add if not found // // Add to UI // { ListViewItem item = new ListViewItem(app.Name); item.SubItems.Add(app.Target); item.SubItems.Add(app.Args); listView_Apps.Items.Add(item); // // Add to Config // string gname = comboBox_Group.Text; object value; bool st; var gdict = (IDictionary <string, object>)ConfigData.Group; st = gdict.TryGetValue(gname, out value); List <dynamic> apps = (List <dynamic>)value; apps.Add(app); } else { MessageBox.Show("Data already exists", "ERROR"); } } }