Example #1
0
        public void LoadPluginConfigurationData()
        {
            if (!File.Exists(this._configurationFilePath))
            {
                this._config = new PluginConfigurationData();
            }
            FileStream fileStream = null;

            try
            {
                XmlSerializer xmlSerializer = new XmlSerializer(typeof(PluginConfigurationData));
                fileStream   = new FileStream(this._configurationFilePath, FileMode.Open);
                this._config = (PluginConfigurationData)xmlSerializer.Deserialize(fileStream);
                fileStream.Close();
                fileStream = null;
            }
            catch (Exception ex)
            {
                if (!(ex is DirectoryNotFoundException) && !(ex is PathTooLongException) && !(ex is FileNotFoundException) && !(ex is IOException) && !(ex is SecurityException) && !(ex is NotSupportedException) && !(ex is ArgumentOutOfRangeException))
                {
                    throw;
                }
                string text = string.Format("Can't load configuration from '{0}' file.\n\nDetails: {1}", this._configurationFilePath, ex.Message);
                MessageBox.Show(text, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
            finally
            {
                if (fileStream != null)
                {
                    fileStream.Close();
                }
            }
        }
Example #2
0
        public PluginConfigurationRepository(PluginConfigurationData config)
        {
            string text = string.Format("{0}\\Windows Live Writer", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));

            this._configurationFilePath = string.Format("{0}\\{1}", text, "OpenLiveWriter.SourceCode.config");
            if (!Directory.Exists(text))
            {
                Directory.CreateDirectory(text);
            }
            this._config = config;
        }
 public OptionsForm(PluginConfigurationData config)
 {
     this.InitializeComponent();
     this.PluginConfigurationData        = config;
     this.checkServerDefaults.Checked    = this.PluginConfigurationData.UseServerDefaults;
     this.checkBoxAutoLinks.Checked      = this.PluginConfigurationData.AutoLinks;
     this.checkBoxCollapse.Checked       = this.PluginConfigurationData.Collapse;
     this.checkBoxGutter.Checked         = this.PluginConfigurationData.Gutter;
     this.checkBoxHtmlScript.Checked     = this.PluginConfigurationData.HtmlScript;
     this.checkBoxLight.Checked          = this.PluginConfigurationData.Light;
     this.checkBoxRuler.Checked          = this.PluginConfigurationData.Ruler;
     this.checkBoxSmartTabs.Checked      = this.PluginConfigurationData.SmartTabs;
     this.checkBoxToolbar.Checked        = this.PluginConfigurationData.Toolbar;
     this.checkLoadFromClipboard.Checked = this.PluginConfigurationData.LoadFromClipboard;
     this.numericTabSize.Value           = this.PluginConfigurationData.TabSize;
     this.textBoxClassName.Text          = (this.PluginConfigurationData.ClassName ?? string.Empty);
     this.labelFamily.Text = this.PluginConfigurationData.CodeFontFamily;
     this.labelSize.Text   = this.PluginConfigurationData.CodeFontSize.ToString();
     this.UpdateCodeFont();
 }
Example #4
0
        private void UpdateConfig(PluginConfigurationData config, string variable, string value)
        {
            switch (variable)
            {
            case "brush":
                config.Brush = this.GetString(value);
                return;

            case "auto-links":
                config.AutoLinks = this.GetBoolean(value, config.AutoLinks);
                return;

            case "class-name":
                config.ClassName = this.GetString(value);
                return;

            case "collapse":
                config.Collapse = this.GetBoolean(value, config.Collapse);
                return;

            case "first-line":
                config.FirstLine = this.GetInt(value, config.FirstLine);
                return;

            case "gutter":
                config.Gutter = this.GetBoolean(value, config.Gutter);
                return;

            case "highlight":
            {
                int num2 = value.IndexOf("[");
                int num3 = value.LastIndexOf("]");
                if (0 <= num2 && num2 < num3)
                {
                    config.Highlight = this.GetString(value.Substring(num2 + 1, num3 - num2 - 1));
                    return;
                }
                break;
            }

            case "html-script":
                config.HtmlScript = this.GetBoolean(value, config.HtmlScript);
                return;

            case "light":
                config.Light = this.GetBoolean(value, config.Light);
                return;

            case "ruler":
                config.Ruler = this.GetBoolean(value, config.Ruler);
                return;

            case "smart-tabs":
                config.SmartTabs = this.GetBoolean(value, config.SmartTabs);
                return;

            case "tab-size":
                config.TabSize = this.GetInt(value, config.TabSize);
                return;

            case "toolbar":
                config.Toolbar = this.GetBoolean(value, config.Toolbar);
                break;
            }
        }