/// <summary>
        ///
        /// </summary>
        /// <param name="settings"></param>
        /// <param name="ignorePlugins"></param>
        public FormOptions(Settings settings,
                           IgnorePlugins ignorePlugins)
        {
            InitializeComponent();

            Settings      = settings;
            IgnorePlugins = ignorePlugins;

            chkAlwaysOnTop.Checked            = Settings.AlwaysOnTop;
            chkColourSevere.Checked           = Settings.ColourSevereItems;
            chkRemoveNewLinesOnExport.Checked = Settings.RemoveNewLinesOnExport;
            chkMoveFocusToList.Checked        = Settings.MoveFocusToList;

            UserInterface.LocateAndSelectComboBoxValue(Settings.NumResultsPerPage.ToString(), cboNumResultsPerPage);

            listPlugins.SetObjects(ignorePlugins.Plugins);

            if (ignorePlugins.Plugins.Count == 0)
            {
                btnRemovePlugin.Enabled = false;
                olvcPluginId.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize);
                olvcPluginName.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize);
            }
            else
            {
                listPlugins.SelectedObject = ignorePlugins.Plugins[0];
                olvcPluginId.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize);
                olvcPluginName.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOk_Click(object sender, EventArgs e)
        {
            Settings.ColourSevereItems      = chkColourSevere.Checked;
            Settings.AlwaysOnTop            = chkAlwaysOnTop.Checked;
            Settings.RemoveNewLinesOnExport = chkRemoveNewLinesOnExport.Checked;
            Settings.MoveFocusToList        = chkMoveFocusToList.Checked;

            if (cboNumResultsPerPage.SelectedIndex == -1)
            {
                UserInterface.DisplayMessageBox(this, "The no. results per page value must be selected", MessageBoxIcon.Exclamation);
                return;
            }
            else
            {
                Settings.NumResultsPerPage = int.Parse(cboNumResultsPerPage.Items[cboNumResultsPerPage.SelectedIndex].ToString());
            }

            IgnorePlugins = new IgnorePlugins();
            foreach (Plugin plugin in listPlugins.Objects)
            {
                Plugin temp = new Plugin();
                temp.PluginId   = plugin.PluginId;
                temp.PluginName = plugin.PluginName;
                IgnorePlugins.Plugins.Add(temp);
            }

            this.DialogResult = DialogResult.OK;
        }
Example #3
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public string Load()
        {
            try
            {
                string path = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"woanware\" + Application.ProductName + @"\");

                if (File.Exists(System.IO.Path.Combine(path, FILENAME)) == false)
                {
                    return(string.Empty);
                }

                XmlSerializer serializer = new XmlSerializer(typeof(IgnorePlugins));
                if (File.Exists(System.IO.Path.Combine(path, FILENAME)) == false)
                {
                    return("Cannot locate Ignore Plugins file: " + System.IO.Path.Combine(path, FILENAME));
                }

                FileInfo info = new FileInfo(System.IO.Path.Combine(path, FILENAME));
                using (FileStream stream = info.OpenRead())
                {
                    IgnorePlugins plugins = (IgnorePlugins)serializer.Deserialize(stream);
                    _plugins = plugins.Plugins;

                    return(string.Empty);
                }
            }
            catch (FileNotFoundException fileNotFoundEx)
            {
                return(fileNotFoundEx.Message);
            }
            catch (UnauthorizedAccessException unauthAccessEx)
            {
                return(unauthAccessEx.Message);
            }
            catch (IOException ioEx)
            {
                return(ioEx.Message);
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }