DotNet 4.8.1 build of DotNetBar

This commit is contained in:
2025-02-07 10:35:23 -05:00
parent 33439b63a0
commit 6b0a5d60f4
2609 changed files with 989814 additions and 7 deletions

View File

@@ -0,0 +1,45 @@
using System;
using System.ComponentModel;
using System.Windows.Forms;
using System.Windows.Forms.Design;
namespace DevComponents.SuperGrid.Design
{
[ToolboxItem(false)]
public class BoolValueTypeDropDown : ValueTypeDropDown
{
public BoolValueTypeDropDown()
{
}
public BoolValueTypeDropDown(object value,
IWindowsFormsEditorService editorService, ITypeDescriptorContext context)
: base(value, editorService, context)
{
}
protected override string[] GetListBoxItems()
{
return (new string[] { "True", "False" });
}
protected override int GetSelectedIndex()
{
if (Value is bool)
return ((bool)Value == true ? 0 : 1);
return (-1);
}
protected override void ListBoxSelectedIndexChanged(object sender, EventArgs e)
{
ListBox listBox = sender as ListBox;
if (listBox != null)
{
if (listBox.SelectedIndex >= 0)
Value = (listBox.SelectedIndex == 0);
}
}
}
}

View File

@@ -0,0 +1,232 @@
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Windows.Forms;
using DevComponents.DotNetBar.SuperGrid;
namespace DevComponents.SuperGrid.Design
{
/// <summary>
/// ColumnGroupHeaderCollectionEditor
/// </summary>
public class ColumnGroupHeaderCollectionEditor : CollectionEditor
{
#region Static variables
static Size _lastSize = Size.Empty;
static Point _lastLoc = Point.Empty;
#endregion
public ColumnGroupHeaderCollectionEditor(Type type)
: base(type)
{
}
#region CreateCollectionForm
protected override CollectionForm CreateCollectionForm()
{
CollectionForm collectionForm = base.CreateCollectionForm();
if (collectionForm.Controls[0] is TableLayoutPanel)
{
TableLayoutPanel tlpf =
collectionForm.Controls["overArchingTableLayoutPanel"] as TableLayoutPanel;
if (tlpf != null)
{
PropertyGrid propertyGrid =
tlpf.Controls["propertyBrowser"] as PropertyGrid;
if (propertyGrid != null)
{
propertyGrid.HelpVisible = true;
propertyGrid.GotFocus += PropertyGridGotFocus;
propertyGrid.SelectedObjectsChanged += PropertyGridSelectedObjectsChanged;
}
}
}
collectionForm.Load += CollectionFormLoad;
collectionForm.Resize += CollectionFormResize;
collectionForm.LocationChanged += CollectionFormLocationChanged;
return (collectionForm);
}
#region CollectionFormLoad
void CollectionFormLoad(object sender, EventArgs e)
{
CollectionForm form = sender as CollectionForm;
if (form != null)
{
if (_lastSize != Size.Empty)
form.Size = _lastSize;
if (_lastLoc != Point.Empty)
form.Location = _lastLoc;
}
}
#endregion
#region CollectionFormResize
void CollectionFormResize(object sender, EventArgs e)
{
CollectionForm form = sender as CollectionForm;
if (form != null && form.Visible == true)
_lastSize = form.Size;
}
#endregion
#region CollectionFormLocationChanged
void CollectionFormLocationChanged(object sender, EventArgs e)
{
CollectionForm form = sender as CollectionForm;
if (form != null && form.Visible == true)
_lastLoc = form.Location;
}
#endregion
#region PropertyGridGotFocus
void PropertyGridGotFocus(object sender, EventArgs e)
{
PropertyGrid propertyGrid = sender as PropertyGrid;
if (propertyGrid != null)
UpdateDesignerFocus(propertyGrid);
}
#endregion
#region PropertyGridSelectedObjectsChanged
void PropertyGridSelectedObjectsChanged(object sender, EventArgs e)
{
PropertyGrid propertyGrid = sender as PropertyGrid;
if (propertyGrid != null)
UpdateDesignerFocus(propertyGrid);
}
#endregion
#region UpdateDesignerFocus
private void UpdateDesignerFocus(PropertyGrid propertyGrid)
{
GridContainer row = Context.Instance as GridContainer;
if (row != null)
{
GridElement item = propertyGrid.SelectedObject as GridElement;
if (item != null)
row.SuperGrid.DesignerElement = item;
}
}
#endregion
#endregion
#region CreateCollectionItemType
protected override Type CreateCollectionItemType()
{
return typeof(ColumnGroupHeader);
}
#endregion
#region CreateNewItemTypes
protected override Type[] CreateNewItemTypes()
{
return new Type[]
{
typeof(ColumnGroupHeader),
};
}
#endregion
#region EditValue
public override object EditValue(
ITypeDescriptorContext context, IServiceProvider provider, object value)
{
object o = base.EditValue(context, provider, value);
return (o);
}
#endregion
#region CreateInstance
protected override object CreateInstance(Type itemType)
{
ColumnGroupHeader item =
(ColumnGroupHeader) base.CreateInstance(typeof (ColumnGroupHeader));
if (item != null)
{
GridColumnHeader gch = Context.Instance as GridColumnHeader;
if (gch != null)
{
item.Name = GetGroupHeaderName(gch.GroupHeaders);
}
else
{
ColumnGroupHeader csh = Context.Instance as ColumnGroupHeader;
if (csh != null)
{
item.Name = GetGroupHeaderName(csh.GroupHeaders);
item.StartDisplayIndex = csh.StartDisplayIndex;
item.EndDisplayIndex = csh.EndDisplayIndex;
item.ShowColumnHeaders = csh.ShowColumnHeaders;
}
}
}
return (item);
}
#region GetGroupHeaderName
private string GetGroupHeaderName(ColumnGroupHeaderCollection csc)
{
for (int i = 1; i < 200; i++)
{
string s = "GroupHeader" + i;
if (csc[s] == null)
return (s);
}
return ("");
}
#endregion
#endregion
}
}

View File

@@ -0,0 +1,98 @@
using System;
using System.ComponentModel;
using System.Drawing.Design;
using System.Windows.Forms;
using System.Windows.Forms.Design;
using DevComponents.DotNetBar.Controls;
using DevComponents.DotNetBar.SuperGrid;
namespace DevComponents.SuperGrid.Design
{
public class ColumnListTypeEditor : UITypeEditor
{
#region Private variables
IWindowsFormsEditorService _EditorService;
#endregion
#region GetEditStyle
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
{
return (UITypeEditorEditStyle.DropDown);
}
#endregion
#region GetPaintValueSupported
public override bool GetPaintValueSupported(ITypeDescriptorContext context)
{
return (false);
}
#endregion
#region EditValue
public override object EditValue(
ITypeDescriptorContext context, IServiceProvider provider, object value)
{
_EditorService =
provider.GetService(typeof (IWindowsFormsEditorService)) as IWindowsFormsEditorService;
if (_EditorService != null)
{
GridPanel panel = context.Instance as GridPanel;
if (panel != null)
{
ListBox lb = new ListBox();
lb.Dock = DockStyle.Fill;
lb.BorderStyle = BorderStyle.None;
lb.MouseClick += ListBoxMouseClick;
for (int i = 0; i < panel.Columns.Count; i++)
{
GridColumn col = panel.Columns[i];
string s = GetColumnText(col, i);
lb.Items.Add(s);
}
_EditorService.DropDownControl(lb);
if (lb.SelectedIndex >= 0)
return (lb.SelectedIndex);
return (panel.PrimaryColumnIndex);
}
}
return (base.EditValue(context, provider, value));
}
private string GetColumnText(GridColumn col, int index)
{
string s = index + " ";
if (string.IsNullOrEmpty(col.Name) == false)
return (s + "-" + col.Name);
if (string.IsNullOrEmpty(col.HeaderText) == false)
return (s + "-" + col.HeaderText);
return (s);
}
private void ListBoxMouseClick(object sender, MouseEventArgs e)
{
_EditorService.CloseDropDown();
}
#endregion
}
}

