diff --git a/src/AddIns/DisplayBindings/SettingsEditor/Project/ProxyPropertyDescriptor.cs b/src/AddIns/DisplayBindings/SettingsEditor/Project/ProxyPropertyDescriptor.cs index 03092f38ce..c318048d73 100644 --- a/src/AddIns/DisplayBindings/SettingsEditor/Project/ProxyPropertyDescriptor.cs +++ b/src/AddIns/DisplayBindings/SettingsEditor/Project/ProxyPropertyDescriptor.cs @@ -13,11 +13,14 @@ using System.Reflection; namespace ICSharpCode.SettingsEditor { - public class ProxyPropertyDescriptor : PropertyDescriptor + /// + /// Forwards calls to the ProxyPropertyDescriptor to the base descriptor. + /// + public abstract class ProxyPropertyDescriptor : PropertyDescriptor { PropertyDescriptor baseDescriptor; - public ProxyPropertyDescriptor(PropertyDescriptor baseDescriptor) + protected ProxyPropertyDescriptor(PropertyDescriptor baseDescriptor) : base(baseDescriptor) { this.baseDescriptor = baseDescriptor; diff --git a/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsDisplayBinding.cs b/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsDisplayBinding.cs index a17f88d07d..c85693a16a 100644 --- a/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsDisplayBinding.cs +++ b/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsDisplayBinding.cs @@ -14,7 +14,7 @@ using ICSharpCode.SharpDevelop.Gui; namespace ICSharpCode.SettingsEditor { - public class SettingsDisplayBinding : IDisplayBinding + public sealed class SettingsDisplayBinding : IDisplayBinding { public bool CanCreateContentForFile(string fileName) { diff --git a/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsEditor.csproj b/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsEditor.csproj index 6881d6f249..a1e24e920b 100644 --- a/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsEditor.csproj +++ b/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsEditor.csproj @@ -60,6 +60,7 @@ SettingsView.cs + @@ -72,6 +73,11 @@ ICSharpCode.Core False + + {924EE450-603D-49C1-A8E5-4AFAA31CE6F3} + ICSharpCode.SharpDevelop.Dom + False + \ No newline at end of file diff --git a/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsEntry.cs b/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsEntry.cs index 145f787c41..4585c65e12 100644 --- a/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsEntry.cs +++ b/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsEntry.cs @@ -20,10 +20,15 @@ namespace ICSharpCode.SettingsEditor Application, User } - public class SettingsEntry : LocalizedObject + /// + /// Describes one settings entry. Used for binding to the DataGridView. + /// + public sealed class SettingsEntry : INotifyPropertyChanged { + public const bool GenerateDefaultValueInCodeDefault = true; + string description; - bool generateDefaultValueInCode = true; + bool generateDefaultValueInCode = GenerateDefaultValueInCodeDefault; string name; string provider = ""; bool roaming; @@ -39,7 +44,7 @@ namespace ICSharpCode.SettingsEditor { description = element.GetAttribute("Description"); if (!bool.TryParse(element.GetAttribute("GenerateDefaultValueInCode"), out generateDefaultValueInCode)) - generateDefaultValueInCode = true; + generateDefaultValueInCode = GenerateDefaultValueInCodeDefault; name = element.GetAttribute("Name"); provider = element.GetAttribute("Provider"); bool.TryParse(element.GetAttribute("Roaming"), out roaming); @@ -50,17 +55,7 @@ namespace ICSharpCode.SettingsEditor } type = GetType(element.GetAttribute("Type")); if (type != null && type != typeof(string)) { - TypeConverter c = TypeDescriptor.GetConverter(type); - SettingsSerializeAs ssa; - if (c.CanConvertFrom(typeof(string)) && c.CanConvertTo(typeof(string))) { - ssa = SettingsSerializeAs.String; - } else { - ssa = SettingsSerializeAs.Xml; - } - SettingsProperty p = new SettingsProperty(name); - p.PropertyType = type; - p.SerializeAs = ssa; - SettingsPropertyValue v = new SettingsPropertyValue(p); + SettingsPropertyValue v = GetSettingConverter(type, name); v.SerializedValue = element["Value"].InnerText; this.value = v.PropertyValue; } else { @@ -68,6 +63,55 @@ namespace ICSharpCode.SettingsEditor } } + static SettingsPropertyValue GetSettingConverter(Type type, string name) + { + TypeConverter c = TypeDescriptor.GetConverter(type); + SettingsSerializeAs ssa; + if (c.CanConvertFrom(typeof(string)) && c.CanConvertTo(typeof(string))) { + ssa = SettingsSerializeAs.String; + } else { + ssa = SettingsSerializeAs.Xml; + } + SettingsProperty p = new SettingsProperty(name); + p.PropertyType = type; + p.SerializeAs = ssa; + return new SettingsPropertyValue(p); + } + + public void WriteTo(XmlWriter writer) + { + writer.WriteStartElement("Setting"); + writer.WriteAttributeString("Name", this.Name); + writer.WriteAttributeString("Type", this.SerializedSettingType); + writer.WriteAttributeString("Scope", this.Scope.ToString()); + + if (!string.IsNullOrEmpty(description)) { + writer.WriteAttributeString("Description", description); + } + if (generateDefaultValueInCode != GenerateDefaultValueInCodeDefault) { + writer.WriteAttributeString("GenerateDefaultValueInCode", XmlConvert.ToString(generateDefaultValueInCode)); + } + if (!string.IsNullOrEmpty(provider)) { + writer.WriteAttributeString("Provider", provider); + } + if (scope == SettingScope.User) { + writer.WriteAttributeString("Roaming", XmlConvert.ToString(roaming)); + } + + writer.WriteStartElement("Value"); + writer.WriteAttributeString("Profile", "(Default)"); + if (type != null && type != typeof(string)) { + SettingsPropertyValue v = GetSettingConverter(type, name); + v.PropertyValue = value; + writer.WriteValue(v.SerializedValue); + } else { + writer.WriteValue((value ?? "").ToString()); + } + writer.WriteEndElement(); + + writer.WriteEndElement(); // Setting + } + Type GetType(string typeName) { return typeof(object).Assembly.GetType(typeName, false) @@ -75,51 +119,63 @@ namespace ICSharpCode.SettingsEditor ?? typeof(System.Data.DataRow).Assembly.GetType(typeName, false); } - [LocalizedProperty("Description", - Description="Description of the setting.")] + [Browsable(false)] public string Description { get { return description; } - set { description = value; } + set { + description = value; + OnPropertyChanged(new PropertyChangedEventArgs("Description")); + } } - [LocalizedProperty("Generate default value in code", - Description="Specifies whether the value should be saved as attribute in the generated code.")] - [DefaultValue(true)] + [Browsable(false)] public bool GenerateDefaultValueInCode { get { return generateDefaultValueInCode; } - set { generateDefaultValueInCode = value; } + set { + generateDefaultValueInCode = value; + OnPropertyChanged(new PropertyChangedEventArgs("GenerateDefaultValueInCode")); + } } [LocalizedProperty("Name", Description="Name of the setting.")] public string Name { get { return name; } - set { name = value; } + set { + if (string.IsNullOrEmpty(value)) + throw new ArgumentException("The name is invalid."); + name = value; + OnPropertyChanged(new PropertyChangedEventArgs("Name")); + } } - [LocalizedProperty("Provider", - Description="The provider used to manage the setting.")] + [Browsable(false)] public string Provider { get { return provider; } - set { provider = value; } + set { + provider = value; + OnPropertyChanged(new PropertyChangedEventArgs("Provider")); + } } - [LocalizedProperty("Roaming", - Description="Specifies whether changes to the setting are stored in 'Application Data' (Roaming=true) or 'Local Application Data' (Roaming=false)")] + [Browsable(false)] public bool Roaming { get { return roaming; } - set { roaming = value; } + set { + roaming = value; + OnPropertyChanged(new PropertyChangedEventArgs("Roaming")); + } } - [LocalizedProperty("Scope", - Description="Specifies whether the setting is per-application (read-only) or per-user (read/write).")] public SettingScope Scope { get { return scope; } - set { scope = value; } + set { + scope = value; + OnPropertyChanged(new PropertyChangedEventArgs("Scope")); + } } - [LocalizedProperty("SerializedSettingType", - Description="The type used for the setting in the strongly-typed settings class.")] + [Browsable(false)] public string SerializedSettingType { get { if (type != null) @@ -129,69 +185,34 @@ namespace ICSharpCode.SettingsEditor } } - [LocalizedProperty("Value", - Description="The default value of the setting.")] public object Value { get { return value; } set { if (type == null || type.IsInstanceOfType(value)) { this.value = value; + OnPropertyChanged(new PropertyChangedEventArgs("Value")); } else { throw new ArgumentException("Invalid type for property value."); } } } - #region Custom property descriptors - protected override void FilterProperties(PropertyDescriptorCollection col) - { - base.FilterProperties(col); - PropertyDescriptor oldValue = col["Value"]; - col.Remove(oldValue); - col.Add(new CustomValuePropertyDescriptor(oldValue, type)); - PropertyDescriptor oldRoaming = col["Roaming"]; - col.Remove(oldRoaming); - col.Add(new RoamingPropertyDescriptor(oldRoaming, this)); - } - - class RoamingPropertyDescriptor : ProxyPropertyDescriptor - { - SettingsEntry entry; - - public RoamingPropertyDescriptor(PropertyDescriptor baseDescriptor, SettingsEntry entry) - : base(baseDescriptor) - { - this.entry = entry; - } - - public override bool IsReadOnly { - get { - return entry.Scope == SettingScope.Application; - } + [Browsable(false)] + public Type Type { + get { return type; } + set { + type = value; + OnPropertyChanged(new PropertyChangedEventArgs("Type")); } } - class CustomValuePropertyDescriptor : ProxyPropertyDescriptor + public event PropertyChangedEventHandler PropertyChanged; + + void OnPropertyChanged(PropertyChangedEventArgs e) { - Type newPropertyType; - - public CustomValuePropertyDescriptor(PropertyDescriptor baseDescriptor, Type newPropertyType) - : base(baseDescriptor) - { - this.newPropertyType = newPropertyType; - } - - public override Type PropertyType { - get { - return newPropertyType; - } - } - - public override object GetEditor(Type editorBaseType) - { - return TypeDescriptor.GetEditor(newPropertyType, editorBaseType); + if (PropertyChanged != null) { + PropertyChanged(this, e); } } - #endregion } } diff --git a/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsEntryPropertyGridWrapper.cs b/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsEntryPropertyGridWrapper.cs new file mode 100644 index 0000000000..dc219ec72a --- /dev/null +++ b/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsEntryPropertyGridWrapper.cs @@ -0,0 +1,148 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.ComponentModel; +using System.Xml; +using System.Configuration; +using ICSharpCode.SharpDevelop.Gui; + +namespace ICSharpCode.SettingsEditor +{ + /// + /// Wraps around one SettingsEntry. Used to bind to the property grid, supporting + /// type editor based on the setting's type. + /// + public sealed class SettingsEntryPropertyGridWrapper : LocalizedObject, INotifyPropertyChanged + { + readonly SettingsEntry entry; + + public SettingsEntryPropertyGridWrapper(SettingsEntry entry) + { + if (entry == null) + throw new ArgumentNullException("entry"); + this.entry = entry; + } + + [LocalizedProperty("Description", + Description="Description of the setting.")] + public string Description { + get { return entry.Description; } + set { entry.Description = value; } + } + + [LocalizedProperty("Generate default value in code", + Description="Specifies whether the value should be saved as attribute in the generated code.")] + [DefaultValue(SettingsEntry.GenerateDefaultValueInCodeDefault)] + public bool GenerateDefaultValueInCode { + get { return entry.GenerateDefaultValueInCode; } + set { entry.GenerateDefaultValueInCode = value; } + } + + [LocalizedProperty("Name", + Description="Name of the setting.")] + public string Name { + get { return entry.Name; } + set { entry.Name = value; } + } + + [LocalizedProperty("Provider", + Description="The provider used to manage the setting.")] + public string Provider { + get { return entry.Provider; } + set { entry.Provider = value; } + } + + [LocalizedProperty("Roaming", + Description="Specifies whether changes to the setting are stored in 'Application Data' (Roaming=true) or 'Local Application Data' (Roaming=false)")] + public bool Roaming { + get { return entry.Roaming; } + set { entry.Roaming = value; } + } + + [LocalizedProperty("Scope", + Description="Specifies whether the setting is per-application (read-only) or per-user (read/write).")] + public SettingScope Scope { + get { return entry.Scope; } + set { entry.Scope = value; } + } + + [LocalizedProperty("SerializedSettingType", + Description="The type used for the setting in the strongly-typed settings class.")] + public string SerializedSettingType { + get { return entry.SerializedSettingType; } + } + + [LocalizedProperty("Value", + Description="The default value of the setting.")] + public object Value { + get { return entry.Value; } + set { entry.Value = value; } + } + + #region Custom property descriptors + protected override void FilterProperties(PropertyDescriptorCollection col) + { + base.FilterProperties(col); + PropertyDescriptor oldValue = col["Value"]; + col.Remove(oldValue); + col.Add(new CustomValuePropertyDescriptor(oldValue, entry.Type ?? typeof(string))); + PropertyDescriptor oldRoaming = col["Roaming"]; + col.Remove(oldRoaming); + col.Add(new RoamingPropertyDescriptor(oldRoaming, entry)); + } + + class RoamingPropertyDescriptor : ProxyPropertyDescriptor + { + SettingsEntry entry; + + public RoamingPropertyDescriptor(PropertyDescriptor baseDescriptor, SettingsEntry entry) + : base(baseDescriptor) + { + if (entry == null) + throw new ArgumentNullException("entry"); + this.entry = entry; + } + + public override bool IsReadOnly { + get { + return entry.Scope == SettingScope.Application; + } + } + } + + class CustomValuePropertyDescriptor : ProxyPropertyDescriptor + { + Type newPropertyType; + + public CustomValuePropertyDescriptor(PropertyDescriptor baseDescriptor, Type newPropertyType) + : base(baseDescriptor) + { + if (newPropertyType == null) + throw new ArgumentNullException("newPropertyType"); + this.newPropertyType = newPropertyType; + } + + public override Type PropertyType { + get { + return newPropertyType; + } + } + + public override object GetEditor(Type editorBaseType) + { + return TypeDescriptor.GetEditor(newPropertyType, editorBaseType); + } + } + #endregion + + public event PropertyChangedEventHandler PropertyChanged { + add { entry.PropertyChanged += value; } + remove { entry.PropertyChanged -= value; } + } + } +} diff --git a/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsView.Designer.cs b/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsView.Designer.cs index 91a6036266..87e90c40fd 100644 --- a/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsView.Designer.cs +++ b/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsView.Designer.cs @@ -8,7 +8,7 @@ */ namespace ICSharpCode.SettingsEditor { - partial class SettingsView : System.Windows.Forms.UserControl + partial class SettingsView { /// /// Designer variable used to keep track of non-visual components. @@ -36,9 +36,15 @@ namespace ICSharpCode.SettingsEditor /// private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); this.grid = new System.Windows.Forms.DataGridView(); + this.bindingSource = new System.Windows.Forms.BindingSource(this.components); this.label1 = new System.Windows.Forms.Label(); + this.NameColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ScopeColumn = new System.Windows.Forms.DataGridViewComboBoxColumn(); + this.ValueColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); ((System.ComponentModel.ISupportInitialize)(this.grid)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.bindingSource)).BeginInit(); this.SuspendLayout(); // // grid @@ -46,13 +52,24 @@ namespace ICSharpCode.SettingsEditor this.grid.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.grid.AutoGenerateColumns = false; this.grid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.grid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.NameColumn, + this.ScopeColumn, + this.ValueColumn}); + this.grid.DataSource = this.bindingSource; + this.grid.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnEnter; this.grid.Location = new System.Drawing.Point(3, 38); this.grid.Name = "grid"; this.grid.Size = new System.Drawing.Size(480, 321); this.grid.TabIndex = 0; this.grid.SelectionChanged += new System.EventHandler(this.GridSelectionChanged); - this.grid.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.GridCellContentClick); + // + // bindingSource + // + this.bindingSource.DataSource = typeof(ICSharpCode.SettingsEditor.SettingsEntry); + this.bindingSource.AddingNew += new System.ComponentModel.AddingNewEventHandler(this.BindingSourceAddingNew); // // label1 // @@ -63,6 +80,25 @@ namespace ICSharpCode.SettingsEditor this.label1.TabIndex = 1; this.label1.Text = "SettingsView prototype. Code generation not implemented!"; // + // NameColumn + // + this.NameColumn.DataPropertyName = "Name"; + this.NameColumn.HeaderText = "Name"; + this.NameColumn.Name = "NameColumn"; + // + // Scope + // + this.ScopeColumn.DataPropertyName = "Scope"; + this.ScopeColumn.HeaderText = "Scope"; + this.ScopeColumn.Name = "ScopeColumn"; + // + // ValueColumn + // + this.ValueColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.ValueColumn.DataPropertyName = "Value"; + this.ValueColumn.HeaderText = "Value"; + this.ValueColumn.Name = "ValueColumn"; + // // SettingsView // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -72,9 +108,14 @@ namespace ICSharpCode.SettingsEditor this.Name = "SettingsView"; this.Size = new System.Drawing.Size(486, 362); ((System.ComponentModel.ISupportInitialize)(this.grid)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.bindingSource)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); } + private System.Windows.Forms.DataGridViewComboBoxColumn ScopeColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn ValueColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn NameColumn; + private System.Windows.Forms.BindingSource bindingSource; private System.Windows.Forms.Label label1; private System.Windows.Forms.DataGridView grid; } diff --git a/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsView.cs b/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsView.cs index db33d0696f..6121c109a3 100644 --- a/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsView.cs +++ b/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsView.cs @@ -12,14 +12,16 @@ using System.ComponentModel; using System.Drawing; using System.Windows.Forms; using System.Collections.Generic; +using ICSharpCode.SharpDevelop.Gui; +using ICSharpCode.Core; namespace ICSharpCode.SettingsEditor { - /// - /// Description of SettingsView. - /// - public partial class SettingsView + public partial class SettingsView : UserControl { + public event EventHandler SelectionChanged; + public event EventHandler SettingsChanged; + public SettingsView() { // @@ -27,35 +29,23 @@ namespace ICSharpCode.SettingsEditor // InitializeComponent(); - // - // TODO: Add constructor code after the InitializeComponent() call. - // - } - - void GridCellContentClick(object sender, System.Windows.Forms.DataGridViewCellEventArgs e) - { - + ScopeColumn.DataSource = Enum.GetValues(typeof(SettingScope)); } - public void ShowEntries(List list) + public void ShowEntries(IList list) { - grid.AutoGenerateColumns = false; - grid.DataSource = list; - if (grid.Columns.Count == 0) { - grid.Columns.Add("Name", "Name"); - grid.Columns[0].DataPropertyName = "Name"; - grid.Columns.Add("Value", "Value"); - grid.Columns[1].DataPropertyName = "Value"; - grid.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - grid.Columns[1].MinimumWidth = 75; + foreach (SettingsEntry entry in list) { + bindingSource.Add(entry); } - grid.AllowUserToAddRows = true; - /*foreach (SettingsEntry e in list) { - grid.Rows.Add(e.Name, - e.SerializedSettingType, - e.Scope, - e.Value); - }*/ + bindingSource.ListChanged += delegate(object sender, ListChangedEventArgs e) { + if (e.NewIndex >= 0 && e.NewIndex < bindingSource.Count) { + if (((SettingsEntry)bindingSource[e.NewIndex]).Name != null) { + if (SettingsChanged != null) { + SettingsChanged(this, e); + } + } + } + }; } void GridSelectionChanged(object sender, EventArgs e) @@ -64,25 +54,49 @@ namespace ICSharpCode.SettingsEditor SelectionChanged(this, e); } - public List GetSelectedEntries() + public IEnumerable GetAllEntries() { List l = new List(); + foreach (SettingsEntry entry in bindingSource) { + if (!string.IsNullOrEmpty(entry.Name)) { + l.Add(entry); + } + } + l.Sort(delegate(SettingsEntry a, SettingsEntry b) { + return a.Name.CompareTo(b.Name); + }); + return l; + } + + public List GetSelectedEntriesForPropertyGrid() + { + List l + = new List(); if (grid.SelectedRows.Count > 0) { foreach (DataGridViewRow row in grid.SelectedRows) { - l.Add((SettingsEntry)row.DataBoundItem); + if (row.DataBoundItem != null) { + l.Add(new SettingsEntryPropertyGridWrapper((SettingsEntry)row.DataBoundItem)); + } } } else { bool[] rowAdded = new bool[grid.Rows.Count]; foreach (DataGridViewCell cell in grid.SelectedCells) { if (rowAdded[cell.RowIndex] == false) { rowAdded[cell.RowIndex] = true; - l.Add((SettingsEntry)cell.OwningRow.DataBoundItem); + if (cell.OwningRow.DataBoundItem != null) { + l.Add(new SettingsEntryPropertyGridWrapper((SettingsEntry)cell.OwningRow.DataBoundItem)); + } } } } return l; } - public event EventHandler SelectionChanged; + void BindingSourceAddingNew(object sender, AddingNewEventArgs e) + { + SettingsEntry entry = new SettingsEntry(); + entry.Type = typeof(string); + e.NewObject = entry; + } } } diff --git a/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsView.resx b/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsView.resx index 7080a7d118..5962756a76 100644 --- a/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsView.resx +++ b/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsView.resx @@ -117,4 +117,10 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + True + + + 28, 18 + \ No newline at end of file diff --git a/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsViewContent.cs b/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsViewContent.cs index 0018503c09..9c60d6d720 100644 --- a/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsViewContent.cs +++ b/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsViewContent.cs @@ -7,14 +7,15 @@ * To change this template use Tools | Options | Coding | Edit Standard Headers. */ -using System.Xml; using System; -using System.IO; using System.Collections.Generic; +using System.IO; +using System.Windows.Forms; +using System.Xml; +using System.Text; + using ICSharpCode.Core; -using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop.Gui; -using System.Windows.Forms; namespace ICSharpCode.SettingsEditor { @@ -26,7 +27,10 @@ namespace ICSharpCode.SettingsEditor public SettingsViewContent() { view.SelectionChanged += delegate { - propertyContainer.SelectedObjects = view.GetSelectedEntries().ToArray(); + propertyContainer.SelectedObjects = view.GetSelectedEntriesForPropertyGrid().ToArray(); + }; + view.SettingsChanged += delegate { + IsDirty = true; }; } @@ -40,7 +44,6 @@ namespace ICSharpCode.SettingsEditor { TitleName = Path.GetFileName(filename); FileName = filename; - IsDirty = false; try { XmlDocument doc = new XmlDocument(); @@ -56,10 +59,35 @@ namespace ICSharpCode.SettingsEditor } catch (XmlException ex) { MessageService.ShowMessage(ex.Message); } + IsDirty = false; } - public override void Save() + const string XmlNamespace = "http://schemas.microsoft.com/VisualStudio/2004/01/settings"; + + public override void Save(string fileName) { + using (XmlTextWriter writer = new XmlTextWriter(fileName, Encoding.UTF8)) { + writer.Formatting = Formatting.Indented; + writer.WriteStartDocument(); + writer.WriteStartElement("SettingsFile", XmlNamespace); + writer.WriteAttributeString("CurrentProfile", "(Default)"); + + writer.WriteStartElement("Profiles"); + writer.WriteStartElement("Profile"); + writer.WriteAttributeString("Name", "(Default)"); + writer.WriteEndElement(); // Profile + writer.WriteEndElement(); // Profiles + + writer.WriteStartElement("Settings"); + foreach (SettingsEntry e in view.GetAllEntries()) { + e.WriteTo(writer); + } + writer.WriteEndElement(); // Settings + + writer.WriteEndElement(); // SettingsFile + writer.WriteEndDocument(); + } + IsDirty = false; } public PropertyContainer PropertyContainer { diff --git a/src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs b/src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs index 1555fb4c73..1d21974e71 100644 --- a/src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs +++ b/src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs @@ -81,12 +81,6 @@ namespace ICSharpCode.SharpDevelop.Gui return viewTabControl.SelectedIndex; } - protected override Size DefaultSize { - get { - return Size.Empty; - } - } - public void SwitchView(int viewNumber) { if (viewTabControl != null) {