Пример #1
0
 private void editWebgrabConfigItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
 {
     if (settings.WorkingDirectoryConfigExists)
     {
         if (!AskQuestion(string.Format("Edit {0} located in working directory?" +
                                        "{1}Selected channels won't be changed. ", Settings.Default.WebGrabConfigFileName, Environment.NewLine)))
         {
             return;
         }
     }
     else if (settings.AppDataConfigExists)
     {
         if (!AskQuestion(string.Format("Edit global {0} located in AppData directory?" +
                                        "{1}Selected channels won't be changed.", Settings.Default.WebGrabConfigFileName, Environment.NewLine)))
         {
             return;
         }
     }
     else
     {
         if (!AskQuestion(string.Format("{0} not found in neither AppData or working directory." +
                                        "{1}Create new one in working directory?", Settings.Default.WebGrabConfigFileName, Environment.NewLine)))
         {
             return;
         }
     }
     try
     {
         var defaultConfig = settings.LoadDefault();
         var frm           = new WebGrabConfigForm(defaultConfig, null);
         frm.ShowDialog();
     }
     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();
     }
 }
Пример #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();
                }
            }
        }