View File

@@ -0,0 +1,64 @@
namespace DevComponents.SuperGrid.Design
{
partial class EditTypeDropDown
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.listBox1 = new System.Windows.Forms.ListBox();
this.SuspendLayout();
//
// listBox1
//
this.listBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.listBox1.FormattingEnabled = true;
this.listBox1.Location = new System.Drawing.Point(0, 0);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(172, 95);
this.listBox1.TabIndex = 1;
this.listBox1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.ListBox1MouseClick);
this.listBox1.SelectedIndexChanged += new System.EventHandler(this.ListBox1SelectedIndexChanged);
//
// EditTypeDropDown
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.listBox1);
this.Name = "EditTypeDropDown";
this.Size = new System.Drawing.Size(172, 95);
this.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.DropDownPreviewKeyDown);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.ListBox listBox1;
}
}

View File

@@ -0,0 +1,147 @@
using System;
using System.ComponentModel;
using System.Windows.Forms;
using System.Windows.Forms.Design;
using DevComponents.DotNetBar.SuperGrid;
namespace DevComponents.SuperGrid.Design
{
[ToolboxItem(false)]
public partial class EditTypeDropDown : UserControl
{
#region Static data
static readonly Type[] Types = new Type[]
{
typeof(GridButtonXEditControl), typeof(GridCheckBoxXEditControl),
typeof(GridColorPickerEditControl), typeof(GridComboBoxExEditControl),
typeof(GridComboTreeEditControl), typeof(GridDateTimeInputEditControl),
typeof(GridDateTimePickerEditControl), typeof(GridDoubleInputEditControl),
typeof(GridIntegerInputEditControl), typeof(GridIpAddressInputEditControl),
typeof(GridLabelXEditControl), typeof(GridMaskedTextBoxEditControl),
typeof(GridMicroChartEditControl), typeof(GridNumericUpDownEditControl),
typeof(GridImageEditControl), typeof(GridProgressBarXEditControl),
typeof(GridRadialMenuEditControl), typeof(GridSliderEditControl),
typeof(GridSwitchButtonEditControl), typeof(GridTextBoxDropDownEditControl),
typeof(GridTextBoxXEditControl),
};
#endregion
#region Private variables
private Type _EditType;
private bool _EscapePressed;
private IWindowsFormsEditorService _EditorService;
private ITypeDescriptorContext _Context;
#endregion
public EditTypeDropDown(Type value,
IWindowsFormsEditorService editorService, ITypeDescriptorContext context)
{
Initialize();
_EditorService = editorService;
_Context = context;
EditType = value;
}
public EditTypeDropDown()
{
Initialize();
}
#region Initialize
private void Initialize()
{
InitializeComponent();
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
listBox1.Items.Add("(None)");
foreach (Type type in Types)
listBox1.Items.Add(type.Name);
}
#endregion
#region Public properties
#region EditorService
public IWindowsFormsEditorService EditorService
{
get { return (_EditorService); }
set { _EditorService = value; }
}
#endregion
#region EscapePressed
public bool EscapePressed
{
get { return (_EscapePressed); }
set { _EscapePressed = value; }
}
#endregion
#region EditType
public Type EditType
{
get { return (_EditType); }
set
{
_EditType = value;
_Context.OnComponentChanging();
_Context.PropertyDescriptor.SetValue(_Context.Instance, value);
_Context.OnComponentChanged();
}
}
#endregion
#endregion
#region DropDownPreviewKeyDown
private void DropDownPreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
if (e.KeyCode == Keys.Escape)
_EscapePressed = true;
}
#endregion
#region ListBox1MouseClick
private void ListBox1MouseClick(object sender, MouseEventArgs e)
{
_EditorService.CloseDropDown();
}
#endregion
#region ListBox1SelectedIndexChanged
private void ListBox1SelectedIndexChanged(object sender, EventArgs e)
{
EditType = (listBox1.SelectedIndex > 0)
? Types[listBox1.SelectedIndex - 1] : null;
}
#endregion
}
}

View File

@@ -0,0 +1,120 @@
<?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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,55 @@
using System;
using System.ComponentModel;
using System.Drawing.Design;
using System.Windows.Forms.Design;
namespace DevComponents.SuperGrid.Design
{
public class EditTypeEditor : UITypeEditor
{
#region GetEditStyle
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
{
return (UITypeEditorEditStyle.DropDown);
}
#endregion
#region GetPaintValueSupported
public override bool GetPaintValueSupported(ITypeDescriptorContext context)
{
return (false);
}
#endregion
#region EditValue
public override object EditValue(
ITypeDescriptorContext context, IServiceProvider provider, object value)
{
IWindowsFormsEditorService editorService =
provider.GetService(typeof (IWindowsFormsEditorService)) as IWindowsFormsEditorService;
if (editorService != null)
{
EditTypeDropDown pv = new EditTypeDropDown((Type)value, editorService, context);
pv.EscapePressed = false;
editorService.DropDownControl(pv);
if (pv.EscapePressed == true)
context.PropertyDescriptor.SetValue(context.Instance, value);
else
return (pv.EditType);
}
return (base.EditValue(context, provider, value));
}
#endregion
}
}

View File

@@ -0,0 +1,148 @@
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Windows.Forms;
using DevComponents.DotNetBar.SuperGrid;
namespace DevComponents.SuperGrid.Design
{
/// <summary>
/// GridRowCollectionEditor
/// </summary>
public class GridCellCollectionEditor : CollectionEditor
{
#region Static variables
static Size _lastSize = Size.Empty;
static Point _lastLoc = Point.Empty;
#endregion
#region Private variables
private CollectionForm _CollectionForm;
private TableLayoutPanel _LayoutPanel;
#endregion
public GridCellCollectionEditor(Type type)
: base(type)
{
}
#region CreateCollectionItemType
protected override Type CreateCollectionItemType()
{
return typeof(GridCell);
}
#endregion
#region CreateCollectionForm
protected override CollectionForm CreateCollectionForm()
{
_CollectionForm = base.CreateCollectionForm();
_LayoutPanel =
_CollectionForm.Controls["overArchingTableLayoutPanel"] as TableLayoutPanel;
if (_LayoutPanel != null)
{
PropertyGrid propertyGrid =
_LayoutPanel.Controls["propertyBrowser"] as PropertyGrid;
if (propertyGrid != null)
{
propertyGrid.HelpVisible = true;
propertyGrid.GotFocus += PropertyGridGotFocus;
}
}
_CollectionForm.Load += CollectionFormLoad;
_CollectionForm.Resize += CollectionFormResize;
_CollectionForm.LocationChanged += CollectionFormLocationChanged;
return (_CollectionForm);
}
#region CollectionFormLoad
void CollectionFormLoad(object sender, EventArgs e)
{
CollectionForm form = sender as CollectionForm;
if (form != null)
{
if (_lastSize != Size.Empty)
form.Size = _lastSize;
if (_lastLoc != Point.Empty)
form.Location = _lastLoc;
}
}
#endregion
#region CollectionFormResize
void CollectionFormResize(object sender, EventArgs e)
{
CollectionForm form = sender as CollectionForm;
if (form != null && form.Visible == true)
_lastSize = form.Size;
}
#endregion
#region CollectionFormLocationChanged
void CollectionFormLocationChanged(object sender, EventArgs e)
{
CollectionForm form = sender as CollectionForm;
if (form != null && form.Visible == true)
_lastLoc = form.Location;
}
#endregion
#region PropertyGridGotFocus
void PropertyGridGotFocus(object sender, EventArgs e)
{
_LayoutPanel.Controls[4].Refresh();
}
#endregion
#endregion
#region EditValue
public override object EditValue(
ITypeDescriptorContext context, IServiceProvider provider, object value)
{
object o = base.EditValue(context, provider, value);
return (o);
}
#endregion
#region CreateInstance
protected override object CreateInstance(Type itemType)
{
object o = base.CreateInstance(itemType);
return (o);
}
#endregion
}
}

