private void addItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e) { try { var template = settings.LoadDefault(); template.channel.Clear(); var frm = new UserConfigForm(); var grabConfig = frm.Add(template); if (grabConfig != null) { var configurations = (BindingList <GrabConfiguration>)grid.DataSource; configurations.Add(grabConfig); grid.RefreshDataSource(); SetMenusEnabled(); } } catch (Exception ex) { Log.Error(string.Format("Failed to create user configuration.{0}{1}", Environment.NewLine, ex.Message), ex); XtraMessageBox.Show(string.Format("Failed to create user configuration.{0}{1}", Environment.NewLine, ex.Message), "Error"); } finally { SplashManager.CloseSplashScreen(); } }
private void editConfigItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e) { try { if (gv.GetFocusedRow() == null) { return; } var loadConfigCommand = new LoadConfiguration(); var userConfig = (GrabConfiguration)gv.GetFocusedRow(); var configFromDisk = loadConfigCommand.Execute(userConfig.Path); var frm = new UserConfigForm(); var editResult = frm.Edit(configFromDisk); if (editResult != null) { var handle = gv.FocusedRowHandle; var configurations = (BindingList <GrabConfiguration>)grid.DataSource; var currentIndex = configurations.IndexOf(userConfig); configurations.Insert(currentIndex, editResult); configurations.Remove(userConfig); gv.FocusedRowHandle = handle; grid.RefreshDataSource(); } } catch (Exception ex) { Log.Error(string.Format("Failed to edit user configuration.{0}{1}", Environment.NewLine, ex.Message), ex); XtraMessageBox.Show(string.Format("Failed to edit user configuration.{0}{1}", Environment.NewLine, ex.Message), "Error"); } finally { navBarControl.Enabled = true; SplashManager.CloseSplashScreen(); } }