diff --git a/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/OptionsDialog.cs b/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/OptionsDialog.cs index 0c85e50d..10dd6028 100644 --- a/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/OptionsDialog.cs +++ b/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/OptionsDialog.cs @@ -65,6 +65,8 @@ namespace UniversalEditor.UserInterface.WindowsForms.Dialogs oppanel.Dock = DockStyle.Fill; pnlContainer.Controls.Add(oppanel); + + oppanel.LoadSettings(); } } @@ -119,6 +121,12 @@ namespace UniversalEditor.UserInterface.WindowsForms.Dialogs private void cmdOK_Click(object sender, EventArgs e) { + IOptionPanelImplementation[] panels = UniversalEditor.UserInterface.Common.Reflection.GetAvailableOptionPanels(); + foreach (IOptionPanelImplementation panel in panels) + { + panel.SaveSettings(); + } + this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); } diff --git a/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/OptionPanels/ApplicationOptionPanel.Designer.cs b/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/OptionPanels/ApplicationOptionPanel.Designer.cs index 3312a615..f632025c 100644 --- a/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/OptionPanels/ApplicationOptionPanel.Designer.cs +++ b/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/OptionPanels/ApplicationOptionPanel.Designer.cs @@ -28,150 +28,204 @@ /// private void InitializeComponent() { - this.fraWindowLayout = new System.Windows.Forms.GroupBox(); - this.radioButton3 = new System.Windows.Forms.RadioButton(); - this.radioButton2 = new System.Windows.Forms.RadioButton(); - this.radioButton1 = new System.Windows.Forms.RadioButton(); - this.fraExtensions = new System.Windows.Forms.GroupBox(); - this.chkEnableExtensionGallery = new System.Windows.Forms.CheckBox(); - this.label1 = new System.Windows.Forms.Label(); - this.txtOnlineGalleryURL = new System.Windows.Forms.TextBox(); - this.chkEnableGalleryAutoUpdate = new System.Windows.Forms.CheckBox(); - this.checkBox1 = new System.Windows.Forms.CheckBox(); - this.fraWindowLayout.SuspendLayout(); - this.fraExtensions.SuspendLayout(); - this.SuspendLayout(); - // - // fraWindowLayout - // - this.fraWindowLayout.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + this.fraWindowLayout = new System.Windows.Forms.GroupBox(); + this.radioButton3 = new System.Windows.Forms.RadioButton(); + this.radioButton2 = new System.Windows.Forms.RadioButton(); + this.radioButton1 = new System.Windows.Forms.RadioButton(); + this.fraExtensions = new System.Windows.Forms.GroupBox(); + this.txtOnlineGalleryURL = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.checkBox1 = new System.Windows.Forms.CheckBox(); + this.chkEnableGalleryAutoUpdate = new System.Windows.Forms.CheckBox(); + this.chkEnableExtensionGallery = new System.Windows.Forms.CheckBox(); + this.fraTitleBarBehavior = new System.Windows.Forms.GroupBox(); + this.optTitleBarBehaviorNone = new System.Windows.Forms.RadioButton(); + this.optTitleBarBehaviorCurrentFileName = new System.Windows.Forms.RadioButton(); + this.optTitleBarBehaviorCurrentFilePath = new System.Windows.Forms.RadioButton(); + this.fraWindowLayout.SuspendLayout(); + this.fraExtensions.SuspendLayout(); + this.fraTitleBarBehavior.SuspendLayout(); + this.SuspendLayout(); + // + // fraWindowLayout + // + this.fraWindowLayout.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.fraWindowLayout.Controls.Add(this.radioButton3); - this.fraWindowLayout.Controls.Add(this.radioButton2); - this.fraWindowLayout.Controls.Add(this.radioButton1); - this.fraWindowLayout.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.fraWindowLayout.Location = new System.Drawing.Point(3, 3); - this.fraWindowLayout.Name = "fraWindowLayout"; - this.fraWindowLayout.Size = new System.Drawing.Size(505, 52); - this.fraWindowLayout.TabIndex = 0; - this.fraWindowLayout.TabStop = false; - this.fraWindowLayout.Text = "Window layout"; - // - // radioButton3 - // - this.radioButton3.AutoSize = true; - this.radioButton3.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.radioButton3.Location = new System.Drawing.Point(273, 19); - this.radioButton3.Name = "radioButton3"; - this.radioButton3.Size = new System.Drawing.Size(118, 18); - this.radioButton3.TabIndex = 0; - this.radioButton3.Text = "&Separate windows"; - this.radioButton3.UseVisualStyleBackColor = true; - // - // radioButton2 - // - this.radioButton2.AutoSize = true; - this.radioButton2.Checked = true; - this.radioButton2.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.radioButton2.Location = new System.Drawing.Point(151, 19); - this.radioButton2.Name = "radioButton2"; - this.radioButton2.Size = new System.Drawing.Size(122, 18); - this.radioButton2.TabIndex = 0; - this.radioButton2.TabStop = true; - this.radioButton2.Text = "&Multiple documents"; - this.radioButton2.UseVisualStyleBackColor = true; - // - // radioButton1 - // - this.radioButton1.AutoSize = true; - this.radioButton1.Enabled = false; - this.radioButton1.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.radioButton1.Location = new System.Drawing.Point(28, 19); - this.radioButton1.Name = "radioButton1"; - this.radioButton1.Size = new System.Drawing.Size(123, 18); - this.radioButton1.TabIndex = 0; - this.radioButton1.Text = "&Tabbed documents"; - this.radioButton1.UseVisualStyleBackColor = true; - // - // fraExtensions - // - this.fraExtensions.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + this.fraWindowLayout.Controls.Add(this.radioButton3); + this.fraWindowLayout.Controls.Add(this.radioButton2); + this.fraWindowLayout.Controls.Add(this.radioButton1); + this.fraWindowLayout.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.fraWindowLayout.Location = new System.Drawing.Point(3, 3); + this.fraWindowLayout.Name = "fraWindowLayout"; + this.fraWindowLayout.Size = new System.Drawing.Size(505, 52); + this.fraWindowLayout.TabIndex = 0; + this.fraWindowLayout.TabStop = false; + this.fraWindowLayout.Text = "Window layout"; + // + // radioButton3 + // + this.radioButton3.AutoSize = true; + this.radioButton3.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.radioButton3.Location = new System.Drawing.Point(273, 19); + this.radioButton3.Name = "radioButton3"; + this.radioButton3.Size = new System.Drawing.Size(118, 18); + this.radioButton3.TabIndex = 0; + this.radioButton3.Text = "&Separate windows"; + this.radioButton3.UseVisualStyleBackColor = true; + // + // radioButton2 + // + this.radioButton2.AutoSize = true; + this.radioButton2.Checked = true; + this.radioButton2.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.radioButton2.Location = new System.Drawing.Point(151, 19); + this.radioButton2.Name = "radioButton2"; + this.radioButton2.Size = new System.Drawing.Size(122, 18); + this.radioButton2.TabIndex = 0; + this.radioButton2.TabStop = true; + this.radioButton2.Text = "&Multiple documents"; + this.radioButton2.UseVisualStyleBackColor = true; + // + // radioButton1 + // + this.radioButton1.AutoSize = true; + this.radioButton1.Enabled = false; + this.radioButton1.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.radioButton1.Location = new System.Drawing.Point(28, 19); + this.radioButton1.Name = "radioButton1"; + this.radioButton1.Size = new System.Drawing.Size(123, 18); + this.radioButton1.TabIndex = 0; + this.radioButton1.Text = "&Tabbed documents"; + this.radioButton1.UseVisualStyleBackColor = true; + // + // fraExtensions + // + this.fraExtensions.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.fraExtensions.Controls.Add(this.txtOnlineGalleryURL); - this.fraExtensions.Controls.Add(this.label1); - this.fraExtensions.Controls.Add(this.checkBox1); - this.fraExtensions.Controls.Add(this.chkEnableGalleryAutoUpdate); - this.fraExtensions.Controls.Add(this.chkEnableExtensionGallery); - this.fraExtensions.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.fraExtensions.Location = new System.Drawing.Point(3, 61); - this.fraExtensions.Name = "fraExtensions"; - this.fraExtensions.Size = new System.Drawing.Size(505, 142); - this.fraExtensions.TabIndex = 1; - this.fraExtensions.TabStop = false; - this.fraExtensions.Text = "Extensions"; - // - // chkEnableExtensionGallery - // - this.chkEnableExtensionGallery.AutoSize = true; - this.chkEnableExtensionGallery.Location = new System.Drawing.Point(28, 19); - this.chkEnableExtensionGallery.Name = "chkEnableExtensionGallery"; - this.chkEnableExtensionGallery.Size = new System.Drawing.Size(258, 17); - this.chkEnableExtensionGallery.TabIndex = 0; - this.chkEnableExtensionGallery.Text = "Enable access to extensions in the Online &Gallery"; - this.chkEnableExtensionGallery.UseVisualStyleBackColor = true; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.label1.Location = new System.Drawing.Point(47, 45); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(98, 13); - this.label1.TabIndex = 1; - this.label1.Text = "Online gallery &URL:"; - // - // txtOnlineGalleryURL - // - this.txtOnlineGalleryURL.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + this.fraExtensions.Controls.Add(this.txtOnlineGalleryURL); + this.fraExtensions.Controls.Add(this.label1); + this.fraExtensions.Controls.Add(this.checkBox1); + this.fraExtensions.Controls.Add(this.chkEnableGalleryAutoUpdate); + this.fraExtensions.Controls.Add(this.chkEnableExtensionGallery); + this.fraExtensions.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.fraExtensions.Location = new System.Drawing.Point(3, 162); + this.fraExtensions.Name = "fraExtensions"; + this.fraExtensions.Size = new System.Drawing.Size(505, 117); + this.fraExtensions.TabIndex = 1; + this.fraExtensions.TabStop = false; + this.fraExtensions.Text = "Extensions"; + // + // txtOnlineGalleryURL + // + this.txtOnlineGalleryURL.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.txtOnlineGalleryURL.Location = new System.Drawing.Point(151, 42); - this.txtOnlineGalleryURL.Name = "txtOnlineGalleryURL"; - this.txtOnlineGalleryURL.Size = new System.Drawing.Size(348, 20); - this.txtOnlineGalleryURL.TabIndex = 2; - // - // chkEnableGalleryAutoUpdate - // - this.chkEnableGalleryAutoUpdate.AutoSize = true; - this.chkEnableGalleryAutoUpdate.Location = new System.Drawing.Point(28, 68); - this.chkEnableGalleryAutoUpdate.Name = "chkEnableGalleryAutoUpdate"; - this.chkEnableGalleryAutoUpdate.Size = new System.Drawing.Size(283, 17); - this.chkEnableGalleryAutoUpdate.TabIndex = 0; - this.chkEnableGalleryAutoUpdate.Text = "Automatically check for up&dates to installed extensions"; - this.chkEnableGalleryAutoUpdate.UseVisualStyleBackColor = true; - // - // checkBox1 - // - this.checkBox1.AutoSize = true; - this.checkBox1.Location = new System.Drawing.Point(28, 91); - this.checkBox1.Name = "checkBox1"; - this.checkBox1.Size = new System.Drawing.Size(288, 17); - this.checkBox1.TabIndex = 0; - this.checkBox1.Text = "Load &per-user extensions when running as Administrator"; - this.checkBox1.UseVisualStyleBackColor = true; - // - // ApplicationOptionsPanel - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.fraExtensions); - this.Controls.Add(this.fraWindowLayout); - this.Name = "ApplicationOptionsPanel"; - this.Size = new System.Drawing.Size(511, 405); - this.fraWindowLayout.ResumeLayout(false); - this.fraWindowLayout.PerformLayout(); - this.fraExtensions.ResumeLayout(false); - this.fraExtensions.PerformLayout(); - this.ResumeLayout(false); + this.txtOnlineGalleryURL.Location = new System.Drawing.Point(151, 42); + this.txtOnlineGalleryURL.Name = "txtOnlineGalleryURL"; + this.txtOnlineGalleryURL.Size = new System.Drawing.Size(348, 20); + this.txtOnlineGalleryURL.TabIndex = 2; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.label1.Location = new System.Drawing.Point(47, 45); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(98, 13); + this.label1.TabIndex = 1; + this.label1.Text = "Online gallery &URL:"; + // + // checkBox1 + // + this.checkBox1.AutoSize = true; + this.checkBox1.Location = new System.Drawing.Point(28, 91); + this.checkBox1.Name = "checkBox1"; + this.checkBox1.Size = new System.Drawing.Size(288, 17); + this.checkBox1.TabIndex = 0; + this.checkBox1.Text = "Load &per-user extensions when running as Administrator"; + this.checkBox1.UseVisualStyleBackColor = true; + // + // chkEnableGalleryAutoUpdate + // + this.chkEnableGalleryAutoUpdate.AutoSize = true; + this.chkEnableGalleryAutoUpdate.Location = new System.Drawing.Point(28, 68); + this.chkEnableGalleryAutoUpdate.Name = "chkEnableGalleryAutoUpdate"; + this.chkEnableGalleryAutoUpdate.Size = new System.Drawing.Size(283, 17); + this.chkEnableGalleryAutoUpdate.TabIndex = 0; + this.chkEnableGalleryAutoUpdate.Text = "Automatically check for up&dates to installed extensions"; + this.chkEnableGalleryAutoUpdate.UseVisualStyleBackColor = true; + // + // chkEnableExtensionGallery + // + this.chkEnableExtensionGallery.AutoSize = true; + this.chkEnableExtensionGallery.Location = new System.Drawing.Point(28, 19); + this.chkEnableExtensionGallery.Name = "chkEnableExtensionGallery"; + this.chkEnableExtensionGallery.Size = new System.Drawing.Size(258, 17); + this.chkEnableExtensionGallery.TabIndex = 0; + this.chkEnableExtensionGallery.Text = "Enable access to extensions in the Online &Gallery"; + this.chkEnableExtensionGallery.UseVisualStyleBackColor = true; + // + // fraTitleBarBehavior + // + this.fraTitleBarBehavior.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.fraTitleBarBehavior.Controls.Add(this.optTitleBarBehaviorCurrentFilePath); + this.fraTitleBarBehavior.Controls.Add(this.optTitleBarBehaviorCurrentFileName); + this.fraTitleBarBehavior.Controls.Add(this.optTitleBarBehaviorNone); + this.fraTitleBarBehavior.Location = new System.Drawing.Point(3, 61); + this.fraTitleBarBehavior.Name = "fraTitleBarBehavior"; + this.fraTitleBarBehavior.Size = new System.Drawing.Size(505, 95); + this.fraTitleBarBehavior.TabIndex = 2; + this.fraTitleBarBehavior.TabStop = false; + this.fraTitleBarBehavior.Text = "Title bar behavior"; + // + // optTitleBarBehaviorNone + // + this.optTitleBarBehaviorNone.AutoSize = true; + this.optTitleBarBehaviorNone.Checked = true; + this.optTitleBarBehaviorNone.Location = new System.Drawing.Point(28, 19); + this.optTitleBarBehaviorNone.Name = "optTitleBarBehaviorNone"; + this.optTitleBarBehaviorNone.Size = new System.Drawing.Size(301, 17); + this.optTitleBarBehaviorNone.TabIndex = 0; + this.optTitleBarBehaviorNone.TabStop = true; + this.optTitleBarBehaviorNone.Text = "Do not display document-specific information in the title bar"; + this.optTitleBarBehaviorNone.UseVisualStyleBackColor = true; + // + // optTitleBarBehaviorCurrentFileName + // + this.optTitleBarBehaviorCurrentFileName.AutoSize = true; + this.optTitleBarBehaviorCurrentFileName.Location = new System.Drawing.Point(28, 42); + this.optTitleBarBehaviorCurrentFileName.Name = "optTitleBarBehaviorCurrentFileName"; + this.optTitleBarBehaviorCurrentFileName.Size = new System.Drawing.Size(304, 17); + this.optTitleBarBehaviorCurrentFileName.TabIndex = 0; + this.optTitleBarBehaviorCurrentFileName.Text = "Display the file &name of the current document in the title bar"; + this.optTitleBarBehaviorCurrentFileName.UseVisualStyleBackColor = true; + // + // optTitleBarBehaviorCurrentFilePath + // + this.optTitleBarBehaviorCurrentFilePath.AutoSize = true; + this.optTitleBarBehaviorCurrentFilePath.Location = new System.Drawing.Point(28, 65); + this.optTitleBarBehaviorCurrentFilePath.Name = "optTitleBarBehaviorCurrentFilePath"; + this.optTitleBarBehaviorCurrentFilePath.Size = new System.Drawing.Size(299, 17); + this.optTitleBarBehaviorCurrentFilePath.TabIndex = 0; + this.optTitleBarBehaviorCurrentFilePath.Text = "Display the full &path to the current document in the title bar"; + this.optTitleBarBehaviorCurrentFilePath.UseVisualStyleBackColor = true; + // + // ApplicationOptionPanel + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.fraTitleBarBehavior); + this.Controls.Add(this.fraExtensions); + this.Controls.Add(this.fraWindowLayout); + this.Name = "ApplicationOptionPanel"; + this.Size = new System.Drawing.Size(511, 405); + this.fraWindowLayout.ResumeLayout(false); + this.fraWindowLayout.PerformLayout(); + this.fraExtensions.ResumeLayout(false); + this.fraExtensions.PerformLayout(); + this.fraTitleBarBehavior.ResumeLayout(false); + this.fraTitleBarBehavior.PerformLayout(); + this.ResumeLayout(false); } @@ -187,5 +241,9 @@ private System.Windows.Forms.CheckBox chkEnableExtensionGallery; private System.Windows.Forms.CheckBox chkEnableGalleryAutoUpdate; private System.Windows.Forms.CheckBox checkBox1; + private System.Windows.Forms.GroupBox fraTitleBarBehavior; + private System.Windows.Forms.RadioButton optTitleBarBehaviorCurrentFilePath; + private System.Windows.Forms.RadioButton optTitleBarBehaviorCurrentFileName; + private System.Windows.Forms.RadioButton optTitleBarBehaviorNone; } } diff --git a/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/OptionPanels/ApplicationOptionPanel.cs b/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/OptionPanels/ApplicationOptionPanel.cs index adb8b196..7128569f 100644 --- a/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/OptionPanels/ApplicationOptionPanel.cs +++ b/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/OptionPanels/ApplicationOptionPanel.cs @@ -7,14 +7,73 @@ using System.Windows.Forms; namespace UniversalEditor.UserInterface.WindowsForms.OptionPanels { - public partial class ApplicationOptionPanel : OptionPanel - { - public ApplicationOptionPanel() - { - InitializeComponent(); - } + public partial class ApplicationOptionPanel : OptionPanel + { + public ApplicationOptionPanel() + { + InitializeComponent(); + } - private string[] mvarOptionGroups = new string[] { "Application" }; - public override string[] OptionGroups { get { return mvarOptionGroups; } } - } + private string[] mvarOptionGroups = new string[] { "Application" }; + public override string[] OptionGroups { get { return mvarOptionGroups; } } + + public override void LoadSettings() + { + base.LoadSettings(); + + string value = Engine.CurrentEngine.ConfigurationManager.GetValue(new string[] + { + "Application", + "TitleBarBehavior" + }); + switch (value) + { + case "CurrentFileName": + { + optTitleBarBehaviorCurrentFileName.Checked = true; + break; + } + case "CurrentFilePath": + { + optTitleBarBehaviorCurrentFilePath.Checked = true; + break; + } + default: + { + optTitleBarBehaviorNone.Checked = true; + break; + } + } + } + public override void SaveSettings() + { + base.SaveSettings(); + + #region Title Bar Behavior + { + string value = "None"; + if (optTitleBarBehaviorCurrentFileName.Checked) + { + value = "CurrentFileName"; + } + if (optTitleBarBehaviorCurrentFilePath.Checked) + { + value = "CurrentFilePath"; + } + + Engine.CurrentEngine.ConfigurationManager.SetValue(new string[] + { + "Application", + "TitleBarBehavior" + }, value); + } + #endregion + } + public override void ResetSettings() + { + base.ResetSettings(); + + optTitleBarBehaviorNone.Checked = true; + } + } } diff --git a/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/OptionPanels/ApplicationOptionPanel.resx b/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/OptionPanels/ApplicationOptionPanel.resx index 058096e6..7080a7d1 100644 --- a/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/OptionPanels/ApplicationOptionPanel.resx +++ b/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/OptionPanels/ApplicationOptionPanel.resx @@ -18,7 +18,7 @@ System.Resources.ResXResourceReader, System.Windows.Forms, ... System.Resources.ResXResourceWriter, System.Windows.Forms, ... this is my long stringthis is a comment - Blue + Blue [base64 mime encoded serialized .NET Framework object] diff --git a/CSharp/Libraries/UniversalEditor.UserInterface.WindowsForms/OptionPanel.cs b/CSharp/Libraries/UniversalEditor.UserInterface.WindowsForms/OptionPanel.cs index ed09819e..c63e056a 100644 --- a/CSharp/Libraries/UniversalEditor.UserInterface.WindowsForms/OptionPanel.cs +++ b/CSharp/Libraries/UniversalEditor.UserInterface.WindowsForms/OptionPanel.cs @@ -17,15 +17,12 @@ namespace UniversalEditor.UserInterface.WindowsForms public virtual void LoadSettings() { - throw new NotImplementedException(); } public virtual void SaveSettings() { - throw new NotImplementedException(); } public virtual void ResetSettings() { - throw new NotImplementedException(); } private string[] mvarOptionGroups = null; diff --git a/CSharp/Libraries/UniversalEditor.UserInterface/ConfigurationManager.cs b/CSharp/Libraries/UniversalEditor.UserInterface/ConfigurationManager.cs new file mode 100644 index 00000000..d373a8fc --- /dev/null +++ b/CSharp/Libraries/UniversalEditor.UserInterface/ConfigurationManager.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UniversalEditor.ObjectModels.PropertyList; + +namespace UniversalEditor.UserInterface +{ + public enum ConfigurationManagerPropertyScope + { + Local, + Global + } + public class ConfigurationManager + { + private PropertyListObjectModel mvarGlobalConfiguration = new PropertyListObjectModel(); + private PropertyListObjectModel mvarLocalConfiguration = new PropertyListObjectModel(); + + public void SetValue(string propertyName, T propertyValue, ConfigurationManagerPropertyScope scope = ConfigurationManagerPropertyScope.Local) + { + SetValue(new string[] { propertyName }, propertyValue, scope); + } + public void SetValue(string[] propertyName, T propertyValue, ConfigurationManagerPropertyScope scope = ConfigurationManagerPropertyScope.Local) + { + if (scope == ConfigurationManagerPropertyScope.Local) + { + mvarLocalConfiguration.SetValue(propertyName, propertyValue); + } + else if (scope == ConfigurationManagerPropertyScope.Global) + { + mvarGlobalConfiguration.SetValue(propertyName, propertyValue); + } + } + public T GetValue(string propertyName, T defaultValue = default(T)) + { + return GetValue(new string[] { propertyName }, defaultValue); + } + public T GetValue(string[] propertyName, T defaultValue = default(T)) + { + if (mvarLocalConfiguration.HasValue(propertyName)) + { + return mvarLocalConfiguration.GetValue(propertyName, defaultValue); + } + return mvarGlobalConfiguration.GetValue(propertyName, defaultValue); + } + + public void Load() + { + UniversalEditor.DataFormats.PropertyList.XML.XMLPropertyListDataFormat xdf = new DataFormats.PropertyList.XML.XMLPropertyListDataFormat(); + Document.Load(mvarLocalConfiguration, xdf, new Accessors.FileAccessor(Engine.DataPath + System.IO.Path.DirectorySeparatorChar.ToString() + "Configuration.xml")); + } + + public void Save() + { + UniversalEditor.DataFormats.PropertyList.XML.XMLPropertyListDataFormat xdf = new DataFormats.PropertyList.XML.XMLPropertyListDataFormat(); + Document.Save(mvarLocalConfiguration, xdf, new Accessors.FileAccessor(Engine.DataPath + System.IO.Path.DirectorySeparatorChar.ToString() + "Configuration.xml", true, true)); + } + } +} diff --git a/CSharp/Libraries/UniversalEditor.UserInterface/Engine.cs b/CSharp/Libraries/UniversalEditor.UserInterface/Engine.cs index 67d569f3..33f3e058 100644 --- a/CSharp/Libraries/UniversalEditor.UserInterface/Engine.cs +++ b/CSharp/Libraries/UniversalEditor.UserInterface/Engine.cs @@ -233,9 +233,6 @@ namespace UniversalEditor.UserInterface /// private MarkupObjectModel mvarRawMarkup = new MarkupObjectModel(); - private PropertyListObjectModel mvarConfiguration = new PropertyListObjectModel(); - public PropertyListObjectModel Configuration { get { return mvarConfiguration; } } - private System.Collections.ObjectModel.ReadOnlyCollection mvarSelectedFileNames = null; public System.Collections.ObjectModel.ReadOnlyCollection SelectedFileNames { get { return mvarSelectedFileNames; } } @@ -438,7 +435,7 @@ namespace UniversalEditor.UserInterface } UpdateSplashScreenStatus("Finalizing configuration"); - + ConfigurationManager.Load(); } private void InitializeLanguage(MarkupTagElement tag) @@ -613,6 +610,9 @@ namespace UniversalEditor.UserInterface } + private ConfigurationManager mvarConfigurationManager = new ConfigurationManager(); + public ConfigurationManager ConfigurationManager { get { return mvarConfigurationManager; } } + private RecentFileManager mvarRecentFileManager = new RecentFileManager(); public RecentFileManager RecentFileManager { get { return mvarRecentFileManager; } } @@ -684,7 +684,7 @@ namespace UniversalEditor.UserInterface Engine.mvarCurrentEngine = this; string INSTANCEID = GetType().FullName + "$2d429aa3371c421fb63b42525e51a50c$92751853175891031214292357218181357901238$"; - if (Configuration.GetValue("SingleInstanceUniquePerDirectory", true)) + if (ConfigurationManager.GetValue("SingleInstanceUniquePerDirectory", true)) { // The single instance should be unique per directory INSTANCEID += System.Reflection.Assembly.GetEntryAssembly().Location; @@ -723,6 +723,7 @@ namespace UniversalEditor.UserInterface SessionManager.Save(); BookmarksManager.Save(); RecentFileManager.Save(); + ConfigurationManager.Save(); } } } diff --git a/CSharp/Libraries/UniversalEditor.UserInterface/UniversalEditor.UserInterface.csproj b/CSharp/Libraries/UniversalEditor.UserInterface/UniversalEditor.UserInterface.csproj index 0b7812cc..0f76159e 100644 --- a/CSharp/Libraries/UniversalEditor.UserInterface/UniversalEditor.UserInterface.csproj +++ b/CSharp/Libraries/UniversalEditor.UserInterface/UniversalEditor.UserInterface.csproj @@ -58,6 +58,7 @@ + diff --git a/CSharp/Plugins/UniversalEditor.Essential/DataFormats/PropertyList/XML/XMLPropertyListDataFormat.cs b/CSharp/Plugins/UniversalEditor.Essential/DataFormats/PropertyList/XML/XMLPropertyListDataFormat.cs index cbc2e8f4..d3f25d9a 100644 --- a/CSharp/Plugins/UniversalEditor.Essential/DataFormats/PropertyList/XML/XMLPropertyListDataFormat.cs +++ b/CSharp/Plugins/UniversalEditor.Essential/DataFormats/PropertyList/XML/XMLPropertyListDataFormat.cs @@ -28,6 +28,23 @@ namespace UniversalEditor.DataFormats.PropertyList.XML LoadMarkup(tagConfiguration, ref plom); } + protected override void BeforeSaveInternal(Stack objectModels) + { + base.BeforeSaveInternal(objectModels); + + PropertyListObjectModel plom = (objectModels.Pop() as PropertyListObjectModel); + MarkupObjectModel mom = new MarkupObjectModel(); + + MarkupTagElement tagConfiguration = new MarkupTagElement(); + tagConfiguration.FullName = "Configuration"; + + SaveMarkup(ref tagConfiguration, plom); + + mom.Elements.Add(new MarkupPreprocessorElement("xml", "version=\"1.0\" encoding=\"UTF-8\"")); + mom.Elements.Add(tagConfiguration); + objectModels.Push(mom); + } + private static DataFormatReference _dfr = null; public override DataFormatReference MakeReference() { @@ -45,18 +62,28 @@ namespace UniversalEditor.DataFormats.PropertyList.XML public static void LoadMarkup(MarkupTagElement tagConfiguration, ref PropertyListObjectModel plom) { - foreach (MarkupElement el in tagConfiguration.Elements) + MarkupTagElement tagProperties = (tagConfiguration.Elements["Properties"] as MarkupTagElement); + if (tagProperties != null) { - MarkupTagElement tag = (el as MarkupTagElement); - if (tag == null) continue; - - if (tag.Name == "Property") + foreach (MarkupElement el in tagProperties.Elements) { + MarkupTagElement tag = (el as MarkupTagElement); + if (tag == null) continue; + if (tag.FullName != "Property") continue; + Property p = LoadPropertyListProperty(tag); if (p != null) plom.Properties.Add(p); } - else if (tag.Name == "Group") + } + MarkupTagElement tagGroups = (tagConfiguration.Elements["Groups"] as MarkupTagElement); + if (tagGroups != null) + { + foreach (MarkupElement el in tagGroups.Elements) { + MarkupTagElement tag = (el as MarkupTagElement); + if (tag == null) continue; + if (tag.FullName != "Group") continue; + Group g = LoadPropertyListGroup(tag); if (g != null) plom.Groups.Add(g); } @@ -213,17 +240,29 @@ namespace UniversalEditor.DataFormats.PropertyList.XML Group group = new Group(); group.Name = attID.Value; - foreach (MarkupElement el1 in tag.Elements) + MarkupTagElement tagProperties = (tag.Elements["Properties"] as MarkupTagElement); + if (tagProperties != null) { - MarkupTagElement tag1 = (el1 as MarkupTagElement); - if (tag1 == null) continue; - if (tag1.Name == "Property") + foreach (MarkupElement el1 in tagProperties.Elements) { + MarkupTagElement tag1 = (el1 as MarkupTagElement); + if (tag1 == null) continue; + if (tag1.Name != "Property") continue; + Property p = LoadPropertyListProperty(tag1); if (p != null) group.Properties.Add(p); } - else if (tag1.Name == "Group") + } + + MarkupTagElement tagGroups = (tag.Elements["Groups"] as MarkupTagElement); + if (tagGroups != null) + { + foreach (MarkupElement el1 in tagGroups.Elements) { + MarkupTagElement tag1 = (el1 as MarkupTagElement); + if (tag1 == null) continue; + if (tag1.Name != "Group") continue; + Group g = LoadPropertyListGroup(tag1); if (g != null) group.Groups.Add(g); } diff --git a/CSharp/Plugins/UniversalEditor.Essential/ObjectModels/PropertyList/PropertyListObjectModel.cs b/CSharp/Plugins/UniversalEditor.Essential/ObjectModels/PropertyList/PropertyListObjectModel.cs index a10e48dc..8641aaaf 100644 --- a/CSharp/Plugins/UniversalEditor.Essential/ObjectModels/PropertyList/PropertyListObjectModel.cs +++ b/CSharp/Plugins/UniversalEditor.Essential/ObjectModels/PropertyList/PropertyListObjectModel.cs @@ -210,9 +210,57 @@ namespace UniversalEditor.ObjectModels.PropertyList } } + /// + /// Finds the property with the specified name. If more than one string is specified, + /// searches for groups in hierarchy with the property name being the last in the list. + /// If the property does not exist, it is created. + /// + /// + /// + public Property FindOrCreateProperty(string[] propertyName, T defaultValue) + { + Group group = null; + for (int i = 0; i < propertyName.Length - 1; i++) + { + if (group == null) + { + Group newgroup = mvarGroups[propertyName[i]]; + if (newgroup == null) newgroup = mvarGroups.Add(propertyName[i]); + group = newgroup; + } + else + { + Group newgroup = group.Groups[propertyName[i]]; + if (newgroup == null) newgroup = group.Groups.Add(propertyName[i]); + group = newgroup; + } + } + + if (group == null) + { + string propName = propertyName[propertyName.Length - 1]; + Property prop = mvarProperties[propName]; + if (prop == null) prop = mvarProperties.Add(propName, defaultValue); + return prop; + } + else + { + string propName = propertyName[propertyName.Length - 1]; + Property prop = group.Properties[propName]; + if (prop == null) prop = group.Properties.Add(propName, defaultValue); + return prop; + } + } + + public bool HasValue(string[] propertyName) + { + return (FindProperty(propertyName) != null); + } + public void SetValue(string[] p, T value) { - + Property prop = FindOrCreateProperty(p, value); + prop.Value = value; } private string mvarTitle = String.Empty;