View File

@@ -0,0 +1,252 @@
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Windows.Forms;
using DevComponents.DotNetBar.SuperGrid;
namespace DevComponents.SuperGrid.Design
{
/// <summary>
/// GridColumnCollectionEditor
/// </summary>
public class GridColumnCollectionEditor : CollectionEditor
{
#region Static variables
static Size _lastSize = Size.Empty;
static Point _lastLoc = Point.Empty;
#endregion
public GridColumnCollectionEditor(Type type)
: base(type)
{
}
#region CreateCollectionForm
protected override CollectionForm CreateCollectionForm()
{
CollectionForm collectionForm = base.CreateCollectionForm();
if (collectionForm.Controls[0] is TableLayoutPanel)
{
TableLayoutPanel tlpf =
collectionForm.Controls["overArchingTableLayoutPanel"] as TableLayoutPanel;
if (tlpf != null)
{
PropertyGrid propertyGrid =
tlpf.Controls["propertyBrowser"] as PropertyGrid;
if (propertyGrid != null)
{
propertyGrid.HelpVisible = true;
propertyGrid.GotFocus += PropertyGridGotFocus;
propertyGrid.SelectedObjectsChanged += PropertyGridSelectedObjectsChanged;
}
}
}
collectionForm.Load += CollectionFormLoad;
collectionForm.Resize += CollectionFormResize;
collectionForm.LocationChanged += CollectionFormLocationChanged;
return (collectionForm);
}
#region CollectionFormLoad
void CollectionFormLoad(object sender, EventArgs e)
{
CollectionForm form = sender as CollectionForm;
if (form != null)
{
if (_lastSize != Size.Empty)
form.Size = _lastSize;
if (_lastLoc != Point.Empty)
form.Location = _lastLoc;
}
}
#endregion
#region CollectionFormResize
void CollectionFormResize(object sender, EventArgs e)
{
CollectionForm form = sender as CollectionForm;
if (form != null && form.Visible == true)
_lastSize = form.Size;
}
#endregion
#region CollectionFormLocationChanged
void CollectionFormLocationChanged(object sender, EventArgs e)
{
CollectionForm form = sender as CollectionForm;
if (form != null && form.Visible == true)
_lastLoc = form.Location;
}
#endregion
#region PropertyGridGotFocus
void PropertyGridGotFocus(object sender, EventArgs e)
{
PropertyGrid propertyGrid = sender as PropertyGrid;
if (propertyGrid != null)
UpdateDesignerFocus(propertyGrid);
}
#endregion
#region PropertyGridSelectedObjectsChanged
void PropertyGridSelectedObjectsChanged(object sender, EventArgs e)
{
PropertyGrid propertyGrid = sender as PropertyGrid;
if (propertyGrid != null)
UpdateDesignerFocus(propertyGrid);
}
#endregion
#region UpdateDesignerFocus
private void UpdateDesignerFocus(PropertyGrid propertyGrid)
{
GridContainer row = Context.Instance as GridContainer;
if (row != null)
{
GridElement item = propertyGrid.SelectedObject as GridElement;
if (item != null)
row.SuperGrid.DesignerElement = item;
}
}
#endregion
#endregion
#region CreateCollectionItemType
protected override Type CreateCollectionItemType()
{
return typeof(GridColumn);
}
#endregion
#region CreateNewItemTypes
protected override Type[] CreateNewItemTypes()
{
return new Type[]
{
typeof(GridTextBoxXEditControl),
typeof(GridButtonXEditControl),
typeof(GridCheckBoxXEditControl),
typeof(GridColorPickerEditControl),
typeof(GridComboBoxExEditControl),
typeof(GridComboTreeEditControl),
typeof(GridDateTimeInputEditControl),
typeof(GridDateTimePickerEditControl),
typeof(GridDoubleInputEditControl),
typeof(GridImageEditControl),
typeof(GridIntegerInputEditControl),
typeof(GridIpAddressInputEditControl),
typeof(GridLabelXEditControl),
typeof(GridMaskedTextBoxEditControl),
typeof(GridMicroChartEditControl),
typeof(GridNumericUpDownEditControl),
typeof(GridImageEditControl),
typeof(GridProgressBarXEditControl),
typeof(GridRadialMenuEditControl),
typeof(GridRatingStarEditControl),
typeof(GridSliderEditControl),
typeof(GridSwitchButtonEditControl),
typeof(GridTextBoxDropDownEditControl),
};
}
#endregion
#region EditValue
public override object EditValue(
ITypeDescriptorContext context, IServiceProvider provider, object value)
{
object o = base.EditValue(context, provider, value);
if (Context != null)
{
GridPanel panel = Context.Instance as GridPanel;
if (panel != null)
{
if (panel.SuperGrid.DesignerElement is GridColumn)
panel.SuperGrid.DesignerElement = null;
}
}
return (o);
}
#endregion
#region CreateInstance
protected override object CreateInstance(Type itemType)
{
GridColumn item = (GridColumn)base.CreateInstance(typeof(GridColumn));
if (item != null)
{
item.EditorType = itemType;
item.Name = GetColumnName(item);
}
return (item);
}
#region GetColumnName
private string GetColumnName(GridColumn item)
{
GridPanel panel = Context.Instance as GridPanel;
if (panel != null)
{
for (int i = 1; i < 200; i++)
{
string s = "Column" + i;
if (panel.Columns[s] == null)
return (s);
}
}
return (this.GetDisplayText(item));
}
#endregion
#endregion
}
}

View File

