diff --git a/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsEditor.csproj b/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsEditor.csproj
index ce5193b16e..06e332f6ca 100644
--- a/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsEditor.csproj
+++ b/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsEditor.csproj
@@ -38,6 +38,8 @@
4096
+
+
3.5
@@ -45,11 +47,15 @@
+
+ 4.0
+
3.5
+
@@ -75,6 +81,10 @@
+
+ SettingsViewXaml.xaml
+ Code
+
@@ -95,6 +105,13 @@
ICSharpCode.Core
False
+
+ {8035765F-D51F-4A0C-A746-2FD100E19419}
+ ICSharpCode.SharpDevelop.Widgets
+
+
+
+
\ 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 5e6db133dd..3c76bff3d4 100644
--- a/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsEntry.cs
+++ b/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsEntry.cs
@@ -33,14 +33,6 @@ namespace ICSharpCode.SettingsEditor
object value;
ISettingsEntryHost host;
- [Obsolete("This constructor is required by the DataGridView, but not used because we " +
- "use the BindingSourceAddingNew event. Use the overload specifying a host " +
- "argument instead!")]
- public SettingsEntry()
- {
- throw new NotSupportedException();
- }
-
public SettingsEntry(ISettingsEntryHost host)
{
if (host == null)
@@ -155,6 +147,7 @@ namespace ICSharpCode.SettingsEditor
OnPropertyChanged(new PropertyChangedEventArgs("Name"));
}
}
+
[Browsable(false)]
public string Provider {
diff --git a/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsViewContent.cs b/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsViewContent.cs
index 7db89e0688..09c58d15c1 100644
--- a/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsViewContent.cs
+++ b/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsViewContent.cs
@@ -19,7 +19,8 @@ namespace ICSharpCode.SettingsEditor
{
public class SettingsViewContent : AbstractViewContentHandlingLoadErrors, IHasPropertyContainer
{
- SettingsView view = new SettingsView();
+// SettingsView view = new SettingsView();
+ SettingsViewXaml view = new SettingsViewXaml();
PropertyContainer propertyContainer = new PropertyContainer();
SettingsDocument setDoc = new SettingsDocument();
MemoryStream appConfigStream;
@@ -28,6 +29,7 @@ namespace ICSharpCode.SettingsEditor
public SettingsViewContent(OpenedFile file) : base(file)
{
TryOpenAppConfig(false);
+ /*
view.SelectionChanged += delegate {
propertyContainer.SelectedObjects = view.GetSelectedEntriesForPropertyGrid().ToArray();
};
@@ -37,7 +39,26 @@ namespace ICSharpCode.SettingsEditor
if (appConfigFile != null)
appConfigFile.MakeDirty();
};
+ */
+
this.UserContent = view;
+
+ view.SelectionChanged += ((s,e) =>
+ {
+ Console.WriteLine("SettingsViewContent.SelectionChanged");
+ propertyContainer.SelectedObjects = view.GetSelectedEntriesForPropertyGrid().ToArray();
+ });
+
+
+ view.SettingsChanged += ((s,e) =>
+ {
+ Console.WriteLine("SettingsViewContent.SettingsChanged");
+ if (this.PrimaryFile != null)
+ this.PrimaryFile.MakeDirty();
+ if (appConfigFile != null)
+ appConfigFile.MakeDirty();
+ });
+
}
void TryOpenAppConfig(bool createIfNotExists)
@@ -61,6 +82,8 @@ namespace ICSharpCode.SettingsEditor
protected override void LoadInternal(OpenedFile file, Stream stream)
{
+ Console.WriteLine ("LoadInternal");
+
if (file == PrimaryFile) {
try {
XmlDocument doc = new XmlDocument();
@@ -75,6 +98,7 @@ namespace ICSharpCode.SettingsEditor
appConfigStream = new MemoryStream();
stream.CopyTo(appConfigStream);
}
+
}
void ShowLoadError(string message)
@@ -117,11 +141,14 @@ namespace ICSharpCode.SettingsEditor
appConfigStream.WriteTo(stream);
}
}
+
}
#region Update app.config
void UpdateAppConfig(XDocument appConfigDoc)
{
+ Console.WriteLine("UpdateAppConfig(XDocument appConfigDoc)");
+ /*
var entries = view.GetAllEntries();
var userEntries = entries.Where(e => e.Scope == SettingScope.User);
var appEntries = entries.Where(e => e.Scope == SettingScope.Application);
@@ -147,6 +174,7 @@ namespace ICSharpCode.SettingsEditor
if (appSettings != null) {
UpdateSettings(appSettings, appEntries);
}
+ */
}
void RegisterAppConfigSection(XElement configSections, bool hasUserEntries, bool hasAppEntries)
diff --git a/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsViewXaml.xaml b/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsViewXaml.xaml
new file mode 100644
index 0000000000..d107534e3f
--- /dev/null
+++ b/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsViewXaml.xaml
@@ -0,0 +1,63 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsViewXaml.xaml.cs b/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsViewXaml.xaml.cs
new file mode 100644
index 0000000000..fe9e2561dd
--- /dev/null
+++ b/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsViewXaml.xaml.cs
@@ -0,0 +1,254 @@
+/*
+ * Created by SharpDevelop.
+ * User: Peter Forstmeier
+ * Date: 21.01.2013
+ * Time: 19:57
+ *
+ * To change this template use Tools | Options | Coding | Edit Standard Headers.
+ */
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Text;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+
+using ICSharpCode.NRefactory.TypeSystem;
+using ICSharpCode.NRefactory.TypeSystem.Implementation;
+using ICSharpCode.SharpDevelop;
+using ICSharpCode.SharpDevelop.Widgets;
+
+namespace ICSharpCode.SettingsEditor
+{
+ ///
+ /// Interaction logic for SettingsViewXaml.xaml
+ ///
+ public partial class SettingsViewXaml : UserControl,ISettingsEntryHost
+ {
+ public event EventHandler SettingsChanged;
+ public event EventHandler SelectionChanged;
+
+ // Remove empty constr from settingsentry
+
+ static readonly Type[] defaultAvailableTypes = new Type[] {
+ typeof(bool),
+ typeof(byte),
+ typeof(char),
+ typeof(decimal),
+ typeof(double),
+ typeof(float),
+ typeof(int),
+ typeof(long),
+ typeof(sbyte),
+ typeof(short),
+ typeof(string),
+ typeof(System.Collections.Specialized.StringCollection),
+ typeof(System.DateTime),
+ typeof(System.Drawing.Color),
+ typeof(System.Drawing.Font),
+ typeof(System.Drawing.Point),
+ typeof(System.Drawing.Size),
+ typeof(System.Guid),
+ typeof(System.TimeSpan),
+ typeof(uint),
+ typeof(ulong),
+ typeof(ushort)
+ };
+
+ List typeNames = new List();
+ List types = new List();
+ IAmbience ambience;
+ ICompilation compilation;
+
+ public SettingsViewXaml()
+ {
+
+ InitializeComponent();
+ ambience = AmbienceService.GetCurrentAmbience();
+ compilation = MinimalCorlib.Instance.CreateCompilation();
+
+ foreach (Type type in defaultAvailableTypes) {
+ types.Add(type);
+ typeNames.Add(ambience.ConvertType(type.ToTypeReference().Resolve(compilation)));
+ }
+ foreach (SpecialTypeDescriptor d in SpecialTypeDescriptor.Descriptors) {
+ types.Add(d.type);
+ typeNames.Add(d.name);
+ }
+ Entries = new ObservableCollection();
+
+
+ }
+
+
+ public void ShowEntries(IList list)
+ {
+ foreach (var element in list) {
+ Entries.Add(new SettingsVM(element));
+ }
+
+ Entries.CollectionChanged += ((s,e)=>
+ {
+ OnSettingsChanged(e);
+ });
+
+ foreach (var element in Entries) {
+ element.PropertyChanged += ((s,e) => {
+ OnSettingsChanged(e);
+ });
+
+ }
+
+ this.DataContext = this;
+ if (Entries.Count > 0) {
+ datagrid.SelectedItem = Entries[0];
+ }
+ }
+
+
+ public IEnumerable GetAllEntries()
+ {
+ List l = new List();
+ foreach (var element in Entries) {
+ var s = element.Entry;
+ if (!String.IsNullOrEmpty(s.Name)) {
+ l.Add(s);
+ }
+ }
+ l.Sort(delegate(SettingsEntry a, SettingsEntry b) {
+ return a.Name.CompareTo(b.Name);
+ });
+ return l;
+ }
+
+
+ public List GetSelectedEntriesForPropertyGrid()
+ {
+ List l = new List();
+
+ if (datagrid.SelectedItems.Count > 0) {
+ foreach (var element in datagrid.SelectedItems) {
+ var vm = element as SettingsVM;
+ if (vm != null) {
+ var settings = vm.Entry;
+ if (settings != null) {
+ l.Add(new SettingsEntryPropertyGridWrapper(settings));
+ }
+ }
+ }
+ }
+ return l;
+ }
+
+ #region Properties
+
+ public ObservableCollection Entries {get;set;}
+
+ public List TypeNames {
+ get {return typeNames;}
+ }
+
+ #endregion
+
+ #region ISettingsEntryHost
+
+ public string GetDisplayNameForType(Type type)
+ {
+ foreach (SpecialTypeDescriptor d in SpecialTypeDescriptor.Descriptors) {
+ if (type == d.type)
+ return d.name;
+ }
+ return ambience.ConvertType(type.ToTypeReference().Resolve(compilation));
+ }
+
+
+ public Type GetTypeByDisplayName(string displayName)
+ {
+ for (int i = 0; i < typeNames.Count; i++) {
+ if (typeNames[i] == displayName)
+ return types[i];
+ }
+ return null;
+ }
+
+ #endregion
+
+ protected virtual void OnSettingsChanged(EventArgs e)
+ {
+ if (SettingsChanged != null) {
+ SettingsChanged(this, e);
+ }
+ }
+
+
+ void datagrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ if (SelectionChanged != null)
+ SelectionChanged(this, e);
+ }
+
+
+ void Datagrid_AddingNewItem(object sender, AddingNewItemEventArgs e)
+ {
+ var settings = new SettingsEntry(this);
+ settings.Type = typeof(string);
+ var vm = new SettingsVM(settings);
+ e.NewItem = vm;
+ }
+ }
+
+
+ public class SettingsVM: ViewModelBase
+ {
+
+ public SettingsVM ()
+ {
+ }
+
+ public SettingsVM (SettingsEntry entry)
+ {
+ this.Entry = entry;
+ }
+
+ public SettingsEntry Entry {get; private set;}
+
+ public string Name
+ {
+ get {return this.Entry.Name;}
+ set {Entry.Name = value;
+ base.OnPropertyChanged("Name");
+ }
+
+ }
+
+ public string Type
+ {
+ get {return Entry.WrappedSettingType;}
+ set {Entry.WrappedSettingType = value;
+ base.OnPropertyChanged("Type");
+ }
+ }
+
+
+ public string SerializedValue {
+ get {return Entry.SerializedValue;}
+ set {Entry.SerializedValue = value;
+ base.OnPropertyChanged("SerializedValue");}
+ }
+
+
+
+ public SettingScope Scope {
+ get { return Entry.Scope; }
+ set { Entry.Scope = value;
+ Console.WriteLine(Scope.ToString());
+ base.OnPropertyChanged("Scope");}
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ApplicationSettings.xaml b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ApplicationSettings.xaml
index bf10010c6e..170eae5c2d 100644
--- a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ApplicationSettings.xaml
+++ b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ApplicationSettings.xaml
@@ -8,7 +8,8 @@
xmlns:widgets="http://icsharpcode.net/sharpdevelop/widgets"
xmlns:core="http://icsharpcode.net/sharpdevelop/core"
xmlns:optionpanels="clr-namespace:ICSharpCode.SharpDevelop.Gui.OptionPanels"
- xmlns:project="clr-namespace:ICSharpCode.SharpDevelop.Project">
+ xmlns:project="clr-namespace:ICSharpCode.SharpDevelop.Project"
+>