7 changed files with 11 additions and 467 deletions
@ -1,121 +0,0 @@
@@ -1,121 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
namespace ICSharpCode.SettingsEditor |
||||
{ |
||||
partial class SettingsView |
||||
{ |
||||
/// <summary>
|
||||
/// Designer variable used to keep track of non-visual components.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null; |
||||
|
||||
/// <summary>
|
||||
/// Disposes resources used by the control.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing) |
||||
{ |
||||
if (disposing) { |
||||
if (components != null) { |
||||
components.Dispose(); |
||||
} |
||||
} |
||||
base.Dispose(disposing); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// This method is required for Windows Forms designer support.
|
||||
/// Do not change the method contents inside the source code editor. The Forms designer might
|
||||
/// not be able to load this method if it was changed manually.
|
||||
/// </summary>
|
||||
private void InitializeComponent() |
||||
{ |
||||
this.components = new System.ComponentModel.Container(); |
||||
this.grid = new System.Windows.Forms.DataGridView(); |
||||
this.NameColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); |
||||
this.TypeColumn = new System.Windows.Forms.DataGridViewComboBoxColumn(); |
||||
this.ScopeColumn = new System.Windows.Forms.DataGridViewComboBoxColumn(); |
||||
this.ValueColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); |
||||
this.bindingSource = new System.Windows.Forms.BindingSource(this.components); |
||||
((System.ComponentModel.ISupportInitialize)(this.grid)).BeginInit(); |
||||
((System.ComponentModel.ISupportInitialize)(this.bindingSource)).BeginInit(); |
||||
this.SuspendLayout(); |
||||
//
|
||||
// grid
|
||||
//
|
||||
this.grid.AutoGenerateColumns = false; |
||||
this.grid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; |
||||
this.grid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { |
||||
this.NameColumn, |
||||
this.TypeColumn, |
||||
this.ScopeColumn, |
||||
this.ValueColumn}); |
||||
this.grid.DataSource = this.bindingSource; |
||||
this.grid.Dock = System.Windows.Forms.DockStyle.Fill; |
||||
this.grid.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnKeystroke; |
||||
this.grid.Location = new System.Drawing.Point(0, 0); |
||||
this.grid.Name = "grid"; |
||||
this.grid.Size = new System.Drawing.Size(486, 362); |
||||
this.grid.TabIndex = 0; |
||||
this.grid.DataError += new System.Windows.Forms.DataGridViewDataErrorEventHandler(this.GridDataError); |
||||
this.grid.SelectionChanged += new System.EventHandler(this.GridSelectionChanged); |
||||
this.grid.UserDeletingRow += new System.Windows.Forms.DataGridViewRowCancelEventHandler(this.GridUserDeletingRow); |
||||
//
|
||||
// NameColumn
|
||||
//
|
||||
this.NameColumn.DataPropertyName = "Name"; |
||||
this.NameColumn.HeaderText = "Name"; |
||||
this.NameColumn.MinimumWidth = 50; |
||||
this.NameColumn.Name = "NameColumn"; |
||||
//
|
||||
// TypeColumn
|
||||
//
|
||||
this.TypeColumn.DataPropertyName = "WrappedSettingType"; |
||||
this.TypeColumn.DropDownWidth = 255; |
||||
this.TypeColumn.HeaderText = "Type"; |
||||
this.TypeColumn.MinimumWidth = 50; |
||||
this.TypeColumn.Name = "TypeColumn"; |
||||
this.TypeColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; |
||||
//
|
||||
// ScopeColumn
|
||||
//
|
||||
this.ScopeColumn.DataPropertyName = "Scope"; |
||||
this.ScopeColumn.DropDownWidth = 80; |
||||
this.ScopeColumn.HeaderText = "Scope"; |
||||
this.ScopeColumn.MinimumWidth = 30; |
||||
this.ScopeColumn.Name = "ScopeColumn"; |
||||
this.ScopeColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; |
||||
//
|
||||
// ValueColumn
|
||||
//
|
||||
this.ValueColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; |
||||
this.ValueColumn.DataPropertyName = "SerializedValue"; |
||||
this.ValueColumn.HeaderText = "Value"; |
||||
this.ValueColumn.MinimumWidth = 50; |
||||
this.ValueColumn.Name = "ValueColumn"; |
||||
//
|
||||
// bindingSource
|
||||
//
|
||||
this.bindingSource.DataSource = typeof(ICSharpCode.SettingsEditor.SettingsEntry); |
||||
this.bindingSource.AddingNew += new System.ComponentModel.AddingNewEventHandler(this.BindingSourceAddingNew); |
||||
//
|
||||
// SettingsView
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); |
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; |
||||
this.Controls.Add(this.grid); |
||||
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); |
||||
} |
||||
private System.Windows.Forms.DataGridViewComboBoxColumn TypeColumn; |
||||
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.DataGridView grid; |
||||
} |
||||
} |
@ -1,181 +0,0 @@
@@ -1,181 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.ComponentModel; |
||||
using System.Drawing; |
||||
using System.Windows.Forms; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.NRefactory.TypeSystem; |
||||
using ICSharpCode.NRefactory.TypeSystem.Implementation; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.SharpDevelop; |
||||
|
||||
namespace ICSharpCode.SettingsEditor |
||||
{ |
||||
public partial class SettingsView : UserControl, ISettingsEntryHost |
||||
{ |
||||
public event EventHandler SelectionChanged; |
||||
public event EventHandler SettingsChanged; |
||||
|
||||
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<string> typeNames = new List<string>(); |
||||
List<Type> types = new List<Type>(); |
||||
IAmbience ambience; |
||||
ICompilation compilation; |
||||
|
||||
public SettingsView() |
||||
{ |
||||
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); |
||||
} |
||||
|
||||
ScopeColumn.DataSource = Enum.GetValues(typeof(SettingScope)); |
||||
TypeColumn.DataSource = typeNames; |
||||
} |
||||
|
||||
public void ShowEntries(IList<SettingsEntry> list) |
||||
{ |
||||
bindingSource.Clear(); |
||||
foreach (SettingsEntry entry in list) { |
||||
bindingSource.Add(entry); |
||||
} |
||||
bindingSource.ListChanged += delegate(object sender, ListChangedEventArgs e) { |
||||
if (e.NewIndex >= 0 && e.NewIndex < bindingSource.Count) { |
||||
if (((SettingsEntry)bindingSource[e.NewIndex]).Name != null) { |
||||
OnSettingsChanged(e); |
||||
} |
||||
} |
||||
}; |
||||
} |
||||
|
||||
void GridSelectionChanged(object sender, EventArgs e) |
||||
{ |
||||
if (SelectionChanged != null) |
||||
SelectionChanged(this, e); |
||||
} |
||||
|
||||
public IEnumerable<SettingsEntry> GetAllEntries() |
||||
{ |
||||
List<SettingsEntry> l = new List<SettingsEntry>(); |
||||
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<SettingsEntryPropertyGridWrapper> GetSelectedEntriesForPropertyGrid() |
||||
{ |
||||
List<SettingsEntryPropertyGridWrapper> l |
||||
= new List<SettingsEntryPropertyGridWrapper>(); |
||||
if (grid.SelectedRows.Count > 0) { |
||||
foreach (DataGridViewRow row in grid.SelectedRows) { |
||||
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; |
||||
if (cell.OwningRow.DataBoundItem != null) { |
||||
l.Add(new SettingsEntryPropertyGridWrapper((SettingsEntry)cell.OwningRow.DataBoundItem)); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
return l; |
||||
} |
||||
|
||||
void BindingSourceAddingNew(object sender, AddingNewEventArgs e) |
||||
{ |
||||
SettingsEntry entry = new SettingsEntry(this); |
||||
entry.Type = typeof(string); |
||||
e.NewObject = entry; |
||||
} |
||||
|
||||
void GridDataError(object sender, DataGridViewDataErrorEventArgs e) |
||||
{ |
||||
LoggingService.Debug("Row " + e.RowIndex + ", column " + e.ColumnIndex + ", error " + e.Exception.ToString()); |
||||
if (e.Exception != null) { |
||||
MessageBox.Show("Error in data entry: " + e.Exception.Message); |
||||
} else { |
||||
MessageBox.Show("Error in data entry"); |
||||
} |
||||
} |
||||
|
||||
string ISettingsEntryHost.GetDisplayNameForType(Type type) |
||||
{ |
||||
foreach (SpecialTypeDescriptor d in SpecialTypeDescriptor.Descriptors) { |
||||
if (type == d.type) |
||||
return d.name; |
||||
} |
||||
return ambience.ConvertType(type.ToTypeReference().Resolve(compilation)); |
||||
} |
||||
|
||||
Type ISettingsEntryHost.GetTypeByDisplayName(string displayName) |
||||
{ |
||||
for (int i = 0; i < typeNames.Count; i++) { |
||||
if (typeNames[i] == displayName) |
||||
return types[i]; |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
void GridUserDeletingRow(object sender, DataGridViewRowCancelEventArgs e) |
||||
{ |
||||
if (e.Row != null && !e.Cancel) { |
||||
OnSettingsChanged(EventArgs.Empty); |
||||
} |
||||
} |
||||
|
||||
protected virtual void OnSettingsChanged(EventArgs e) |
||||
{ |
||||
if (SettingsChanged != null) { |
||||
SettingsChanged(this, e); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,128 +0,0 @@
@@ -1,128 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<root> |
||||
<!-- |
||||
Microsoft ResX Schema |
||||
|
||||
Version 2.0 |
||||
|
||||
The primary goals of this format is to allow a simple XML format |
||||
that is mostly human readable. The generation and parsing of the |
||||
various data types are done through the TypeConverter classes |
||||
associated with the data types. |
||||
|
||||
Example: |
||||
|
||||
... ado.net/XML headers & schema ... |
||||
<resheader name="resmimetype">text/microsoft-resx</resheader> |
||||
<resheader name="version">2.0</resheader> |
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> |
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> |
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> |
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> |
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> |
||||
<value>[base64 mime encoded serialized .NET Framework object]</value> |
||||
</data> |
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> |
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> |
||||
<comment>This is a comment</comment> |
||||
</data> |
||||
|
||||
There are any number of "resheader" rows that contain simple |
||||
name/value pairs. |
||||
|
||||
Each data row contains a name, and value. The row also contains a |
||||
type or mimetype. Type corresponds to a .NET class that support |
||||
text/value conversion through the TypeConverter architecture. |
||||
Classes that don't support this are serialized and stored with the |
||||
mimetype set. |
||||
|
||||
The mimetype is used for serialized objects, and tells the |
||||
ResXResourceReader how to depersist the object. This is currently not |
||||
extensible. For a given mimetype the value must be set accordingly: |
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format |
||||
that the ResXResourceWriter will generate, however the reader can |
||||
read any of the formats listed below. |
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64 |
||||
value : The object must be serialized with |
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter |
||||
: and then encoded with base64 encoding. |
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64 |
||||
value : The object must be serialized with |
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter |
||||
: and then encoded with base64 encoding. |
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64 |
||||
value : The object must be serialized into a byte array |
||||
: using a System.ComponentModel.TypeConverter |
||||
: and then encoded with base64 encoding. |
||||
--> |
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> |
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> |
||||
<xsd:element name="root" msdata:IsDataSet="true"> |
||||
<xsd:complexType> |
||||
<xsd:choice maxOccurs="unbounded"> |
||||
<xsd:element name="metadata"> |
||||
<xsd:complexType> |
||||
<xsd:sequence> |
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" /> |
||||
</xsd:sequence> |
||||
<xsd:attribute name="name" use="required" type="xsd:string" /> |
||||
<xsd:attribute name="type" type="xsd:string" /> |
||||
<xsd:attribute name="mimetype" type="xsd:string" /> |
||||
<xsd:attribute ref="xml:space" /> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
<xsd:element name="assembly"> |
||||
<xsd:complexType> |
||||
<xsd:attribute name="alias" type="xsd:string" /> |
||||
<xsd:attribute name="name" type="xsd:string" /> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
<xsd:element name="data"> |
||||
<xsd:complexType> |
||||
<xsd:sequence> |
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> |
||||
</xsd:sequence> |
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> |
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> |
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> |
||||
<xsd:attribute ref="xml:space" /> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
<xsd:element name="resheader"> |
||||
<xsd:complexType> |
||||
<xsd:sequence> |
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
||||
</xsd:sequence> |
||||
<xsd:attribute name="name" type="xsd:string" use="required" /> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
</xsd:choice> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
</xsd:schema> |
||||
<resheader name="resmimetype"> |
||||
<value>text/microsoft-resx</value> |
||||
</resheader> |
||||
<resheader name="version"> |
||||
<value>2.0</value> |
||||
</resheader> |
||||
<resheader name="reader"> |
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
||||
</resheader> |
||||
<resheader name="writer"> |
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
||||
</resheader> |
||||
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> |
||||
<data name="TypeColumn.UserAddedColumn" type="System.Boolean, mscorlib"> |
||||
<value>True</value> |
||||
</data> |
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> |
||||
<data name="bindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing"> |
||||
<value>28, 18</value> |
||||
</data> |
||||
</root> |
@ -1,6 +1,6 @@
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<UserControl |
||||
x:Class="ICSharpCode.SettingsEditor.SettingsViewXaml" |
||||
x:Class="ICSharpCode.SettingsEditor.SettingsView" |
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
xmlns:sd="clr-namespace:ICSharpCode.SharpDevelop;assembly=ICSharpCode.SharpDevelop" |
Loading…
Reference in new issue