@@ -0,0 +1,311 @@
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Windows.Forms;
using DevComponents.DotNetBar.SuperGrid;
namespace DevComponents.SuperGrid.Design
{
/// <summary>
/// GridRowCollectionEditor
/// </summary>
public class GridRowCollectionEditor : CollectionEditor
{
#region Static variables
static Size _lastSize = Size.Empty;
static Point _lastLoc = Point.Empty;
#endregion
#region Private variables
private CollectionForm _CollectionForm;
private TableLayoutPanel _LayoutPanel;
private PropertyGrid _PropertyGrid;
#endregion
public GridRowCollectionEditor(Type type)
: base(type)
{
}
#region CreateCollectionItemType
protected override Type CreateCollectionItemType()
{
return typeof(GridRow);
}
#endregion
#region CreateCollectionForm
protected override CollectionForm CreateCollectionForm()
{
_CollectionForm = base.CreateCollectionForm();
_LayoutPanel =
_CollectionForm.Controls["overArchingTableLayoutPanel"] as TableLayoutPanel;
if (_LayoutPanel != null)
{
_PropertyGrid =
_LayoutPanel.Controls["propertyBrowser"] as PropertyGrid;
if (_PropertyGrid != null)
{
_PropertyGrid.HelpVisible = true;
_PropertyGrid.GotFocus += PropertyGridGotFocus;
_PropertyGrid.SelectedObjectsChanged += PropertyGridSelectedObjectsChanged;
}
}
_CollectionForm.Load += CollectionFormLoad;
_CollectionForm.Resize += CollectionFormResize;
_CollectionForm.LocationChanged += CollectionFormLocationChanged;
return (_CollectionForm);
}
#region CollectionFormLoad
void CollectionFormLoad(object sender, EventArgs e)
{
CollectionForm form = sender as CollectionForm;
if (form != null)
{
if (_lastSize != Size.Empty)
form.Size = _lastSize;
if (_lastLoc != Point.Empty)
form.Location = _lastLoc;
}
}
#endregion
#region CollectionFormResize
void CollectionFormResize(object sender, EventArgs e)
{
CollectionForm form = sender as CollectionForm;
if (form != null && form.Visible == true)
_lastSize = form.Size;
}
#endregion
#region CollectionFormLocationChanged
void CollectionFormLocationChanged(object sender, EventArgs e)
{
CollectionForm form = sender as CollectionForm;
if (form != null && form.Visible == true)
_lastLoc = form.Location;
}
#endregion
#region PropertyGridGotFocus
void PropertyGridGotFocus(object sender, EventArgs e)
{
UpdateDesignerFocus();
_LayoutPanel.Controls[4].Refresh();
}
#endregion
#region PropertyGridSelectedObjectsChanged
void PropertyGridSelectedObjectsChanged(object sender, EventArgs e)
{
UpdateDesignerFocus();
}
#endregion
#region UpdateDesignerFocus
private void UpdateDesignerFocus()
{
if (_PropertyGrid != null)
{
GridContainer row = Context.Instance as GridContainer;
if (row != null)
{
GridElement item = _PropertyGrid.SelectedObject as GridElement;
if (item != null)
row.SuperGrid.DesignerElement = item;
}
}
}
#endregion
#endregion
#region CreateNewItemTypes
protected override Type[] CreateNewItemTypes()
{
GridPanel panel = Context.Instance as GridPanel;
if (panel == null)
{
return new Type[]
{
typeof (GridRow),
typeof (GridPanel),
};
}
return (base.CreateNewItemTypes());
}
#endregion
#region EditValue
public override object EditValue(
ITypeDescriptorContext context, IServiceProvider provider, object value)
{
object o;
if (_CollectionForm != null && _CollectionForm.Visible)
{
GridRowCollectionEditor editor =
new GridRowCollectionEditor(this.CollectionType);
o = editor.EditValue(context, provider, value);
}
else
{
o = base.EditValue(context, provider, value);
GridPanel panel = Context.Instance as GridPanel;
if (panel != null && panel.Parent == null)
panel.SuperGrid.DesignerElement = null;
}
return (o);
}
#endregion
#region CreateInstance
protected override object CreateInstance(Type itemType)
{
object o = base.CreateInstance(itemType);
GridContainer crow = Context.Instance as GridContainer;
if (crow != null)
{
IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));
crow.Expanded = true;
GridPanel cpanel = crow.GridPanel;
GridRow row = o as GridRow;
if (row != null)
{
if (cpanel.Columns.Count == 0)
{
if (dh != null)
{
GridColumn col = dh.CreateComponent(typeof(GridColumn)) as GridColumn;
if (col != null)
{
col.Name = "Column1";
cpanel.Columns.Add(col);
GridCell cell = dh.CreateComponent(typeof(GridCell)) as GridCell;
if (cell != null)
row.Cells.Add(cell);
row.InvalidateRender();
}
}
}
}
else
{
GridPanel panel = o as GridPanel;
if (panel != null)
{
if (cpanel != null)
{
panel.Name = GetPanelName(cpanel);
if (dh != null)
{
GridColumn col = dh.CreateComponent(typeof(GridColumn)) as GridColumn;
col.Name = "Column1";
panel.Columns.Add(col);
}
}
}
}
}
return (o);
}
#region GetPanelName
private string GetPanelName(GridPanel panel)
{
for (int i = 1; i < 200; i++)
{
string s = "GridPanel" + i;
if (UnusedPanelName(panel, s) == true)
return (s);
}
return ("GridPanel");
}
#region UnusedPanelName
private bool UnusedPanelName(GridPanel panel, string s)
{
foreach (GridContainer row in panel.Rows)
{
if (row is GridPanel)
{
if (s.Equals(((GridPanel) row).Name) == true)
return (false);
}
}
return (true);
}
#endregion
#endregion
#endregion
}
}

View File

@@ -0,0 +1,124 @@
using System;
using System.ComponentModel.Design;
using System.Drawing;
using System.Drawing.Design;
using System.ComponentModel;
using System.Windows.Forms;
using System.Windows.Forms.Design;
using DevComponents.DotNetBar.Controls;
using DevComponents.DotNetBar.SuperGrid;
namespace DevComponents.SuperGrid.Design
{
/// <summary>
/// Represents the class used for picking an image from image list
/// </summary>
public class ImageIndexEditor : UITypeEditor
{
#region Private variables
private ImageList _ImageList;
#endregion
#region GetEditStyle
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
{
if (context != null)
_ImageList = GetImageList(context);
return (UITypeEditorEditStyle.DropDown);
}
#region GetImageList
private ImageList GetImageList(ITypeDescriptorContext context)
{
IReferenceService r = (IReferenceService)context.GetService(typeof(IReferenceService));
object[] objs = r.GetReferences(typeof(GridPanel));
if (objs.Length > 0)
{
GridPanel panel = (GridPanel)objs[0];
GridElement item = panel.SuperGrid.DesignerElement;
if (item != null)
return (item.GridPanel.ImageList);
return (panel.ImageList);
}
return (null);
}
#endregion
#endregion
#region GetPaintValueSupported
public override bool GetPaintValueSupported(ITypeDescriptorContext context)
{
return (true);
}
#endregion
#region PaintValue
public override void PaintValue(PaintValueEventArgs e)
{
if (e.Value != null)
{
Image img = GetImage((int)e.Value);
if (img != null)
e.Graphics.DrawImage(img, e.Bounds);
}
}
#region GetImage
private Image GetImage(int index)
{
if (_ImageList != null && (uint)index < _ImageList.Images.Count)
return (_ImageList.Images[index]);
return (null);
}
#endregion
#endregion
#region EditValue
public override object EditValue(
ITypeDescriptorContext context, IServiceProvider provider, object value)
{
IWindowsFormsEditorService editorService =
provider.GetService(typeof (IWindowsFormsEditorService)) as IWindowsFormsEditorService;
if (editorService != null && value is int)
{
ImageIndexTypeDropDown dd = new
ImageIndexTypeDropDown((int)value, _ImageList, editorService, context);
dd.EscapePressed = false;
editorService.DropDownControl(dd);
if (dd.EscapePressed == true)
context.PropertyDescriptor.SetValue(context.Instance, value);
else
return (dd.Value);
}
return (base.EditValue(context, provider, value));
}
#endregion
}
}

View File

@@ -0,0 +1,47 @@
namespace DevComponents.SuperGrid.Design
{
partial class ImageIndexTypeDropDown
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.SuspendLayout();
//
// ImageIndexTypeDropDown
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Name = "ImageIndexTypeDropDown";
this.Size = new System.Drawing.Size(132, 78);
this.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.DropDownPreviewKeyDown);
this.ResumeLayout(false);
}
#endregion
}
}

View File

