public void LoadPluginConfigurationData() { try { XmlSerializer serializer = new XmlSerializer(typeof(PluginConfigurationData)); if (File.Exists(this._configurationFilePath)) { using (FileStream stream = new FileStream(this._configurationFilePath, FileMode.Open)) { this._config = (PluginConfigurationData)serializer.Deserialize(stream); return; } } this._config = new PluginConfigurationData(); using (FileStream stream2 = new FileStream(this._configurationFilePath, FileMode.Create)) { serializer.Serialize((Stream)stream2, this._config); } } catch (Exception exception) { if (((!(exception is DirectoryNotFoundException) && !(exception is PathTooLongException)) && (!(exception is FileNotFoundException) && !(exception is IOException))) && ((!(exception is SecurityException) && !(exception is NotSupportedException)) && !(exception is ArgumentOutOfRangeException))) { throw; } MessageBox.Show(string.Format("Can't load configuration from '{0}' file.\n\nDetails: {1}", this._configurationFilePath, exception.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); } }
public PluginConfigurationRepository(PluginConfigurationData config) { string str = string.Format(@"{0}\Local\OpenLiveWriter\app-0.6.0.0", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)); this._configurationFilePath = string.Format(@"{0}\{1}", str, "OpenLiveWriter.CNBlogs.CodeHighlighter.config"); if (!Directory.Exists(str)) { Directory.CreateDirectory(str); } this._config = config; }
/// <summary> /// Initializes a new instance of the <see cref="OptionsForm"/> class. /// </summary> /// <param name="config">The config.</param> public OptionsForm(PluginConfigurationData config) { InitializeComponent(); PluginConfigurationData = config; checkServerDefaults.Checked = PluginConfigurationData.UseServerDefaults; checkBoxAutoLinks.Checked = PluginConfigurationData.AutoLinks; checkBoxCollapse.Checked = PluginConfigurationData.Collapse; checkBoxGutter.Checked = PluginConfigurationData.Gutter; checkBoxHtmlScript.Checked = PluginConfigurationData.HtmlScript; checkBoxLight.Checked = PluginConfigurationData.Light; checkBoxRuler.Checked = PluginConfigurationData.Ruler; checkBoxSmartTabs.Checked = PluginConfigurationData.SmartTabs; checkBoxToolbar.Checked = PluginConfigurationData.Toolbar; checkLoadFromClipboard.Checked = PluginConfigurationData.LoadFromClipboard; numericTabSize.Value = PluginConfigurationData.TabSize; textBoxClassName.Text = (PluginConfigurationData.ClassName ?? string.Empty); labelFamily.Text = PluginConfigurationData.CodeFontFamily; labelSize.Text = PluginConfigurationData.CodeFontSize.ToString(); this.UpdateCodeFont(); }
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 index = value.IndexOf("["); int num2 = value.LastIndexOf("]"); if ((0 > index) || (index >= num2)) { break; } config.Highlight = this.GetString(value.Substring(index + 1, (num2 - index) - 1)); return; } 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; default: return; } }