示例#1
0
 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();
     }
 }
示例#2
0
        private void editSelectedWebGrabConfigItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            var userConfig = (GrabConfiguration)gv.GetFocusedRow();

            if (userConfig != null)
            {
                if (!AskQuestion(string.Format("Edit grabbing settings for {0}?", userConfig.Name)))
                {
                    return;
                }
                try
                {
                    var loadConfigCommand = new LoadConfiguration();
                    var configFromDisk    = loadConfigCommand.Execute(userConfig.Path);
                    var frm = new WebGrabConfigForm(configFromDisk.Config, null);
                    if (frm.Edit())
                    {
                        var handle         = gv.FocusedRowHandle;
                        var configurations = (BindingList <GrabConfiguration>)grid.DataSource;
                        var currentIndex   = configurations.IndexOf(userConfig);
                        configurations.Insert(currentIndex, configFromDisk);
                        configurations.Remove(userConfig);
                        gv.FocusedRowHandle = handle;
                        grid.RefreshDataSource();
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(string.Format("Edit failed.{0}{1}", Environment.NewLine, ex.Message), ex);
                    XtraMessageBox.Show(string.Format("Edit failed.{0}{1}", Environment.NewLine, ex.Message), "Error");
                }
                finally
                {
                    SplashManager.CloseSplashScreen();
                }
            }
        }