@@ -0,0 +1,155 @@
using System;
using System.ComponentModel;
using System.Windows.Forms;
using System.Windows.Forms.Design;
namespace DevComponents.SuperGrid.Design
{
[ToolboxItem(false)]
public partial class ImageIndexTypeDropDown : UserControl
{
#region Private variables
private int _Value;
private bool _EscapePressed;
private ImageList _ImageList;
private ImageListBox _ListBox;
private IWindowsFormsEditorService _EditorService;
private ITypeDescriptorContext _Context;
#endregion
public ImageIndexTypeDropDown(int value, ImageList imageList,
IWindowsFormsEditorService editorService, ITypeDescriptorContext context)
{
_EditorService = editorService;
_Context = context;
_Value = value;
_ImageList = imageList;
Initialize();
}
public ImageIndexTypeDropDown()
{
Initialize();
}
#region Initialize
private void Initialize()
{
InitializeComponent();
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
if (_ImageList != null)
{
_ListBox = new ImageListBox();
Controls.Add(_ListBox);
_ListBox.MouseClick += ListBoxMouseClick;
_ListBox.SelectedIndexChanged += ListBoxSelectedIndexChanged;
_ListBox.ImageList = _ImageList;
_ListBox.BorderStyle = BorderStyle.None;
_ListBox.Dock = DockStyle.Fill;
for (int i = 0; i < _ImageList.Images.Count; i++)
{
ImageListBoxItem item =
new ImageListBoxItem(i.ToString(), i);
_ListBox.Items.Add(item);
}
_ListBox.Items.Add(new ImageListBoxItem("(none)", _ImageList.Images.Count));
int index = Value;
_ListBox.SelectedIndex =
(index >= 0 && index < _ImageList.Images.Count)
? index : _ImageList.Images.Count;
Size = _ListBox.PreferredSize;
}
}
#endregion
#region Public properties
#region EditorService
public IWindowsFormsEditorService EditorService
{
get { return (_EditorService); }
set { _EditorService = value; }
}
#endregion
#region EscapePressed
public bool EscapePressed
{
get { return (_EscapePressed); }
set { _EscapePressed = value; }
}
#endregion
#region Value
public int Value
{
get { return (_Value); }
set
{
_Value = value;
_Context.OnComponentChanging();
_Context.PropertyDescriptor.SetValue(_Context.Instance, value);
_Context.OnComponentChanged();
}
}
#endregion
#endregion
#region DropDownPreviewKeyDown
private void DropDownPreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
if (e.KeyCode == Keys.Escape)
_EscapePressed = true;
}
#endregion
#region ListBoxMouseClick
private void ListBoxMouseClick(object sender, MouseEventArgs e)
{
_EditorService.CloseDropDown();
}
#endregion
#region ListBoxSelectedIndexChanged
protected virtual void ListBoxSelectedIndexChanged(object sender, EventArgs e)
{
int index = _ListBox.SelectedIndex;
Value = (index >= _ImageList.Images.Count ? -1 : index);
}
#endregion
}
}

View File

@@ -0,0 +1,120 @@
<?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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,143 @@
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace DevComponents.SuperGrid.Design
{
[ToolboxItem(false)]
public class ImageListBox : ListBox
{
#region Private variables
private ImageList _ImageList;
#endregion
public ImageListBox()
{
MinimumSize = new Size(20, 20);
IntegralHeight = true;
DrawMode = DrawMode.OwnerDrawVariable;
}
#region Public properties
public ImageList ImageList
{
get { return (_ImageList); }
set { _ImageList = value; }
}
#endregion
#region OnMeasureItem
protected override void OnMeasureItem(MeasureItemEventArgs e)
{
base.OnMeasureItem(e);
e.ItemWidth += 22;
if (e.ItemHeight < 20)
e.ItemHeight = 20;
}
#endregion
#region OnDrawItem
protected override void OnDrawItem(DrawItemEventArgs e)
{
Graphics g = e.Graphics;
e.DrawBackground();
if (e.Index < Items.Count)
{
Rectangle r = e.Bounds;
r.Width = 18;
if (r.Height > 18)
{
r.Y += (r.Height - 18)/2;
r.Height = 18;
}
ImageListBoxItem item = (ImageListBoxItem) Items[e.Index];
Image image = (uint) item.ImageIndex < _ImageList.Images.Count
? _ImageList.Images[item.ImageIndex]
: null;
if (image != null)
g.DrawImage(image, r);
g.DrawRectangle(Pens.Black, r);
using (Brush br = new SolidBrush(e.ForeColor))
{
using (StringFormat sf = new StringFormat())
{
sf.Alignment = StringAlignment.Near;
sf.LineAlignment = StringAlignment.Center;
r = e.Bounds;
r.X += 30;
r.Width -= 30;
g.DrawString(item.Text, e.Font, br, r, sf);
}
}
}
}
#endregion
}
public class ImageListBoxItem
{
#region Private variables
private string _Text;
private int _ImageIndex;
#endregion
#region Constructors
public ImageListBoxItem(string text, int index)
{
Text = text;
ImageIndex = index;
}
public ImageListBoxItem(string text)
: this(text, -1)
{
}
public ImageListBoxItem()
: this("", -1)
{
}
#endregion
#region Public properties
public int ImageIndex
{
get { return (_ImageIndex); }
set { _ImageIndex = value; }
}
public string Text
{
get { return (_Text); }
set { _Text = value; }
}
#endregion
}
}

View File

@@ -0,0 +1,401 @@
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Data;
using System.Data.SqlTypes;
using System.Drawing.Design;
using System.Windows.Forms;
using System.Windows.Forms.Design;
using DevComponents.DotNetBar.Controls;
using DevComponents.DotNetBar.SuperGrid;
namespace DevComponents.SuperGrid.Design
{
public class SuperGridActionList : DesignerActionList,
ITypeDescriptorContext, IWindowsFormsEditorService, IServiceProvider
{
#region Private variables
private SuperGridControl _SuperGrid;
private PropertyDescriptor _PropertyDescriptor;
private IComponentChangeService _ChangeService;
private IDesignerHost dh;
#endregion
/// <summary>
/// SuperGridActionList
/// </summary>
/// <param name="superGrid">Associated SuperGridControl</param>
public SuperGridActionList(SuperGridControl superGrid)
: base(superGrid)
{
_SuperGrid = superGrid;
_ChangeService = Component.Site.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
}
#region Public properties
/// <summary>
/// Gets or sets the GridPanel DataSource
/// </summary>
[AttributeProvider(typeof(IListSource))]
public object DataSource
{
get { return (_SuperGrid.PrimaryGrid.DataSource); }
set { SetValue("DataSource", value); }
}
/// <summary>
/// Gets or sets whether rows can be deleted
/// </summary>
public bool AllowRowDelete
{
get { return (_SuperGrid.PrimaryGrid.AllowRowDelete); }
set { SetValue("AllowRowDelete", value); }
}
/// <summary>
/// Gets or sets whether rows can be Inserted
/// </summary>
public bool AllowRowInsert
{
get { return (_SuperGrid.PrimaryGrid.AllowRowInsert); }
set { SetValue("AllowRowInsert", value); }
}
/// <summary>
/// Gets or sets whether the Insert Row is displayed at runtime
/// </summary>
public bool ShowInsertRow
{
get { return (_SuperGrid.PrimaryGrid.ShowInsertRow); }
set { SetValue("ShowInsertRow", value); }
}
/// <summary>
/// Gets or sets which Grid Lines are displayed
/// </summary>
public GridLines GridLines
{
get { return (_SuperGrid.PrimaryGrid.GridLines); }
set { SetValue("GridLines", value); }
}
/// <summary>
/// Gets or sets whether Tree Lines are displayed
/// </summary>
public bool ShowTreeLines
{
get { return (_SuperGrid.PrimaryGrid.ShowTreeLines); }
set { SetValue("ShowTreeLines", value); }
}
/// <summary>
/// Gets or sets whether Tree Buttons are displayed
/// </summary>
public bool ShowTreeButtons
{
get { return (_SuperGrid.PrimaryGrid.ShowTreeButtons); }
set { SetValue("ShowTreeButtons", value); }
}
/// <summary>
/// Gets or sets whether to use the Alternate Row Style
/// </summary>
public bool UseAlternateRowStyle
{
get { return (_SuperGrid.PrimaryGrid.UseAlternateRowStyle); }
set { SetValue("UseAlternateRowStyle", value); }
}
/// <summary>
/// Gets or sets whether to use the Alternate Column Style
/// </summary>
public bool UseAlternateColumnStyle
{
get { return (_SuperGrid.PrimaryGrid.UseAlternateColumnStyle); }
set { SetValue("UseAlternateColumnStyle", value); }
}
/// <summary>
/// Gets or sets whether to allow multi selection
/// </summary>
public bool MultiSelect
{
get { return (_SuperGrid.PrimaryGrid.MultiSelect); }
set { SetValue("MultiSelect", value); }
}
/// <summary>
/// Gets or sets the selection granularity
/// </summary>
public SelectionGranularity SelectionGranularity
{
get { return (_SuperGrid.PrimaryGrid.SelectionGranularity); }
set { SetValue("SelectionGranularity", value); }
}
#endregion
#region SetValue
private void SetValue(string property, object value)
{
_ChangeService.OnComponentChanging(_SuperGrid.PrimaryGrid, null);
GetPrimaryGridPropertyByName(property).SetValue(_SuperGrid.PrimaryGrid, value);
_ChangeService.OnComponentChanged(_SuperGrid.PrimaryGrid, null, null, null);
}
#endregion
#region GetPrimaryGridPropertyByName
/// <summary>
/// Gets the PrimaryGrid property via the given name
/// </summary>
/// <param name="propName">Property name</param>
/// <returns>PropertyDescriptor</returns>
private PropertyDescriptor GetPrimaryGridPropertyByName(string propName)
{
PropertyDescriptor prop =
TypeDescriptor.GetProperties(_SuperGrid.PrimaryGrid)[propName];
if (prop == null)
throw new ArgumentException("Matching property not found.", propName);
return (prop);
}
#endregion
#region GetSortedActionItems
/// <summary>
/// Gets the SortedActionItems
/// </summary>
/// <returns>DesignerActionItemCollection</returns>
public override DesignerActionItemCollection GetSortedActionItems()
{
DesignerActionItemCollection items = new DesignerActionItemCollection();
items.Add(new DesignerActionPropertyItem("DataSource", "Data Source",
"Data", "Sets the GridPanel Data Source."));
items.Add(new DesignerActionPropertyItem("AllowRowDelete", "Allow Row Delete",
"User Interaction", "Determines whether rows can be deleted."));
items.Add(new DesignerActionPropertyItem("AllowRowInsert", "Allow Row Insert",
"User Interaction", "Determines whether rows can be inserted."));
items.Add(new DesignerActionPropertyItem("ShowInsertRow", "Show Insert Row",
"User Interaction", "Determines whether the InsertRow is shown at runtime."));
items.Add(new DesignerActionPropertyItem("GridLines", "Grid Lines",
"Appearance", "Determines which Grid Lines are displayed."));
items.Add(new DesignerActionPropertyItem("ShowTreeLines", "Show Tree Lines",
"Appearance", "Determines whether Tree Lines are displayed."));
items.Add(new DesignerActionPropertyItem("ShowTreeButtons", "Show Tree Buttons",
"Appearance", "Determines whether Tree Buttons are displayed."));
items.Add(new DesignerActionPropertyItem("UseAlternateColumnStyle", "Use Alternate Column Style",
"Style", "Determines whether to use the defined Alternate Column Style."));
items.Add(new DesignerActionPropertyItem("UseAlternateRowStyle", "Use Alternate Row Style",
"Style", "Determines whether to use the defined Alternate Row Style."));
items.Add(new DesignerActionPropertyItem("SelectionGranularity", "Selection Granularity",
"Behavior", "Determines user selection granularity."));
items.Add(new DesignerActionPropertyItem("MultiSelect", "Enable Multi Selection",
"Behavior", "Determines whether Multi Selection is enabled."));
if (DataSource != null)
{
items.Add(new DesignerActionMethodItem(this, "GenBoundColumns", "Generate Bound Columns",
"Data1", "Clears all previous bound column definitions and\r\ngenerates new column definitions from current DataSource."));
}
items.Add(new DesignerActionMethodItem(this, "EditColumns", "Edit Columns...", "Data2"));
items.Add(new DesignerActionMethodItem(this, "EditRows", "Edit Rows...", "Data2"));
return (items);
}
#endregion
#region EditColumns
/// <summary>
/// EditColumns
/// </summary>
private void EditColumns()
{
_PropertyDescriptor = TypeDescriptor.GetProperties(_SuperGrid.PrimaryGrid)["Columns"];
UITypeEditor editor = (UITypeEditor)_PropertyDescriptor.GetEditor(typeof(UITypeEditor));
if (editor != null)
editor.EditValue(this, this, _SuperGrid.PrimaryGrid.Columns);
}
#endregion
#region EditRows
/// <summary>
/// EditRows
/// </summary>
private void EditRows()
{
_PropertyDescriptor = TypeDescriptor.GetProperties(_SuperGrid.PrimaryGrid)["Rows"];
UITypeEditor editor = (UITypeEditor)_PropertyDescriptor.GetEditor(typeof(UITypeEditor));
if (editor != null)
editor.EditValue(this, this, _SuperGrid.PrimaryGrid.Rows);
}
#endregion
#region GenBoundColumns
/// <summary>
/// GenBoundColumns
/// </summary>
private void GenBoundColumns()
{
dh = (IDesignerHost)GetService(typeof(IDesignerHost));
if (dh != null)
{
DesignerTransaction dt = dh.CreateTransaction();
try
{
IComponentChangeService change =
GetService(typeof(IComponentChangeService)) as IComponentChangeService;
if (change != null)
{
change.OnComponentChanging(Component, null);
GridColumnCollection colc = _SuperGrid.PrimaryGrid.Columns;
_SuperGrid.PrimaryGrid.GenerateColumns(CreateGridColumn);
GridColumnCollection cc = _SuperGrid.PrimaryGrid.Columns;
for (int i = cc.Count - 1; i >= 0; i--)
{
GridColumn col = cc[i];
if (string.IsNullOrEmpty(col.DataPropertyName) == false && col.IsDataBound == false)
cc.RemoveAt(i);
}
change.OnComponentChanged(Component, null, null, null);
}
}
catch
{
dt.Cancel();
}
finally
{
if (dt.Canceled == false)
dt.Commit();
}
}
}
#region CreateGridColumn
private GridColumn CreateGridColumn()
{
if (dh != null)
return (dh.CreateComponent(typeof(GridColumn)) as GridColumn);
return (null);
}
#endregion
#endregion
#region ITypeDescriptorContext Members
public IContainer Container
{
get { return (Component.Site.Container); }
}
public object Instance
{
get { return (Component); }
}
public void OnComponentChanged()
{
object value = _SuperGrid.PrimaryGrid.Columns;
_ChangeService.OnComponentChanged(Component, _PropertyDescriptor, value, value);
}
public bool OnComponentChanging()
{
if (Component is SuperGridControl)
_ChangeService.OnComponentChanging(((SuperGridControl)Component).PrimaryGrid, _PropertyDescriptor);
else
_ChangeService.OnComponentChanging(Component, _PropertyDescriptor);
return true;
}
public PropertyDescriptor PropertyDescriptor
{
get { return (_PropertyDescriptor); }
}
#endregion
#region IWindowsFormsEditorService Members
public void CloseDropDown()
{
throw new Exception("The method or operation is not implemented.");
}
public void DropDownControl(Control control)
{
throw new Exception("The method or operation is not implemented.");
}
public DialogResult ShowDialog(Form dialog)
{
return (dialog.ShowDialog());
}
#endregion
#region IServiceProvider
object IServiceProvider.GetService(Type serviceType)
{
if (serviceType.Equals(typeof(IWindowsFormsEditorService)))
return (this);
return GetService(serviceType);
}
#endregion
}
}

View File

@@ -0,0 +1,169 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{D06A8233-416A-4547-BFF6-7A26345B7396}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DevComponents.SuperGrid.Design</RootNamespace>
<AssemblyName>DevComponents.SuperGrid.Design</AssemblyName>
<StartupObject>
</StartupObject>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>SuperGridDesignTime.snk</AssemblyOriginatorKeyFile>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>2.0</OldToolsVersion>
<UpgradeBackupLocation />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;SUPERGRID</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>
</DocumentationFile>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseTrial|AnyCPU' ">
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;SUPERGRID;TRIAL</DefineConstants>
<DocumentationFile>
</DocumentationFile>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<ItemGroup>
<Compile Include="BoolValueTypeDropDown.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="ColumnGroupHeaderCollectionEditor.cs" />
<Compile Include="ColumnListTypeEditor.cs" />
<Compile Include="ImageIndexTypeDropDown.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="ImageIndexTypeDropDown.Designer.cs">
<DependentUpon>ImageIndexTypeDropDown.cs</DependentUpon>
</Compile>
<Compile Include="ImageIndexEditor.cs">
</Compile>
<Compile Include="ImageListBox.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="SuperGridActionList.cs" />
<Compile Include="SuperGridDesigner.cs" />
<Compile Include="ValueTypeDropDown.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="ValueTypeDropDown.Designer.cs">
<DependentUpon>ValueTypeDropDown.cs</DependentUpon>
</Compile>
<Compile Include="ValueTypeEditor.cs" />
<Compile Include="GridCellCollectionEditor.cs" />
<Compile Include="GridRowCollectionEditor.cs" />
<Compile Include="GridColumnCollectionEditor.cs" />
<Compile Include="EditTypeDropDown.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="EditTypeDropDown.Designer.cs">
<DependentUpon>EditTypeDropDown.cs</DependentUpon>
</Compile>
<Compile Include="EditTypeEditor.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DevComponents.DotNetBar.SuperGrid\SuperGrid.csproj">
<Project>{A344305F-D2E2-4350-B61E-D7277959A5B4}</Project>
<Name>SuperGrid</Name>
</ProjectReference>
<ProjectReference Include="..\DotNetBar.csproj">
<Project>{36546CE3-335C-4AB6-A2F3-40F8C818BC66}</Project>
<Name>DotNetBar</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Design" />
<Reference Include="System.Drawing" />
<Reference Include="System.Drawing.Design" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.XML" />
</ItemGroup>
<ItemGroup>
<None Include="SuperGridDesignTime.snk" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="ImageIndexTypeDropDown.resx">
<DependentUpon>ImageIndexTypeDropDown.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="ValueTypeDropDown.resx">
<DependentUpon>ValueTypeDropDown.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="EditTypeDropDown.resx">
<DependentUpon>EditTypeDropDown.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,278 @@
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Windows.Forms;
using System.Windows.Forms.Design;
using DevComponents.DotNetBar.Controls;
using DevComponents.DotNetBar.SuperGrid;
using System;
using System.Collections;
namespace DevComponents.SuperGrid.Design
{
/// <summary>
/// SuperGridDesigner
/// </summary>
public class SuperGridDesigner : ControlDesigner
{
#region Private variables
private SuperGridControl _SuperGrid;
private DesignerActionListCollection _ActionLists;
#endregion
#region Initialize
/// <summary>
/// Initializes our designer
/// </summary>
/// <param name="component"></param>
public override void Initialize(IComponent component)
{
base.Initialize(component);
if (component.Site.DesignMode == true)
_SuperGrid = component as SuperGridControl;
#if !TRIAL
IDesignerHost dh = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
if (dh != null)
dh.LoadComplete += new EventHandler(DesignerLoadComplete);
#endif
// If our component is removed we need to clean-up
IComponentChangeService cc = (IComponentChangeService)GetService(typeof(IComponentChangeService));
if (cc != null)
cc.ComponentRemoving += new ComponentEventHandler(OnComponentRemoving);
}
#endregion
#region Dispose
protected override void Dispose(bool disposing)
{
// If our component is removed we need to clean-up
IComponentChangeService cc = (IComponentChangeService)GetService(typeof(IComponentChangeService));
if (cc != null)
cc.ComponentRemoving -= new ComponentEventHandler(OnComponentRemoving);
}
#endregion
#region Verbs
/// <summary>
/// Creates our verb collection
/// </summary>
public override DesignerVerbCollection Verbs
{
get
{
DesignerVerb[] verbs = new DesignerVerb[]
{
//new DesignerVerb("KnobStyle 1", SetStyle1),
//new DesignerVerb("KnobStyle 2", SetStyle2),
//new DesignerVerb("KnobStyle 3", SetStyle3),
//new DesignerVerb("KnobStyle 4", SetStyle4),
};
return (new DesignerVerbCollection(verbs));
}
}
#endregion
#region ActionLists
/// <summary>
/// Gets our DesignerActionListCollection list
/// </summary>
public override DesignerActionListCollection ActionLists
{
get
{
if (_ActionLists == null)
{
_ActionLists = new DesignerActionListCollection();
_ActionLists.Add(new SuperGridActionList(_SuperGrid));
}
return (_ActionLists);
}
}
#endregion
#region OnSetCursor
protected override void OnSetCursor()
{
if (InScrollBar(Control.MousePosition) == true)
Cursor.Current = Cursors.Default;
base.OnSetCursor();
}
#region InScrollBar
private bool InScrollBar(Point point)
{
if (_SuperGrid != null)
{
Point pt = _SuperGrid.PointToClient(point);
if (_SuperGrid.HScrollBar.Visible)
{
if (_SuperGrid.HScrollBar.Bounds.Contains(pt))
return (true);
}
if (_SuperGrid.VScrollBar.Visible)
{
if (_SuperGrid.VScrollBar.Bounds.Contains(pt))
return (true);
}
}
return (false);
}
#endregion
#endregion
#region OnComponentRemoving
/// <summary>Called when component is about to be removed from designer.</summary>
/// <param name="sender">Event sender.</param>
/// <param name="e">Event arguments.</param>
public void OnComponentRemoving(object sender, ComponentEventArgs e)
{
if (e.Component == this.Component)
{
IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));
if (dh == null)
return;
ArrayList list = new ArrayList(AssociatedComponents);
foreach (IComponent c in list)
dh.DestroyComponent(c);
}
}
#endregion
#region AssociatedComponents
/// <summary>
/// Returns all components associated with this control
/// </summary>
public override ICollection AssociatedComponents
{
get
{
ArrayList c = new ArrayList(base.AssociatedComponents);
SuperGridControl sg = Control as SuperGridControl;
if (sg != null)
GetComponents(sg.PrimaryGrid, c);
return (c);
}
}
#region GetComponents
private void GetComponents(GridContainer cont, ArrayList c)
{
if (cont is GridPanel)
{
foreach (GridColumn col in ((GridPanel)cont).Columns)
c.Add(col);
}
if (cont.Rows != null && cont.Rows.Count > 0)
{
foreach (GridElement item in cont.Rows)
{
c.Add(item);
if (item is GridRow)
{
foreach (GridCell cell in ((GridRow)item).Cells)
c.Add(cell);
}
if (item is GridContainer)
GetComponents((GridContainer)item, c);
}
}
}
#endregion
#endregion
#region GetHitTest
protected override bool GetHitTest(Point point)
{
if (InScrollBar(point) == true)
return (true);
return (base.GetHitTest(point));
}
#endregion
#region Licensing Stuff
public override void InitializeNewComponent(IDictionary defaultValues)
{
base.InitializeNewComponent(defaultValues);
SetDesignTimeDefaults();
}
private void SetDesignTimeDefaults()
{
SuperGridControl c = this.Control as SuperGridControl;
#if !TRIAL
string key = GetLicenseKey();
c.LicenseKey = key;
#endif
}
#if !TRIAL
internal static string GetLicenseKey()
{
string key = "";
Microsoft.Win32.RegistryKey regkey = Microsoft.Win32.Registry.LocalMachine;
regkey = regkey.OpenSubKey("Software\\DevComponents\\Licenses", false);
if (regkey != null)
{
object keyValue = regkey.GetValue("DevComponents.DotNetBar.DotNetBarManager2");
if (keyValue != null)
key = keyValue.ToString();
}
return key;
}
private void DesignerLoadComplete(object sender, EventArgs e)
{
IDesignerHost dh = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
if (dh != null)
dh.LoadComplete -= new EventHandler(DesignerLoadComplete);
string key = GetLicenseKey();
SuperGridControl grid = this.Control as SuperGridControl;
if (key != "" && grid != null && grid.LicenseKey == "" && grid.LicenseKey != key)
TypeDescriptor.GetProperties(grid)["LicenseKey"].SetValue(grid, key);
}
#endif
#endregion
}
}

View File

@@ -0,0 +1,66 @@
namespace DevComponents.SuperGrid.Design
{
partial class ValueTypeDropDown
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.listBox1 = new System.Windows.Forms.ListBox();
this.SuspendLayout();
//
// listBox1
//
this.listBox1.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.listBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.listBox1.FormattingEnabled = true;
this.listBox1.IntegralHeight = false;
this.listBox1.Location = new System.Drawing.Point(0, 0);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(172, 78);
this.listBox1.TabIndex = 1;
this.listBox1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.ListBoxMouseClick);
this.listBox1.SelectedIndexChanged += new System.EventHandler(this.ListBoxSelectedIndexChanged);
//
// ValueTypeDropDown
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.listBox1);
this.Name = "ValueTypeDropDown";
this.Size = new System.Drawing.Size(172, 78);
this.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.DropDownPreviewKeyDown);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.ListBox listBox1;
}
}

View File

@@ -0,0 +1,151 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Windows.Forms.Design;
namespace DevComponents.SuperGrid.Design
{
[ToolboxItem(false)]
public partial class ValueTypeDropDown : UserControl
{
#region Private variables
private object _Value;
private bool _EscapePressed;
private IWindowsFormsEditorService _EditorService;
private ITypeDescriptorContext _Context;
#endregion
public ValueTypeDropDown(object value,
IWindowsFormsEditorService editorService, ITypeDescriptorContext context)
{
_EditorService = editorService;
_Context = context;
_Value = value;
Initialize();
}
public ValueTypeDropDown()
{
Initialize();
}
#region Initialize
private void Initialize()
{
InitializeComponent();
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
string[] items = GetListBoxItems();
listBox1.Items.Clear();
listBox1.Items.AddRange(items);
listBox1.SelectedIndex = GetSelectedIndex();
int height = 0;
int width = 0;
foreach (string s in listBox1.Items)
{
Size size = TextRenderer.MeasureText(s, listBox1.Font);
width = Math.Max(width, size.Width);
height += listBox1.ItemHeight;
}
height += 5;
Size = new Size(width, height);
}
protected virtual string[] GetListBoxItems()
{
return (null);
}
protected virtual int GetSelectedIndex()
{
return (0);
}
#endregion
#region Public properties
#region EditorService
public IWindowsFormsEditorService EditorService
{
get { return (_EditorService); }
set { _EditorService = value; }
}
#endregion
#region EscapePressed
public bool EscapePressed
{
get { return (_EscapePressed); }
set { _EscapePressed = value; }
}
#endregion
#region Value
public object Value
{
get { return (_Value); }
set
{
_Value = value;
_Context.OnComponentChanging();
_Context.PropertyDescriptor.SetValue(_Context.Instance, value);
_Context.OnComponentChanged();
}
}
#endregion
#endregion
#region DropDownPreviewKeyDown
private void DropDownPreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
if (e.KeyCode == Keys.Escape)
_EscapePressed = true;
}
#endregion
#region ListBoxMouseClick
private void ListBoxMouseClick(object sender, MouseEventArgs e)
{
_EditorService.CloseDropDown();
}
#endregion
#region ListBoxSelectedIndexChanged
protected virtual void ListBoxSelectedIndexChanged(object sender, EventArgs e)
{
}
#endregion
}
}

View File

@@ -0,0 +1,120 @@
<?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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,144 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Design;
using System.Windows.Forms;
using System.Windows.Forms.Design;
using DevComponents.DotNetBar.SuperGrid;
namespace DevComponents.SuperGrid.Design
{
public class ValueTypeEditor : UITypeEditor
{
#region Private variables
private GridCell _Cell;
private GridColumn _Column;
private bool _HasBoolDropDown;
#endregion
#region GetEditStyle
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
{
if (context != null)
{
_Cell = context.Instance as GridCell;
if (_Cell != null)
{
_HasBoolDropDown = HasBoolDropDown(_Cell);
}
else
{
_Column = context.Instance as GridColumn;
if (_Column != null)
_HasBoolDropDown = HasBoolDropDown(_Column);
}
}
return (UITypeEditorEditStyle.DropDown);
}
#region HasBoolDropDown
private bool HasBoolDropDown(GridCell cell)
{
if (cell.EditorType != null)
return (HasBoolDropDown(cell.EditorType));
return (HasBoolDropDown(cell.GridColumn));
}
private bool HasBoolDropDown(GridColumn column)
{
if (column != null)
return (HasBoolDropDown(column.EditorType));
return (false);
}
private bool HasBoolDropDown(Type type)
{
if (type == typeof(GridCheckBoxEditControl) ||
type == typeof(GridCheckBoxXEditControl) ||
type == typeof(GridSwitchButtonEditControl))
{
return (true);
}
return (false);
}
#endregion
#region IsDropDownResizable
public override bool IsDropDownResizable
{
get { return (_HasBoolDropDown == false); }
}
#endregion
#endregion
#region GetPaintValueSupported
public override bool GetPaintValueSupported(ITypeDescriptorContext context)
{
return (false);
}
#endregion
#region EditValue
public override object EditValue(
ITypeDescriptorContext context, IServiceProvider provider, object value)
{
IWindowsFormsEditorService editorService =
provider.GetService(typeof (IWindowsFormsEditorService)) as IWindowsFormsEditorService;
if (editorService != null)
{
if (_HasBoolDropDown == true)
{
BoolValueTypeDropDown bv = new BoolValueTypeDropDown(value, editorService, context);
bv.EscapePressed = false;
editorService.DropDownControl(bv);
if (bv.EscapePressed == true)
context.PropertyDescriptor.SetValue(context.Instance, value);
else
return (bv.Value);
}
else
{
TextBox tb = new TextBox();
tb.Multiline = true;
tb.Size = new Size(300, 100);
tb.ScrollBars = ScrollBars.Both;
if (value != null)
tb.Text = value.ToString();
editorService.DropDownControl(tb);
return (tb.Text);
}
}
return (base.EditValue(context, provider, value));
}
#endregion
}
}