DotNet 4.8.1 build of DotNetBar
This commit is contained in:
@@ -0,0 +1,155 @@
|
||||
#if FRAMEWORK20
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.ComponentModel.Design;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.AdvTree.Design
|
||||
{
|
||||
internal class AdvTreeActionList : DesignerActionList
|
||||
{
|
||||
private AdvTreeDesigner _Designer = null;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the AdvTreeActionList class.
|
||||
/// </summary>
|
||||
/// <param name="designer"></param>
|
||||
public AdvTreeActionList(AdvTreeDesigner designer):base(designer.Component)
|
||||
{
|
||||
_Designer = designer;
|
||||
}
|
||||
|
||||
public override DesignerActionItemCollection GetSortedActionItems()
|
||||
{
|
||||
DesignerActionItemCollection items = new DesignerActionItemCollection();
|
||||
items.Add(new DesignerActionHeaderItem("Nodes"));
|
||||
items.Add(new DesignerActionHeaderItem("Columns"));
|
||||
items.Add(new DesignerActionHeaderItem("Selection"));
|
||||
|
||||
items.Add(new DesignerActionMethodItem(this, "CreateNode", "Create Node", "Nodes", true));
|
||||
items.Add(new DesignerActionPropertyItem("CellEdit", "Allow node text editing?", "Nodes", "Indicates whether node cells are editable"));
|
||||
|
||||
items.Add(new DesignerActionMethodItem(this, "EditColumns", "Edit Columns...", "Columns", "Edit Tree Control Columns", true));
|
||||
items.Add(new DesignerActionPropertyItem("ColumnsVisible", "Column header visible?", "Columns", "Indicates whether tree column header is visible"));
|
||||
items.Add(new DesignerActionPropertyItem("GridColumnLines", "Show grid column lines?", "Columns", "Indicates whether grid lines are visible"));
|
||||
items.Add(new DesignerActionPropertyItem("GridRowLines", "Show grid row lines?", "Nodes", "Indicates whether grid lines between nodes are visible"));
|
||||
items.Add(new DesignerActionPropertyItem("GridLinesColor", "Grid lines color:", "Columns", "Indicates custom color for grid lines"));
|
||||
|
||||
items.Add(new DesignerActionPropertyItem("SelectionBox", "Show selection?", "Selection", "Indicates whether selection is shown for selected node"));
|
||||
items.Add(new DesignerActionPropertyItem("SelectionBoxStyle", "Selection style:", "Selection", "Indicates selection style"));
|
||||
items.Add(new DesignerActionPropertyItem("HotTracking", "Highlight mouse over node?", "Selection", "Indicates whether node that mouse is over is highlighted"));
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
public void CreateNode()
|
||||
{
|
||||
_Designer.CreateNode();
|
||||
}
|
||||
|
||||
public void EditColumns()
|
||||
{
|
||||
_Designer.EditColumns();
|
||||
}
|
||||
|
||||
public bool HotTracking
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((AdvTree)base.Component).HotTracking;
|
||||
}
|
||||
set
|
||||
{
|
||||
TypeDescriptor.GetProperties(base.Component)["HotTracking"].SetValue(base.Component, value);
|
||||
}
|
||||
}
|
||||
|
||||
public bool SelectionBox
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((AdvTree)base.Component).SelectionBox;
|
||||
}
|
||||
set
|
||||
{
|
||||
TypeDescriptor.GetProperties(base.Component)["SelectionBox"].SetValue(base.Component, value);
|
||||
}
|
||||
}
|
||||
|
||||
public eSelectionStyle SelectionBoxStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((AdvTree)base.Component).SelectionBoxStyle;
|
||||
}
|
||||
set
|
||||
{
|
||||
TypeDescriptor.GetProperties(base.Component)["SelectionBoxStyle"].SetValue(base.Component, value);
|
||||
}
|
||||
}
|
||||
|
||||
public bool ColumnsVisible
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((AdvTree)base.Component).ColumnsVisible;
|
||||
}
|
||||
set
|
||||
{
|
||||
TypeDescriptor.GetProperties(base.Component)["ColumnsVisible"].SetValue(base.Component, value);
|
||||
}
|
||||
}
|
||||
|
||||
public bool GridColumnLines
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((AdvTree)base.Component).GridColumnLines;
|
||||
}
|
||||
set
|
||||
{
|
||||
TypeDescriptor.GetProperties(base.Component)["GridColumnLines"].SetValue(base.Component, value);
|
||||
}
|
||||
}
|
||||
|
||||
public bool GridRowLines
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((AdvTree)base.Component).GridRowLines;
|
||||
}
|
||||
set
|
||||
{
|
||||
TypeDescriptor.GetProperties(base.Component)["GridRowLines"].SetValue(base.Component, value);
|
||||
}
|
||||
}
|
||||
|
||||
public Color GridLinesColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((AdvTree)base.Component).GridLinesColor;
|
||||
}
|
||||
set
|
||||
{
|
||||
TypeDescriptor.GetProperties(base.Component)["GridLinesColor"].SetValue(base.Component, value);
|
||||
}
|
||||
}
|
||||
|
||||
public bool CellEdit
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((AdvTree)base.Component).CellEdit;
|
||||
}
|
||||
set
|
||||
{
|
||||
TypeDescriptor.GetProperties(base.Component)["CellEdit"].SetValue(base.Component, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace DevComponents.AdvTree.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Support for Cell tabs design-time editor.
|
||||
/// </summary>
|
||||
public class CellCollectionEditor : System.ComponentModel.Design.CollectionEditor
|
||||
{
|
||||
/// <summary>Creates new instance of cell collection editor.</summary>
|
||||
/// <param name="type">Type to initialize editor with.</param>
|
||||
public CellCollectionEditor(Type type)
|
||||
: base(type)
|
||||
{
|
||||
}
|
||||
protected override Type CreateCollectionItemType()
|
||||
{
|
||||
return typeof(Cell);
|
||||
}
|
||||
protected override Type[] CreateNewItemTypes()
|
||||
{
|
||||
return new Type[] { typeof(Cell) };
|
||||
}
|
||||
protected override object CreateInstance(Type itemType)
|
||||
{
|
||||
object item = base.CreateInstance(itemType);
|
||||
if (item is Cell)
|
||||
{
|
||||
Cell cell = item as Cell;
|
||||
cell.Text = cell.Name;
|
||||
}
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.ComponentModel.Design;
|
||||
using DevComponents.AdvTree;
|
||||
using System.Collections;
|
||||
|
||||
namespace DevComponents.AdvTree.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines designer for ColumnHeader class.
|
||||
/// </summary>
|
||||
public class ColumnHeaderDesigner : ComponentDesigner
|
||||
{
|
||||
#region Internal Implementation
|
||||
#if FRAMEWORK20
|
||||
public override void InitializeNewComponent(IDictionary defaultValues)
|
||||
{
|
||||
SetDefaults();
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
}
|
||||
#else
|
||||
/// <summary>Sets design-time defaults for component.</summary>
|
||||
public override void OnSetComponentDefaults()
|
||||
{
|
||||
base.OnSetComponentDefaults();
|
||||
SetDefaults();
|
||||
}
|
||||
#endif
|
||||
|
||||
private void SetDefaults()
|
||||
{
|
||||
ColumnHeader ch = this.Component as ColumnHeader;
|
||||
ch.Width.Absolute = 150;
|
||||
ch.Text = "Column";
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,271 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.AdvTree.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for ComponentNotLicensed.
|
||||
/// </summary>
|
||||
public class ComponentNotLicensed : System.Windows.Forms.Form
|
||||
{
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.Label label7;
|
||||
private System.Windows.Forms.LinkLabel linkOrder;
|
||||
private System.Windows.Forms.Label label6;
|
||||
private System.Windows.Forms.Label label5;
|
||||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.LinkLabel linkHome;
|
||||
private System.Windows.Forms.LinkLabel linkEmail;
|
||||
private System.Windows.Forms.Button button2;
|
||||
private System.Windows.Forms.Button button1;
|
||||
private System.Windows.Forms.Timer timer1;
|
||||
private System.ComponentModel.IContainer components;
|
||||
|
||||
public ComponentNotLicensed()
|
||||
{
|
||||
//
|
||||
// Required for Windows Form Designer support
|
||||
//
|
||||
InitializeComponent();
|
||||
|
||||
//
|
||||
// TODO: Add any constructor code after InitializeComponent call
|
||||
//
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
protected override void Dispose( bool disposing )
|
||||
{
|
||||
if( disposing )
|
||||
{
|
||||
if(components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
}
|
||||
base.Dispose( disposing );
|
||||
}
|
||||
|
||||
#region Windows Form 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.components = new System.ComponentModel.Container();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.label7 = new System.Windows.Forms.Label();
|
||||
this.linkOrder = new System.Windows.Forms.LinkLabel();
|
||||
this.label6 = new System.Windows.Forms.Label();
|
||||
this.label5 = new System.Windows.Forms.Label();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.linkHome = new System.Windows.Forms.LinkLabel();
|
||||
this.linkEmail = new System.Windows.Forms.LinkLabel();
|
||||
this.button2 = new System.Windows.Forms.Button();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.timer1 = new System.Windows.Forms.Timer(this.components);
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.label7);
|
||||
this.groupBox1.Controls.Add(this.linkOrder);
|
||||
this.groupBox1.Controls.Add(this.label6);
|
||||
this.groupBox1.Controls.Add(this.label5);
|
||||
this.groupBox1.Location = new System.Drawing.Point(11, 54);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(294, 135);
|
||||
this.groupBox1.TabIndex = 17;
|
||||
this.groupBox1.TabStop = false;
|
||||
//
|
||||
// label7
|
||||
//
|
||||
this.label7.Location = new System.Drawing.Point(3, 104);
|
||||
this.label7.Name = "label7";
|
||||
this.label7.Size = new System.Drawing.Size(285, 12);
|
||||
this.label7.TabIndex = 3;
|
||||
this.label7.Text = "Order at:";
|
||||
this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// linkOrder
|
||||
//
|
||||
this.linkOrder.Location = new System.Drawing.Point(6, 116);
|
||||
this.linkOrder.Name = "linkOrder";
|
||||
this.linkOrder.Size = new System.Drawing.Size(280, 15);
|
||||
this.linkOrder.TabIndex = 2;
|
||||
this.linkOrder.TabStop = true;
|
||||
this.linkOrder.Text = "http://www.devcomponents.com/AdvTree/order.html";
|
||||
this.linkOrder.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.linkOrder.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkOrder_LinkClicked);
|
||||
//
|
||||
// label6
|
||||
//
|
||||
this.label6.Location = new System.Drawing.Point(9, 72);
|
||||
this.label6.Name = "label6";
|
||||
this.label6.Size = new System.Drawing.Size(276, 31);
|
||||
this.label6.TabIndex = 1;
|
||||
this.label6.Text = "For pricing and licensing information please visit our web site. ";
|
||||
//
|
||||
// label5
|
||||
//
|
||||
this.label5.ForeColor = System.Drawing.Color.Maroon;
|
||||
this.label5.Location = new System.Drawing.Point(8, 20);
|
||||
this.label5.Name = "label5";
|
||||
this.label5.Size = new System.Drawing.Size(276, 52);
|
||||
this.label5.TabIndex = 0;
|
||||
this.label5.Text = "This component is not registered and it is provided for evaluation purposes only." +
|
||||
" This message will not appear after you register the component.";
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(10, 216);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(31, 16);
|
||||
this.label4.TabIndex = 16;
|
||||
this.label4.Text = "Web:";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(9, 200);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(40, 16);
|
||||
this.label3.TabIndex = 14;
|
||||
this.label3.Text = "E-Mail:";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(7, 31);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(307, 16);
|
||||
this.label2.TabIndex = 11;
|
||||
this.label2.Text = "(c) 2005-2006 by DevComponents.com, All Rights Reserved";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
|
||||
this.label1.Location = new System.Drawing.Point(9, 7);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(236, 18);
|
||||
this.label1.TabIndex = 9;
|
||||
this.label1.Text = "DevComponents AdvTree Component";
|
||||
//
|
||||
// linkHome
|
||||
//
|
||||
this.linkHome.Location = new System.Drawing.Point(50, 215);
|
||||
this.linkHome.Name = "linkHome";
|
||||
this.linkHome.Size = new System.Drawing.Size(145, 16);
|
||||
this.linkHome.TabIndex = 15;
|
||||
this.linkHome.TabStop = true;
|
||||
this.linkHome.Text = "www.devcomponents.com";
|
||||
this.linkHome.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkHome_LinkClicked);
|
||||
//
|
||||
// linkEmail
|
||||
//
|
||||
this.linkEmail.Location = new System.Drawing.Point(49, 199);
|
||||
this.linkEmail.Name = "linkEmail";
|
||||
this.linkEmail.Size = new System.Drawing.Size(167, 16);
|
||||
this.linkEmail.TabIndex = 13;
|
||||
this.linkEmail.TabStop = true;
|
||||
this.linkEmail.Text = "support@devcomponents.com";
|
||||
this.linkEmail.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkEmail_LinkClicked);
|
||||
//
|
||||
// button2
|
||||
//
|
||||
this.button2.Location = new System.Drawing.Point(232, 240);
|
||||
this.button2.Name = "button2";
|
||||
this.button2.Size = new System.Drawing.Size(72, 24);
|
||||
this.button2.TabIndex = 12;
|
||||
this.button2.Text = "Buy Now";
|
||||
this.button2.Click += new System.EventHandler(this.button2_Click);
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.Enabled = false;
|
||||
this.button1.Location = new System.Drawing.Point(152, 240);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(72, 24);
|
||||
this.button1.TabIndex = 10;
|
||||
this.button1.Text = "OK";
|
||||
this.button1.Click += new System.EventHandler(this.button1_Click);
|
||||
//
|
||||
// timer1
|
||||
//
|
||||
this.timer1.Enabled = true;
|
||||
this.timer1.Interval = 800;
|
||||
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
|
||||
//
|
||||
// ComponentNotLicensed
|
||||
//
|
||||
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
|
||||
this.BackColor = System.Drawing.Color.BlanchedAlmond;
|
||||
this.ClientSize = new System.Drawing.Size(314, 273);
|
||||
this.ControlBox = false;
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Controls.Add(this.label4);
|
||||
this.Controls.Add(this.label3);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.linkHome);
|
||||
this.Controls.Add(this.linkEmail);
|
||||
this.Controls.Add(this.button2);
|
||||
this.Controls.Add(this.button1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.Name = "ComponentNotLicensed";
|
||||
this.Text = "AdvTree License not found";
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void button2_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
System.Diagnostics.Process.Start(linkOrder.Text);
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void linkHome_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
|
||||
{
|
||||
System.Diagnostics.Process.Start("http://www.devcomponents.com");
|
||||
}
|
||||
|
||||
private void linkOrder_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
|
||||
{
|
||||
System.Diagnostics.Process.Start(linkOrder.Text);
|
||||
}
|
||||
|
||||
private void linkEmail_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
|
||||
{
|
||||
System.Diagnostics.Process.Start(linkEmail.Text);
|
||||
}
|
||||
|
||||
private void timer1_Tick(object sender, System.EventArgs e)
|
||||
{
|
||||
timer1.Enabled=false;
|
||||
button1.Enabled=true;
|
||||
button1.Focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,265 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 1.3
|
||||
|
||||
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">1.3</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1">this is my long string</data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
[base64 mime encoded serialized .NET Framework object]
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
[base64 mime encoded string representing a byte array form of the .NET Framework object]
|
||||
</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 forserialized 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.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:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<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" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</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>1.3</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="groupBox1.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Private</value>
|
||||
</data>
|
||||
<data name="groupBox1.GridSize" type="System.Drawing.Size, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>8, 8</value>
|
||||
</data>
|
||||
<data name="groupBox1.SnapToGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</data>
|
||||
<data name="groupBox1.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="groupBox1.DrawGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</data>
|
||||
<data name="groupBox1.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Private</value>
|
||||
</data>
|
||||
<data name="label7.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="label7.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Private</value>
|
||||
</data>
|
||||
<data name="label7.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Private</value>
|
||||
</data>
|
||||
<data name="linkOrder.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Private</value>
|
||||
</data>
|
||||
<data name="linkOrder.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Private</value>
|
||||
</data>
|
||||
<data name="linkOrder.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="label6.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="label6.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Private</value>
|
||||
</data>
|
||||
<data name="label6.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Private</value>
|
||||
</data>
|
||||
<data name="label5.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="label5.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Private</value>
|
||||
</data>
|
||||
<data name="label5.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Private</value>
|
||||
</data>
|
||||
<data name="label4.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="label4.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Private</value>
|
||||
</data>
|
||||
<data name="label4.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Private</value>
|
||||
</data>
|
||||
<data name="label3.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="label3.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Private</value>
|
||||
</data>
|
||||
<data name="label3.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Private</value>
|
||||
</data>
|
||||
<data name="label2.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="label2.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Private</value>
|
||||
</data>
|
||||
<data name="label2.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Private</value>
|
||||
</data>
|
||||
<data name="label1.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="label1.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Private</value>
|
||||
</data>
|
||||
<data name="label1.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Private</value>
|
||||
</data>
|
||||
<data name="linkHome.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Private</value>
|
||||
</data>
|
||||
<data name="linkHome.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Private</value>
|
||||
</data>
|
||||
<data name="linkHome.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="linkEmail.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Private</value>
|
||||
</data>
|
||||
<data name="linkEmail.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Private</value>
|
||||
</data>
|
||||
<data name="linkEmail.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="button2.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="button2.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Private</value>
|
||||
</data>
|
||||
<data name="button2.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Private</value>
|
||||
</data>
|
||||
<data name="button1.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="button1.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Private</value>
|
||||
</data>
|
||||
<data name="button1.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Private</value>
|
||||
</data>
|
||||
<data name="timer1.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Private</value>
|
||||
</data>
|
||||
<data name="timer1.Location" type="System.Drawing.Point, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</data>
|
||||
<data name="timer1.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Private</value>
|
||||
</data>
|
||||
<data name="$this.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="$this.Language" type="System.Globalization.CultureInfo, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>(Default)</value>
|
||||
</data>
|
||||
<data name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="$this.Localizable" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="$this.GridSize" type="System.Drawing.Size, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>8, 8</value>
|
||||
</data>
|
||||
<data name="$this.Name">
|
||||
<value>ComponentNotLicensed</value>
|
||||
</data>
|
||||
<data name="$this.DrawGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="$this.TrayHeight" type="System.Int32, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>80</value>
|
||||
</data>
|
||||
<data name="$this.SnapToGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</data>
|
||||
<data name="$this.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Private</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -0,0 +1,151 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing.Design;
|
||||
using System.Windows.Forms.Design;
|
||||
using System.Windows.Forms;
|
||||
using System.ComponentModel.Design;
|
||||
using DevComponents.DotNetBar;
|
||||
|
||||
namespace DevComponents.AdvTree.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents type editor for ElementStyle used for Windows Forms design-time support.
|
||||
/// </summary>
|
||||
public class ElementStyleTypeEditor:System.Drawing.Design.UITypeEditor
|
||||
{
|
||||
#region Private Variables
|
||||
private IWindowsFormsEditorService m_EditorService = null;
|
||||
private const string OPTION_CREATE="Create style";
|
||||
private const string OPTION_REMOVE="Delete selected style";
|
||||
private const string OPTION_STYLES="Styles.";
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
|
||||
{
|
||||
if (context != null
|
||||
&& context.Instance != null
|
||||
&& provider != null)
|
||||
{
|
||||
ElementStyle es=value as ElementStyle;
|
||||
|
||||
m_EditorService = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
|
||||
|
||||
if(m_EditorService!=null)
|
||||
{
|
||||
AdvTree tree = null;
|
||||
if(context.Instance is AdvTree)
|
||||
tree=context.Instance as AdvTree;
|
||||
else if(context.Instance is Node)
|
||||
tree=((Node)context.Instance).TreeControl;
|
||||
else if(context.Instance is Cell)
|
||||
tree=((Cell)context.Instance).TreeControl;
|
||||
|
||||
ListBox lb=new ListBox();
|
||||
|
||||
if(es==null)
|
||||
lb.Items.Add(OPTION_CREATE);
|
||||
else
|
||||
lb.Items.Add(OPTION_REMOVE);
|
||||
|
||||
if(tree!=null)
|
||||
{
|
||||
foreach(ElementStyle style in tree.Styles)
|
||||
lb.Items.Add(style);
|
||||
}
|
||||
|
||||
string[] styles = Enum.GetNames(typeof (ePredefinedElementStyle));
|
||||
foreach(string s in styles)
|
||||
lb.Items.Add(OPTION_STYLES + s);
|
||||
|
||||
lb.SelectedIndexChanged+=new EventHandler(this.SelectedChanged);
|
||||
m_EditorService.DropDownControl(lb);
|
||||
|
||||
IDesignerHost dh=(IDesignerHost)provider.GetService(typeof(IDesignerHost));
|
||||
if(lb.SelectedItem!=null && dh!=null)
|
||||
{
|
||||
if(lb.SelectedItem is ElementStyle)
|
||||
{
|
||||
value=lb.SelectedItem as ElementStyle;
|
||||
}
|
||||
else if(lb.SelectedItem!=null && lb.SelectedItem.ToString().StartsWith(OPTION_STYLES))
|
||||
{
|
||||
string styleName = lb.SelectedItem.ToString().Substring(OPTION_STYLES.Length);
|
||||
Type t = typeof (NodeStyles);
|
||||
ElementStyle predefinedStyle=t.GetProperty(styleName).GetValue(null, null) as ElementStyle;
|
||||
ElementStyle newStyle=dh.CreateComponent(typeof(ElementStyle)) as ElementStyle;
|
||||
newStyle.ApplyStyle(predefinedStyle);
|
||||
newStyle.Description = styleName;
|
||||
value = newStyle;
|
||||
if(tree!=null)
|
||||
{
|
||||
IComponentChangeService cc = provider.GetService(typeof (IComponentChangeService)) as IComponentChangeService;
|
||||
if(cc!=null)
|
||||
cc.OnComponentChanging(tree, TypeDescriptor.GetProperties(tree)["Style"]);
|
||||
tree.Styles.Add(value as ElementStyle);
|
||||
if(cc!=null)
|
||||
cc.OnComponentChanged(tree, TypeDescriptor.GetProperties(tree)["Style"],null,null);
|
||||
}
|
||||
}
|
||||
else if(lb.SelectedItem!=null && lb.SelectedItem.ToString()==OPTION_CREATE)
|
||||
{
|
||||
value=dh.CreateComponent(typeof(ElementStyle)) as ElementStyle;
|
||||
if(tree!=null)
|
||||
{
|
||||
IComponentChangeService cc = provider.GetService(typeof (IComponentChangeService)) as IComponentChangeService;
|
||||
if(cc!=null)
|
||||
cc.OnComponentChanging(tree, TypeDescriptor.GetProperties(tree)["Style"]);
|
||||
tree.Styles.Add(value as ElementStyle);
|
||||
if(cc!=null)
|
||||
cc.OnComponentChanged(tree, TypeDescriptor.GetProperties(tree)["Style"],null,null);
|
||||
}
|
||||
}
|
||||
else if(lb.SelectedItem!=null && lb.SelectedItem.ToString()==OPTION_REMOVE)
|
||||
{
|
||||
if(tree!=null)
|
||||
{
|
||||
IComponentChangeService cc = provider.GetService(typeof (IComponentChangeService)) as IComponentChangeService;
|
||||
if(cc!=null)
|
||||
cc.OnComponentChanging(tree, TypeDescriptor.GetProperties(tree)["Style"]);
|
||||
if(tree!=null)
|
||||
tree.Styles.Remove(value as ElementStyle);
|
||||
if(cc!=null)
|
||||
cc.OnComponentChanged(tree, TypeDescriptor.GetProperties(tree)["Style"],null,null);
|
||||
if(tree.Styles.Count>0)
|
||||
value = tree.Styles[0];
|
||||
else
|
||||
value=null;
|
||||
}
|
||||
else
|
||||
value=null;
|
||||
dh.DestroyComponent(es);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
private void SelectedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if(m_EditorService!=null)
|
||||
m_EditorService.CloseDropDown();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the editor style used by the EditValue method.
|
||||
/// </summary>
|
||||
/// <param name="context">An ITypeDescriptorContext that can be used to gain additional context information.</param>
|
||||
/// <returns>A UITypeEditorEditStyle value that indicates the style of editor used by EditValue. If the UITypeEditor does not support this method, then GetEditStyle will return None</returns>
|
||||
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
|
||||
{
|
||||
if (context != null && context.Instance != null)
|
||||
{
|
||||
return UITypeEditorEditStyle.DropDown;
|
||||
}
|
||||
return base.GetEditStyle(context);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms.Design;
|
||||
using DevComponents.DotNetBar;
|
||||
using System.Windows.Forms;
|
||||
using System.Collections;
|
||||
using System.ComponentModel.Design;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing.Design;
|
||||
|
||||
namespace DevComponents.AdvTree.Design
|
||||
{
|
||||
public class HostedItemTypeEditor : System.Drawing.Design.UITypeEditor
|
||||
{
|
||||
#region Private Variables
|
||||
private IWindowsFormsEditorService m_EditorService = null;
|
||||
private const string OPTION_REMOVE = "Delete Item";
|
||||
private Dictionary<string, Type> _Items = new Dictionary<string, Type>();
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the HostedItemTypeEditor class.
|
||||
/// </summary>
|
||||
public HostedItemTypeEditor() : base()
|
||||
{
|
||||
_Items.Add("Button", typeof(ButtonItem));
|
||||
_Items.Add("Check-box", typeof(CheckBoxItem));
|
||||
_Items.Add("Micro-Chart", typeof(MicroChartItem));
|
||||
_Items.Add("Switch", typeof(SwitchButtonItem));
|
||||
_Items.Add("Slider", typeof(SliderItem));
|
||||
_Items.Add("Rating", typeof(RatingItem));
|
||||
_Items.Add("Progress bar", typeof(ProgressBarItem));
|
||||
_Items.Add("Container", typeof(ItemContainer));
|
||||
}
|
||||
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
|
||||
{
|
||||
if (context != null
|
||||
&& context.Instance != null
|
||||
&& provider != null)
|
||||
{
|
||||
m_EditorService = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
|
||||
|
||||
if (m_EditorService != null)
|
||||
{
|
||||
Cell currentCell = null;
|
||||
if (context.Instance is Node)
|
||||
currentCell = ((Node)context.Instance).Cells[0];
|
||||
else if (context.Instance is Cell)
|
||||
currentCell = (Cell)context.Instance;
|
||||
if (currentCell == null)
|
||||
{
|
||||
MessageBox.Show(string.Format("Invalid context.Instance. Instance: {0}", context.Instance));
|
||||
return value;
|
||||
}
|
||||
|
||||
ListBox lb = new ListBox();
|
||||
|
||||
if (currentCell.HostedItem != null)
|
||||
{
|
||||
lb.Items.Add(OPTION_REMOVE);
|
||||
lb.Items.Add("------------------");
|
||||
}
|
||||
foreach (KeyValuePair<string, Type> item in _Items)
|
||||
{
|
||||
lb.Items.Add(item.Key);
|
||||
}
|
||||
|
||||
|
||||
lb.SelectedIndexChanged += new EventHandler(this.SelectedChanged);
|
||||
m_EditorService.DropDownControl(lb);
|
||||
|
||||
IDesignerHost dh = (IDesignerHost)provider.GetService(typeof(IDesignerHost));
|
||||
if (lb.SelectedItem != null && dh != null)
|
||||
{
|
||||
if (lb.SelectedItem == OPTION_REMOVE)
|
||||
{
|
||||
BaseItem item = currentCell.HostedItem;
|
||||
dh.DestroyComponent(item);
|
||||
value = null;
|
||||
}
|
||||
else if (_Items.ContainsKey(lb.SelectedItem.ToString()))
|
||||
{
|
||||
if (currentCell.HostedItem != null)
|
||||
{
|
||||
BaseItem item = currentCell.HostedItem;
|
||||
dh.DestroyComponent(item);
|
||||
}
|
||||
|
||||
BaseItem newItem = dh.CreateComponent(_Items[(string)lb.SelectedItem]) as BaseItem;
|
||||
if (!string.IsNullOrEmpty(newItem.Name) && string.IsNullOrEmpty(newItem.Text))
|
||||
TypeDescriptor.GetProperties(newItem)["Text"].SetValue(newItem, newItem.Name);
|
||||
value = newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
private void SelectedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (m_EditorService != null)
|
||||
m_EditorService.CloseDropDown();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the editor style used by the EditValue method.
|
||||
/// </summary>
|
||||
/// <param name="context">An ITypeDescriptorContext that can be used to gain additional context information.</param>
|
||||
/// <returns>A UITypeEditorEditStyle value that indicates the style of editor used by EditValue. If the UITypeEditor does not support this method, then GetEditStyle will return None</returns>
|
||||
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
|
||||
{
|
||||
if (context != null && context.Instance != null)
|
||||
{
|
||||
return UITypeEditorEditStyle.DropDown;
|
||||
}
|
||||
return base.GetEditStyle(context);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Drawing.Design;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms.ComponentModel;
|
||||
using System.Windows.Forms.Design;
|
||||
|
||||
namespace DevComponents.AdvTree.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the class used by windows forms editor for picking an image from image list.
|
||||
/// </summary>
|
||||
public class ImageIndexEditor:UITypeEditor
|
||||
{
|
||||
private ImageEditor m_ImageEditor;
|
||||
private System.Windows.Forms.ImageList m_ImageList=null;
|
||||
public ImageIndexEditor():base()
|
||||
{
|
||||
m_ImageEditor=System.ComponentModel.TypeDescriptor.GetEditor(typeof(System.Drawing.Image),typeof(UITypeEditor)) as ImageEditor;
|
||||
}
|
||||
|
||||
public override bool GetPaintValueSupported(ITypeDescriptorContext context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void PaintValue(PaintValueEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(e==null || e.Value==null)
|
||||
return;
|
||||
int iIndex=(int)e.Value;
|
||||
System.Drawing.Image img=this.GetImage(e.Context,iIndex);
|
||||
if(img==null)
|
||||
return;
|
||||
PaintValueEventArgs pi=new PaintValueEventArgs(e.Context,img,e.Graphics,e.Bounds);
|
||||
m_ImageEditor.PaintValue(pi);
|
||||
//m_ImageEditor.PaintValue(img,e.Graphics,e.Bounds);
|
||||
}
|
||||
catch{}
|
||||
}
|
||||
|
||||
private System.Drawing.Image GetImage(System.ComponentModel.ITypeDescriptorContext context,int index)
|
||||
{
|
||||
if(m_ImageList!=null && index>=0 && index<=m_ImageList.Images.Count)
|
||||
{
|
||||
return m_ImageList.Images[index];
|
||||
}
|
||||
if(context==null)
|
||||
return null;
|
||||
|
||||
object o=context.Instance;
|
||||
if(o==null)
|
||||
return null;
|
||||
System.ComponentModel.PropertyDescriptorCollection pd=System.ComponentModel.TypeDescriptor.GetProperties(o);
|
||||
if(pd==null)
|
||||
return null;
|
||||
|
||||
foreach(System.ComponentModel.PropertyDescriptor prop in pd)
|
||||
{
|
||||
if(prop.PropertyType==typeof(System.Windows.Forms.ImageList))
|
||||
{
|
||||
m_ImageList=prop.GetValue(o) as System.Windows.Forms.ImageList;
|
||||
if(m_ImageList!=null && index>=0 && index<=m_ImageList.Images.Count)
|
||||
{
|
||||
return m_ImageList.Images[index];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace DevComponents.AdvTree.Design
|
||||
{
|
||||
#region NodeCollectionEditor
|
||||
/// <summary>
|
||||
/// Support for Node tabs design-time editor.
|
||||
/// </summary>
|
||||
public class NodeCollectionEditor : System.ComponentModel.Design.CollectionEditor
|
||||
{
|
||||
public NodeCollectionEditor(Type type)
|
||||
: base(type)
|
||||
{
|
||||
}
|
||||
protected override Type CreateCollectionItemType()
|
||||
{
|
||||
return typeof(Node);
|
||||
}
|
||||
protected override Type[] CreateNewItemTypes()
|
||||
{
|
||||
return new Type[] { typeof(Node) };
|
||||
}
|
||||
protected override object CreateInstance(Type itemType)
|
||||
{
|
||||
object item = base.CreateInstance(itemType);
|
||||
if (item is Node)
|
||||
{
|
||||
Node node = item as Node;
|
||||
node.Text = node.Name;
|
||||
}
|
||||
return item;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Design;
|
||||
using System.Windows.Forms.Design;
|
||||
using System.Windows.Forms;
|
||||
using System.ComponentModel.Design;
|
||||
|
||||
namespace DevComponents.AdvTree.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents type editor for NodeConnector used for Windows Forms design-time support.
|
||||
/// </summary>
|
||||
public class NodeConnectorTypeEditor:System.Drawing.Design.UITypeEditor
|
||||
{
|
||||
#region Private Variables
|
||||
private IWindowsFormsEditorService m_EditorService = null;
|
||||
private const string OPTION_CREATE="Create new connector";
|
||||
private const string OPTION_REMOVE="Remove connector";
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
|
||||
{
|
||||
if (context != null
|
||||
&& context.Instance != null
|
||||
&& provider != null)
|
||||
{
|
||||
NodeConnector conn=value as NodeConnector;
|
||||
|
||||
m_EditorService = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
|
||||
|
||||
if(m_EditorService!=null)
|
||||
{
|
||||
ListBox lb=new ListBox();
|
||||
lb.SelectedIndexChanged+=new EventHandler(this.SelectedChanged);
|
||||
if(conn==null)
|
||||
lb.Items.Add(OPTION_CREATE);
|
||||
else
|
||||
lb.Items.Add(OPTION_REMOVE);
|
||||
|
||||
m_EditorService.DropDownControl(lb);
|
||||
|
||||
IDesignerHost dh=(IDesignerHost)provider.GetService(typeof(IDesignerHost));
|
||||
if(lb.SelectedItem!=null && dh!=null)
|
||||
{
|
||||
if(lb.SelectedItem.ToString()==OPTION_CREATE)
|
||||
{
|
||||
NodeConnector nd=dh.CreateComponent(typeof(NodeConnector)) as NodeConnector;
|
||||
nd.LineWidth = 1;
|
||||
value = nd;
|
||||
}
|
||||
else if(lb.SelectedItem.ToString()==OPTION_REMOVE)
|
||||
{
|
||||
value=null;
|
||||
dh.DestroyComponent(conn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
private void SelectedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if(m_EditorService!=null)
|
||||
m_EditorService.CloseDropDown();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the editor style used by the EditValue method.
|
||||
/// </summary>
|
||||
/// <param name="context">An ITypeDescriptorContext that can be used to gain additional context information.</param>
|
||||
/// <returns>A UITypeEditorEditStyle value that indicates the style of editor used by EditValue. If the UITypeEditor does not support this method, then GetEditStyle will return None</returns>
|
||||
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
|
||||
{
|
||||
if (context != null && context.Instance != null)
|
||||
{
|
||||
return UITypeEditorEditStyle.DropDown;
|
||||
}
|
||||
return base.GetEditStyle(context);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Design;
|
||||
using System.Windows.Forms.Design;
|
||||
using System.Windows.Forms;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Collections;
|
||||
using DevComponents.DotNetBar;
|
||||
|
||||
namespace DevComponents.AdvTree.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents context menu type editor for Node.ContextMenu property.
|
||||
/// </summary>
|
||||
public class NodeContextMenuTypeEditor:System.Drawing.Design.UITypeEditor
|
||||
{
|
||||
#region Private Variables
|
||||
private IWindowsFormsEditorService m_EditorService = null;
|
||||
public static string DotNetBarPrefix="DotNetBar.";
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
|
||||
{
|
||||
if (context != null
|
||||
&& context.Instance != null
|
||||
&& provider != null)
|
||||
{
|
||||
m_EditorService = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
|
||||
|
||||
if(m_EditorService!=null)
|
||||
{
|
||||
ListBox lb=new ListBox();
|
||||
DevComponents.DotNetBar.ContextMenuBar contextMenuBar = null;
|
||||
lb.SelectedIndexChanged+=new EventHandler(this.SelectedChanged);
|
||||
|
||||
IDesignerHost host = (IDesignerHost)provider.GetService(typeof(IDesignerHost));
|
||||
foreach(IComponent component in host.Container.Components)
|
||||
{
|
||||
if(component is ContextMenu || component.GetType().FullName=="System.Windows.Forms.ContextMenuStrip")
|
||||
{
|
||||
lb.Items.Add(component);
|
||||
}
|
||||
if (component is DevComponents.DotNetBar.ContextMenuBar)
|
||||
{
|
||||
contextMenuBar = component as DevComponents.DotNetBar.ContextMenuBar;
|
||||
foreach (BaseItem item in contextMenuBar.Items)
|
||||
{
|
||||
lb.Items.Add(DotNetBarPrefix + item.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_EditorService.DropDownControl(lb);
|
||||
|
||||
if(lb.SelectedItem!=null)
|
||||
{
|
||||
if(lb.SelectedItem.ToString().StartsWith(DotNetBarPrefix))
|
||||
{
|
||||
Node node=context.Instance as Node;
|
||||
if (node != null && node.TreeControl != null)
|
||||
{
|
||||
TypeDescriptor.GetProperties(node.TreeControl)["ContextMenuBar"].SetValue(node.TreeControl, contextMenuBar);
|
||||
}
|
||||
return contextMenuBar.Items[lb.SelectedItem.ToString().Substring(DotNetBarPrefix.Length)];
|
||||
}
|
||||
return lb.SelectedItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
private void SelectedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if(m_EditorService!=null)
|
||||
m_EditorService.CloseDropDown();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the editor style used by the EditValue method.
|
||||
/// </summary>
|
||||
/// <param name="context">An ITypeDescriptorContext that can be used to gain additional context information.</param>
|
||||
/// <returns>A UITypeEditorEditStyle value that indicates the style of editor used by EditValue. If the UITypeEditor does not support this method, then GetEditStyle will return None</returns>
|
||||
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
|
||||
{
|
||||
if (context != null && context.Instance != null)
|
||||
{
|
||||
return UITypeEditorEditStyle.DropDown;
|
||||
}
|
||||
return base.GetEditStyle(context);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,207 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms.Design;
|
||||
|
||||
namespace DevComponents.AdvTree.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents Windows Forms designer for Node object.
|
||||
/// </summary>
|
||||
public class NodeDesigner:ComponentDesigner
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes designer with given component.
|
||||
/// </summary>
|
||||
/// <param name="component">Component to initialize designer with.</param>
|
||||
public override void Initialize(IComponent component)
|
||||
{
|
||||
base.Initialize(component);
|
||||
if(!component.Site.DesignMode)
|
||||
return;
|
||||
|
||||
ISelectionService ss =(ISelectionService)GetService(typeof(ISelectionService));
|
||||
if(ss!=null)
|
||||
ss.SelectionChanged+=new EventHandler(OnSelectionChanged);
|
||||
|
||||
Node n=component as Node;
|
||||
if(n!=null)
|
||||
this.Visible=n.Visible;
|
||||
}
|
||||
private void OnSelectionChanged(object sender, EventArgs e)
|
||||
{
|
||||
ISelectionService ss = (ISelectionService)sender;
|
||||
if (this.Component != null && ss.PrimarySelection != this.Component)
|
||||
{
|
||||
Node node = this.Component as Node;
|
||||
if (ss.PrimarySelection is Node)
|
||||
{
|
||||
Node selected = ss.PrimarySelection as Node;
|
||||
|
||||
if (selected.TreeControl != node.TreeControl)
|
||||
{
|
||||
node.TreeControl.SelectedNode = null;
|
||||
}
|
||||
}
|
||||
else if (node != null && node.TreeControl != null)
|
||||
node.TreeControl.SelectedNode = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void PreFilterProperties(System.Collections.IDictionary properties)
|
||||
{
|
||||
base.PreFilterProperties(properties);
|
||||
properties["Visible"] = TypeDescriptor.CreateProperty(typeof(NodeDesigner),(PropertyDescriptor)properties["Visible"], new Attribute[]
|
||||
{
|
||||
new DefaultValueAttribute(true),
|
||||
new BrowsableAttribute(true),
|
||||
new CategoryAttribute("Layout")});
|
||||
// properties["HostedControl"] = TypeDescriptor.CreateProperty(typeof(NodeDesigner),(PropertyDescriptor)properties["HostedControl"], new Attribute[]
|
||||
// {
|
||||
// new DefaultValueAttribute(null),
|
||||
// new BrowsableAttribute(true),
|
||||
// new CategoryAttribute("Behavior"),
|
||||
// new DescriptionAttribute("Indicates control hosted inside of the cell.")});
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether item is visible.
|
||||
/// </summary>
|
||||
[DefaultValue(true),Browsable(true),Category("Layout"),Description("Gets or sets whether node is visible.")]
|
||||
public bool Visible
|
||||
{
|
||||
get
|
||||
{
|
||||
return (bool)ShadowProperties["Visible"];
|
||||
}
|
||||
set
|
||||
{
|
||||
// this value is not passed to the actual control
|
||||
this.ShadowProperties["Visible"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
// /// <summary>
|
||||
// /// Gets or sets whether item is visible.
|
||||
// /// </summary>
|
||||
// [DefaultValue(null),Browsable(true),Category("Behavior"),Description("Indicates control hosted inside of the cell.")]
|
||||
// public Control HostedControl
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// Node node = this.Component as Node;
|
||||
// return node.HostedControl;
|
||||
// }
|
||||
// set
|
||||
// {
|
||||
// Node node = this.Component as Node;
|
||||
// node.HostedControl = value;
|
||||
// if(value!=null)
|
||||
// {
|
||||
// IDesignerHost dh = this.GetService(typeof (IDesignerHost)) as IDesignerHost;
|
||||
// if(dh!=null)
|
||||
// {
|
||||
// AdvTreeDesigner ds = dh.GetDesigner(node.TreeControl) as AdvTreeDesigner;
|
||||
// if(ds!=null)
|
||||
// ds.HookControl(value);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
/// <summary>Returns design-time commands applicable to this designer.</summary>
|
||||
public override DesignerVerbCollection Verbs
|
||||
{
|
||||
get
|
||||
{
|
||||
DesignerVerb[] verbs = new DesignerVerb[]
|
||||
{
|
||||
new DesignerVerb("Create Child Node", new EventHandler(CreateNode)),
|
||||
new DesignerVerb("Edit Cells...", new EventHandler(EditCells)),
|
||||
new DesignerVerb("Edit Columns...", new EventHandler(EditColumns))
|
||||
};
|
||||
return new DesignerVerbCollection(verbs);
|
||||
}
|
||||
}
|
||||
|
||||
private void EditCells(object sender, EventArgs e)
|
||||
{
|
||||
AdvTreeDesigner.EditValue(this, this.Component, "Cells");
|
||||
}
|
||||
|
||||
private void EditColumns(object sender, EventArgs e)
|
||||
{
|
||||
AdvTreeDesigner.EditValue(this, this.Component, "NodesColumns");
|
||||
}
|
||||
|
||||
private void CreateNode(object sender, EventArgs e)
|
||||
{
|
||||
Node node=CreateNode(this.Component as Node);
|
||||
if(node!=null)
|
||||
{
|
||||
ISelectionService sel = this.GetService(typeof (ISelectionService)) as ISelectionService;
|
||||
ArrayList list=new ArrayList(1);
|
||||
list.Add(node);
|
||||
if(sel!=null)
|
||||
{
|
||||
sel.SetSelectedComponents(list, SelectionTypes.MouseDown);
|
||||
node.TreeControl.SelectedNode = node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Node CreateNode(Node parentNode)
|
||||
{
|
||||
IDesignerHost dh=(IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
if(dh==null)
|
||||
return null;
|
||||
|
||||
Node node=null;
|
||||
AdvTree tree=((Node)this.Component).TreeControl;
|
||||
tree.BeginUpdate();
|
||||
try
|
||||
{
|
||||
IComponentChangeService change=this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if(change!=null)
|
||||
{
|
||||
if(parentNode!=null)
|
||||
change.OnComponentChanging(this.Component,TypeDescriptor.GetProperties(parentNode).Find("Nodes",true));
|
||||
else
|
||||
change.OnComponentChanging(this.Component,TypeDescriptor.GetProperties(tree).Find("Nodes",true));
|
||||
}
|
||||
|
||||
node=dh.CreateComponent(typeof(Node)) as Node;
|
||||
if(node!=null)
|
||||
{
|
||||
node.Text=node.Name;
|
||||
node.Expanded = true;
|
||||
if(parentNode==null)
|
||||
tree.Nodes.Add(node);
|
||||
else
|
||||
{
|
||||
parentNode.Nodes.Add(node);
|
||||
parentNode.Expand();
|
||||
TypeDescriptor.GetProperties(node)["Style"].SetValue(node,parentNode.Style);
|
||||
}
|
||||
|
||||
if(change!=null)
|
||||
{
|
||||
if(parentNode!=null)
|
||||
change.OnComponentChanged(this.Component,TypeDescriptor.GetProperties(parentNode).Find("Nodes",true),null,null);
|
||||
else
|
||||
change.OnComponentChanged(this.Component,TypeDescriptor.GetProperties(tree).Find("Nodes",true),null,null);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
tree.EndUpdate();
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,253 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel.Design;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
public class ApplicationButtonDesigner : BaseItemDesigner
|
||||
{
|
||||
#region Internal Implementation
|
||||
protected override DesignerVerb[] GetVerbs()
|
||||
{
|
||||
DesignerVerb[] baseVerbs = base.GetVerbs();
|
||||
int verbsCount = baseVerbs.Length + 1;
|
||||
if (IsBackstageSet) verbsCount = 1;
|
||||
|
||||
bool includeClearSubItems = false;
|
||||
ApplicationButton appButton = this.Component as ApplicationButton;
|
||||
if (appButton != null && appButton.BackstageTab != null && appButton.SubItems.Count > 0)
|
||||
{
|
||||
includeClearSubItems = true;
|
||||
verbsCount++;
|
||||
}
|
||||
|
||||
int verbsOffset = 1;
|
||||
DesignerVerb[] verbs = new DesignerVerb[verbsCount];
|
||||
verbs[0] = new DesignerVerb((IsBackstageSet ? "Remove Backstage" : "Set Backstage"), new EventHandler(CreateBackstageTab));
|
||||
|
||||
if (includeClearSubItems)
|
||||
{
|
||||
verbs[1] = new DesignerVerb("Clear Sub-items", new EventHandler(ClearSubItems));
|
||||
verbsOffset++;
|
||||
}
|
||||
|
||||
if (!IsBackstageSet)
|
||||
{
|
||||
for (int i = 0; i < baseVerbs.Length; i++)
|
||||
{
|
||||
verbs[i + verbsOffset] = baseVerbs[i];
|
||||
}
|
||||
}
|
||||
|
||||
return verbs;
|
||||
}
|
||||
|
||||
private void ClearSubItems(object sender, EventArgs e)
|
||||
{
|
||||
if (MessageBox.Show("Are you sure you want to delete all sub-items?", "DotNetBar Application Button", MessageBoxButtons.YesNo) == DialogResult.No) return;
|
||||
|
||||
IDesignerHost dh = GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
IComponentChangeService cc = GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (dh == null) return;
|
||||
ApplicationButton appButton = (ApplicationButton)this.Component;
|
||||
if (appButton.SubItems.Count == 0) return;
|
||||
|
||||
DesignerTransaction trans = dh.CreateTransaction("Clearing Application Button SubItems");
|
||||
try
|
||||
{
|
||||
cc.OnComponentChanging(appButton, TypeDescriptor.GetProperties(appButton)["SubItems"]);
|
||||
BaseItem[] items = new BaseItem[appButton.SubItems.Count];
|
||||
appButton.SubItems.CopyTo(items, 0);
|
||||
foreach (BaseItem item in items)
|
||||
{
|
||||
appButton.SubItems.Remove(item);
|
||||
dh.DestroyComponent(item);
|
||||
}
|
||||
cc.OnComponentChanged(appButton, TypeDescriptor.GetProperties(appButton)["SubItems"], null, null);
|
||||
}
|
||||
catch
|
||||
{
|
||||
trans.Cancel();
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!trans.Canceled)
|
||||
trans.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsBackstageSet
|
||||
{
|
||||
get
|
||||
{
|
||||
ApplicationButton appButton = (ApplicationButton)this.Component;
|
||||
if (appButton != null && appButton.BackstageTab != null) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateBackstageTab()
|
||||
{
|
||||
IDesignerHost dh = GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
IComponentChangeService cc = GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (dh == null) return;
|
||||
|
||||
ApplicationButton appButton = (ApplicationButton)this.Component;
|
||||
if (appButton.BackstageTab != null)
|
||||
{
|
||||
DesignerTransaction trans1 = dh.CreateTransaction("Removing Backstage tab");
|
||||
try
|
||||
{
|
||||
SuperTabControl backstageTab = appButton.BackstageTab;
|
||||
SetProperty(appButton, "BackstageTab", null);
|
||||
backstageTab.Visible = true;
|
||||
SetProperty(backstageTab, "Location", new System.Drawing.Point(0, 150));
|
||||
SetProperty(backstageTab, "Size", new System.Drawing.Size(250, 350));
|
||||
ISelectionService selection = (ISelectionService)GetService(typeof(ISelectionService));
|
||||
if (selection != null) selection.SetSelectedComponents(new Control[] { backstageTab }, SelectionTypes.Primary);
|
||||
}
|
||||
catch
|
||||
{
|
||||
trans1.Cancel();
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!trans1.Canceled)
|
||||
trans1.Commit();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
DesignerTransaction trans = dh.CreateTransaction("Create Backstage");
|
||||
try
|
||||
{
|
||||
|
||||
if (appButton.Expanded) appButton.Expanded = false;
|
||||
SuperTabControl backstageTab = (SuperTabControl)dh.CreateComponent(typeof(SuperTabControl));
|
||||
SetProperty(appButton, "BackstageTab", backstageTab);
|
||||
|
||||
Control root = dh.RootComponent as Control;
|
||||
if (root != null)
|
||||
{
|
||||
cc.OnComponentChanging(root, TypeDescriptor.GetProperties(root)["Controls"]);
|
||||
root.Controls.Add(backstageTab);
|
||||
cc.OnComponentChanged(root, TypeDescriptor.GetProperties(root)["Controls"], null, null);
|
||||
}
|
||||
SetupBackstageTab(backstageTab, dh);
|
||||
}
|
||||
catch
|
||||
{
|
||||
trans.Cancel();
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!trans.Canceled)
|
||||
trans.Commit();
|
||||
}
|
||||
}
|
||||
private void CreateBackstageTab(object sender, EventArgs e)
|
||||
{
|
||||
CreateBackstageTab();
|
||||
}
|
||||
|
||||
private void SetupBackstageTab(SuperTabControl backstageTab, IDesignerHost dh)
|
||||
{
|
||||
backstageTab.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
backstageTab.ControlBox.Visible = false;
|
||||
backstageTab.ItemPadding.Left = 6;
|
||||
backstageTab.ItemPadding.Right = 4;
|
||||
backstageTab.ItemPadding.Top = 4;
|
||||
backstageTab.ReorderTabsEnabled = false;
|
||||
try
|
||||
{
|
||||
backstageTab.SelectedTabFont = new System.Drawing.Font("Segoe UI", 9.75F);
|
||||
}
|
||||
catch { }
|
||||
backstageTab.SelectedTabIndex = 0;
|
||||
backstageTab.Size = new System.Drawing.Size(614, 315);
|
||||
backstageTab.TabAlignment = DevComponents.DotNetBar.eTabStripAlignment.Left;
|
||||
try
|
||||
{
|
||||
backstageTab.TabFont = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
}
|
||||
catch { }
|
||||
backstageTab.TabHorizontalSpacing = 16;
|
||||
backstageTab.TabStyle = DevComponents.DotNetBar.eSuperTabStyle.Office2010BackstageBlue;
|
||||
backstageTab.TabVerticalSpacing = 8;
|
||||
|
||||
SuperTabControlDesigner tabDesigner = dh.GetDesigner(backstageTab) as SuperTabControlDesigner;
|
||||
if (tabDesigner != null)
|
||||
{
|
||||
ButtonItem button;
|
||||
// Save button
|
||||
button = tabDesigner.CreateButton();
|
||||
SetProperty(button, "Text", "Save");
|
||||
SetProperty(button, "KeyTips", "S");
|
||||
SetProperty(button, "Image", RibbonControlDesigner.LoadImage("Save16.png"));
|
||||
|
||||
// Open
|
||||
button = tabDesigner.CreateButton();
|
||||
SetProperty(button, "Text", "Open");
|
||||
SetProperty(button, "KeyTips", "O");
|
||||
SetProperty(button, "Image", RibbonControlDesigner.LoadImage("Open.png"));
|
||||
|
||||
// Close
|
||||
button = tabDesigner.CreateButton();
|
||||
SetProperty(button, "Text", "Close");
|
||||
SetProperty(button, "KeyTips", "C");
|
||||
SetProperty(button, "Image", RibbonControlDesigner.LoadImage("Close16.png"));
|
||||
|
||||
SuperTabItem tab;
|
||||
tab = tabDesigner.CreateNewTab();
|
||||
SetProperty(tab, "Text", "Recent");
|
||||
SetProperty(tab, "KeyTips", "R");
|
||||
SetProperty((SuperTabControlPanel)tab.AttachedControl, "BackgroundImage", RibbonControlDesigner.LoadImage("BlueBackstageBgImage.png"));
|
||||
SetProperty((SuperTabControlPanel)tab.AttachedControl, "BackgroundImagePosition", DevComponents.DotNetBar.eStyleBackgroundImage.BottomRight);
|
||||
|
||||
tab = tabDesigner.CreateNewTab();
|
||||
SetProperty(tab, "Text", "New");
|
||||
SetProperty(tab, "KeyTips", "N");
|
||||
SetProperty((SuperTabControlPanel)tab.AttachedControl, "BackgroundImage", RibbonControlDesigner.LoadImage("BlueBackstageBgImage.png"));
|
||||
SetProperty((SuperTabControlPanel)tab.AttachedControl, "BackgroundImagePosition", DevComponents.DotNetBar.eStyleBackgroundImage.BottomRight);
|
||||
|
||||
tab = tabDesigner.CreateNewTab();
|
||||
SetProperty(tab, "Text", "Print");
|
||||
SetProperty(tab, "KeyTips", "P");
|
||||
SetProperty((SuperTabControlPanel)tab.AttachedControl, "BackgroundImage", RibbonControlDesigner.LoadImage("BlueBackstageBgImage.png"));
|
||||
SetProperty((SuperTabControlPanel)tab.AttachedControl, "BackgroundImagePosition", DevComponents.DotNetBar.eStyleBackgroundImage.BottomRight);
|
||||
|
||||
tab = tabDesigner.CreateNewTab();
|
||||
SetProperty(tab, "Text", "Help");
|
||||
SetProperty(tab, "KeyTips", "H");
|
||||
SetProperty((SuperTabControlPanel)tab.AttachedControl, "BackgroundImage", RibbonControlDesigner.LoadImage("BlueBackstageBgImage.png"));
|
||||
SetProperty((SuperTabControlPanel)tab.AttachedControl, "BackgroundImagePosition", DevComponents.DotNetBar.eStyleBackgroundImage.BottomRight);
|
||||
|
||||
// Options
|
||||
button = tabDesigner.CreateButton();
|
||||
SetProperty(button, "Text", "Options");
|
||||
SetProperty(button, "KeyTips", "T");
|
||||
SetProperty(button, "Image", RibbonControlDesigner.LoadImage("Options2.png"));
|
||||
|
||||
// Exit
|
||||
button = tabDesigner.CreateButton();
|
||||
SetProperty(button, "Text", "Exit");
|
||||
SetProperty(button, "KeyTips", "X");
|
||||
SetProperty(button, "Image", RibbonControlDesigner.LoadImage("Exit2.png"));
|
||||
}
|
||||
}
|
||||
|
||||
private void SetProperty(object targetObject, string propertyName, object propertyValue)
|
||||
{
|
||||
TypeDescriptor.GetProperties(targetObject)[propertyName].SetValue(targetObject, propertyValue);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
1092
PROMS/DotNetBar Source Code/DotNetBarDesignTime/BarDesigner.cs
Normal file
1092
PROMS/DotNetBar Source Code/DotNetBarDesignTime/BarDesigner.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,585 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents designer for BaseItem objects and derived classes.
|
||||
/// </summary>
|
||||
public class BaseItemDesigner:System.ComponentModel.Design.ComponentDesigner,IDesignerServices
|
||||
{
|
||||
#region Private Variables
|
||||
protected bool m_AddingItem = false;
|
||||
protected bool m_CreatingItem = false;
|
||||
protected DesignerTransaction m_InsertItemTransaction = null;
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
/// <summary>
|
||||
/// Creates new instance of the class.
|
||||
/// </summary>
|
||||
public BaseItemDesigner()
|
||||
{
|
||||
}
|
||||
|
||||
public override void Initialize(IComponent component)
|
||||
{
|
||||
base.Initialize(component);
|
||||
if(!component.Site.DesignMode)
|
||||
return;
|
||||
|
||||
ISelectionService ss =(ISelectionService)GetService(typeof(ISelectionService));
|
||||
if(ss!=null)
|
||||
ss.SelectionChanged+=new EventHandler(OnSelectionChanged);
|
||||
|
||||
BaseItem c=component as BaseItem;
|
||||
if(c!=null)
|
||||
this.Visible=c.Visible;
|
||||
|
||||
// If our component is removed we need to clean-up
|
||||
IComponentChangeService cc=(IComponentChangeService)GetService(typeof(IComponentChangeService));
|
||||
if(cc!=null)
|
||||
{
|
||||
cc.ComponentRemoved+=new ComponentEventHandler(this.OnComponentRemoved);
|
||||
cc.ComponentAdding += new ComponentEventHandler(ComponentChangeComponentAdding);
|
||||
cc.ComponentAdded += new ComponentEventHandler(ComponentChangeComponentAdded);
|
||||
}
|
||||
}
|
||||
|
||||
#if FRAMEWORK20
|
||||
public override void InitializeNewComponent(IDictionary defaultValues)
|
||||
{
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#else
|
||||
public override void OnSetComponentDefaults()
|
||||
{
|
||||
base.OnSetComponentDefaults();
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#endif
|
||||
|
||||
protected virtual void SetDesignTimeDefaults()
|
||||
{
|
||||
}
|
||||
|
||||
protected virtual void ComponentChangeComponentAdded(object sender, ComponentEventArgs e)
|
||||
{
|
||||
if (m_AddingItem)
|
||||
{
|
||||
m_AddingItem = false;
|
||||
IComponentChangeService cc = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
BaseItem parent = this.Component as BaseItem;
|
||||
|
||||
if (cc != null)
|
||||
cc.OnComponentChanging(parent, TypeDescriptor.GetProperties(parent)["SubItems"]);
|
||||
|
||||
parent.SubItems.Add(e.Component as BaseItem);
|
||||
|
||||
if (cc != null)
|
||||
cc.OnComponentChanged(parent, TypeDescriptor.GetProperties(parent)["SubItems"], null, null);
|
||||
|
||||
m_InsertItemTransaction.Commit();
|
||||
m_InsertItemTransaction = null;
|
||||
this.RecalcLayout();
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void ComponentChangeComponentAdding(object sender, ComponentEventArgs e)
|
||||
{
|
||||
if (m_InsertItemTransaction == null && !m_AddingItem && !m_CreatingItem && e.Component is BaseItem)
|
||||
{
|
||||
ISelectionService ss = this.GetService(typeof(ISelectionService)) as ISelectionService;
|
||||
if (ss != null && ss.PrimarySelection == this.Component)
|
||||
{
|
||||
m_AddingItem = true;
|
||||
IDesignerHost dh = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
m_InsertItemTransaction = dh.CreateTransaction("Adding Item Clip");
|
||||
}
|
||||
}
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
ISelectionService ss =(ISelectionService)GetService(typeof(ISelectionService));
|
||||
if(ss!=null)
|
||||
ss.SelectionChanged-=new EventHandler(OnSelectionChanged);
|
||||
|
||||
IComponentChangeService cc=(IComponentChangeService)GetService(typeof(IComponentChangeService));
|
||||
if(cc!=null)
|
||||
{
|
||||
cc.ComponentRemoved-=new ComponentEventHandler(this.OnComponentRemoved);
|
||||
}
|
||||
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private void OnComponentRemoved(object sender,ComponentEventArgs e)
|
||||
{
|
||||
if(e.Component is BaseItem)
|
||||
{
|
||||
BaseItem parent=this.Component as BaseItem;
|
||||
BaseItem item=e.Component as BaseItem;
|
||||
if(item!=null && parent!=null && parent.SubItems.Contains(item))
|
||||
{
|
||||
IComponentChangeService cc=(IComponentChangeService)GetService(typeof(IComponentChangeService));
|
||||
if(cc!=null)
|
||||
cc.OnComponentChanging(parent,TypeDescriptor.GetProperties(parent)["SubItems"]);
|
||||
parent.SubItems.Remove(item);
|
||||
if(cc!=null)
|
||||
cc.OnComponentChanged(parent,TypeDescriptor.GetProperties(parent)["SubItems"],null,null);
|
||||
this.RecalcLayout();
|
||||
}
|
||||
}
|
||||
ComponentRemoved(e);
|
||||
}
|
||||
|
||||
protected virtual void ComponentRemoved(ComponentEventArgs e) { }
|
||||
|
||||
private void OnSelectionChanged(object sender, EventArgs e)
|
||||
{
|
||||
ISelectionService ss = (ISelectionService)sender;
|
||||
|
||||
if (ss != null && ss.PrimarySelection != this.Component)
|
||||
{
|
||||
((BaseItem)this.Component).DesignTimeMouseDownPoint = Point.Empty;
|
||||
}
|
||||
|
||||
if(ss!=null && ss.PrimarySelection!=this.Component && ss.PrimarySelection is BaseItem)
|
||||
{
|
||||
BaseItem item=this.Component as BaseItem;
|
||||
if(item!=null)
|
||||
{
|
||||
BaseItem selected=ss.PrimarySelection as BaseItem;
|
||||
IOwner owner=item.GetOwner() as IOwner;
|
||||
if(owner!=null)
|
||||
{
|
||||
if(owner.GetItem(selected.Name)!=selected)
|
||||
owner.SetFocusItem(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ss != null)
|
||||
{
|
||||
ICollection selectedComponents = ss.GetSelectedComponents();
|
||||
bool selected = false;
|
||||
foreach(object o in selectedComponents)
|
||||
{
|
||||
if (o == this.Component)
|
||||
{
|
||||
selected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
BaseItem item = this.Component as BaseItem;
|
||||
if (selected)
|
||||
{
|
||||
if (!item.Focused)
|
||||
item.OnGotFocus();
|
||||
}
|
||||
else if (item.Focused)
|
||||
item.OnLostFocus();
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual DesignerVerb[] GetVerbs()
|
||||
{
|
||||
DesignerVerb[] verbs = new DesignerVerb[]
|
||||
{
|
||||
new DesignerVerb("Add Button", new EventHandler(CreateButton)),
|
||||
new DesignerVerb("Add Text Box", new EventHandler(CreateTextBox)),
|
||||
new DesignerVerb("Add Combo Box", new EventHandler(CreateComboBox)),
|
||||
new DesignerVerb("Add Label", new EventHandler(CreateLabel)),
|
||||
new DesignerVerb("Add Color Picker", new EventHandler(CreateColorPicker)),
|
||||
new DesignerVerb("Add Check Box", new EventHandler(CreateCheckBox)),
|
||||
new DesignerVerb("Add Control Container", new EventHandler(CreateControlContainer)),
|
||||
new DesignerVerb("Add Micro-Chart", new EventHandler(CreateMicroChart)),
|
||||
new DesignerVerb("Add Switch Button", new EventHandler(CreateSwitch)),
|
||||
new DesignerVerb("Add Slider", new EventHandler(CreateSlider)),
|
||||
new DesignerVerb("Add Rating Item", new EventHandler(CreateRatingItem)),
|
||||
new DesignerVerb("Add Horizontal Container", new EventHandler(CreateHorizontalContainer)),
|
||||
new DesignerVerb("Add Vertical Container", new EventHandler(CreateVerticalContainer)),
|
||||
new DesignerVerb("Add Gallery Container", new EventHandler(CreateGallery))
|
||||
};
|
||||
return verbs;
|
||||
}
|
||||
|
||||
public override DesignerVerbCollection Verbs
|
||||
{
|
||||
get
|
||||
{
|
||||
DesignerVerb[] verbs = GetVerbs();
|
||||
return new DesignerVerbCollection(verbs);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void CreateMicroChart(object sender, EventArgs e)
|
||||
{
|
||||
CreateNewItem(typeof(MicroChartItem));
|
||||
}
|
||||
|
||||
|
||||
protected virtual void CreateCheckBox(object sender, EventArgs e)
|
||||
{
|
||||
CreateNewItem(typeof(CheckBoxItem));
|
||||
}
|
||||
|
||||
protected virtual void CreateRatingItem(object sender, EventArgs e)
|
||||
{
|
||||
CreateNewItem(typeof(RatingItem));
|
||||
}
|
||||
|
||||
protected virtual void CreateButton(object sender, EventArgs e)
|
||||
{
|
||||
CreateNewItem(typeof(ButtonItem));
|
||||
}
|
||||
|
||||
protected virtual void CreateComboBox(object sender, EventArgs e)
|
||||
{
|
||||
CreateNewItem(typeof(ComboBoxItem));
|
||||
}
|
||||
|
||||
protected virtual void CreateLabel(object sender, EventArgs e)
|
||||
{
|
||||
CreateNewItem(typeof(LabelItem));
|
||||
}
|
||||
|
||||
protected virtual void CreateTextBox(object sender, EventArgs e)
|
||||
{
|
||||
CreateNewItem(typeof(TextBoxItem));
|
||||
}
|
||||
|
||||
protected virtual void CreateColorPicker(object sender, EventArgs e)
|
||||
{
|
||||
CreateNewItem(typeof(ColorPickerDropDown));
|
||||
}
|
||||
|
||||
protected virtual void CreateControlContainer(object sender, EventArgs e)
|
||||
{
|
||||
CreateNewItem(typeof(ControlContainerItem));
|
||||
}
|
||||
|
||||
protected virtual void CreateSlider(object sender, EventArgs e)
|
||||
{
|
||||
CreateNewItem(typeof(SliderItem));
|
||||
}
|
||||
|
||||
protected virtual void CreateRangeSlider(object sender, EventArgs e)
|
||||
{
|
||||
CreateNewItem(typeof(RangeSliderItem));
|
||||
}
|
||||
|
||||
protected virtual void CreateSwitch(object sender, EventArgs e)
|
||||
{
|
||||
CreateNewItem(typeof(SwitchButtonItem));
|
||||
}
|
||||
|
||||
protected virtual void CreateProgressBar(object sender, EventArgs e)
|
||||
{
|
||||
CreateNewItem(typeof(ProgressBarItem));
|
||||
}
|
||||
|
||||
protected virtual void CreateCircularProgressItem(object sender, EventArgs e)
|
||||
{
|
||||
CreateNewItem(typeof(CircularProgressItem));
|
||||
}
|
||||
#if FRAMEWORK20
|
||||
protected virtual void CreateMonthCalendar(object sender, EventArgs e)
|
||||
{
|
||||
CreateNewItem(typeof(DevComponents.Editors.DateTimeAdv.MonthCalendarItem));
|
||||
}
|
||||
#endif
|
||||
|
||||
protected virtual void CreateMetroTile(object sender, EventArgs e)
|
||||
{
|
||||
CreateNewItem(typeof(DevComponents.DotNetBar.Metro.MetroTileItem));
|
||||
}
|
||||
|
||||
private void CreateVerticalContainer(object sender, EventArgs e)
|
||||
{
|
||||
CreateContainer(eOrientation.Vertical);
|
||||
}
|
||||
|
||||
private void CreateHorizontalContainer(object sender, EventArgs e)
|
||||
{
|
||||
CreateContainer(eOrientation.Horizontal);
|
||||
}
|
||||
|
||||
private void CreateContainer(eOrientation orientation)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_CreatingItem = true;
|
||||
DesignerSupport.CreateItemContainer(this, (BaseItem)this.Component, orientation);
|
||||
}
|
||||
finally
|
||||
{
|
||||
m_CreatingItem = false;
|
||||
}
|
||||
this.RecalcLayout();
|
||||
}
|
||||
|
||||
protected virtual void CreateGallery(object sender, EventArgs e)
|
||||
{
|
||||
CreateNewItem(typeof(GalleryContainer));
|
||||
}
|
||||
|
||||
protected virtual void CreateNewItem(Type itemType)
|
||||
{
|
||||
BaseItem parent=this.Component as BaseItem;
|
||||
System.ComponentModel.Design.IDesignerHost dh=(System.ComponentModel.Design.IDesignerHost)GetService(typeof(System.ComponentModel.Design.IDesignerHost));
|
||||
|
||||
DesignerTransaction trans = dh.CreateTransaction("Creating New Item");
|
||||
try
|
||||
{
|
||||
m_CreatingItem = true;
|
||||
BaseItem item = dh.CreateComponent(itemType) as BaseItem;
|
||||
if (item == null)
|
||||
return;
|
||||
if (itemType != typeof(RatingItem))
|
||||
item.Text = item.Name;
|
||||
BeforeNewItemAdded(item);
|
||||
|
||||
AddNewItem(item);
|
||||
|
||||
AfterNewItemAdded(item);
|
||||
this.RecalcLayout();
|
||||
this.NewItemAdded(item);
|
||||
}
|
||||
catch
|
||||
{
|
||||
trans.Cancel();
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
m_CreatingItem = false;
|
||||
if (!trans.Canceled)
|
||||
trans.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void AddNewItem(BaseItem newItem)
|
||||
{
|
||||
BaseItem parent = this.Component as BaseItem;
|
||||
System.ComponentModel.Design.IComponentChangeService change = this.GetService(typeof(System.ComponentModel.Design.IComponentChangeService)) as IComponentChangeService;
|
||||
if (change != null)
|
||||
change.OnComponentChanging(this.Component, TypeDescriptor.GetProperties(parent).Find("SubItems", true));
|
||||
|
||||
parent.SubItems.Add(newItem);
|
||||
|
||||
if (change != null)
|
||||
change.OnComponentChanged(this.Component, TypeDescriptor.GetProperties(parent).Find("SubItems", true), null, null);
|
||||
}
|
||||
|
||||
protected virtual void BeforeNewItemAdded(BaseItem item) {}
|
||||
|
||||
protected virtual void AfterNewItemAdded(BaseItem item)
|
||||
{
|
||||
if (item is LabelItem && Helpers.IsOffice2007Style(item.EffectiveStyle))
|
||||
{
|
||||
LabelItem label = item as LabelItem;
|
||||
if (item.Parent is PopupItem && ((PopupItem)item.Parent).PopupType == ePopupType.Menu)
|
||||
{
|
||||
label.BackColor = ColorScheme.GetColor("DDE7EE");
|
||||
label.BorderType = eBorderType.SingleLine;
|
||||
label.SingleLineColor = ColorScheme.GetColor("C5C5C5");
|
||||
label.ForeColor = ColorScheme.GetColor("00156E");
|
||||
label.BorderSide = eBorderSide.Bottom;
|
||||
label.PaddingTop = 1;
|
||||
label.PaddingLeft = 10;
|
||||
label.PaddingBottom = 1;
|
||||
}
|
||||
}
|
||||
else if (item is GalleryContainer && item.Parent is ButtonItem)
|
||||
{
|
||||
TypeDescriptor.GetProperties(item)["MinimumSize"].SetValue(item, new Size(150, 200));
|
||||
item.NeedRecalcSize = true;
|
||||
TypeDescriptor.GetProperties(((GalleryContainer)item).BackgroundStyle)["Class"].SetValue(((GalleryContainer)item).BackgroundStyle, "");
|
||||
if(item.Parent is PopupItem)
|
||||
TypeDescriptor.GetProperties(item)["EnableGalleryPopup"].SetValue(item, false);
|
||||
}
|
||||
else if (item is GalleryContainer && item.Parent is ItemContainer && !(item.ContainerControl is RibbonBar))
|
||||
{
|
||||
TypeDescriptor.GetProperties(item)["MinimumSize"].SetValue(item, new Size(150, 200));
|
||||
TypeDescriptor.GetProperties(((GalleryContainer)item).BackgroundStyle)["Class"].SetValue(((GalleryContainer)item).BackgroundStyle, "");
|
||||
TypeDescriptor.GetProperties(item)["EnableGalleryPopup"].SetValue(item, false);
|
||||
TypeDescriptor.GetProperties(item)["LayoutOrientation"].SetValue(item, DevComponents.DotNetBar.eOrientation.Vertical);
|
||||
TypeDescriptor.GetProperties(item)["MultiLine"].SetValue(item, false);
|
||||
TypeDescriptor.GetProperties(item)["PopupUsesStandardScrollbars"].SetValue(item, false);
|
||||
item.NeedRecalcSize = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void RecalcLayout()
|
||||
{
|
||||
BaseItem item=this.Component as BaseItem;
|
||||
System.Windows.Forms.Control control=item.ContainerControl as System.Windows.Forms.Control;
|
||||
|
||||
if(control is Bar)
|
||||
((Bar)control).RecalcLayout();
|
||||
else if(control is ExplorerBar)
|
||||
((ExplorerBar)control).RecalcLayout();
|
||||
else if(control is BarBaseControl)
|
||||
((BarBaseControl)control).RecalcLayout();
|
||||
else if(control is SideBar)
|
||||
((SideBar)control).RecalcLayout();
|
||||
else if(control is ItemControl)
|
||||
((ItemControl)control).RecalcLayout();
|
||||
else if (control is MenuPanel)
|
||||
((MenuPanel)control).RecalcSize();
|
||||
|
||||
if (item.Expanded && item is PopupItem && ((PopupItem)item).PopupControl != null)
|
||||
{
|
||||
control = ((PopupItem)item).PopupControl;
|
||||
if (control is MenuPanel)
|
||||
((MenuPanel)control).RecalcSize();
|
||||
else if (control is Bar)
|
||||
((Bar)control).RecalcLayout();
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void NewItemAdded(BaseItem itemAdded)
|
||||
{
|
||||
BaseItem item=this.Component as BaseItem;
|
||||
System.Windows.Forms.Control control=item.GetOwner() as System.Windows.Forms.Control;
|
||||
|
||||
//if(control is Bar)
|
||||
// ((Bar)control).RecalcLayout();
|
||||
//else if(control is ExplorerBar)
|
||||
// ((ExplorerBar)control).RecalcLayout();
|
||||
//else if(control is BarBaseControl)
|
||||
// ((BarBaseControl)control).RecalcLayout();
|
||||
//else if(control is SideBar)
|
||||
// ((SideBar)control).RecalcLayout();
|
||||
if(control is ItemControl)
|
||||
((ItemControl)control).DesignerNewItemAdded();
|
||||
//else if (control is MenuPanel)
|
||||
// ((MenuPanel)control).RecalcSize();
|
||||
|
||||
}
|
||||
|
||||
public override System.Collections.ICollection AssociatedComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
System.Collections.ArrayList components=new System.Collections.ArrayList();
|
||||
BaseItem parent=this.Component as BaseItem;
|
||||
if(parent==null)
|
||||
return base.AssociatedComponents;
|
||||
parent.SubItems.CopyTo(components);
|
||||
return components;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void PreFilterProperties(IDictionary properties)
|
||||
{
|
||||
base.PreFilterProperties(properties);
|
||||
properties["Visible"] = TypeDescriptor.CreateProperty(typeof(BaseItemDesigner),(PropertyDescriptor)properties["Visible"], new Attribute[]
|
||||
{
|
||||
new DefaultValueAttribute(true),
|
||||
new BrowsableAttribute(true),
|
||||
new CategoryAttribute("Layout")});
|
||||
properties["CanCustomize"] = TypeDescriptor.CreateProperty(typeof(BaseItemDesigner),(PropertyDescriptor)properties["CanCustomize"], new Attribute[]
|
||||
{
|
||||
new DefaultValueAttribute(true),
|
||||
new BrowsableAttribute(true),
|
||||
new CategoryAttribute("Behavior"),
|
||||
new DescriptionAttribute("Indicates whether item can be customized by user.")});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether item can be customized by end user.
|
||||
/// </summary>
|
||||
[System.ComponentModel.Browsable(true),DevCoBrowsable(true),System.ComponentModel.DefaultValue(true),System.ComponentModel.Category("Behavior"),System.ComponentModel.Description("Indicates whether item can be customized by user.")]
|
||||
public virtual bool CanCustomize
|
||||
{
|
||||
get
|
||||
{
|
||||
return (bool)ShadowProperties["CanCustomize"];
|
||||
}
|
||||
set
|
||||
{
|
||||
// this value is not passed to the actual control
|
||||
this.ShadowProperties["CanCustomize"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether item is visible.
|
||||
/// </summary>
|
||||
[DefaultValue(true),Browsable(true),DevCoBrowsable(true),Category("Layout"),Description("Gets or sets whether item is visible.")]
|
||||
public bool Visible
|
||||
{
|
||||
get
|
||||
{
|
||||
return (bool)ShadowProperties["Visible"];
|
||||
}
|
||||
set
|
||||
{
|
||||
// this value is not passed to the actual control
|
||||
this.ShadowProperties["Visible"] = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IDesignerServices Implementation
|
||||
object IDesignerServices.CreateComponent(System.Type componentClass)
|
||||
{
|
||||
IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
if (dh == null)
|
||||
return null;
|
||||
object comp = null;
|
||||
try
|
||||
{
|
||||
m_CreatingItem = true;
|
||||
comp = dh.CreateComponent(componentClass);
|
||||
}
|
||||
finally
|
||||
{
|
||||
m_CreatingItem = false;
|
||||
}
|
||||
|
||||
return comp;
|
||||
}
|
||||
|
||||
object IDesignerServices.CreateComponent(System.Type componentClass, string name)
|
||||
{
|
||||
IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
if (dh == null)
|
||||
return null;
|
||||
object comp = null;
|
||||
try
|
||||
{
|
||||
m_CreatingItem = true;
|
||||
comp = dh.CreateComponent(componentClass, name);
|
||||
}
|
||||
finally
|
||||
{
|
||||
m_CreatingItem = false;
|
||||
}
|
||||
|
||||
return comp;
|
||||
}
|
||||
|
||||
void IDesignerServices.DestroyComponent(IComponent c)
|
||||
{
|
||||
IDesignerHost dh=(IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
if(dh==null)
|
||||
return;
|
||||
dh.DestroyComponent(c);
|
||||
}
|
||||
|
||||
object IDesignerServices.GetService(Type serviceType)
|
||||
{
|
||||
return this.GetService(serviceType);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,253 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel.Design;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design.Serialization;
|
||||
using System.Collections;
|
||||
using System.Globalization;
|
||||
using DevComponents.DotNetBar.Controls;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides design-time support for BindingNavigatorEx control.
|
||||
/// </summary>
|
||||
public class BindingNavigatorExDesigner : BarDesigner
|
||||
{
|
||||
#region Internal Implementation
|
||||
private static readonly string[] ItemPropertyNames =
|
||||
new string[] {
|
||||
"MovePreviousButton",
|
||||
"MoveFirstButton",
|
||||
"MoveNextButton",
|
||||
"MoveLastButton",
|
||||
"AddNewRecordButton",
|
||||
"DeleteButton",
|
||||
"PositionTextBox",
|
||||
"CountLabel" };
|
||||
|
||||
public override void InitializeNewComponent(IDictionary defaultValues)
|
||||
{
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
BindingNavigatorEx navigator = (BindingNavigatorEx)base.Component;
|
||||
IDesignerHost designerHost = (IDesignerHost)base.Component.Site.GetService(typeof(IDesignerHost));
|
||||
navigator.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
navigator.SuspendLayout();
|
||||
navigator.AddDefaultItems();
|
||||
this.SiteItems(designerHost, navigator.Items);
|
||||
this.RaiseItemsChanged();
|
||||
navigator.ResumeLayout();
|
||||
navigator.RecalcLayout();
|
||||
}
|
||||
|
||||
public override void Initialize(IComponent component)
|
||||
{
|
||||
base.Initialize(component);
|
||||
IComponentChangeService service = (IComponentChangeService)this.GetService(typeof(IComponentChangeService));
|
||||
if (service != null)
|
||||
{
|
||||
service.ComponentRemoved += ComponentRemoved;
|
||||
service.ComponentChanged += ComponentChanged;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
IComponentChangeService service = (IComponentChangeService)this.GetService(typeof(IComponentChangeService));
|
||||
if (service != null)
|
||||
{
|
||||
service.ComponentRemoved -= this.ComponentRemoved;
|
||||
service.ComponentChanged -= this.ComponentChanged;
|
||||
}
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
|
||||
private void ComponentChanged(object sender, ComponentChangedEventArgs e)
|
||||
{
|
||||
BindingNavigatorEx component = (BindingNavigatorEx)base.Component;
|
||||
if (((e.Component != null) && (e.Component == component.CountLabel)) && ((e.Member != null) && (e.Member.Name == "Text")))
|
||||
{
|
||||
component.CountLabelFormat = component.CountLabel.Text;
|
||||
}
|
||||
}
|
||||
|
||||
private void ComponentRemoved(object sender, ComponentEventArgs e)
|
||||
{
|
||||
BaseItem item = e.Component as BaseItem;
|
||||
if (item != null)
|
||||
{
|
||||
BindingNavigatorEx navigator = (BindingNavigatorEx)base.Component;
|
||||
if (item == navigator.MoveFirstButton)
|
||||
{
|
||||
navigator.MoveFirstButton = null;
|
||||
}
|
||||
else if (item == navigator.MovePreviousButton)
|
||||
{
|
||||
navigator.MovePreviousButton = null;
|
||||
}
|
||||
else if (item == navigator.MoveNextButton)
|
||||
{
|
||||
navigator.MoveNextButton = null;
|
||||
}
|
||||
else if (item == navigator.MoveLastButton)
|
||||
{
|
||||
navigator.MoveLastButton = null;
|
||||
}
|
||||
else if (item == navigator.PositionTextBox)
|
||||
{
|
||||
navigator.PositionTextBox = null;
|
||||
}
|
||||
else if (item == navigator.CountLabel)
|
||||
{
|
||||
navigator.CountLabel = null;
|
||||
}
|
||||
else if (item == navigator.AddNewRecordButton)
|
||||
{
|
||||
navigator.AddNewRecordButton = null;
|
||||
}
|
||||
else if (item == navigator.DeleteButton)
|
||||
{
|
||||
navigator.DeleteButton = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RaiseItemsChanged()
|
||||
{
|
||||
BindingNavigatorEx component = (BindingNavigatorEx)base.Component;
|
||||
IComponentChangeService service = (IComponentChangeService)this.GetService(typeof(IComponentChangeService));
|
||||
if (service != null)
|
||||
{
|
||||
MemberDescriptor member = TypeDescriptor.GetProperties(component)["Items"];
|
||||
service.OnComponentChanging(component, member);
|
||||
service.OnComponentChanged(component, member, null, null);
|
||||
foreach (string str in ItemPropertyNames)
|
||||
{
|
||||
PropertyDescriptor itemsDescriptor = TypeDescriptor.GetProperties(component)[str];
|
||||
if (itemsDescriptor != null)
|
||||
{
|
||||
service.OnComponentChanging(component, itemsDescriptor);
|
||||
service.OnComponentChanged(component, itemsDescriptor, null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void SiteItems(IDesignerHost host, SubItemsCollection items)
|
||||
{
|
||||
foreach (BaseItem item in items)
|
||||
{
|
||||
this.SiteItem(host, item);
|
||||
}
|
||||
}
|
||||
private void SiteItem(IDesignerHost host, BaseItem item)
|
||||
{
|
||||
host.Container.Add(item, GetUniqueSiteName(host, item.Name));
|
||||
item.Name = item.Site.Name;
|
||||
if (item.SubItems.Count > 0)
|
||||
{
|
||||
this.SiteItems(host, item.SubItems);
|
||||
}
|
||||
}
|
||||
|
||||
internal static string GetUniqueSiteName(IDesignerHost host, string name)
|
||||
{
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
INameCreationService service = (INameCreationService)host.GetService(typeof(INameCreationService));
|
||||
if (service == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (host.Container.Components[name] == null)
|
||||
{
|
||||
if (!service.IsValidName(name))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
string str = name;
|
||||
for (int i = 1; !service.IsValidName(str); i++)
|
||||
{
|
||||
str = name + i.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
protected override void PreFilterProperties(System.Collections.IDictionary properties)
|
||||
{
|
||||
base.PreFilterProperties(properties);
|
||||
RemoveDescriptors(properties,
|
||||
new String[] { "AlwaysDisplayDockTab",
|
||||
"AlwaysDisplayKeyAccelerators",
|
||||
"AutoCreateCaptionMenu",
|
||||
"AutoHide",
|
||||
"AutoHideAnimationTime",
|
||||
"AutoHideTabTextAlwaysVisible",
|
||||
"AutoSyncBarCaption",
|
||||
"BarType",
|
||||
"CanAutoHide",
|
||||
"CanCustomize",
|
||||
"CanDockBottom",
|
||||
"CanDockDocument",
|
||||
"CanDockLeft",
|
||||
"CanDockRight",
|
||||
"CanDockTab",
|
||||
"CanDockTop",
|
||||
"CanDockHide",
|
||||
"CanReorderTabs",
|
||||
"CanUndock",
|
||||
"CaptionHeight",
|
||||
"CloseSingleTab",
|
||||
"DisplayMoreItemsOnMenu",
|
||||
"DockOrientation",
|
||||
"DockTabAlignment",
|
||||
"DockTabCloseButtonVisible",
|
||||
"DockTabStripHeight",
|
||||
"EqualButtonSize",
|
||||
"LayoutType",
|
||||
"MenuBar",
|
||||
"SaveLayoutChanges",
|
||||
"SelectedDockTab",
|
||||
"TabNavigation",
|
||||
"WrapItemsDock" });
|
||||
}
|
||||
private void RemoveDescriptors(System.Collections.IDictionary properties, String[] propNames)
|
||||
{
|
||||
foreach (String propName in propNames)
|
||||
{
|
||||
if (properties.Contains(propName))
|
||||
properties.Remove(propName);
|
||||
}
|
||||
}
|
||||
protected override void PreFilterEvents(System.Collections.IDictionary events)
|
||||
{
|
||||
RemoveDescriptors(events,
|
||||
new string[] {
|
||||
"AutoHideChanged",
|
||||
"AutoHideDisplay",
|
||||
"BarDock",
|
||||
"BarUndock",
|
||||
"BeforeAutoHideDisplayed",
|
||||
"BeforeAutoHideHidden",
|
||||
"BeforeDockTabDisplayed",
|
||||
"Closing",
|
||||
"DefinitionLoaded",
|
||||
"DeserializeItem",
|
||||
"DockTabChange",
|
||||
"DockTabClosed",
|
||||
"DockTabClosing",
|
||||
"SerializeItem",
|
||||
});
|
||||
base.PreFilterEvents(events);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,673 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Drawing;
|
||||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents Windows Forms designer for BubbleBar control.
|
||||
/// </summary>
|
||||
public class BubbleBarDesigner:System.Windows.Forms.Design.ControlDesigner
|
||||
{
|
||||
#region Private Variables
|
||||
private bool m_IgnoreMouseUp=false;
|
||||
private Point m_MouseDownPosition=Point.Empty;
|
||||
private bool m_Capture=false;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
public BubbleBarDesigner()
|
||||
{
|
||||
}
|
||||
|
||||
public override void Initialize(IComponent component)
|
||||
{
|
||||
base.Initialize(component);
|
||||
if(!component.Site.DesignMode)
|
||||
return;
|
||||
|
||||
ISelectionService ss =(ISelectionService)GetService(typeof(ISelectionService));
|
||||
if(ss!=null)
|
||||
ss.SelectionChanged+=new EventHandler(OnSelectionChanged);
|
||||
|
||||
// If our component is removed we need to clean-up
|
||||
IComponentChangeService cc=(IComponentChangeService)GetService(typeof(IComponentChangeService));
|
||||
if(cc!=null)
|
||||
cc.ComponentRemoving+=new ComponentEventHandler(this.OnComponentRemoving);
|
||||
|
||||
#if !TRIAL
|
||||
IDesignerHost dh = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
if (dh != null)
|
||||
dh.LoadComplete += new EventHandler(dh_LoadComplete);
|
||||
#endif
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
ISelectionService ss =(ISelectionService)GetService(typeof(ISelectionService));
|
||||
if(ss!=null)
|
||||
ss.SelectionChanged-=new EventHandler(OnSelectionChanged);
|
||||
|
||||
// If our component is removed we need to clean-up
|
||||
IComponentChangeService cc=(IComponentChangeService)GetService(typeof(IComponentChangeService));
|
||||
if(cc!=null)
|
||||
cc.ComponentRemoving-=new ComponentEventHandler(this.OnComponentRemoving);
|
||||
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
public override DesignerVerbCollection Verbs
|
||||
{
|
||||
get
|
||||
{
|
||||
DesignerVerb[] verbs = new DesignerVerb[]
|
||||
{
|
||||
new DesignerVerb("Create Tab", new EventHandler(CreateTab)),
|
||||
new DesignerVerb("Create Button", new EventHandler(CreateButton))};
|
||||
return new DesignerVerbCollection(verbs);
|
||||
}
|
||||
}
|
||||
|
||||
#if FRAMEWORK20
|
||||
public override void InitializeNewComponent(IDictionary defaultValues)
|
||||
{
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#else
|
||||
public override void OnSetComponentDefaults()
|
||||
{
|
||||
base.OnSetComponentDefaults();
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#endif
|
||||
|
||||
private void SetDesignTimeDefaults()
|
||||
{
|
||||
BubbleBar bar = this.Component as BubbleBar;
|
||||
if (bar == null)
|
||||
return;
|
||||
// Setup default back style
|
||||
bar.ButtonBackAreaStyle.SetColorScheme(new ColorScheme(eDotNetBarStyle.Office2003));
|
||||
bar.ButtonBackAreaStyle.BackColor = Color.FromArgb(66, Color.DimGray);
|
||||
bar.ButtonBackAreaStyle.BorderColor = Color.FromArgb(180, Color.WhiteSmoke);
|
||||
bar.ButtonBackAreaStyle.BorderTop = eStyleBorderType.Solid;
|
||||
bar.ButtonBackAreaStyle.BorderTopWidth = 1;
|
||||
bar.ButtonBackAreaStyle.BorderBottom = eStyleBorderType.Solid;
|
||||
bar.ButtonBackAreaStyle.BorderBottomWidth = 1;
|
||||
bar.ButtonBackAreaStyle.BorderLeft = eStyleBorderType.Solid;
|
||||
bar.ButtonBackAreaStyle.BorderLeftWidth = 1;
|
||||
bar.ButtonBackAreaStyle.BorderRight = eStyleBorderType.Solid;
|
||||
bar.ButtonBackAreaStyle.BorderRightWidth = 1;
|
||||
bar.ButtonBackAreaStyle.PaddingBottom = 3;
|
||||
bar.ButtonBackAreaStyle.PaddingTop = 3;
|
||||
bar.ButtonBackAreaStyle.PaddingLeft = 3;
|
||||
bar.ButtonBackAreaStyle.PaddingRight = 3;
|
||||
bar.SelectedTabColors.BorderColor = Color.Black;
|
||||
bar.MouseOverTabColors.BorderColor = SystemColors.Highlight;
|
||||
|
||||
#if !TRIAL
|
||||
string key = GetLicenseKey();
|
||||
bar.LicenseKey = key;
|
||||
#endif
|
||||
}
|
||||
|
||||
private void OnSelectionChanged(object sender, EventArgs e)
|
||||
{
|
||||
ISelectionService ss =(ISelectionService)GetService(typeof(ISelectionService));
|
||||
if(ss==null)
|
||||
return;
|
||||
|
||||
bool refresh=ResetFocus();
|
||||
if(ss.PrimarySelection is BubbleBarTab)
|
||||
{
|
||||
if(((BubbleBarTab)ss.PrimarySelection).Parent==this.Control)
|
||||
{
|
||||
((BubbleBarTab)ss.PrimarySelection).Focus=true;
|
||||
refresh=true;
|
||||
}
|
||||
}
|
||||
else if(ss.PrimarySelection is BubbleButton)
|
||||
{
|
||||
if(((BubbleButton)ss.PrimarySelection).Parent.Parent==this.Control)
|
||||
{
|
||||
((BubbleButton)ss.PrimarySelection).Focus=true;
|
||||
refresh=true;
|
||||
}
|
||||
}
|
||||
|
||||
if(refresh)
|
||||
this.Control.Refresh();
|
||||
}
|
||||
|
||||
private bool ResetFocus()
|
||||
{
|
||||
bool refresh=false;
|
||||
BubbleBar bar=this.Control as BubbleBar;
|
||||
foreach(BubbleBarTab tab in bar.Tabs)
|
||||
{
|
||||
if(tab.Focus)
|
||||
{
|
||||
tab.Focus=false;
|
||||
refresh=true;
|
||||
}
|
||||
foreach(BubbleButton button in tab.Buttons)
|
||||
{
|
||||
if(button.Focus)
|
||||
{
|
||||
button.Focus=false;
|
||||
refresh=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return refresh;
|
||||
}
|
||||
|
||||
private void OnComponentRemoving(object sender,ComponentEventArgs e)
|
||||
{
|
||||
if(e.Component==this.Component)
|
||||
ThisComponentRemoving(sender,e);
|
||||
else if(e.Component is BubbleBarTab)
|
||||
{
|
||||
BubbleBarTab tab=e.Component as BubbleBarTab;
|
||||
if(tab.Parent==this.Control)
|
||||
{
|
||||
IDesignerHost dh=(IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
BubbleButton[] buttons = new BubbleButton[tab.Buttons.Count];
|
||||
tab.Buttons.CopyTo(buttons, 0);
|
||||
foreach(BubbleButton button in buttons)
|
||||
dh.DestroyComponent(button);
|
||||
BubbleBar bar=this.Component as BubbleBar;
|
||||
if(bar.Tabs.Contains(tab))
|
||||
bar.Tabs.Remove(tab);
|
||||
dh.DestroyComponent(tab);
|
||||
bar.RecalcLayout();
|
||||
bar.Refresh();
|
||||
}
|
||||
}
|
||||
else if(e.Component is BubbleButton)
|
||||
{
|
||||
BubbleButton button=e.Component as BubbleButton;
|
||||
if(button.GetBubbleBar()==this.Control)
|
||||
{
|
||||
if (button.Parent.Buttons.Contains(button))
|
||||
button.Parent.Buttons.Remove(button);
|
||||
IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
dh.DestroyComponent(button);
|
||||
BubbleBar bar=this.Component as BubbleBar;
|
||||
bar.RecalcLayout();
|
||||
bar.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all tabs and buttons.
|
||||
/// </summary>
|
||||
protected virtual void ThisComponentRemoving(object sender, ComponentEventArgs e)
|
||||
{
|
||||
//m_InternalRemoving=true;
|
||||
// try
|
||||
// {
|
||||
// Unhook events
|
||||
IComponentChangeService cc=(IComponentChangeService)GetService(typeof(IComponentChangeService));
|
||||
if(cc!=null)
|
||||
cc.ComponentRemoving-=new ComponentEventHandler(this.OnComponentRemoving);
|
||||
|
||||
ISelectionService ss =(ISelectionService)GetService(typeof(ISelectionService));
|
||||
if(ss!=null)
|
||||
ss.SelectionChanged-=new EventHandler(OnSelectionChanged);
|
||||
|
||||
IDesignerHost dh=(IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
BubbleBar bar=this.Component as BubbleBar;
|
||||
if(dh==null)
|
||||
return;
|
||||
|
||||
foreach(BubbleBarTab tab in bar.Tabs)
|
||||
{
|
||||
foreach(BubbleButton button in tab.Buttons)
|
||||
dh.DestroyComponent(button);
|
||||
dh.DestroyComponent(tab);
|
||||
}
|
||||
//}
|
||||
// finally
|
||||
// {
|
||||
// m_InternalRemoving=false;
|
||||
// }
|
||||
}
|
||||
|
||||
private void CreateButton(object sender,EventArgs e)
|
||||
{
|
||||
BubbleBar bar=this.Control as BubbleBar;
|
||||
if(bar==null)
|
||||
return;
|
||||
|
||||
if(bar.SelectedTab==null)
|
||||
{
|
||||
BubbleBarTab tab=CreateTab();
|
||||
IComponentChangeService change=this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if(change!=null)
|
||||
change.OnComponentChanging(this.Component,TypeDescriptor.GetProperties(bar).Find("SelectedTab",true));
|
||||
bar.SelectedTab=tab;
|
||||
if(change!=null)
|
||||
change.OnComponentChanged(this.Component,TypeDescriptor.GetProperties(bar).Find("SelectedTab",true),null,null);
|
||||
}
|
||||
|
||||
if(bar.SelectedTab==null)
|
||||
return;
|
||||
|
||||
BubbleButton button=CreateButton(bar.SelectedTab);
|
||||
|
||||
if(button==null)
|
||||
return;
|
||||
|
||||
ISelectionService ss=(ISelectionService)GetService(typeof(ISelectionService));
|
||||
if(ss!=null)
|
||||
{
|
||||
ArrayList list=new ArrayList();
|
||||
list.Add(button);
|
||||
ss.SetSelectedComponents(list);
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateTab(object sender,EventArgs e)
|
||||
{
|
||||
BubbleBar bar=this.Control as BubbleBar;
|
||||
if(bar==null)
|
||||
return;
|
||||
|
||||
BubbleBarTab tab=CreateTab();
|
||||
if(tab!=null)
|
||||
{
|
||||
if(bar.SelectedTab!=tab)
|
||||
{
|
||||
IComponentChangeService change=this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if(change!=null)
|
||||
change.OnComponentChanging(this.Component,TypeDescriptor.GetProperties(bar).Find("SelectedTab",true));
|
||||
bar.SelectedTab=tab;
|
||||
if(change!=null)
|
||||
change.OnComponentChanged(this.Component,TypeDescriptor.GetProperties(bar).Find("SelectedTab",true),null,null);
|
||||
}
|
||||
|
||||
ISelectionService ss=(ISelectionService)GetService(typeof(ISelectionService));
|
||||
if(ss!=null)
|
||||
{
|
||||
ArrayList list=new ArrayList();
|
||||
list.Add(tab);
|
||||
ss.SetSelectedComponents(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private BubbleBarTab CreateTab()
|
||||
{
|
||||
BubbleBar bar=this.Control as BubbleBar;
|
||||
if(bar==null)
|
||||
return null;
|
||||
|
||||
IDesignerHost dh=(IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
if(dh==null)
|
||||
return null;
|
||||
|
||||
IComponentChangeService change=this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if(change!=null)
|
||||
change.OnComponentChanging(this.Component,TypeDescriptor.GetProperties(bar).Find("Tabs",true));
|
||||
|
||||
BubbleBarTab tab=dh.CreateComponent(typeof(BubbleBarTab)) as BubbleBarTab;
|
||||
if(tab==null)
|
||||
return null;
|
||||
|
||||
tab.Text=tab.Name;
|
||||
eTabItemColor color=eTabItemColor.Blue;
|
||||
if(bar.Tabs.Count>0)
|
||||
{
|
||||
int tt=bar.Tabs.Count+1;
|
||||
Type t=typeof(eTabItemColor);
|
||||
FieldInfo[] fi=t.GetFields(BindingFlags.Public | BindingFlags.Static);
|
||||
int count=fi.Length;
|
||||
while(tt>count)
|
||||
tt-=count;
|
||||
if(tt==0) tt++;
|
||||
color=(eTabItemColor)Enum.Parse(typeof(eTabItemColor),fi[tt].Name);
|
||||
}
|
||||
tab.PredefinedColor=color;
|
||||
|
||||
bar.Tabs.Add(tab);
|
||||
|
||||
if(change!=null)
|
||||
change.OnComponentChanged(this.Component,TypeDescriptor.GetProperties(bar).Find("Tabs",true),null,null);
|
||||
|
||||
return tab;
|
||||
}
|
||||
|
||||
private BubbleButton CreateButton(BubbleBarTab tab)
|
||||
{
|
||||
BubbleBar bar=this.Control as BubbleBar;
|
||||
if(bar==null)
|
||||
return null;
|
||||
|
||||
IDesignerHost dh=(IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
if(dh==null)
|
||||
return null;
|
||||
|
||||
IComponentChangeService change=this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if(change!=null)
|
||||
change.OnComponentChanging(this.Component,TypeDescriptor.GetProperties(tab).Find("Buttons",true));
|
||||
|
||||
BubbleButton button=dh.CreateComponent(typeof(BubbleButton)) as BubbleButton;
|
||||
if(button==null)
|
||||
return null;
|
||||
button.Image=Helpers.LoadBitmap("SystemImages.Note24.png");
|
||||
button.ImageLarge = Helpers.LoadBitmap("SystemImages.Note64.png");
|
||||
tab.Buttons.Add(button);
|
||||
|
||||
if(change!=null)
|
||||
change.OnComponentChanged(this.Component,TypeDescriptor.GetProperties(tab).Find("Buttons",true),null,null);
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns all components associated with this control
|
||||
/// </summary>
|
||||
public override System.Collections.ICollection AssociatedComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
ArrayList c=new ArrayList(base.AssociatedComponents);
|
||||
BubbleBar bar=this.Control as BubbleBar;
|
||||
if(bar!=null)
|
||||
{
|
||||
foreach(BubbleBarTab tab in bar.Tabs)
|
||||
{
|
||||
c.Add(tab);
|
||||
GetTabComponents(tab,c);
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
private void GetTabComponents(BubbleBarTab tab, ArrayList c)
|
||||
{
|
||||
foreach(BubbleButton b in tab.Buttons)
|
||||
c.Add(b);
|
||||
}
|
||||
|
||||
protected override void OnSetCursor()
|
||||
{
|
||||
BubbleBar bar=this.Control as BubbleBar;
|
||||
Point pos=bar.PointToClient(System.Windows.Forms.Control.MousePosition);
|
||||
BubbleButton button=bar.GetButtonAt(pos);
|
||||
if(button!=null)
|
||||
{
|
||||
Cursor.Current=Cursors.Default;
|
||||
return;
|
||||
}
|
||||
BubbleBarTab tab=bar.GetTabAt(pos);
|
||||
if(tab!=null)
|
||||
{
|
||||
Cursor.Current=Cursors.Default;
|
||||
return;
|
||||
}
|
||||
base.OnSetCursor();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Selection support for items on container.
|
||||
/// </summary>
|
||||
protected override void WndProc(ref Message m)
|
||||
{
|
||||
switch(m.Msg)
|
||||
{
|
||||
case WinApi.WM_LBUTTONDOWN:
|
||||
case WinApi.WM_RBUTTONDOWN:
|
||||
{
|
||||
if(OnMouseDown(ref m))
|
||||
return;
|
||||
break;
|
||||
}
|
||||
case WinApi.WM_RBUTTONUP:
|
||||
case WinApi.WM_LBUTTONUP:
|
||||
{
|
||||
if(OnMouseUp(ref m))
|
||||
return;
|
||||
break;
|
||||
}
|
||||
case WinApi.WM_MOUSEMOVE:
|
||||
{
|
||||
if(OnMouseMove(ref m))
|
||||
return;
|
||||
break;
|
||||
}
|
||||
case WinApi.WM_LBUTTONDBLCLK:
|
||||
{
|
||||
if(OnMouseDoubleClick(m))
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
base.WndProc(ref m);
|
||||
}
|
||||
|
||||
private bool OnMouseDoubleClick(Message m)
|
||||
{
|
||||
bool processed=false;
|
||||
|
||||
ISelectionService selection = (ISelectionService) this.GetService(typeof(ISelectionService));
|
||||
if(selection!=null && selection.PrimarySelection is BubbleButton && ((BubbleButton)selection.PrimarySelection).GetBubbleBar()==this.Control)
|
||||
{
|
||||
IDesignerHost host=(IDesignerHost) this.GetService(typeof(IDesignerHost));
|
||||
if(host!=null)
|
||||
{
|
||||
IDesigner designer=host.GetDesigner(selection.PrimarySelection as IComponent);
|
||||
if(designer!=null)
|
||||
{
|
||||
designer.DoDefaultAction();
|
||||
processed=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return processed;
|
||||
}
|
||||
|
||||
protected virtual bool OnMouseDown(ref Message m)
|
||||
{
|
||||
BubbleBar bar=this.Control as BubbleBar;
|
||||
|
||||
if(bar==null)
|
||||
return false;
|
||||
|
||||
Point pos=bar.PointToClient(System.Windows.Forms.Control.MousePosition);
|
||||
m_MouseDownPosition=pos;
|
||||
|
||||
BubbleButton button=bar.GetButtonAt(pos);
|
||||
if(button!=null)
|
||||
{
|
||||
ISelectionService selection = (ISelectionService) this.GetService(typeof(ISelectionService));
|
||||
if(selection!=null)
|
||||
{
|
||||
ArrayList arr=new ArrayList(1);
|
||||
arr.Add(button);
|
||||
#if FRAMEWORK20
|
||||
selection.SetSelectedComponents(arr, SelectionTypes.Primary);
|
||||
#else
|
||||
selection.SetSelectedComponents(arr,SelectionTypes.MouseDown);
|
||||
#endif
|
||||
m_IgnoreMouseUp =true;
|
||||
|
||||
if(m.Msg==WinApi.WM_RBUTTONDOWN)
|
||||
{
|
||||
this.OnContextMenu(System.Windows.Forms.Control.MousePosition.X,System.Windows.Forms.Control.MousePosition.Y);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
BubbleBarTab tab=bar.GetTabAt(pos);
|
||||
if(tab!=null)
|
||||
{
|
||||
ISelectionService selection = (ISelectionService) this.GetService(typeof(ISelectionService));
|
||||
if(selection!=null && selection.PrimarySelection!=tab)
|
||||
{
|
||||
ArrayList arr=new ArrayList(1);
|
||||
arr.Add(tab);
|
||||
#if FRAMEWORK20
|
||||
selection.SetSelectedComponents(arr, SelectionTypes.Primary);
|
||||
#else
|
||||
selection.SetSelectedComponents(arr,SelectionTypes.MouseDown);
|
||||
#endif
|
||||
|
||||
if (bar.SelectedTab!=tab)
|
||||
{
|
||||
IComponentChangeService change=this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if(change!=null)
|
||||
change.OnComponentChanging(this.Component,TypeDescriptor.GetProperties(bar).Find("SelectedTab",true));
|
||||
|
||||
bar.SelectedTab=tab;
|
||||
|
||||
if(change!=null)
|
||||
change.OnComponentChanged(this.Component,TypeDescriptor.GetProperties(bar).Find("SelectedTab",true),null,null);
|
||||
}
|
||||
m_IgnoreMouseUp=true;
|
||||
if(m.Msg!=WinApi.WM_RBUTTONDOWN)
|
||||
return true;
|
||||
}
|
||||
|
||||
if(m.Msg==WinApi.WM_RBUTTONDOWN)
|
||||
{
|
||||
this.OnContextMenu(System.Windows.Forms.Control.MousePosition.X,System.Windows.Forms.Control.MousePosition.Y);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected virtual bool OnMouseMove(ref Message m)
|
||||
{
|
||||
BubbleBar bar=this.Control as BubbleBar;
|
||||
Point pos=bar.PointToClient(System.Windows.Forms.Control.MousePosition);
|
||||
|
||||
if(Control.MouseButtons==MouseButtons.Left)
|
||||
{
|
||||
if(bar.DragInProgress)
|
||||
{
|
||||
bar.DragMouseMove(pos);
|
||||
return true;
|
||||
}
|
||||
else if(!m_MouseDownPosition.IsEmpty && Math.Abs(m_MouseDownPosition.X-pos.X)>=2 || Math.Abs(m_MouseDownPosition.Y-pos.Y)>=2)
|
||||
{
|
||||
BubbleBarTab tabDrag=bar.GetTabAt(pos);
|
||||
if(tabDrag!=null)
|
||||
{
|
||||
bar.StartDrag(tabDrag);
|
||||
System.Windows.Forms.Control c=System.Windows.Forms.Control.FromHandle(m.HWnd);
|
||||
if(c!=null)
|
||||
{
|
||||
m_Capture=true;
|
||||
c.Capture=true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
BubbleButton buttonDrag=bar.GetButtonAt(pos);
|
||||
if(buttonDrag!=null)
|
||||
{
|
||||
bar.StartDrag(buttonDrag);
|
||||
System.Windows.Forms.Control c=System.Windows.Forms.Control.FromHandle(m.HWnd);
|
||||
if(c!=null)
|
||||
{
|
||||
m_Capture=true;
|
||||
c.Capture=true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
m_MouseDownPosition=Point.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
//BubbleButton button=bar.GetButtonAt(pos);
|
||||
BubbleBarTab tab=bar.GetTabAt(pos);
|
||||
if(tab!=null)
|
||||
bar.SetMouseOverTab(tab);
|
||||
else
|
||||
bar.SetMouseOverTab(null);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool OnMouseUp(ref Message m)
|
||||
{
|
||||
if(m_Capture)
|
||||
{
|
||||
System.Windows.Forms.Control c=System.Windows.Forms.Control.FromHandle(m.HWnd);
|
||||
if(c!=null)
|
||||
c.Capture=false;
|
||||
m_Capture=false;
|
||||
}
|
||||
|
||||
BubbleBar bar=this.Control as BubbleBar;
|
||||
if(bar!=null && bar.DragInProgress)
|
||||
{
|
||||
Point pos=bar.PointToClient(System.Windows.Forms.Control.MousePosition);
|
||||
bar.DragMouseUp(pos);
|
||||
|
||||
BubbleBarTab tab=bar.SelectedTab;
|
||||
if(tab!=null)
|
||||
{
|
||||
IComponentChangeService change=this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if(change!=null)
|
||||
change.OnComponentChanging(this.Component,TypeDescriptor.GetProperties(tab).Find("Buttons",true));
|
||||
if(change!=null)
|
||||
change.OnComponentChanged(this.Component,TypeDescriptor.GetProperties(tab).Find("Buttons",true),null,null);
|
||||
}
|
||||
}
|
||||
|
||||
if(m_IgnoreMouseUp)
|
||||
{
|
||||
m_IgnoreMouseUp=false;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Licensing Stuff
|
||||
#if !TRIAL
|
||||
private 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 dh_LoadComplete(object sender, EventArgs e)
|
||||
{
|
||||
IDesignerHost dh = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
if (dh != null)
|
||||
dh.LoadComplete -= new EventHandler(dh_LoadComplete);
|
||||
|
||||
string key = GetLicenseKey();
|
||||
BubbleBar bar = this.Control as BubbleBar;
|
||||
if (key != "" && bar != null && bar.LicenseKey == "" && bar.LicenseKey != key)
|
||||
TypeDescriptor.GetProperties(bar)["LicenseKey"].SetValue(bar, key);
|
||||
}
|
||||
#endif
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Support for BubbleBarTab tabs design-time editor.
|
||||
/// </summary>
|
||||
public class BubbleBarTabCollectionEditor : System.ComponentModel.Design.CollectionEditor
|
||||
{
|
||||
public BubbleBarTabCollectionEditor(Type type)
|
||||
: base(type)
|
||||
{
|
||||
}
|
||||
protected override Type CreateCollectionItemType()
|
||||
{
|
||||
return typeof(BubbleBarTab);
|
||||
}
|
||||
protected override Type[] CreateNewItemTypes()
|
||||
{
|
||||
return new Type[] { typeof(BubbleBarTab) };
|
||||
}
|
||||
protected override object CreateInstance(Type itemType)
|
||||
{
|
||||
object item = base.CreateInstance(itemType);
|
||||
if (item is BubbleBarTab)
|
||||
{
|
||||
BubbleBarTab tabItem = item as BubbleBarTab;
|
||||
tabItem.Text = "My Tab";
|
||||
tabItem.PredefinedColor = eTabItemColor.Blue;
|
||||
}
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Collections;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
#region BubbleBarTabDesigner
|
||||
/// <summary>
|
||||
/// Represents designer for BaseItem objects and derived classes.
|
||||
/// </summary>
|
||||
public class BubbleBarTabDesigner : ComponentDesigner
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates new instance of the class.
|
||||
/// </summary>
|
||||
public BubbleBarTabDesigner()
|
||||
{
|
||||
}
|
||||
|
||||
public override ICollection AssociatedComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
ArrayList components = new ArrayList();
|
||||
BubbleBarTab parent = this.Component as BubbleBarTab;
|
||||
if (parent == null)
|
||||
return base.AssociatedComponents;
|
||||
parent.Buttons.CopyTo(components);
|
||||
return components;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
#region BubbleButtonCollectionEditor
|
||||
/// <summary>
|
||||
/// Support for BubbleBarTab tabs design-time editor.
|
||||
/// </summary>
|
||||
public class BubbleButtonCollectionEditor : System.ComponentModel.Design.CollectionEditor
|
||||
{
|
||||
public BubbleButtonCollectionEditor(Type type)
|
||||
: base(type)
|
||||
{
|
||||
}
|
||||
protected override Type CreateCollectionItemType()
|
||||
{
|
||||
return typeof(BubbleButton);
|
||||
}
|
||||
protected override Type[] CreateNewItemTypes()
|
||||
{
|
||||
return new Type[] { typeof(BubbleButton) };
|
||||
}
|
||||
protected override object CreateInstance(Type itemType)
|
||||
{
|
||||
object item = base.CreateInstance(itemType);
|
||||
if (item is BubbleButton)
|
||||
{
|
||||
BubbleButton button = item as BubbleButton;
|
||||
button.Image = Helpers.LoadBitmap("SystemImages.Note24.png");
|
||||
button.ImageLarge = Helpers.LoadBitmap("SystemImages.Note64.png");
|
||||
}
|
||||
return item;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for ComboItemsEditor.
|
||||
/// </summary>
|
||||
public class ButtonItemEditor : System.ComponentModel.Design.CollectionEditor
|
||||
{
|
||||
public ButtonItemEditor(Type type)
|
||||
: base(type)
|
||||
{
|
||||
}
|
||||
protected override Type CreateCollectionItemType()
|
||||
{
|
||||
return typeof(ButtonItem);
|
||||
}
|
||||
protected override object CreateInstance(Type itemType)
|
||||
{
|
||||
object item = base.CreateInstance(itemType);
|
||||
if (item is ButtonItem)
|
||||
{
|
||||
ButtonItem button = item as ButtonItem;
|
||||
button.Text = "New Item";
|
||||
button.ImagePosition = eImagePosition.Left;
|
||||
}
|
||||
else if (item is LabelItem)
|
||||
{
|
||||
LabelItem label = item as LabelItem;
|
||||
label.Text = "New Label";
|
||||
}
|
||||
return item;
|
||||
}
|
||||
protected override Type[] CreateNewItemTypes()
|
||||
{
|
||||
return new Type[] { typeof(ButtonItem), typeof(LabelItem) };
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,220 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using System.ComponentModel;
|
||||
using System.Collections;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents Windows Forms designer for ButtonX control.
|
||||
/// </summary>
|
||||
public class ButtonXDesigner : BarBaseControlDesigner
|
||||
{
|
||||
#region Constructor
|
||||
public ButtonXDesigner()
|
||||
{
|
||||
this.EnableItemDragDrop=false;
|
||||
this.PassiveContainer = true;
|
||||
}
|
||||
|
||||
public override void Initialize(IComponent component)
|
||||
{
|
||||
base.Initialize(component);
|
||||
if (!component.Site.DesignMode)
|
||||
return;
|
||||
|
||||
((ButtonX)component).SetDesignMode(true);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
#if FRAMEWORK20
|
||||
public override void InitializeNewComponent(IDictionary defaultValues)
|
||||
{
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#else
|
||||
public override void OnSetComponentDefaults()
|
||||
{
|
||||
base.OnSetComponentDefaults();
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#endif
|
||||
|
||||
private void SetDesignTimeDefaults()
|
||||
{
|
||||
ButtonX button = this.Control as ButtonX;
|
||||
if (button == null)
|
||||
return;
|
||||
button.ColorTable = eButtonColor.OrangeWithBackground;
|
||||
button.Style = eDotNetBarStyle.StyleManagerControlled;
|
||||
}
|
||||
|
||||
public override DesignerVerbCollection Verbs
|
||||
{
|
||||
get
|
||||
{
|
||||
Bar bar = this.Control as Bar;
|
||||
DesignerVerb[] verbs = null;
|
||||
verbs = new DesignerVerb[]
|
||||
{
|
||||
new DesignerVerb("Add Button", new EventHandler(CreateButton)),
|
||||
new DesignerVerb("Add Horizontal Container", new EventHandler(CreateHorizontalContainer)),
|
||||
new DesignerVerb("Add Vertical Container", new EventHandler(CreateVerticalContainer)),
|
||||
new DesignerVerb("Add Gallery Container", new EventHandler(CreateGalleryContainer)),
|
||||
new DesignerVerb("Add Scrollable Container", new EventHandler(CreateScrollContainer)),
|
||||
new DesignerVerb("Add Text Box", new EventHandler(CreateTextBox)),
|
||||
new DesignerVerb("Add Combo Box", new EventHandler(CreateComboBox)),
|
||||
new DesignerVerb("Add Label", new EventHandler(CreateLabel)),
|
||||
new DesignerVerb("Add Check Box", new EventHandler(CreateCheckBox)),
|
||||
new DesignerVerb("Add Micro-Chart", new EventHandler(CreateMicroChart)),
|
||||
new DesignerVerb("Add Switch Button", new EventHandler(CreateSwitch)),
|
||||
new DesignerVerb("Add Slider", new EventHandler(CreateSliderItem)),
|
||||
new DesignerVerb("Add Rating Item", new EventHandler(CreateRatingItem)),
|
||||
new DesignerVerb("Add Control Container", new EventHandler(CreateControlContainer)),
|
||||
new DesignerVerb("Add Color Picker", new EventHandler(CreateColorPicker))};
|
||||
return new DesignerVerbCollection(verbs);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnitemCreated(BaseItem item)
|
||||
{
|
||||
TypeDescriptor.GetProperties(item)["GlobalItem"].SetValue(item, false);
|
||||
}
|
||||
|
||||
private void CreateScrollContainer(object sender, EventArgs e)
|
||||
{
|
||||
GalleryContainer item = CreateComponent(typeof(GalleryContainer)) as GalleryContainer;
|
||||
TypeDescriptor.GetProperties(item)["MinimumSize"].SetValue(item, new Size(150, 200));
|
||||
TypeDescriptor.GetProperties(((GalleryContainer)item).BackgroundStyle)["Class"].SetValue(((GalleryContainer)item).BackgroundStyle, "");
|
||||
TypeDescriptor.GetProperties(item)["EnableGalleryPopup"].SetValue(item, false);
|
||||
TypeDescriptor.GetProperties(item)["LayoutOrientation"].SetValue(item, DevComponents.DotNetBar.eOrientation.Vertical);
|
||||
TypeDescriptor.GetProperties(item)["MultiLine"].SetValue(item, false);
|
||||
TypeDescriptor.GetProperties(item)["PopupUsesStandardScrollbars"].SetValue(item, false);
|
||||
item.NeedRecalcSize = true;
|
||||
this.RecalcLayout();
|
||||
}
|
||||
|
||||
|
||||
private void CreateVerticalContainer(object sender, EventArgs e)
|
||||
{
|
||||
CreateContainer(this.GetItemContainer(), eOrientation.Vertical);
|
||||
}
|
||||
|
||||
private void CreateHorizontalContainer(object sender, EventArgs e)
|
||||
{
|
||||
CreateContainer(this.GetItemContainer(), eOrientation.Horizontal);
|
||||
}
|
||||
|
||||
private void CreateContainer(BaseItem parent, eOrientation orientation)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_CreatingItem = true;
|
||||
DesignerSupport.CreateItemContainer(this, parent, orientation);
|
||||
}
|
||||
finally
|
||||
{
|
||||
m_CreatingItem = false;
|
||||
}
|
||||
this.RecalcLayout();
|
||||
}
|
||||
|
||||
protected override BaseItem GetItemContainer()
|
||||
{
|
||||
ButtonX button = this.Control as ButtonX;
|
||||
if (button != null)
|
||||
return button.InternalItem;
|
||||
return base.GetItemContainer();
|
||||
}
|
||||
|
||||
public override bool CanParent(Control control)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override void OnMouseDragBegin(int x, int y)
|
||||
{
|
||||
ButtonX ctrl = this.GetItemContainerControl() as ButtonX;
|
||||
if (ctrl != null)
|
||||
{
|
||||
ISelectionService ss = GetService(typeof(ISelectionService)) as ISelectionService;
|
||||
bool selected = false;
|
||||
if (ss != null) selected = ss.PrimarySelection == this.Component;
|
||||
ButtonItem container = this.GetItemContainer() as ButtonItem;
|
||||
Point pos = ctrl.PointToClient(new Point(x, y));
|
||||
MouseEventArgs e = new MouseEventArgs(MouseButtons.Left, 0, pos.X, pos.Y, 0);
|
||||
if (container != null &&
|
||||
(!container.SubItemsRect.IsEmpty && container.SubItemsRect.Contains(pos) ||
|
||||
(!container.ShowSubItems || container.SubItemsExpandWidth <= 1) && selected)
|
||||
&& container.SubItems.Count > 0)
|
||||
{
|
||||
container.Expanded = !container.Expanded;
|
||||
return;
|
||||
}
|
||||
}
|
||||
base.OnMouseDragBegin(x, y);
|
||||
}
|
||||
|
||||
protected override bool OnMouseDown(ref Message m, MouseButtons button)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override bool OnMouseUp(ref Message m)
|
||||
{
|
||||
ButtonX ctrl = this.GetItemContainerControl() as ButtonX;
|
||||
if (ctrl != null)
|
||||
{
|
||||
if (ctrl.Expanded && !this.DragInProgress)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool bProcessed = false;
|
||||
|
||||
BaseItem container = this.GetItemContainer();
|
||||
IOwner owner = this.GetIOwner();
|
||||
|
||||
if (ctrl == null || owner == null || container == null)
|
||||
return false;
|
||||
|
||||
Point pos = ctrl.PointToClient(System.Windows.Forms.Control.MousePosition);
|
||||
MouseEventArgs e = new MouseEventArgs(MouseButtons.Left, 0, pos.X, pos.Y, 0);
|
||||
container.InternalMouseUp(e);
|
||||
|
||||
if (this.DragItem != null)
|
||||
{
|
||||
MouseDragDrop(pos.X, pos.Y);
|
||||
return true;
|
||||
}
|
||||
|
||||
return bProcessed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Triggered when some other component on the form is removed.
|
||||
/// </summary>
|
||||
protected override void OtherComponentRemoving(object sender, ComponentEventArgs e)
|
||||
{
|
||||
bool callBase = true;
|
||||
if (e.Component is BaseItem)
|
||||
{
|
||||
BaseItem item = e.Component as BaseItem;
|
||||
BaseItem parent = this.GetItemContainer();
|
||||
if (item!=null && parent!=null && parent.SubItems.Contains(item))
|
||||
{
|
||||
parent.SubItems.Remove(item);
|
||||
this.RecalcLayout();
|
||||
callBase = false;
|
||||
}
|
||||
}
|
||||
if(callBase)
|
||||
base.OtherComponentRemoving(sender, e);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.ComponentModel.Design;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
public class CheckBoxItemDesigner : BaseItemDesigner
|
||||
{
|
||||
public override DesignerVerbCollection Verbs
|
||||
{
|
||||
get
|
||||
{
|
||||
return new DesignerVerbCollection();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void SetDesignTimeDefaults()
|
||||
{
|
||||
CheckBoxItem c = this.Component as CheckBoxItem;
|
||||
if (c != null) c.AutoCollapseOnClick = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Windows.Forms.Design;
|
||||
using DevComponents.DotNetBar.Controls;
|
||||
#if FRAMEWORK20
|
||||
using System.Collections.Generic;
|
||||
using System.Collections;
|
||||
#endif
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents WinForms designer for Slider control.
|
||||
/// </summary>
|
||||
public class CheckBoxXDesigner : ControlDesigner
|
||||
{
|
||||
#if FRAMEWORK20
|
||||
public override void InitializeNewComponent(IDictionary defaultValues)
|
||||
{
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#else
|
||||
public override void OnSetComponentDefaults()
|
||||
{
|
||||
SetDesignTimeDefaults();
|
||||
base.OnSetComponentDefaults();
|
||||
}
|
||||
#endif
|
||||
|
||||
private void SetDesignTimeDefaults()
|
||||
{
|
||||
CheckBoxX checkBox = this.Control as CheckBoxX;
|
||||
if (checkBox != null)
|
||||
{
|
||||
checkBox.Style = eDotNetBarStyle.StyleManagerControlled;
|
||||
checkBox.Width = 100;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
PROMS/DotNetBar Source Code/DotNetBarDesignTime/CheckedListBoxSelector.Designer.cs
generated
Normal file
BIN
PROMS/DotNetBar Source Code/DotNetBarDesignTime/CheckedListBoxSelector.Designer.cs
generated
Normal file
Binary file not shown.
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
public partial class CheckedListBoxSelector : UserControl
|
||||
{
|
||||
public CheckedListBoxSelector()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
buttonMoveUp.Enabled = checkedListBox1.SelectedIndex >= 0;
|
||||
buttonMoveDown.Enabled = buttonMoveUp.Enabled;
|
||||
}
|
||||
|
||||
public CheckedListBox ListBox
|
||||
{
|
||||
get
|
||||
{
|
||||
return checkedListBox1;
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonMoveUp_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (checkedListBox1.SelectedIndex > 0)
|
||||
{
|
||||
int index = checkedListBox1.SelectedIndex;
|
||||
object item = checkedListBox1.Items[index];
|
||||
CheckState checkState = checkedListBox1.GetItemCheckState(index);
|
||||
checkedListBox1.Items.RemoveAt(index);
|
||||
index--;
|
||||
checkedListBox1.Items.Insert(index, item);
|
||||
checkedListBox1.SelectedIndex = index;
|
||||
checkedListBox1.SetItemCheckState(index, checkState);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonMoveDown_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (checkedListBox1.SelectedIndex < checkedListBox1.Items.Count - 1)
|
||||
{
|
||||
int index = checkedListBox1.SelectedIndex;
|
||||
object item = checkedListBox1.Items[index];
|
||||
CheckState checkState = checkedListBox1.GetItemCheckState(index);
|
||||
checkedListBox1.Items.RemoveAt(index);
|
||||
index++;
|
||||
checkedListBox1.Items.Insert(index, item);
|
||||
checkedListBox1.SelectedIndex = index;
|
||||
checkedListBox1.SetItemCheckState(index, checkState);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Collections;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
public class ColorPickerButtonDesigner : ButtonXDesigner
|
||||
{
|
||||
#if FRAMEWORK20
|
||||
public override void InitializeNewComponent(IDictionary defaultValues)
|
||||
{
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#else
|
||||
public override void OnSetComponentDefaults()
|
||||
{
|
||||
base.OnSetComponentDefaults();
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#endif
|
||||
|
||||
private void SetDesignTimeDefaults()
|
||||
{
|
||||
ColorPickerButton b = this.Control as ColorPickerButton;
|
||||
TypeDescriptor.GetProperties(b)["Image"].SetValue(b, Helpers.LoadBitmap("SystemImages.ColorPickerButtonImage.png"));
|
||||
TypeDescriptor.GetProperties(b)["SelectedColorImageRectangle"].SetValue(b, new Rectangle(2,2,12,12));
|
||||
TypeDescriptor.GetProperties(b)["Text"].SetValue(b, "");
|
||||
TypeDescriptor.GetProperties(b)["Size"].SetValue(b, new Size(37,23));
|
||||
TypeDescriptor.GetProperties(b)["Style"].SetValue(b, eDotNetBarStyle.StyleManagerControlled);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
|
||||
#if AdvTree
|
||||
namespace DevComponents.Tree.Design
|
||||
#elif DOTNETBAR
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
#endif
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for ColorSchemeColorConverter.
|
||||
/// </summary>
|
||||
public class ColorSchemeColorConverter:ColorConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// This member supports the .NET Framework infrastructure and is not intended to be used directly from your code.
|
||||
/// </summary>
|
||||
/// <param name="context">An ITypeDescriptorContext that provides a format context. </param>
|
||||
/// <param name="culture">The CultureInfo to use as the current culture. </param>
|
||||
/// <param name="value">The Object to convert. </param>
|
||||
/// <returns>An Object that represents the converted value.</returns>
|
||||
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
|
||||
{
|
||||
Color color=Color.Empty;
|
||||
if(value is string && value.ToString().StartsWith("CS."))
|
||||
{
|
||||
string propertyName=context.PropertyDescriptor.Name;
|
||||
PropertyInfo property=context.Instance.GetType().GetProperty(propertyName+"SchemePart",BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
|
||||
if(property!=null)
|
||||
{
|
||||
property.SetValue(context.Instance,Enum.Parse(typeof(eColorSchemePart),value.ToString().Substring(4)),new object[]{});
|
||||
color=(Color)context.PropertyDescriptor.GetValue(context.Instance);
|
||||
}
|
||||
}
|
||||
else
|
||||
return base.ConvertFrom(context, culture, value);
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the given value object to the specified type.
|
||||
/// </summary>
|
||||
/// <param name="context">An ITypeDescriptorContext that provides a format context. </param>
|
||||
/// <param name="culture">A CultureInfo object. If a null reference (Nothing in Visual Basic) is passed, the current culture is assumed. </param>
|
||||
/// <param name="value">The Object to convert.</param>
|
||||
/// <param name="destinationType">The Type to convert the value parameter to. </param>
|
||||
/// <returns>An Object that represents the converted value.</returns>
|
||||
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
|
||||
{
|
||||
if(context!=null && (destinationType == typeof(string)) && (value is Color))
|
||||
{
|
||||
string propertyName=context.PropertyDescriptor.Name;
|
||||
PropertyInfo property=context.Instance.GetType().GetProperty(propertyName+"SchemePart",BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
|
||||
if(property!=null)
|
||||
{
|
||||
eColorSchemePart part = (eColorSchemePart)property.GetValue(context.Instance, new object[] {});
|
||||
if(part!=eColorSchemePart.None)
|
||||
return "CS." + part.ToString();
|
||||
}
|
||||
}
|
||||
return base.ConvertTo(context, culture, value, destinationType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using DevComponents.AdvTree;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
#region ColumnHeaderCollectionEditor
|
||||
/// <summary>
|
||||
/// Support for ColumnHeader tabs design-time editor.
|
||||
/// </summary>
|
||||
public class ColumnHeaderCollectionEditor : System.ComponentModel.Design.CollectionEditor
|
||||
{
|
||||
/// <summary>Creates new instance of the class</summary>
|
||||
/// <param name="type">Type to initialize editor with.</param>
|
||||
public ColumnHeaderCollectionEditor(Type type)
|
||||
: base(type)
|
||||
{
|
||||
}
|
||||
protected override Type CreateCollectionItemType()
|
||||
{
|
||||
return typeof(ColumnHeader);
|
||||
}
|
||||
protected override Type[] CreateNewItemTypes()
|
||||
{
|
||||
return new Type[] { typeof(ColumnHeader) };
|
||||
}
|
||||
protected override object CreateInstance(Type itemType)
|
||||
{
|
||||
object item = base.CreateInstance(itemType);
|
||||
if (item is ColumnHeader)
|
||||
{
|
||||
ColumnHeader ch = item as ColumnHeader;
|
||||
ch.Text = ch.Name;
|
||||
}
|
||||
return item;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing.Design;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms.Design;
|
||||
using DevComponents.DotNetBar.Controls;
|
||||
using DevComponents.DotNetBar.Rendering;
|
||||
using System.Globalization;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
public class ColumnNamesEditor : UITypeEditor
|
||||
{
|
||||
#region Constructor
|
||||
private TextBoxX _TextBox = null;
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the ColumnNamesEditor class.
|
||||
/// </summary>
|
||||
public ColumnNamesEditor()
|
||||
{
|
||||
_TextBox = new TextBoxX();
|
||||
_TextBox.Multiline = true;
|
||||
_TextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
|
||||
_TextBox.WatermarkBehavior = eWatermarkBehavior.HideNonEmpty;
|
||||
_TextBox.WatermarkText = "Use Enter key to separate custom column names";
|
||||
_TextBox.Border.Class = ElementStyleClassKeys.TextBoxBorderKey;
|
||||
_TextBox.AcceptsReturn = true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Implementation
|
||||
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
|
||||
{
|
||||
if (context != null
|
||||
&& context.Instance != null
|
||||
&& provider != null)
|
||||
{
|
||||
IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
|
||||
if (edSvc != null)
|
||||
{
|
||||
PropertyDescriptor descriptor = TypeDescriptor.GetProperties(context.Instance)["DataSource"];
|
||||
if (descriptor == null)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
_TextBox.Text = (string)value;
|
||||
_TextBox.MinimumSize = new System.Drawing.Size(24, 120);
|
||||
edSvc.DropDownControl(_TextBox);
|
||||
|
||||
return _TextBox.Text;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
|
||||
{
|
||||
return UITypeEditorEditStyle.DropDown;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region ColumnNamesConverter
|
||||
public class ColumnNamesConverter : TypeConverter
|
||||
{
|
||||
// Methods
|
||||
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
|
||||
{
|
||||
return ((sourceType == typeof(string)) || base.CanConvertFrom(context, sourceType));
|
||||
}
|
||||
const string tempCommaReplacement = "```";
|
||||
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
|
||||
{
|
||||
if (value != null && value is string)
|
||||
{
|
||||
string s = ((string)value).Replace(",,", tempCommaReplacement);
|
||||
s = s.Replace(",", "\r\n");
|
||||
s = s.Replace(tempCommaReplacement, ",");
|
||||
return s;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
|
||||
{
|
||||
if ((destinationType != typeof(string)) || !(value is string))
|
||||
{
|
||||
return base.ConvertTo(context, culture, value, destinationType);
|
||||
}
|
||||
if (value != null)
|
||||
{
|
||||
string s = ((string)value).Replace(",", tempCommaReplacement);
|
||||
s = s.Replace("\r\n", ",");
|
||||
s = s.Replace(tempCommaReplacement, ",");
|
||||
return s;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Windows.Forms.Design;
|
||||
using DevComponents.DotNetBar.Controls;
|
||||
using System.ComponentModel;
|
||||
using System.Collections;
|
||||
using System.Windows.Forms;
|
||||
using System.ComponentModel.Design;
|
||||
using DevComponents.Editors;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents Windows Forms designer for the ComboBoxEx control.
|
||||
/// </summary>
|
||||
public class ComboBoxExDesigner : ControlDesigner
|
||||
{
|
||||
#if FRAMEWORK20
|
||||
public override void InitializeNewComponent(IDictionary defaultValues)
|
||||
{
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#else
|
||||
public override void OnSetComponentDefaults()
|
||||
{
|
||||
base.OnSetComponentDefaults();
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#endif
|
||||
|
||||
public override void Initialize(IComponent component)
|
||||
{
|
||||
base.Initialize(component);
|
||||
if (component.Site!=null && !component.Site.DesignMode)
|
||||
return;
|
||||
|
||||
// If our component is removed we need to clean-up
|
||||
IComponentChangeService cc = (IComponentChangeService)GetService(typeof(IComponentChangeService));
|
||||
if (cc != null)
|
||||
{
|
||||
cc.ComponentRemoving += new ComponentEventHandler(this.OnComponentRemoved);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
IComponentChangeService cc = (IComponentChangeService)GetService(typeof(IComponentChangeService));
|
||||
if (cc != null)
|
||||
cc.ComponentRemoved -= new ComponentEventHandler(this.OnComponentRemoved);
|
||||
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private void SetDesignTimeDefaults()
|
||||
{
|
||||
ComboBoxEx c = this.Control as ComboBoxEx;
|
||||
c.DisplayMember = "Text";
|
||||
c.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
|
||||
c.ItemHeight = c.GetFontHeight() + 1;
|
||||
c.Style = eDotNetBarStyle.StyleManagerControlled;
|
||||
#if FRAMEWORK20
|
||||
c.FormattingEnabled = true;
|
||||
#endif
|
||||
|
||||
PropertyDescriptor d = TypeDescriptor.GetProperties(c)["Text"];
|
||||
if (d != null && d.PropertyType == typeof(string) && !d.IsReadOnly && d.IsBrowsable)
|
||||
{
|
||||
d.SetValue(c, "");
|
||||
}
|
||||
}
|
||||
|
||||
#if FRAMEWORK20
|
||||
private DesignerActionListCollection m_ActionLists;
|
||||
public override DesignerActionListCollection ActionLists
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_ActionLists == null)
|
||||
{
|
||||
m_ActionLists = new DesignerActionListCollection();
|
||||
object o = this.GetType().Assembly.CreateInstance("System.Windows.Forms.Design.ListControlBoundActionList", false, System.Reflection.BindingFlags.NonPublic, null, new object[] { this }, null, null);
|
||||
if(o!=null)
|
||||
m_ActionLists.Add(o as DesignerActionList);
|
||||
}
|
||||
return m_ActionLists;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
public override SelectionRules SelectionRules
|
||||
{
|
||||
get
|
||||
{
|
||||
SelectionRules r = base.SelectionRules;
|
||||
ComboBoxEx c = this.Control as ComboBoxEx; ;
|
||||
PropertyDescriptor d = TypeDescriptor.GetProperties(c)["DropDownStyle"];
|
||||
if (d == null)
|
||||
return r;
|
||||
|
||||
ComboBoxStyle style = (ComboBoxStyle)d.GetValue(c);
|
||||
if (style != ComboBoxStyle.DropDown && style != ComboBoxStyle.DropDownList)
|
||||
{
|
||||
return r;
|
||||
}
|
||||
return (r & ~(SelectionRules.BottomSizeable | SelectionRules.TopSizeable));
|
||||
}
|
||||
}
|
||||
|
||||
#if FRAMEWORK20
|
||||
protected override void PreFilterProperties(System.Collections.IDictionary properties)
|
||||
{
|
||||
base.PreFilterProperties(properties);
|
||||
|
||||
properties["FlatStyle"] = TypeDescriptor.CreateProperty(
|
||||
this.GetType(),
|
||||
"FlatStyle",
|
||||
typeof(FlatStyle),
|
||||
new Attribute[] { new BrowsableAttribute(true), new DefaultValueAttribute(FlatStyle.Flat)});
|
||||
}
|
||||
|
||||
|
||||
[Browsable(true), DefaultValue(FlatStyle.Flat), Description("Gets or sets the combo box flat style")]
|
||||
public FlatStyle FlatStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
ComboBox cb = this.Control as ComboBox;
|
||||
return cb.FlatStyle;
|
||||
}
|
||||
set
|
||||
{
|
||||
ComboBox cb = this.Control as ComboBox;
|
||||
cb.FlatStyle = value;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
public override ICollection AssociatedComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
ArrayList al = new ArrayList(base.AssociatedComponents);
|
||||
ComboBoxEx cex = this.Component as ComboBoxEx;
|
||||
foreach(object o in cex.Items)
|
||||
{
|
||||
if (o is ComboItem)
|
||||
{
|
||||
al.Add(o);
|
||||
}
|
||||
}
|
||||
return al;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnComponentRemoved(object sender, ComponentEventArgs e)
|
||||
{
|
||||
if (e.Component == this.Component)
|
||||
{
|
||||
ComboBoxEx cex = this.Component as ComboBoxEx;
|
||||
IDesignerHost dh = GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
if (dh == null) return;
|
||||
foreach (object o in cex.Items)
|
||||
{
|
||||
if (o is ComboItem)
|
||||
{
|
||||
ComboItem ci = o as ComboItem;
|
||||
dh.DestroyComponent(ci);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
using System;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Drawing.Design;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms.ComponentModel;
|
||||
using System.Windows.Forms.Design;
|
||||
using System.Drawing;
|
||||
using DevComponents.Editors;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for ComboItemsEditor.
|
||||
/// </summary>
|
||||
public class ComboItemsEditor:CollectionEditor
|
||||
{
|
||||
public ComboItemsEditor(Type type):base(type)
|
||||
{
|
||||
}
|
||||
protected override Type CreateCollectionItemType()
|
||||
{
|
||||
return typeof(ComboItem);
|
||||
}
|
||||
protected override object CreateInstance(Type itemType)
|
||||
{
|
||||
object o = base.CreateInstance(itemType);
|
||||
ComboItem ci = o as ComboItem;
|
||||
if (ci != null)
|
||||
{
|
||||
if (ci.Site != null && ci.Site.Name != "")
|
||||
ci.Text = ci.Site.Name;
|
||||
else
|
||||
ci.Text = "comboItem";
|
||||
}
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
||||
public class ImageIndexEditor:UITypeEditor
|
||||
{
|
||||
//private System.Windows.Forms.Design.IWindowsFormsEditorService m_EditorService=null;
|
||||
//private UITypeEditor m_ImageEditor;
|
||||
private System.Windows.Forms.ImageList m_ImageList=null;
|
||||
public ImageIndexEditor():base()
|
||||
{
|
||||
//m_ImageEditor= System.ComponentModel.TypeDescriptor.GetEditor(typeof(System.Drawing.Image),typeof(UITypeEditor)) as ImageEditor;
|
||||
}
|
||||
|
||||
public override bool GetPaintValueSupported(ITypeDescriptorContext context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void PaintValue(PaintValueEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(e==null || e.Value==null)
|
||||
return;
|
||||
int iIndex=(int)e.Value;
|
||||
System.Drawing.Image img=this.GetImage(e.Context,iIndex);
|
||||
if(img==null)
|
||||
return;
|
||||
PaintValueEventArgs pi=new PaintValueEventArgs(e.Context,img,e.Graphics,e.Bounds);
|
||||
if (img != null)
|
||||
{
|
||||
Rectangle r = e.Bounds;
|
||||
r.Width--;
|
||||
r.Height--;
|
||||
e.Graphics.DrawRectangle(SystemPens.WindowFrame, r);
|
||||
e.Graphics.DrawImage(img, e.Bounds);
|
||||
}
|
||||
|
||||
//m_ImageEditor.PaintValue(pi);
|
||||
//m_ImageEditor.PaintValue(img,e.Graphics,e.Bounds);
|
||||
}
|
||||
catch{}
|
||||
}
|
||||
|
||||
private System.Drawing.Image GetImage(System.ComponentModel.ITypeDescriptorContext context,int index)
|
||||
{
|
||||
if(m_ImageList!=null && index>=0 && index<=m_ImageList.Images.Count)
|
||||
{
|
||||
return m_ImageList.Images[index];
|
||||
}
|
||||
if(context==null)
|
||||
return null;
|
||||
|
||||
object o=context.Instance;
|
||||
if(o==null)
|
||||
return null;
|
||||
System.ComponentModel.PropertyDescriptorCollection pd=System.ComponentModel.TypeDescriptor.GetProperties(o);
|
||||
if(pd==null)
|
||||
return null;
|
||||
|
||||
foreach(System.ComponentModel.PropertyDescriptor prop in pd)
|
||||
{
|
||||
if(prop.PropertyType==typeof(System.Windows.Forms.ImageList))
|
||||
{
|
||||
m_ImageList=prop.GetValue(o) as System.Windows.Forms.ImageList;
|
||||
if(m_ImageList!=null && index>=0 && index<=m_ImageList.Images.Count)
|
||||
{
|
||||
return m_ImageList.Images[index];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
#if FRAMEWORK20
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.ComponentModel.Design;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using DevComponents.DotNetBar.Controls;
|
||||
using DevComponents.AdvTree;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
internal class ComboTreeActionList : DesignerActionList
|
||||
{
|
||||
private ComboTreeDesigner _Designer = null;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the ComboTreeActionList class.
|
||||
/// </summary>
|
||||
/// <param name="designer"></param>
|
||||
public ComboTreeActionList(ComboTreeDesigner designer)
|
||||
: base(designer.Component)
|
||||
{
|
||||
_Designer = designer;
|
||||
}
|
||||
|
||||
public override DesignerActionItemCollection GetSortedActionItems()
|
||||
{
|
||||
DesignerActionItemCollection items = new DesignerActionItemCollection();
|
||||
items.Add(new DesignerActionHeaderItem("Nodes"));
|
||||
items.Add(new DesignerActionHeaderItem("Columns"));
|
||||
|
||||
items.Add(new DesignerActionMethodItem(this, "EditColumns", "Edit Columns...", "Columns", "Edit Tree Control Columns", true));
|
||||
items.Add(new DesignerActionPropertyItem("ColumnsVisible", "Column header visible?", "Columns", "Indicates whether tree column header is visible"));
|
||||
items.Add(new DesignerActionPropertyItem("GridColumnLines", "Show grid column lines?", "Columns", "Indicates whether grid lines are visible"));
|
||||
items.Add(new DesignerActionPropertyItem("GridRowLines", "Show grid row lines?", "Nodes", "Indicates whether grid lines between nodes are visible"));
|
||||
items.Add(new DesignerActionPropertyItem("GridLinesColor", "Grid lines color:", "Columns", "Indicates custom color for grid lines"));
|
||||
|
||||
items.Add(new DesignerActionPropertyItem("SelectionBoxStyle", "Selection style:", "Selection", "Indicates selection style"));
|
||||
items.Add(new DesignerActionPropertyItem("HotTracking", "Highlight mouse over node?", "Selection", "Indicates whether node that mouse is over is highlighted"));
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
public void CreateNode()
|
||||
{
|
||||
_Designer.CreateNode();
|
||||
}
|
||||
|
||||
public void EditColumns()
|
||||
{
|
||||
_Designer.EditColumns();
|
||||
}
|
||||
|
||||
public bool HotTracking
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((ComboTree)base.Component).HotTracking;
|
||||
}
|
||||
set
|
||||
{
|
||||
TypeDescriptor.GetProperties(base.Component)["HotTracking"].SetValue(base.Component, value);
|
||||
}
|
||||
}
|
||||
|
||||
public eSelectionStyle SelectionBoxStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((ComboTree)base.Component).SelectionBoxStyle;
|
||||
}
|
||||
set
|
||||
{
|
||||
TypeDescriptor.GetProperties(base.Component)["SelectionBoxStyle"].SetValue(base.Component, value);
|
||||
}
|
||||
}
|
||||
|
||||
public bool ColumnsVisible
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((ComboTree)base.Component).ColumnsVisible;
|
||||
}
|
||||
set
|
||||
{
|
||||
TypeDescriptor.GetProperties(base.Component)["ColumnsVisible"].SetValue(base.Component, value);
|
||||
}
|
||||
}
|
||||
|
||||
public bool GridColumnLines
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((ComboTree)base.Component).GridColumnLines;
|
||||
}
|
||||
set
|
||||
{
|
||||
TypeDescriptor.GetProperties(base.Component)["GridColumnLines"].SetValue(base.Component, value);
|
||||
}
|
||||
}
|
||||
|
||||
public bool GridRowLines
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((ComboTree)base.Component).GridRowLines;
|
||||
}
|
||||
set
|
||||
{
|
||||
TypeDescriptor.GetProperties(base.Component)["GridRowLines"].SetValue(base.Component, value);
|
||||
}
|
||||
}
|
||||
|
||||
public Color GridLinesColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((ComboTree)base.Component).GridLinesColor;
|
||||
}
|
||||
set
|
||||
{
|
||||
TypeDescriptor.GetProperties(base.Component)["GridLinesColor"].SetValue(base.Component, value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,195 @@
|
||||
#if FRAMEWORK20
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms.Design;
|
||||
using System.Collections;
|
||||
using DevComponents.DotNetBar.Controls;
|
||||
using DevComponents.AdvTree;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using DevComponents.DotNetBar.Rendering;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
public class ComboTreeDesigner : ControlDesigner
|
||||
{
|
||||
public override void InitializeNewComponent(IDictionary defaultValues)
|
||||
{
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
|
||||
public override void Initialize(IComponent component)
|
||||
{
|
||||
base.Initialize(component);
|
||||
if (component.Site!=null && !component.Site.DesignMode)
|
||||
return;
|
||||
|
||||
// If our component is removed we need to clean-up
|
||||
IComponentChangeService cc = (IComponentChangeService)GetService(typeof(IComponentChangeService));
|
||||
if (cc != null)
|
||||
{
|
||||
cc.ComponentRemoving += new ComponentEventHandler(this.OnComponentRemoved);
|
||||
}
|
||||
|
||||
#if !TRIAL
|
||||
IDesignerHost dh = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
if (dh != null)
|
||||
dh.LoadComplete += new EventHandler(dh_LoadComplete);
|
||||
#endif
|
||||
}
|
||||
#if !TRIAL
|
||||
private void dh_LoadComplete(object sender, EventArgs e)
|
||||
{
|
||||
IDesignerHost dh = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
if (dh != null)
|
||||
dh.LoadComplete -= new EventHandler(dh_LoadComplete);
|
||||
|
||||
string key = RibbonBarDesigner.GetLicenseKey();
|
||||
ComboTree bar = this.Control as ComboTree;
|
||||
if (key != "" && bar != null && bar.LicenseKey == "" && bar.LicenseKey != key)
|
||||
TypeDescriptor.GetProperties(bar)["LicenseKey"].SetValue(bar, key);
|
||||
}
|
||||
#endif
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
IComponentChangeService cc = (IComponentChangeService)GetService(typeof(IComponentChangeService));
|
||||
if (cc != null)
|
||||
cc.ComponentRemoved -= new ComponentEventHandler(this.OnComponentRemoved);
|
||||
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private void SetDesignTimeDefaults()
|
||||
{
|
||||
ComboTree c = this.Control as ComboTree;
|
||||
PropertyDescriptor d = TypeDescriptor.GetProperties(c)["Text"];
|
||||
if (d != null && d.PropertyType == typeof(string) && !d.IsReadOnly && d.IsBrowsable)
|
||||
{
|
||||
d.SetValue(c, "");
|
||||
}
|
||||
c.ButtonDropDown.Visible = true;
|
||||
c.BackgroundStyle.Class = ElementStyleClassKeys.TextBoxBorderKey;
|
||||
c.Style = eDotNetBarStyle.StyleManagerControlled;
|
||||
#if !TRIAL
|
||||
string key = RibbonBarDesigner.GetLicenseKey();
|
||||
c.LicenseKey = key;
|
||||
#endif
|
||||
}
|
||||
|
||||
public override ICollection AssociatedComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
ArrayList al = new ArrayList(base.AssociatedComponents);
|
||||
ComboTree combo = this.Component as ComboTree;
|
||||
foreach(Node o in combo.Nodes)
|
||||
{
|
||||
al.Add(o);
|
||||
AddChildNodes(o, al);
|
||||
}
|
||||
return al;
|
||||
}
|
||||
}
|
||||
|
||||
private void AddChildNodes(Node parent, ArrayList al)
|
||||
{
|
||||
foreach (Node item in parent.Nodes)
|
||||
{
|
||||
al.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnComponentRemoved(object sender, ComponentEventArgs e)
|
||||
{
|
||||
if (e.Component == this.Component)
|
||||
{
|
||||
ICollection nodes = AssociatedComponents;
|
||||
IDesignerHost dh = GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
if (dh == null) return;
|
||||
foreach (object item in nodes)
|
||||
{
|
||||
if (item is Node)
|
||||
{
|
||||
Node ci = item as Node;
|
||||
dh.DestroyComponent(ci);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void EditColumns()
|
||||
{
|
||||
ComboTree tree = this.Component as ComboTree;
|
||||
DevComponents.AdvTree.Design.AdvTreeDesigner.EditValue(this, tree, "Columns");
|
||||
}
|
||||
|
||||
private DesignerActionListCollection _ActionLists = null;
|
||||
public override DesignerActionListCollection ActionLists
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._ActionLists == null)
|
||||
{
|
||||
this._ActionLists = new DesignerActionListCollection();
|
||||
this._ActionLists.Add(new ComboTreeActionList(this));
|
||||
}
|
||||
return this._ActionLists;
|
||||
}
|
||||
}
|
||||
|
||||
internal void CreateNode()
|
||||
{
|
||||
Node node = CreateNode(this.Component as ComboTree);
|
||||
//if (node != null)
|
||||
//{
|
||||
// ISelectionService sel = this.GetService(typeof(ISelectionService)) as ISelectionService;
|
||||
// ArrayList list = new ArrayList(1);
|
||||
// list.Add(node);
|
||||
// if (sel != null)
|
||||
// {
|
||||
// sel.SetSelectedComponents(list, SelectionTypes.MouseDown);
|
||||
// node.TreeControl.SelectedNode = node;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
private Node CreateNode(ComboTree tree)
|
||||
{
|
||||
IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
if (dh == null)
|
||||
return null;
|
||||
|
||||
Node node = null;
|
||||
tree.AdvTree.BeginUpdate();
|
||||
try
|
||||
{
|
||||
IComponentChangeService change = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (change != null)
|
||||
{
|
||||
change.OnComponentChanging(this.Component, TypeDescriptor.GetProperties(tree).Find("Nodes", true));
|
||||
}
|
||||
|
||||
node = dh.CreateComponent(typeof(Node)) as Node;
|
||||
if (node != null)
|
||||
{
|
||||
node.Text = node.Name;
|
||||
node.Expanded = true;
|
||||
tree.Nodes.Add(node);
|
||||
|
||||
if (change != null)
|
||||
change.OnComponentChanged(this.Component, TypeDescriptor.GetProperties(tree).Find("Nodes", true), null, null);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
tree.AdvTree.EndUpdate();
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,468 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Drawing;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms.Design;
|
||||
using System.Windows.Forms.Design.Behavior;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
public class ComponentDesignerWithAction : ComponentDesigner
|
||||
|
||||
{
|
||||
private Adorner _DesignerActionAdorner = null;
|
||||
|
||||
public override void Initialize(System.ComponentModel.IComponent component)
|
||||
{
|
||||
base.Initialize(component);
|
||||
|
||||
if (DesignerActionUIEnabled)
|
||||
{
|
||||
ISelectionService selectionService = (ISelectionService) GetService(typeof(ISelectionService));
|
||||
if (selectionService != null)
|
||||
selectionService.SelectionChanged += SelectionChanged;
|
||||
|
||||
_DesignerActionAdorner = new Adorner();
|
||||
|
||||
// If our component is removed we need to clean-up
|
||||
IComponentChangeService cc = (IComponentChangeService) GetService(typeof(IComponentChangeService));
|
||||
if (cc != null)
|
||||
{
|
||||
cc.ComponentRemoving += ComponentRemoving;
|
||||
cc.ComponentRemoved += ComponentRemoved;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ComponentRemoved(object sender, ComponentEventArgs e)
|
||||
{
|
||||
if (e.Component is BaseItem)
|
||||
{
|
||||
BaseItem parent = this.Component as BaseItem;
|
||||
BaseItem item = e.Component as BaseItem;
|
||||
if (item != null && parent != null && parent.SubItems.Contains(item))
|
||||
{
|
||||
IComponentChangeService cc = (IComponentChangeService)GetService(typeof(IComponentChangeService));
|
||||
if (cc != null)
|
||||
cc.OnComponentChanging(parent, TypeDescriptor.GetProperties(parent)["SubItems"]);
|
||||
parent.SubItems.Remove(item);
|
||||
if (cc != null)
|
||||
cc.OnComponentChanged(parent, TypeDescriptor.GetProperties(parent)["SubItems"], null, null);
|
||||
this.RecalcLayout();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void RecalcLayout()
|
||||
{
|
||||
}
|
||||
|
||||
private void ComponentRemoving(object sender, ComponentEventArgs e)
|
||||
{
|
||||
if(e.Component == this.Component)
|
||||
RemoveGlyph();
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (DesignerActionUIEnabled)
|
||||
{
|
||||
ISelectionService selectionService = (ISelectionService) GetService(typeof(ISelectionService));
|
||||
if (selectionService != null)
|
||||
selectionService.SelectionChanged -= SelectionChanged;
|
||||
|
||||
IComponentChangeService cc = (IComponentChangeService)GetService(typeof(IComponentChangeService));
|
||||
if (cc != null)
|
||||
{
|
||||
cc.ComponentRemoving -= ComponentRemoving;
|
||||
cc.ComponentRemoved -= ComponentRemoved;
|
||||
}
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
public bool IsSelected = false;
|
||||
|
||||
private void SelectionChanged(object sender, EventArgs e)
|
||||
{
|
||||
bool selected = false;
|
||||
ISelectionService selectionService = (ISelectionService) GetService(typeof(ISelectionService));
|
||||
if (selectionService == null) return;
|
||||
|
||||
if (selectionService.PrimarySelection == this.Component)
|
||||
selected = true;
|
||||
else
|
||||
{
|
||||
ICollection selectedComponents = selectionService.GetSelectedComponents();
|
||||
foreach (object o in selectedComponents)
|
||||
{
|
||||
if (o.Equals(this.Component))
|
||||
{
|
||||
selected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
OnDesignerSelectionChanged(selected);
|
||||
|
||||
if (selected)
|
||||
{
|
||||
Control hostControl = GetContainerControl();
|
||||
if (hostControl != null)
|
||||
{
|
||||
Rectangle itemScreenBounds = hostControl.RectangleToScreen(ComponentBounds);
|
||||
_DesignerGlyph = CreateDesignerGlyphWrapper((Component) this.Component, GetParentControl(),
|
||||
itemScreenBounds,
|
||||
this.ActionLists);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RemoveGlyph();
|
||||
}
|
||||
IsSelected = selected;
|
||||
}
|
||||
|
||||
protected virtual Rectangle ComponentBounds
|
||||
{
|
||||
get
|
||||
{
|
||||
BaseItem item = this.Component as BaseItem;
|
||||
if (item != null)
|
||||
return item.Bounds;
|
||||
return Rectangle.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual Control GetHostControl()
|
||||
{
|
||||
return GetParentControl();
|
||||
}
|
||||
|
||||
protected virtual Control GetParentControl()
|
||||
{
|
||||
return GetContainerControl();
|
||||
}
|
||||
|
||||
protected virtual Control GetContainerControl()
|
||||
{
|
||||
BaseItem item = this.Component as BaseItem;
|
||||
if (item != null)
|
||||
return (Control) item.ContainerControl;
|
||||
return null;
|
||||
}
|
||||
|
||||
protected virtual void OnDesignerSelectionChanged(bool isSelected)
|
||||
{
|
||||
}
|
||||
|
||||
protected virtual bool DesignerActionUIEnabled
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
private Glyph _DesignerGlyph = null;
|
||||
|
||||
private void RemoveGlyph()
|
||||
{
|
||||
BehaviorService svc = (BehaviorService) this.GetService(typeof(BehaviorService));
|
||||
if (svc == null) return;
|
||||
_DesignerActionAdorner.Glyphs.Clear();
|
||||
if (svc.Adorners.Contains(_DesignerActionAdorner))
|
||||
svc.Adorners.Remove(_DesignerActionAdorner);
|
||||
if (_ActionListToolStrip != null)
|
||||
_ActionListToolStrip.LocationChanged -= HostLocationChanged;
|
||||
_ActionListToolStrip = null;
|
||||
InvalidateDesignerSurface();
|
||||
}
|
||||
|
||||
private void InvalidateDesignerSurface()
|
||||
{
|
||||
BehaviorService behaviorService = (BehaviorService) GetService(typeof(BehaviorService));
|
||||
if (behaviorService == null) return;
|
||||
object actionUi = GetActionUI(behaviorService);
|
||||
if (actionUi == null) return;
|
||||
object mainParentWindow = ReflectionHelpers.GetValueField(actionUi, "mainParentWindow",
|
||||
BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
if (mainParentWindow is IWin32Window)
|
||||
{
|
||||
WinApi.RedrawWindow(((IWin32Window) mainParentWindow).Handle, IntPtr.Zero, IntPtr.Zero,
|
||||
(uint) (WinApi.RedrawWindowFlags.RDW_INVALIDATE | WinApi.RedrawWindowFlags.RDW_ALLCHILDREN));
|
||||
}
|
||||
}
|
||||
|
||||
private ToolStripDropDown _ActionListToolStrip = null;
|
||||
|
||||
private Glyph CreateDesignerGlyphWrapper(Component targetComponent, Control ownerControl,
|
||||
Rectangle screenBounds, DesignerActionListCollection actionLists)
|
||||
{
|
||||
BehaviorService behaviorService = (BehaviorService) GetService(typeof(BehaviorService));
|
||||
|
||||
if (targetComponent != null && behaviorService != null && actionLists != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
object actionUi = GetActionUI(behaviorService);
|
||||
FieldInfo fieldInfo1 = ReflectionHelpers.GetFieldInfo(actionUi, "designerActionHost",
|
||||
BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
ToolStripDropDown designerActionHost = null;
|
||||
object mainParentWindow = ReflectionHelpers.GetValueField(actionUi, "mainParentWindow",
|
||||
BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
if (!(fieldInfo1.GetValue(actionUi) is ToolStripDropDown))
|
||||
{
|
||||
ConstructorInfo constructorInfo = ReflectionHelpers.GetConstructorInfo(fieldInfo1.FieldType,
|
||||
new Type[2]
|
||||
{
|
||||
actionUi.GetType(),
|
||||
typeof(IWin32Window)
|
||||
});
|
||||
designerActionHost = constructorInfo.Invoke(new object[2]
|
||||
{
|
||||
actionUi,
|
||||
mainParentWindow
|
||||
}) as ToolStripDropDown;
|
||||
designerActionHost.AutoSize = false;
|
||||
designerActionHost.Padding = System.Windows.Forms.Padding.Empty;
|
||||
designerActionHost.Renderer = (ToolStripRenderer) new NoBorderRenderer();
|
||||
designerActionHost.Text = "DesignerActionTopLevelForm";
|
||||
fieldInfo1.SetValue(actionUi, (object) designerActionHost);
|
||||
}
|
||||
else
|
||||
{
|
||||
designerActionHost = fieldInfo1.GetValue(actionUi) as ToolStripDropDown;
|
||||
}
|
||||
Glyph glyph = ReflectionHelpers.InvokeMethod(actionUi, "GetDesignerActionGlyph",
|
||||
BindingFlags.Instance | BindingFlags.NonPublic, new object[2]
|
||||
{
|
||||
(object) targetComponent,
|
||||
(object) actionLists
|
||||
}) as Glyph;
|
||||
if (glyph != null)
|
||||
{
|
||||
BarUtilities.InvokeDelayed(new MethodInvoker(delegate { SetGlyphBounds(glyph, screenBounds, behaviorService); }), 100);
|
||||
if (designerActionHost != null)
|
||||
{
|
||||
designerActionHost.LocationChanged += HostLocationChanged;
|
||||
Point p = new Point(glyph.Bounds.Right, glyph.Bounds.Y);
|
||||
designerActionHost.Bounds =
|
||||
new Rectangle(behaviorService.AdornerWindowPointToScreen(p), designerActionHost.Size);
|
||||
}
|
||||
FieldInfo fieldInfo2 = ReflectionHelpers.GetFieldInfo((object) glyph.Behavior,
|
||||
"serviceProvider", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
GlyphServiceProvider glyphServiceProvider =
|
||||
new GlyphServiceProvider((IServiceProvider) fieldInfo2.GetValue((object) glyph.Behavior));
|
||||
fieldInfo2.SetValue((object) glyph.Behavior, (object) glyphServiceProvider);
|
||||
//SmartTagInfoCache.Default.Add(info.TargetComponent, new SmartTagCacheElement(glyph, info.TargetComponent, (Control)null, actionUi, info.BehaviorService));
|
||||
behaviorService.Adorners.Add(_DesignerActionAdorner);
|
||||
_DesignerActionAdorner.Glyphs.Add(glyph);
|
||||
//TestGlyph testGlyph = new TestGlyph(behaviorService, this);
|
||||
//_DesignerActionAdorner.Glyphs.Add(testGlyph);
|
||||
if (mainParentWindow is Control) ((Control) mainParentWindow).Invalidate();
|
||||
}
|
||||
if (mainParentWindow is IWin32Window)
|
||||
{
|
||||
WinApi.RedrawWindow(((IWin32Window) mainParentWindow).Handle, IntPtr.Zero, IntPtr.Zero,
|
||||
(uint) (WinApi.RedrawWindowFlags.RDW_INVALIDATE |
|
||||
WinApi.RedrawWindowFlags.RDW_ALLCHILDREN));
|
||||
}
|
||||
if (_ActionListToolStrip != designerActionHost)
|
||||
{
|
||||
if (_ActionListToolStrip != null)
|
||||
_ActionListToolStrip.LocationChanged -= HostLocationChanged;
|
||||
_ActionListToolStrip = designerActionHost;
|
||||
}
|
||||
return glyph;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return (Glyph) null;
|
||||
}
|
||||
}
|
||||
return (Glyph) null;
|
||||
}
|
||||
|
||||
private bool _SettingBounds = false;
|
||||
|
||||
private void HostLocationChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (_SettingBounds) return;
|
||||
|
||||
ToolStripDropDown toolStripDropDown = sender as ToolStripDropDown;
|
||||
BehaviorService svc = (BehaviorService) this.GetService(typeof(BehaviorService));
|
||||
if (toolStripDropDown == null || _DesignerGlyph == null || svc == null)
|
||||
return;
|
||||
_SettingBounds = true;
|
||||
Point p = new Point(_DesignerGlyph.Bounds.Right, _DesignerGlyph.Bounds.Y);
|
||||
Rectangle r = new Rectangle(svc.AdornerWindowPointToScreen(p), toolStripDropDown.Size);
|
||||
toolStripDropDown.Bounds = r;
|
||||
_SettingBounds = false;
|
||||
}
|
||||
|
||||
private void SetGlyphBounds(Glyph gl, Rectangle itemBounds, BehaviorService behaviorService)
|
||||
{
|
||||
Size glyphSize = GetGlyphSize();
|
||||
Point adornerWindow = behaviorService.ScreenToAdornerWindow(new Point(itemBounds.Right - 6, itemBounds.Y));
|
||||
Point p = behaviorService.ScreenToAdornerWindow(Point.Empty);
|
||||
ReflectionHelpers.SetValueField((object) gl, "bounds",
|
||||
BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField,
|
||||
(object) new Rectangle(adornerWindow, glyphSize));
|
||||
InvalidateDesignerSurface();
|
||||
}
|
||||
|
||||
private class NoBorderRenderer : ToolStripProfessionalRenderer
|
||||
{
|
||||
public NoBorderRenderer()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private object GetActionUI(BehaviorService behaviorService)
|
||||
{
|
||||
if (behaviorService == null)
|
||||
return null;
|
||||
return ReflectionHelpers.GetValueProperty((object) behaviorService, "DesignerActionUI",
|
||||
BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
}
|
||||
|
||||
|
||||
private Rectangle GetGlyphBounds(Rectangle componentBounds)
|
||||
{
|
||||
Size glyphSize = GetGlyphSize();
|
||||
return new Rectangle(componentBounds.Right - glyphSize.Width, componentBounds.Y, glyphSize.Width,
|
||||
glyphSize.Height);
|
||||
}
|
||||
|
||||
private Size GetGlyphSize()
|
||||
{
|
||||
try
|
||||
{
|
||||
Type type = typeof(ControlDesigner).Assembly.GetType("System.Windows.Forms.DpiHelper");
|
||||
if (type != (Type) null)
|
||||
{
|
||||
if ((bool) type.GetProperty("IsScalingRequired", BindingFlags.Static | BindingFlags.Public)
|
||||
.GetValue((object) null, (object[]) null))
|
||||
{
|
||||
object[] parameters = new object[2]
|
||||
{
|
||||
(object) new Bitmap(10, 10),
|
||||
(object) 0
|
||||
};
|
||||
type.GetMethod("ScaleBitmapLogicalToDevice", BindingFlags.Static | BindingFlags.Public)
|
||||
.Invoke((object) null, parameters);
|
||||
return ((Image) parameters[0]).Size;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
}
|
||||
return new Size(10, 10);
|
||||
}
|
||||
|
||||
class TestBehavior : Behavior
|
||||
{
|
||||
}
|
||||
|
||||
class TestGlyph : Glyph
|
||||
{
|
||||
ComponentDesignerWithAction _Item;
|
||||
BehaviorService _BehaviorSvc;
|
||||
|
||||
public TestGlyph(BehaviorService behaviorSvc, ComponentDesignerWithAction item)
|
||||
:
|
||||
base(new TestBehavior())
|
||||
{
|
||||
_BehaviorSvc = behaviorSvc;
|
||||
_Item = item;
|
||||
}
|
||||
|
||||
public ComponentDesignerWithAction Item
|
||||
{
|
||||
get { return _Item; }
|
||||
}
|
||||
|
||||
public override Rectangle Bounds
|
||||
{
|
||||
get
|
||||
{
|
||||
// Glyph coordinates are in adorner window coordinates, so we must map using the behavior service.
|
||||
Rectangle bounds = Rectangle.Empty;
|
||||
if (_Item != null && _Item.GetHostControl() != null)
|
||||
{
|
||||
Point edge = _BehaviorSvc.ControlToAdornerWindow(_Item.GetHostControl());
|
||||
|
||||
bounds = _Item.ComponentBounds;
|
||||
bounds.Offset(edge);
|
||||
}
|
||||
|
||||
return bounds;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override Cursor GetHitTest(Point p)
|
||||
{
|
||||
if (_Item != null && !_Item.IsSelected)
|
||||
return null;
|
||||
// GetHitTest is called to see if the point is
|
||||
// within this glyph. This gives us a chance to decide
|
||||
// what cursor to show. Returning null from here means
|
||||
// the mouse pointer is not currently inside of the glyph.
|
||||
// Returning a valid cursor here indicates the pointer is
|
||||
// inside the glyph, and also enables our Behavior property
|
||||
// as the active behavior.
|
||||
if (Bounds.Contains(p))
|
||||
{
|
||||
return Cursors.SizeAll;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Rectangle CompleteBounds
|
||||
{
|
||||
get
|
||||
{
|
||||
Rectangle bounds = Rectangle.Empty;
|
||||
if (_Item != null && _Item.GetHostControl() != null)
|
||||
{
|
||||
Point edge = _BehaviorSvc.ControlToAdornerWindow(_Item.GetContainerControl());
|
||||
bounds = _Item.ComponentBounds;
|
||||
bounds.Offset(edge);
|
||||
}
|
||||
return bounds;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Paint(PaintEventArgs pe)
|
||||
{
|
||||
// Draw our glyph
|
||||
if (_Item != null)
|
||||
{
|
||||
if (_Item.IsSelected)
|
||||
{
|
||||
Rectangle r = CompleteBounds;
|
||||
r.Width--;
|
||||
r.Height--;
|
||||
Graphics g = pe.Graphics;
|
||||
using(SolidBrush brush=new SolidBrush(Color.FromArgb(129,Color.Red)))
|
||||
{
|
||||
g.FillRectangle(brush, r);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.ComponentModel.Design;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents designer for the ContextMenuBar control.
|
||||
/// </summary>
|
||||
public class ContextMenuBarDesigner : BarDesigner
|
||||
{
|
||||
protected override void PreFilterProperties(System.Collections.IDictionary properties)
|
||||
{
|
||||
base.PreFilterProperties(properties);
|
||||
string[] remove = new string[] {
|
||||
"AccessibleDescription", "AccessibleName", "AccessibleRole",
|
||||
"AlwaysDisplayDockTab", "AlwaysDisplayKeyAccelerators", "AutoCreateCaptionMenu",
|
||||
"AutoHide", "AutoHideAnimationTime", "AutoSyncBarCaption",
|
||||
"BackColor", "BackgroundImage", "BackgroundImageAlpha","BackgroundImageLayout",
|
||||
"BarType", "CanDockBottom", "CanDockTop","CanDockLeft", "CanDockRight", "CanDockTab",
|
||||
"CanHide", "CanReorderTabs", "CanUndock",
|
||||
"DisplayMoreItemsOnMenu", "DockedBorderStyle", "DockOrientation",
|
||||
"DockTabAlignment", "Enabled", "EqualButtonSize",
|
||||
"FadeEffect", "GrabHandleStyle", "ImageSize",
|
||||
"ImagesLarge", "ImagesMedium", "ItemSpacing",
|
||||
"LayoutType", "MenuBar", "PaddingBottom","PaddingTop","PaddingLeft","PaddingRight",
|
||||
"RoundCorners", "SaveLayoutChanges", "SingleLineColor", "SelectedDockTab",
|
||||
"TabNavigation", "ThemeAware",
|
||||
"WrapItemsDock"
|
||||
};
|
||||
foreach(string prop in remove)
|
||||
properties.Remove(prop);
|
||||
}
|
||||
|
||||
public override System.ComponentModel.Design.DesignerVerbCollection Verbs
|
||||
{
|
||||
get
|
||||
{
|
||||
DesignerVerb[] verbs = null;
|
||||
verbs = new DesignerVerb[]
|
||||
{
|
||||
new DesignerVerb("Add Context Menu", new EventHandler(CreateButton))
|
||||
};
|
||||
return new DesignerVerbCollection(verbs);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnitemCreated(BaseItem item)
|
||||
{
|
||||
if (item is ButtonItem) ((ButtonItem)item).AutoExpandOnClick = true;
|
||||
base.OnitemCreated(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,387 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Windows.Forms.Design;
|
||||
using System.Collections;
|
||||
using System.ComponentModel.Design;
|
||||
using System.ComponentModel;
|
||||
using DevComponents.DotNetBar.Rendering;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents VS.NET designer for the CrumbBar control.
|
||||
/// </summary>
|
||||
public class CrumbBarDesigner : ControlDesigner
|
||||
{
|
||||
#region Internal Implementation
|
||||
/// <summary>Initializes designer with given component.</summary>
|
||||
/// <param name="component">Component to initialize designer with.</param>
|
||||
public override void Initialize(IComponent component)
|
||||
{
|
||||
base.Initialize(component);
|
||||
if (!component.Site.DesignMode)
|
||||
return;
|
||||
|
||||
// If our component is removed we need to clean-up
|
||||
IComponentChangeService cc = (IComponentChangeService)GetService(typeof(IComponentChangeService));
|
||||
if (cc != null)
|
||||
{
|
||||
cc.ComponentRemoving += new ComponentEventHandler(this.OnComponentRemoving);
|
||||
}
|
||||
|
||||
#if !TRIAL
|
||||
IDesignerHost dh = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
if (dh != null)
|
||||
dh.LoadComplete += new EventHandler(dh_LoadComplete);
|
||||
#endif
|
||||
}
|
||||
|
||||
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(this.OnComponentRemoving);
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#if FRAMEWORK20
|
||||
public override void InitializeNewComponent(IDictionary defaultValues)
|
||||
{
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#else
|
||||
public override void OnSetComponentDefaults()
|
||||
{
|
||||
base.OnSetComponentDefaults();
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#endif
|
||||
private void SetDesignTimeDefaults()
|
||||
{
|
||||
SetVistaBackgroundStyle();
|
||||
CrumbBar bar = this.Control as CrumbBar;
|
||||
#if (FRAMEWORK20)
|
||||
bar.AutoSize = true;
|
||||
#endif
|
||||
#if !TRIAL
|
||||
string key = RibbonBarDesigner.GetLicenseKey();
|
||||
bar.LicenseKey = key;
|
||||
#endif
|
||||
if(IsMetroHosted())
|
||||
bar.Style = eCrumbBarStyle.Office2007;
|
||||
}
|
||||
|
||||
private bool IsMetroHosted()
|
||||
{
|
||||
IDesignerHost dh = (IDesignerHost)this.GetService(typeof(IDesignerHost));
|
||||
if (dh != null && (dh.RootComponent is DevComponents.DotNetBar.Metro.MetroAppForm || dh.RootComponent is DevComponents.DotNetBar.Metro.MetroForm))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
#if !TRIAL
|
||||
private void dh_LoadComplete(object sender, EventArgs e)
|
||||
{
|
||||
IDesignerHost dh = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
if (dh != null)
|
||||
dh.LoadComplete -= new EventHandler(dh_LoadComplete);
|
||||
|
||||
string key = RibbonBarDesigner.GetLicenseKey();
|
||||
CrumbBar bar = this.Control as CrumbBar;
|
||||
if (key != "" && bar != null && bar.LicenseKey == "" && bar.LicenseKey != key)
|
||||
TypeDescriptor.GetProperties(bar)["LicenseKey"].SetValue(bar, key);
|
||||
}
|
||||
#endif
|
||||
|
||||
private void SetVistaBackgroundStyle()
|
||||
{
|
||||
CrumbBar cb = this.Control as CrumbBar;
|
||||
|
||||
IComponentChangeService cc = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (cc != null)
|
||||
cc.OnComponentChanging(this, TypeDescriptor.GetProperties(cb)["BackgroundStyle"]);
|
||||
|
||||
cb.BackgroundStyle.Reset();
|
||||
cb.BackgroundStyle.Border = eStyleBorderType.Solid;
|
||||
cb.BackgroundStyle.BorderWidth = 1;
|
||||
cb.BackgroundStyle.BorderColor = ColorScheme.GetColor("53595E");
|
||||
cb.BackgroundStyle.BorderColor2 = ColorScheme.GetColor("A9B4BF");
|
||||
cb.BackgroundStyle.BackColor = ColorScheme.GetColor("F8FAFD");
|
||||
if (cc != null)
|
||||
cc.OnComponentChanged(this, TypeDescriptor.GetProperties(cb)["BackgroundStyle"], null, null);
|
||||
|
||||
}
|
||||
|
||||
private void SetOffice2007BackgroundStyle()
|
||||
{
|
||||
CrumbBar cb = this.Control as CrumbBar;
|
||||
|
||||
IComponentChangeService cc = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (cc != null)
|
||||
cc.OnComponentChanging(this, TypeDescriptor.GetProperties(cb)["BackgroundStyle"]);
|
||||
|
||||
cb.BackgroundStyle.Reset();
|
||||
cb.BackgroundStyle.Class = ElementStyleClassKeys.CrumbBarBackgroundKey;
|
||||
|
||||
if (cc != null)
|
||||
cc.OnComponentChanged(this, TypeDescriptor.GetProperties(cb)["BackgroundStyle"], null, null);
|
||||
}
|
||||
|
||||
protected override void PreFilterProperties(System.Collections.IDictionary properties)
|
||||
{
|
||||
base.PreFilterProperties(properties);
|
||||
properties["Style"] = TypeDescriptor.CreateProperty(typeof(CrumbBarDesigner), (PropertyDescriptor)properties["Style"], new Attribute[]
|
||||
{
|
||||
new DefaultValueAttribute(eCrumbBarStyle.Vista),
|
||||
new BrowsableAttribute(true),
|
||||
new CategoryAttribute("Appearance")});
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the visual style of the control. Default value is Windows Vista style.
|
||||
/// </summary>
|
||||
[DefaultValue(eCrumbBarStyle.Vista), Category("Appearance"), Description("Indicates visual style of the control.")]
|
||||
public eCrumbBarStyle Style
|
||||
{
|
||||
get { return ((CrumbBar)this.Control).Style; }
|
||||
set
|
||||
{
|
||||
CrumbBar b = this.Control as CrumbBar;
|
||||
bool isChanged = (b.Style != value);
|
||||
b.Style = value;
|
||||
if (isChanged)
|
||||
{
|
||||
IDesignerHost ds = GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
if (ds != null && !ds.Loading)
|
||||
{
|
||||
if (value == eCrumbBarStyle.Vista)
|
||||
SetVistaBackgroundStyle();
|
||||
else if (value == eCrumbBarStyle.Office2007)
|
||||
SetOffice2007BackgroundStyle();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Returns design-time commands applicable to this designer.</summary>
|
||||
public override DesignerVerbCollection Verbs
|
||||
{
|
||||
get
|
||||
{
|
||||
DesignerVerb[] verbs = null;
|
||||
#if (FRAMEWORK20)
|
||||
verbs = new DesignerVerb[]
|
||||
{
|
||||
new DesignerVerb("Edit Items...", new EventHandler(EditItems))
|
||||
};
|
||||
#else
|
||||
verbs = new DesignerVerb[]
|
||||
{
|
||||
new DesignerVerb("Create Item", new EventHandler(CreateItem))
|
||||
};
|
||||
#endif
|
||||
return new DesignerVerbCollection(verbs);
|
||||
}
|
||||
}
|
||||
|
||||
private void EditItems(object sender, EventArgs e)
|
||||
{
|
||||
EditItems();
|
||||
}
|
||||
|
||||
internal void EditItems()
|
||||
{
|
||||
CrumbBar crumbBar = this.Component as CrumbBar;
|
||||
#if (FRAMEWORK20)
|
||||
Form form = new Form();
|
||||
form.Text = "CrumbBar control editor";
|
||||
form.FormBorderStyle = FormBorderStyle.Sizable;
|
||||
form.MinimizeBox = false;
|
||||
form.StartPosition = FormStartPosition.CenterScreen;
|
||||
CrumbBarItemsEditor editor = new CrumbBarItemsEditor();
|
||||
editor.Dock = DockStyle.Fill;
|
||||
form.Size = new System.Drawing.Size(800, 600);
|
||||
form.Controls.Add(editor);
|
||||
|
||||
editor.CrumbBar = crumbBar;
|
||||
editor.Designer = this;
|
||||
editor.UpdateDisplay();
|
||||
form.ShowDialog();
|
||||
form.Dispose();
|
||||
#else
|
||||
DevComponents.AdvTree.Design.AdvTreeDesigner.EditValue(this, crumbBar, "Items");
|
||||
#endif
|
||||
}
|
||||
|
||||
private void CreateItem(object sender, EventArgs e)
|
||||
{
|
||||
CreateItem();
|
||||
}
|
||||
|
||||
internal void CreateItem()
|
||||
{
|
||||
CrumbBarItem node = CreateItem(this.Component as CrumbBar);
|
||||
if (node != null)
|
||||
{
|
||||
ISelectionService sel = this.GetService(typeof(ISelectionService)) as ISelectionService;
|
||||
ArrayList list = new ArrayList(1);
|
||||
list.Add(node);
|
||||
if (sel != null)
|
||||
{
|
||||
sel.SetSelectedComponents(list, SelectionTypes.MouseDown);
|
||||
CrumbBar crumbBar = this.Component as CrumbBar;
|
||||
if (crumbBar != null && crumbBar.SelectedItem == null)
|
||||
crumbBar.SelectedItem = node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public object GetDesignService(Type serviceType)
|
||||
{
|
||||
return GetService(serviceType);
|
||||
}
|
||||
|
||||
private CrumbBarItem CreateItem(CrumbBar crumbBar)
|
||||
{
|
||||
IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
if (dh == null)
|
||||
return null;
|
||||
|
||||
CrumbBarItem node = null;
|
||||
try
|
||||
{
|
||||
IComponentChangeService change = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (change != null)
|
||||
{
|
||||
change.OnComponentChanging(this.Component, TypeDescriptor.GetProperties(crumbBar).Find("Items", true));
|
||||
}
|
||||
|
||||
node = dh.CreateComponent(typeof(CrumbBarItem)) as CrumbBarItem;
|
||||
if (node != null)
|
||||
{
|
||||
node.Text = node.Name;
|
||||
crumbBar.Items.Add(node);
|
||||
|
||||
if (change != null)
|
||||
change.OnComponentChanged(this.Component, TypeDescriptor.GetProperties(crumbBar).Find("Items", true), null, null);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
crumbBar.RecalcLayout();
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
/// <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(this.AssociatedComponents);
|
||||
foreach (IComponent c in list)
|
||||
dh.DestroyComponent(c);
|
||||
}
|
||||
else if (e.Component is CrumbBarItem && ((CrumbBarItem)e.Component).GetOwner() == this.Control)
|
||||
{
|
||||
OnNodeRemoving(e.Component as CrumbBarItem);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnNodeRemoving(CrumbBarItem node)
|
||||
{
|
||||
IComponentChangeService cc = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
|
||||
// Root node
|
||||
CrumbBar tree = this.Control as CrumbBar;
|
||||
bool wasSelected = tree.GetIsInSelectedPath(node);
|
||||
|
||||
if (node.Parent != null)
|
||||
{
|
||||
CrumbBarItem parent = node.Parent as CrumbBarItem;
|
||||
if (parent != null)
|
||||
{
|
||||
if (cc != null)
|
||||
cc.OnComponentChanging(parent, TypeDescriptor.GetProperties(parent)["SubItems"]);
|
||||
parent.SubItems.Remove(node);
|
||||
if (cc != null)
|
||||
cc.OnComponentChanged(parent, TypeDescriptor.GetProperties(parent)["SubItems"], null, null);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cc != null)
|
||||
cc.OnComponentChanging(tree, TypeDescriptor.GetProperties(tree)["Items"]);
|
||||
tree.Items.Remove(node);
|
||||
if (cc != null)
|
||||
cc.OnComponentChanged(tree, TypeDescriptor.GetProperties(tree)["Items"], null, null);
|
||||
}
|
||||
|
||||
if (node.SubItems.Count > 0)
|
||||
{
|
||||
BaseItem[] nodes = new BaseItem[node.SubItems.Count];
|
||||
node.SubItems.CopyTo(nodes, 0);
|
||||
foreach (BaseItem n in nodes)
|
||||
{
|
||||
node.SubItems.Remove(n);
|
||||
|
||||
if (dh != null)
|
||||
dh.DestroyComponent(n);
|
||||
}
|
||||
}
|
||||
|
||||
if (wasSelected)
|
||||
{
|
||||
tree.SelectedItem = tree.GetFirstVisibleItem();
|
||||
}
|
||||
|
||||
this.RecalcLayout();
|
||||
}
|
||||
|
||||
private void RecalcLayout()
|
||||
{
|
||||
CrumbBar tree = this.Control as CrumbBar;
|
||||
if (tree != null) tree.RecalcLayout();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns all components associated with this control
|
||||
/// </summary>
|
||||
public override ICollection AssociatedComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
ArrayList c = new ArrayList(base.AssociatedComponents);
|
||||
CrumbBar tree = this.Control as CrumbBar;
|
||||
if (tree != null)
|
||||
{
|
||||
foreach (BaseItem node in tree.Items)
|
||||
GetItemsRecursive(node, c);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
private void GetItemsRecursive(BaseItem parent, ArrayList c)
|
||||
{
|
||||
c.Add(parent);
|
||||
foreach (BaseItem node in parent.SubItems)
|
||||
{
|
||||
c.Add(node);
|
||||
GetItemsRecursive(node, c);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Support for ColumnHeader tabs design-time editor.
|
||||
/// </summary>
|
||||
public class CrumbBarItemCollectionEditor : System.ComponentModel.Design.CollectionEditor
|
||||
{
|
||||
/// <summary>Creates new instance of the class</summary>
|
||||
/// <param name="type">Type to initialize editor with.</param>
|
||||
public CrumbBarItemCollectionEditor(Type type)
|
||||
: base(type)
|
||||
{
|
||||
}
|
||||
protected override Type CreateCollectionItemType()
|
||||
{
|
||||
return typeof(CrumbBarItem);
|
||||
}
|
||||
protected override Type[] CreateNewItemTypes()
|
||||
{
|
||||
return new Type[] { typeof(CrumbBarItem) };
|
||||
}
|
||||
protected override object CreateInstance(Type itemType)
|
||||
{
|
||||
object item = base.CreateInstance(itemType);
|
||||
if (item is CrumbBarItem)
|
||||
{
|
||||
CrumbBarItem ch = item as CrumbBarItem;
|
||||
ch.Text = ch.Name;
|
||||
}
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Collections;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
public class CrumbBarItemDesigner : ComponentDesigner
|
||||
{
|
||||
#region Internal Implementation
|
||||
public override System.Collections.ICollection AssociatedComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
ArrayList c = new ArrayList(base.AssociatedComponents);
|
||||
CrumbBarItem item = this.Component as CrumbBarItem;
|
||||
if (item != null)
|
||||
{
|
||||
foreach (BaseItem node in item.SubItems)
|
||||
GetItemsRecursive(node, c);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
}
|
||||
private void GetItemsRecursive(BaseItem parent, ArrayList c)
|
||||
{
|
||||
c.Add(parent);
|
||||
foreach (BaseItem node in parent.SubItems)
|
||||
{
|
||||
c.Add(node);
|
||||
GetItemsRecursive(node, c);
|
||||
}
|
||||
}
|
||||
|
||||
#if FRAMEWORK20
|
||||
public override void InitializeNewComponent(IDictionary defaultValues)
|
||||
{
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#else
|
||||
public override void OnSetComponentDefaults()
|
||||
{
|
||||
base.OnSetComponentDefaults();
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#endif
|
||||
private void SetDesignTimeDefaults()
|
||||
{
|
||||
CrumbBarItem item = this.Component as CrumbBarItem;
|
||||
item.Text = item.Name;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,610 @@
|
||||
#if FRAMEWORK20
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using DevComponents.DotNetBar;
|
||||
using DevComponents.DotNetBar.Design;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Drawing.Imaging;
|
||||
using DevComponents.DotNetBar.Rendering;
|
||||
using DevComponents.AdvTree;
|
||||
using System.Windows.Forms.Design;
|
||||
using System.Reflection;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
internal class CrumbBarItemsEditor : UserControl
|
||||
{
|
||||
#region Private Variables
|
||||
private DevComponents.AdvTree.AdvTree advTree1;
|
||||
private DevComponents.AdvTree.Node node1;
|
||||
private DevComponents.DotNetBar.ElementStyle elementStyle1;
|
||||
private DevComponents.DotNetBar.ButtonX buttonAddItem;
|
||||
private DevComponents.AdvTree.ColumnHeader columnHeader1;
|
||||
private DevComponents.AdvTree.ColumnHeader columnHeader2;
|
||||
private DevComponents.DotNetBar.ButtonX buttonRemoveItem;
|
||||
private System.Windows.Forms.PropertyGrid propertyGrid1;
|
||||
internal DevComponents.DotNetBar.ButtonX buttonX1;
|
||||
|
||||
private CrumbBar _CrumbBar = null;
|
||||
private Label label1;
|
||||
private CrumbBarDesigner _Designer = null;
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
public CrumbBarItemsEditor()
|
||||
{
|
||||
InitializeComponent();
|
||||
#if (!TRIAL)
|
||||
this.advTree1.LicenseKey = "F962CEC7-CD8F-4911-A9E9-CAB39962FC1F";
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <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);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#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.propertyGrid1 = new System.Windows.Forms.PropertyGrid();
|
||||
this.buttonX1 = new DevComponents.DotNetBar.ButtonX();
|
||||
this.buttonRemoveItem = new DevComponents.DotNetBar.ButtonX();
|
||||
this.buttonAddItem = new DevComponents.DotNetBar.ButtonX();
|
||||
this.advTree1 = new DevComponents.AdvTree.AdvTree();
|
||||
this.columnHeader1 = new DevComponents.AdvTree.ColumnHeader();
|
||||
this.columnHeader2 = new DevComponents.AdvTree.ColumnHeader();
|
||||
this.node1 = new DevComponents.AdvTree.Node();
|
||||
this.elementStyle1 = new DevComponents.DotNetBar.ElementStyle();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
((System.ComponentModel.ISupportInitialize)(this.advTree1)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// propertyGrid1
|
||||
//
|
||||
this.propertyGrid1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.propertyGrid1.Location = new System.Drawing.Point(300, 3);
|
||||
this.propertyGrid1.Name = "propertyGrid1";
|
||||
this.propertyGrid1.Size = new System.Drawing.Size(284, 331);
|
||||
this.propertyGrid1.TabIndex = 4;
|
||||
this.propertyGrid1.PropertyValueChanged += new System.Windows.Forms.PropertyValueChangedEventHandler(this.propertyGrid1_PropertyValueChanged);
|
||||
//
|
||||
// buttonX1
|
||||
//
|
||||
this.buttonX1.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
this.buttonX1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonX1.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
|
||||
this.buttonX1.Location = new System.Drawing.Point(515, 341);
|
||||
this.buttonX1.Name = "buttonX1";
|
||||
this.buttonX1.Shape = new DevComponents.DotNetBar.RoundRectangleShapeDescriptor();
|
||||
this.buttonX1.Size = new System.Drawing.Size(69, 24);
|
||||
this.buttonX1.TabIndex = 5;
|
||||
this.buttonX1.Text = "&Close";
|
||||
this.buttonX1.Click += new System.EventHandler(this.buttonX1_Click);
|
||||
//
|
||||
// buttonRemoveItem
|
||||
//
|
||||
this.buttonRemoveItem.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
this.buttonRemoveItem.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.buttonRemoveItem.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
|
||||
this.buttonRemoveItem.Enabled = false;
|
||||
this.buttonRemoveItem.FocusCuesEnabled = false;
|
||||
this.buttonRemoveItem.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.buttonRemoveItem.Location = new System.Drawing.Point(32, 341);
|
||||
this.buttonRemoveItem.Name = "buttonRemoveItem";
|
||||
this.buttonRemoveItem.Shape = new DevComponents.DotNetBar.RoundRectangleShapeDescriptor();
|
||||
this.buttonRemoveItem.Size = new System.Drawing.Size(24, 24);
|
||||
this.buttonRemoveItem.TabIndex = 3;
|
||||
this.buttonRemoveItem.Click += new System.EventHandler(this.buttonRemoveItem_Click);
|
||||
//
|
||||
// buttonAddItem
|
||||
//
|
||||
this.buttonAddItem.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
this.buttonAddItem.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.buttonAddItem.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
|
||||
this.buttonAddItem.FocusCuesEnabled = false;
|
||||
this.buttonAddItem.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.buttonAddItem.Location = new System.Drawing.Point(4, 341);
|
||||
this.buttonAddItem.Name = "buttonAddItem";
|
||||
this.buttonAddItem.Shape = new DevComponents.DotNetBar.RoundRectangleShapeDescriptor();
|
||||
this.buttonAddItem.Size = new System.Drawing.Size(24, 24);
|
||||
this.buttonAddItem.TabIndex = 1;
|
||||
this.buttonAddItem.Click += new System.EventHandler(this.buttonAddItem_Click);
|
||||
//
|
||||
// advTree1
|
||||
//
|
||||
this.advTree1.AccessibleRole = System.Windows.Forms.AccessibleRole.Outline;
|
||||
this.advTree1.AllowDrop = true;
|
||||
this.advTree1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.advTree1.BackColor = System.Drawing.SystemColors.Window;
|
||||
//
|
||||
//
|
||||
//
|
||||
this.advTree1.BackgroundStyle.Class = "TreeBorderKey";
|
||||
this.advTree1.Columns.Add(this.columnHeader1);
|
||||
this.advTree1.Columns.Add(this.columnHeader2);
|
||||
this.advTree1.ExpandButtonType = DevComponents.AdvTree.eExpandButtonType.Triangle;
|
||||
this.advTree1.ExpandWidth = 18;
|
||||
this.advTree1.Location = new System.Drawing.Point(3, 3);
|
||||
this.advTree1.Name = "advTree1";
|
||||
this.advTree1.Nodes.AddRange(new DevComponents.AdvTree.Node[] {
|
||||
this.node1});
|
||||
this.advTree1.NodeStyle = this.elementStyle1;
|
||||
this.advTree1.PathSeparator = ";";
|
||||
this.advTree1.SelectionBoxStyle = DevComponents.AdvTree.eSelectionStyle.FullRowSelect;
|
||||
this.advTree1.Size = new System.Drawing.Size(291, 332);
|
||||
this.advTree1.Styles.Add(this.elementStyle1);
|
||||
this.advTree1.SuspendPaint = false;
|
||||
this.advTree1.TabIndex = 0;
|
||||
this.advTree1.Text = "advTree1";
|
||||
this.advTree1.AfterNodeDrop += new DevComponents.AdvTree.TreeDragDropEventHandler(this.advTree1_AfterNodeDrop);
|
||||
this.advTree1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.advTree1_MouseUp);
|
||||
this.advTree1.AfterNodeSelect += new DevComponents.AdvTree.AdvTreeNodeEventHandler(this.advTree1_AfterNodeSelect);
|
||||
//
|
||||
// columnHeader1
|
||||
//
|
||||
this.columnHeader1.Name = "columnHeader1";
|
||||
this.columnHeader1.Text = "Text";
|
||||
this.columnHeader1.Width.Relative = 70;
|
||||
//
|
||||
// columnHeader2
|
||||
//
|
||||
this.columnHeader2.Name = "columnHeader2";
|
||||
this.columnHeader2.Text = "Name";
|
||||
this.columnHeader2.Width.Relative = 30;
|
||||
//
|
||||
// node1
|
||||
//
|
||||
this.node1.Expanded = true;
|
||||
this.node1.Name = "node1";
|
||||
this.node1.Text = "node1";
|
||||
//
|
||||
// elementStyle1
|
||||
//
|
||||
this.elementStyle1.Name = "elementStyle1";
|
||||
this.elementStyle1.TextColor = System.Drawing.SystemColors.ControlText;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(153, 352);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(141, 13);
|
||||
this.label1.TabIndex = 6;
|
||||
this.label1.Text = "Drag && drop items to re-order";
|
||||
this.label1.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
//
|
||||
// CrumbBarItemsEditor
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = Color.White;
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.buttonX1);
|
||||
this.Controls.Add(this.propertyGrid1);
|
||||
this.Controls.Add(this.buttonRemoveItem);
|
||||
this.Controls.Add(this.buttonAddItem);
|
||||
this.Controls.Add(this.advTree1);
|
||||
this.Name = "CrumbBarItemsEditor";
|
||||
this.Size = new System.Drawing.Size(587, 373);
|
||||
this.Load += new System.EventHandler(this.CrumbBarItemsEditor_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.advTree1)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
|
||||
private object GetDesignService(Type serviceType)
|
||||
{
|
||||
if (_Designer != null)
|
||||
{
|
||||
return _Designer.GetDesignService(serviceType);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private CrumbBarItem CreateItem()
|
||||
{
|
||||
IDesignerHost dh = (IDesignerHost)GetDesignService(typeof(IDesignerHost));
|
||||
if (dh == null)
|
||||
return null;
|
||||
|
||||
CrumbBarItem item = (CrumbBarItem)dh.CreateComponent(typeof(CrumbBarItem));
|
||||
item.Text = item.Name;
|
||||
return item;
|
||||
}
|
||||
|
||||
private void AddNewItem()
|
||||
{
|
||||
AddNewItem(null);
|
||||
}
|
||||
|
||||
private void AddNewItem(CrumbBarItem parent)
|
||||
{
|
||||
IDesignerHost dh = (IDesignerHost)GetDesignService(typeof(IDesignerHost));
|
||||
DesignerTransaction dt = null;
|
||||
if (dh != null)
|
||||
{
|
||||
dt = dh.CreateTransaction("New CrumbBarItem");
|
||||
}
|
||||
bool isEmpty = advTree1.Nodes.Count == 0;
|
||||
CrumbBarItem item = CreateItem();
|
||||
if (item == null) return;
|
||||
|
||||
IComponentChangeService cc = GetDesignService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (cc != null)
|
||||
{
|
||||
if (parent == null)
|
||||
cc.OnComponentChanging(_CrumbBar, TypeDescriptor.GetProperties(_CrumbBar)["Items"]);
|
||||
else
|
||||
cc.OnComponentChanging(parent, TypeDescriptor.GetProperties(parent)["SubItems"]);
|
||||
}
|
||||
|
||||
if (parent == null)
|
||||
_CrumbBar.Items.Add(item);
|
||||
else
|
||||
parent.SubItems.Add(item);
|
||||
|
||||
if (cc != null)
|
||||
{
|
||||
if (parent == null)
|
||||
cc.OnComponentChanged(_CrumbBar, TypeDescriptor.GetProperties(_CrumbBar)["Items"], null, null);
|
||||
else
|
||||
cc.OnComponentChanged(parent, TypeDescriptor.GetProperties(parent)["SubItems"], null, null);
|
||||
}
|
||||
|
||||
if (dt != null)
|
||||
dt.Commit();
|
||||
|
||||
if (parent == null)
|
||||
advTree1.Nodes.Add(CreateNodeForItem(item));
|
||||
else
|
||||
{
|
||||
advTree1.SelectedNode.Nodes.Add(CreateNodeForItem(item));
|
||||
advTree1.SelectedNode.Expand();
|
||||
}
|
||||
|
||||
if (isEmpty && advTree1.SelectedNode == null && advTree1.Nodes.Count > 0)
|
||||
advTree1.SelectedNode = advTree1.Nodes[0];
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void CrumbBarItemsEditor_Load(object sender, EventArgs e)
|
||||
{
|
||||
Bitmap img = new Bitmap(16, 16, PixelFormat.Format32bppArgb);
|
||||
Color c = Color.DarkGray;
|
||||
if (GlobalManager.Renderer is Office2007Renderer)
|
||||
c = ((Office2007Renderer)GlobalManager.Renderer).ColorTable.CheckBoxItem.Default.Text;
|
||||
using (Graphics g = Graphics.FromImage(img))
|
||||
{
|
||||
using (Brush brush = new SolidBrush(c))
|
||||
{
|
||||
g.FillRectangle(brush, 7, 2, 3, 13);
|
||||
g.FillRectangle(brush, 2, 7, 13, 3);
|
||||
}
|
||||
}
|
||||
buttonAddItem.Image = img;
|
||||
|
||||
img = new Bitmap(16, 16, PixelFormat.Format32bppArgb);
|
||||
using (Graphics g = Graphics.FromImage(img))
|
||||
{
|
||||
using (Brush brush = new SolidBrush(c))
|
||||
{
|
||||
g.FillRectangle(brush, 2, 7, 13, 3);
|
||||
}
|
||||
}
|
||||
buttonRemoveItem.Image = img;
|
||||
|
||||
#if (FRAMEWORK20)
|
||||
IUIService service = GetDesignService(typeof(IUIService)) as IUIService;
|
||||
if (service != null)
|
||||
{
|
||||
PropertyInfo pi = propertyGrid1.GetType().GetProperty("ToolStripRenderer", System.Reflection.BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
|
||||
if (pi != null)
|
||||
{
|
||||
pi.SetValue(propertyGrid1, (ToolStripProfessionalRenderer)service.Styles["VsToolWindowRenderer"], null);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private void advTree1_MouseUp(object sender, MouseEventArgs e)
|
||||
{
|
||||
Node node = advTree1.GetNodeAt(e.Y);
|
||||
if (node == null) advTree1.SelectedNode = null;
|
||||
}
|
||||
|
||||
internal void UpdateDisplay()
|
||||
{
|
||||
advTree1.Nodes.Clear();
|
||||
if (_CrumbBar == null) return;
|
||||
|
||||
advTree1.BeginUpdate();
|
||||
|
||||
foreach (CrumbBarItem item in _CrumbBar.Items)
|
||||
{
|
||||
Node node = CreateNodeForItem(item);
|
||||
advTree1.Nodes.Add(node);
|
||||
LoadSubItems(node, item);
|
||||
}
|
||||
|
||||
advTree1.EndUpdate();
|
||||
}
|
||||
|
||||
private void LoadSubItems(Node parent, CrumbBarItem item)
|
||||
{
|
||||
foreach (BaseItem o in item.SubItems)
|
||||
{
|
||||
if (o is CrumbBarItem)
|
||||
{
|
||||
CrumbBarItem cb = (CrumbBarItem)o;
|
||||
Node node = CreateNodeForItem(cb);
|
||||
parent.Nodes.Add(node);
|
||||
LoadSubItems(node, cb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Node CreateNodeForItem(CrumbBarItem item)
|
||||
{
|
||||
Node node = new Node();
|
||||
node.Expanded = true;
|
||||
node.Tag = item;
|
||||
node.Text = item.Text;
|
||||
node.Image = item.GetItemImage();
|
||||
node.Cells.Add(new Cell(item.Name));
|
||||
return node;
|
||||
}
|
||||
|
||||
public CrumbBarDesigner Designer
|
||||
{
|
||||
get { return _Designer; }
|
||||
set
|
||||
{
|
||||
_Designer = value;
|
||||
if(_Designer!=null)
|
||||
this.propertyGrid1.Site = new PropertyGridSite((IServiceProvider)_Designer.Component.Site, this.propertyGrid1);
|
||||
}
|
||||
}
|
||||
|
||||
public CrumbBar CrumbBar
|
||||
{
|
||||
get { return _CrumbBar; }
|
||||
set
|
||||
{
|
||||
if (value != _CrumbBar)
|
||||
{
|
||||
CrumbBar oldValue = _CrumbBar;
|
||||
_CrumbBar = value;
|
||||
OnCrumbBarChanged(oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCrumbBarChanged(CrumbBar oldValue, CrumbBar newValue)
|
||||
{
|
||||
UpdateDisplay();
|
||||
}
|
||||
|
||||
private void buttonAddItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
CrumbBarItem parent = null;
|
||||
if (advTree1.SelectedNode != null) parent = advTree1.SelectedNode.Tag as CrumbBarItem;
|
||||
AddNewItem(parent);
|
||||
}
|
||||
|
||||
private void buttonRemoveItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (advTree1.SelectedNode == null) return;
|
||||
CrumbBarItem item = advTree1.SelectedNode.Tag as CrumbBarItem;
|
||||
if (item == null) return;
|
||||
advTree1.SelectedNode.Remove();
|
||||
DeleteItem(item);
|
||||
}
|
||||
|
||||
private void DeleteItem(CrumbBarItem item)
|
||||
{
|
||||
IDesignerHost dh = (IDesignerHost)GetDesignService(typeof(IDesignerHost));
|
||||
if (dh == null)
|
||||
return;
|
||||
dh.DestroyComponent(item);
|
||||
}
|
||||
|
||||
private void advTree1_AfterNodeSelect(object sender, AdvTreeNodeEventArgs e)
|
||||
{
|
||||
buttonRemoveItem.Enabled = e.Node != null;
|
||||
if (e.Node != null)
|
||||
propertyGrid1.SelectedObject = e.Node.Tag;
|
||||
else
|
||||
propertyGrid1.SelectedObject = null;
|
||||
}
|
||||
|
||||
private void advTree1_AfterNodeDrop(object sender, TreeDragDropEventArgs e)
|
||||
{
|
||||
IDesignerHost dh = (IDesignerHost)GetDesignService(typeof(IDesignerHost));
|
||||
DesignerTransaction dt = null;
|
||||
if (dh != null) dt = dh.CreateTransaction("Move items");
|
||||
|
||||
IComponentChangeService cc = GetDesignService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
|
||||
try
|
||||
{
|
||||
CrumbBarItem movedItem = e.Node.Tag as CrumbBarItem;
|
||||
CrumbBarItem parent = (CrumbBarItem)movedItem.Parent;
|
||||
if (cc != null)
|
||||
{
|
||||
if (parent == null)
|
||||
cc.OnComponentChanging(_CrumbBar, TypeDescriptor.GetProperties(_CrumbBar)["Items"]);
|
||||
else
|
||||
cc.OnComponentChanging(parent, TypeDescriptor.GetProperties(parent)["SubItems"]);
|
||||
}
|
||||
|
||||
if (parent == null)
|
||||
_CrumbBar.Items.Remove(movedItem);
|
||||
else
|
||||
parent.SubItems.Remove(movedItem);
|
||||
|
||||
if (cc != null)
|
||||
{
|
||||
if (parent == null)
|
||||
cc.OnComponentChanged(_CrumbBar, TypeDescriptor.GetProperties(_CrumbBar)["Items"], null, null);
|
||||
else
|
||||
cc.OnComponentChanged(parent, TypeDescriptor.GetProperties(parent)["SubItems"], null, null);
|
||||
}
|
||||
|
||||
if (e.NewParentNode == null)
|
||||
{
|
||||
int index = advTree1.Nodes.IndexOf(e.Node);
|
||||
if (cc != null) cc.OnComponentChanging(_CrumbBar, TypeDescriptor.GetProperties(_CrumbBar)["Items"]);
|
||||
_CrumbBar.Items.Insert(index, movedItem);
|
||||
if (cc != null) cc.OnComponentChanged(_CrumbBar, TypeDescriptor.GetProperties(_CrumbBar)["Items"], null, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
parent = e.NewParentNode.Tag as CrumbBarItem;
|
||||
int index = e.NewParentNode.Nodes.IndexOf(e.Node);
|
||||
if (cc != null) cc.OnComponentChanging(parent, TypeDescriptor.GetProperties(parent)["SubItems"]);
|
||||
parent.SubItems.Insert(index, movedItem);
|
||||
if (cc != null) cc.OnComponentChanged(parent, TypeDescriptor.GetProperties(parent)["SubItems"], null, null);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (dt != null)
|
||||
dt.Cancel();
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (dt != null && !dt.Canceled)
|
||||
dt.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
private void propertyGrid1_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
|
||||
{
|
||||
if (advTree1.SelectedNode == null) return;
|
||||
Node node = advTree1.SelectedNode;
|
||||
CrumbBarItem item = (CrumbBarItem)propertyGrid1.SelectedObject;
|
||||
if (e.ChangedItem.PropertyDescriptor.Name == "Text")
|
||||
{
|
||||
node.Text = item.Text;
|
||||
}
|
||||
else if (e.ChangedItem.PropertyDescriptor.Name == "Image" || e.ChangedItem.PropertyDescriptor.Name=="ImageIndex")
|
||||
{
|
||||
node.Image = item.GetItemImage();
|
||||
}
|
||||
else if (e.ChangedItem.PropertyDescriptor.Name == "Name")
|
||||
{
|
||||
node.Cells[1].Text = item.Name;
|
||||
}
|
||||
}
|
||||
|
||||
#region PropertyGridSite
|
||||
internal class PropertyGridSite : ISite, IServiceProvider
|
||||
{
|
||||
// Fields
|
||||
private IComponent comp;
|
||||
private bool inGetService;
|
||||
private IServiceProvider sp;
|
||||
|
||||
// Methods
|
||||
public PropertyGridSite(IServiceProvider sp, IComponent comp)
|
||||
{
|
||||
this.sp = sp;
|
||||
this.comp = comp;
|
||||
}
|
||||
|
||||
public object GetService(Type t)
|
||||
{
|
||||
if (!this.inGetService && (this.sp != null))
|
||||
{
|
||||
try
|
||||
{
|
||||
this.inGetService = true;
|
||||
return this.sp.GetService(t);
|
||||
}
|
||||
finally
|
||||
{
|
||||
this.inGetService = false;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Properties
|
||||
public IComponent Component
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.comp;
|
||||
}
|
||||
}
|
||||
|
||||
public IContainer Container
|
||||
{
|
||||
get
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public bool DesignMode
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void buttonX1_Click(object sender, EventArgs e)
|
||||
{
|
||||
Form form = this.FindForm();
|
||||
if (form != null) form.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,106 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms.Design;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
public class CustomTypeEditorProvider : ITypeDescriptorContext, IWindowsFormsEditorService
|
||||
{
|
||||
#region Private Variables, Constructor
|
||||
private IContainer m_Container = null;
|
||||
private object m_Instance = null;
|
||||
private IServiceProvider m_Provider = null;
|
||||
private PropertyDescriptor m_PropertyDescriptor = null;
|
||||
|
||||
public CustomTypeEditorProvider(IContainer container, IServiceProvider provider)
|
||||
{
|
||||
m_Container = container;
|
||||
m_Provider = provider;
|
||||
}
|
||||
|
||||
public void SetInstance(object instance, PropertyDescriptor desc)
|
||||
{
|
||||
m_Instance = instance;
|
||||
m_PropertyDescriptor = desc;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ITypeDescriptorContext Members
|
||||
|
||||
public IContainer Container
|
||||
{
|
||||
get { return m_Container; }
|
||||
}
|
||||
|
||||
public object Instance
|
||||
{
|
||||
get { return m_Instance; }
|
||||
}
|
||||
|
||||
public void OnComponentChanged()
|
||||
{
|
||||
IComponentChangeService cc = m_Provider.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (cc != null)
|
||||
cc.OnComponentChanged(m_Instance, m_PropertyDescriptor, null, null);
|
||||
}
|
||||
|
||||
public bool OnComponentChanging()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public PropertyDescriptor PropertyDescriptor
|
||||
{
|
||||
get { return m_PropertyDescriptor; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IServiceProvider Members
|
||||
|
||||
public object GetService(Type serviceType)
|
||||
{
|
||||
return m_Provider.GetService(serviceType);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IWindowsFormsEditorService Members
|
||||
|
||||
public void CloseDropDown()
|
||||
{
|
||||
throw new Exception("The method or operation is not implemented.");
|
||||
}
|
||||
|
||||
public void DropDownControl(System.Windows.Forms.Control control)
|
||||
{
|
||||
throw new Exception("The method or operation is not implemented.");
|
||||
}
|
||||
|
||||
public System.Windows.Forms.DialogResult ShowDialog(System.Windows.Forms.Form dialog)
|
||||
{
|
||||
DialogResult result;
|
||||
|
||||
IntPtr focushWnd = WinApi.GetFocus();
|
||||
IUIService uiService = (IUIService)this.GetService(typeof(IUIService));
|
||||
if (uiService != null)
|
||||
{
|
||||
result = uiService.ShowDialog(dialog);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dialog.ShowDialog();
|
||||
}
|
||||
if (focushWnd != IntPtr.Zero)
|
||||
{
|
||||
WinApi.SetFocus(focushWnd);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing.Design;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms.Design;
|
||||
using System.Windows.Forms;
|
||||
using System.Threading;
|
||||
using System.Collections;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
public class DataMembersSelector : UITypeEditor
|
||||
{
|
||||
#region Constructor
|
||||
private CheckedListBoxSelector _ListSelector;
|
||||
private BindingContext _BindingContext;
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the DataMembersSelector class.
|
||||
/// </summary>
|
||||
public DataMembersSelector()
|
||||
{
|
||||
_ListSelector = new CheckedListBoxSelector();
|
||||
_BindingContext = new BindingContext();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Implementation
|
||||
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
|
||||
{
|
||||
if (context != null
|
||||
&& context.Instance != null
|
||||
&& provider != null)
|
||||
{
|
||||
IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
|
||||
if (edSvc != null)
|
||||
{
|
||||
PropertyDescriptor descriptor = TypeDescriptor.GetProperties(context.Instance)["DataSource"];
|
||||
if (descriptor == null)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
object dataSource = descriptor.GetValue(context.Instance);
|
||||
LoadDataMembers(_ListSelector, dataSource, value);
|
||||
|
||||
edSvc.DropDownControl(_ListSelector);
|
||||
|
||||
string returnValue = "";
|
||||
foreach (string item in _ListSelector.ListBox.CheckedItems)
|
||||
{
|
||||
if (returnValue.Length > 0) returnValue += ",";
|
||||
returnValue += item;
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
private bool IsSelected(string str,ref string[] selected)
|
||||
{
|
||||
string strl = str.ToLower();
|
||||
for (int i = 0; i < selected.Length; i++)
|
||||
{
|
||||
string item = selected[i];
|
||||
if (item.Trim().ToLower() == strl)
|
||||
{
|
||||
selected[i] = str;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private void LoadDataMembers(CheckedListBoxSelector listSelector, object dataSource, object value)
|
||||
{
|
||||
listSelector.ListBox.Items.Clear();
|
||||
string v = value as string;
|
||||
if (v == null) v = "";
|
||||
string[] selected = v.Split(',');
|
||||
string dataMember = string.Empty;
|
||||
|
||||
if (dataSource is Type)
|
||||
{
|
||||
try
|
||||
{
|
||||
BindingSource source = new BindingSource();
|
||||
source.DataSource = dataSource;
|
||||
dataSource = source.List;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
if (IsCriticalException(exception))
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
if (this.IsBindableDataSource(dataSource))
|
||||
{
|
||||
PropertyDescriptorCollection properties = GetItemProperties(dataSource, string.Empty);
|
||||
if (properties == null)
|
||||
return;
|
||||
for (int i = 0; i < properties.Count; i++)
|
||||
{
|
||||
PropertyDescriptor property = properties[i];
|
||||
if (this.IsBindableDataMember(property))
|
||||
{
|
||||
string str = string.IsNullOrEmpty(dataMember) ? property.Name : (dataMember + "." + property.Name);
|
||||
_ListSelector.ListBox.Items.Add(str, IsSelected(str,ref selected));
|
||||
}
|
||||
}
|
||||
if (selected.Length > 1)
|
||||
{
|
||||
for (int i = 0; i < selected.Length; i++)
|
||||
{
|
||||
string s1 = selected[i];
|
||||
int i1 = _ListSelector.ListBox.Items.IndexOf(s1);
|
||||
_ListSelector.ListBox.Items.RemoveAt(i1);
|
||||
_ListSelector.ListBox.Items.Insert(i, s1);
|
||||
_ListSelector.ListBox.SetItemChecked(i, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsBindableDataMember(PropertyDescriptor property)
|
||||
{
|
||||
if (!typeof(byte[]).IsAssignableFrom(property.PropertyType))
|
||||
{
|
||||
ListBindableAttribute attribute = (ListBindableAttribute)property.Attributes[typeof(ListBindableAttribute)];
|
||||
if ((attribute != null) && !attribute.ListBindable)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private PropertyDescriptorCollection GetItemProperties(object dataSource, string dataMember)
|
||||
{
|
||||
CurrencyManager manager = (CurrencyManager)_BindingContext[dataSource, dataMember];
|
||||
if (manager != null)
|
||||
{
|
||||
return manager.GetItemProperties();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private bool IsBindableDataSource(object dataSource)
|
||||
{
|
||||
if ((!(dataSource is IListSource) && !(dataSource is IList)) && !(dataSource is Array))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
ListBindableAttribute attribute = (ListBindableAttribute)TypeDescriptor.GetAttributes(dataSource)[typeof(ListBindableAttribute)];
|
||||
if ((attribute != null) && !attribute.ListBindable)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private static bool IsCriticalException(Exception ex)
|
||||
{
|
||||
return (((((ex is NullReferenceException) || (ex is StackOverflowException)) || ((ex is OutOfMemoryException) ||
|
||||
(ex is ThreadAbortException))) || ((ex is ExecutionEngineException) ||
|
||||
(ex is IndexOutOfRangeException))) || (ex is AccessViolationException));
|
||||
}
|
||||
|
||||
|
||||
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
|
||||
{
|
||||
return UITypeEditorEditStyle.DropDown;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
public class DateNavigatorDesigner : DotNetBar.Design.PanelExDesigner
|
||||
{
|
||||
protected override void SetDesignTimeDefaults()
|
||||
{
|
||||
PanelEx p = this.Control as PanelEx;
|
||||
if (p == null)
|
||||
return;
|
||||
p.CanvasColor = SystemColors.Control;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Drawing;
|
||||
using DevComponents.DotNetBar.Design;
|
||||
|
||||
namespace DevComponents.DotNetBar
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for DesignerSupport.
|
||||
/// </summary>
|
||||
internal class DesignerSupport
|
||||
{
|
||||
public static ItemContainer CreateItemContainer(IDesignerServices designer, BaseItem parent, eOrientation containerOrientation)
|
||||
{
|
||||
IDesignerHost dh=designer.GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
IComponentChangeService cc=designer.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
|
||||
if(dh==null || parent==null || cc==null)
|
||||
return null;
|
||||
|
||||
ItemContainer c=null;
|
||||
|
||||
DesignerTransaction trans=dh.CreateTransaction("New DotNetBar Item Container");
|
||||
try
|
||||
{
|
||||
c=dh.CreateComponent(typeof(ItemContainer)) as ItemContainer;
|
||||
TypeDescriptor.GetProperties(c)["LayoutOrientation"].SetValue(c,containerOrientation);
|
||||
cc.OnComponentChanging(parent,TypeDescriptor.GetProperties(c)["SubItems"]);
|
||||
parent.SubItems.Add(c);
|
||||
cc.OnComponentChanged(parent,TypeDescriptor.GetProperties(c)["SubItems"],null,null);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if(!trans.Canceled)
|
||||
trans.Commit();
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
public static ItemDockContainer CreateItemDockContainer(IDesignerServices designer, BaseItem parent)
|
||||
{
|
||||
IDesignerHost dh = designer.GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
IComponentChangeService cc = designer.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
|
||||
if (dh == null || parent == null || cc == null)
|
||||
return null;
|
||||
|
||||
ItemDockContainer c = null;
|
||||
|
||||
DesignerTransaction trans = dh.CreateTransaction("New DotNetBar Item Dock Container");
|
||||
try
|
||||
{
|
||||
c = dh.CreateComponent(typeof(ItemDockContainer)) as ItemDockContainer;
|
||||
cc.OnComponentChanging(parent, TypeDescriptor.GetProperties(c)["SubItems"]);
|
||||
parent.SubItems.Add(c);
|
||||
cc.OnComponentChanged(parent, TypeDescriptor.GetProperties(c)["SubItems"], null, null);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!trans.Canceled)
|
||||
trans.Commit();
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
public static RibbonTabItemGroup CreateRibbonTabItemGroup(RibbonStrip strip, IServiceProvider provider)
|
||||
{
|
||||
IDesignerHost dh=provider.GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
IComponentChangeService cc=provider.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if(dh==null || cc==null) return null;
|
||||
|
||||
DesignerTransaction trans=dh.CreateTransaction("New RibbonTabItemGroup");
|
||||
RibbonTabItemGroup group=null;
|
||||
try
|
||||
{
|
||||
group=dh.CreateComponent(typeof(RibbonTabItemGroup)) as RibbonTabItemGroup;
|
||||
cc.OnComponentChanging(strip,TypeDescriptor.GetProperties(strip)["TabGroups"]);
|
||||
strip.TabGroups.Add(group);
|
||||
cc.OnComponentChanged(strip,TypeDescriptor.GetProperties(strip)["TabGroups"],null,null);
|
||||
SetDefaults(group);
|
||||
}
|
||||
catch
|
||||
{
|
||||
trans.Cancel();
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if(!trans.Canceled)
|
||||
trans.Commit();
|
||||
}
|
||||
return group;
|
||||
}
|
||||
|
||||
public static GalleryGroup CreateGalleryGroup(GalleryContainer gallery, IServiceProvider provider)
|
||||
{
|
||||
IDesignerHost dh = provider.GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
IComponentChangeService cc = provider.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (dh == null || cc == null) return null;
|
||||
|
||||
DesignerTransaction trans = dh.CreateTransaction("New GalleryGroup");
|
||||
GalleryGroup group = null;
|
||||
try
|
||||
{
|
||||
group = dh.CreateComponent(typeof(GalleryGroup)) as GalleryGroup;
|
||||
|
||||
cc.OnComponentChanging(gallery, TypeDescriptor.GetProperties(gallery)["GalleryGroups"]);
|
||||
gallery.GalleryGroups.Add(group);
|
||||
cc.OnComponentChanged(gallery, TypeDescriptor.GetProperties(gallery)["GalleryGroups"], null, null);
|
||||
|
||||
group.Text = group.Name;
|
||||
}
|
||||
catch
|
||||
{
|
||||
trans.Cancel();
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!trans.Canceled)
|
||||
trans.Commit();
|
||||
}
|
||||
return group;
|
||||
}
|
||||
|
||||
|
||||
public static void SetDefaults(RibbonTabItemGroup group)
|
||||
{
|
||||
TypeDescriptor.GetProperties(group)["GroupTitle"].SetValue(group,"New Group");
|
||||
TypeDescriptor.GetProperties(group.Style)["Border"].SetValue(group.Style,eStyleBorderType.Solid);
|
||||
TypeDescriptor.GetProperties(group.Style)["BorderColor"].SetValue(group.Style,ColorScheme.GetColor("9A3A3B"));
|
||||
TypeDescriptor.GetProperties(group.Style)["CornerType"].SetValue(group.Style,eCornerType.Square);
|
||||
TypeDescriptor.GetProperties(group.Style)["BackColor"].SetValue(group.Style, ColorScheme.GetColor("AE6D94"));
|
||||
TypeDescriptor.GetProperties(group.Style)["BackColor2"].SetValue(group.Style, ColorScheme.GetColor("90487B"));
|
||||
TypeDescriptor.GetProperties(group.Style)["BackColorGradientAngle"].SetValue(group.Style,90);
|
||||
TypeDescriptor.GetProperties(group.Style)["BorderWidth"].SetValue(group.Style,1);
|
||||
TypeDescriptor.GetProperties(group.Style)["TextColor"].SetValue(group.Style,Color.White);
|
||||
TypeDescriptor.GetProperties(group.Style)["TextShadowColor"].SetValue(group.Style, Color.Black);
|
||||
TypeDescriptor.GetProperties(group.Style)["TextShadowOffset"].SetValue(group.Style, new Point(1,1));
|
||||
TypeDescriptor.GetProperties(group.Style)["TextAlignment"].SetValue(group.Style,eStyleTextAlignment.Center);
|
||||
TypeDescriptor.GetProperties(group.Style)["TextLineAlignment"].SetValue(group.Style,eStyleTextAlignment.Near);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for DockContainerItemDesigner.
|
||||
/// </summary>
|
||||
public class DockContainerItemDesigner:ComponentDesigner
|
||||
{
|
||||
public override void Initialize(IComponent component)
|
||||
{
|
||||
base.Initialize(component);
|
||||
|
||||
if(!component.Site.DesignMode)
|
||||
return;
|
||||
|
||||
DockContainerItem c=component as DockContainerItem;
|
||||
if(c!=null)
|
||||
{
|
||||
this.Visible=c.Visible;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void PreFilterProperties(IDictionary properties)
|
||||
{
|
||||
base.PreFilterProperties(properties);
|
||||
properties["Visible"] = TypeDescriptor.CreateProperty(typeof(DockContainerItemDesigner),(PropertyDescriptor)properties["Visible"], new Attribute[]
|
||||
{
|
||||
new DefaultValueAttribute(true),
|
||||
new BrowsableAttribute(true),
|
||||
new CategoryAttribute("Layout")});
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether item is visible.
|
||||
/// </summary>
|
||||
[DefaultValue(true),Browsable(true),DevCoBrowsable(true),Category("Layout"),Description("Gets or sets whether item is visible.")]
|
||||
public bool Visible
|
||||
{
|
||||
get
|
||||
{
|
||||
return (bool)ShadowProperties["Visible"];
|
||||
}
|
||||
set
|
||||
{
|
||||
// this value is not passed to the actual control
|
||||
this.ShadowProperties["Visible"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,224 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Windows.Forms.Design;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for DockSiteDesigner.
|
||||
/// </summary>
|
||||
public class DockSiteDesigner:ParentControlDesigner
|
||||
{
|
||||
private bool m_MouseDrag=false;
|
||||
internal bool DotNetBarManagerRemoving = false;
|
||||
|
||||
public override SelectionRules SelectionRules
|
||||
{
|
||||
get{return SelectionRules.None;}
|
||||
}
|
||||
protected override void OnContextMenu(int x,int y)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool CanParent(Control control)
|
||||
{
|
||||
if (control is IDockInfo && !(control is ContextMenuBar))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Initialize(IComponent component)
|
||||
{
|
||||
base.Initialize(component);
|
||||
if(!component.Site.DesignMode)
|
||||
return;
|
||||
// If our component is removed we need to clean-up
|
||||
IComponentChangeService cc=(IComponentChangeService)GetService(typeof(IComponentChangeService));
|
||||
if(cc!=null)
|
||||
{
|
||||
cc.ComponentRemoving+=new ComponentEventHandler(this.OnComponentRemoving);
|
||||
}
|
||||
|
||||
IDesignerHost dh = GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
if (dh != null && dh.Loading)
|
||||
{
|
||||
((DockSite)component)._DesignerLoading = true;
|
||||
dh.LoadComplete += new EventHandler(DesignerHostLoadComplete);
|
||||
}
|
||||
}
|
||||
|
||||
private void DesignerHostLoadComplete(object sender, EventArgs e)
|
||||
{
|
||||
DockSite site = (DockSite)this.Control;
|
||||
site._DesignerLoading = false;
|
||||
|
||||
IDesignerHost dh = GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
if (dh != null)
|
||||
dh.LoadComplete -= new EventHandler(DesignerHostLoadComplete);
|
||||
#if !FRAMEWORK20
|
||||
if(site.Dock == DockStyle.Fill && site.Controls.Count > 0)
|
||||
site.RecalcLayout();
|
||||
#endif
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
// Unhook events
|
||||
IComponentChangeService cc=(IComponentChangeService)GetService(typeof(IComponentChangeService));
|
||||
if(cc!=null)
|
||||
{
|
||||
cc.ComponentRemoving-=new ComponentEventHandler(this.OnComponentRemoving);
|
||||
}
|
||||
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private void OnComponentRemoving(object sender,ComponentEventArgs e)
|
||||
{
|
||||
|
||||
if(e.Component!=this.Component)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
DockSite c = this.Control as DockSite;
|
||||
if (c.Dock != DockStyle.Fill && !DotNetBarManagerRemoving)
|
||||
{
|
||||
throw new InvalidOperationException("DotNetBarManager dock sites must not be removed manually. Delete DotNetBarManager component to remove all dock sites.");
|
||||
}
|
||||
else
|
||||
{
|
||||
IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
if (dh != null)
|
||||
{
|
||||
Bar[] bars = new Bar[c.Controls.Count];
|
||||
c.Controls.CopyTo(bars, 0);
|
||||
foreach (Bar bar in bars)
|
||||
{
|
||||
if (bar != null)
|
||||
{
|
||||
dh.DestroyComponent(bar);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Unhook events
|
||||
IComponentChangeService cc=(IComponentChangeService)GetService(typeof(IComponentChangeService));
|
||||
if(cc!=null)
|
||||
cc.ComponentRemoving-=new ComponentEventHandler(this.OnComponentRemoving);
|
||||
|
||||
if(c==null)
|
||||
return;
|
||||
if(c.Owner!=null)
|
||||
{
|
||||
if(c.Owner.FillDockSite==c)
|
||||
c.Owner.FillDockSite=null;
|
||||
else if(c.Owner.LeftDockSite==c)
|
||||
c.Owner.LeftDockSite=null;
|
||||
else if(c.Owner.RightDockSite==c)
|
||||
c.Owner.RightDockSite=null;
|
||||
else if(c.Owner.TopDockSite==c)
|
||||
c.Owner.TopDockSite=null;
|
||||
else if(c.Owner.BottomDockSite==c)
|
||||
c.Owner.BottomDockSite=null;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnSetCursor()
|
||||
{
|
||||
DockSite site = this.Control as DockSite;
|
||||
if(site.Dock!=DockStyle.Fill && site.DocumentDockContainer==null)
|
||||
return;
|
||||
Point p=Control.MousePosition;
|
||||
if(site==null || site.Controls.Count==0) return;
|
||||
|
||||
DocumentDockUIManager m=site.GetDocumentUIManager();
|
||||
Point pClient=site.PointToClient(p);
|
||||
Cursor c=m.GetCursor(pClient.X,pClient.Y);
|
||||
if(c!=null)
|
||||
Cursor.Current=c;
|
||||
else
|
||||
Cursor.Current=Cursors.Default;
|
||||
}
|
||||
|
||||
protected override void OnMouseDragBegin(int x, int y)
|
||||
{
|
||||
DockSite site=this.Control as DockSite;
|
||||
if (this.Control.Dock == DockStyle.Fill && site != null || site.DocumentDockContainer != null)
|
||||
{
|
||||
DocumentDockUIManager m=site.GetDocumentUIManager();
|
||||
Point pClient=site.PointToClient(new Point(x,y));
|
||||
Cursor c=m.GetCursor(pClient.X,pClient.Y);
|
||||
if(c!=null)
|
||||
{
|
||||
m.OnMouseDown(new MouseEventArgs(MouseButtons.Left,0,pClient.X,pClient.Y,0));
|
||||
m_MouseDrag=true;
|
||||
}
|
||||
}
|
||||
|
||||
base.OnMouseDragBegin(x,y);
|
||||
|
||||
if(m_MouseDrag)
|
||||
{
|
||||
site.Capture = true;
|
||||
if (site.Dock == DockStyle.Fill || site.GetDocumentUIManager().IsResizingDocument)
|
||||
{
|
||||
WinApi.RECT rect = new WinApi.RECT(0, 0, 0, 0);
|
||||
WinApi.GetWindowRect(site.Handle, ref rect);
|
||||
Rectangle r = Rectangle.FromLTRB(rect.Left, rect.Top, rect.Right, rect.Bottom);
|
||||
Cursor.Clip = r;
|
||||
}
|
||||
#if !FRAMEWORK20
|
||||
else
|
||||
Cursor.Clip = Rectangle.Empty;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnMouseDragMove(int x, int y)
|
||||
{
|
||||
DockSite site=this.Control as DockSite;
|
||||
if(m_MouseDrag && site!=null)
|
||||
{
|
||||
DocumentDockUIManager m=site.GetDocumentUIManager();
|
||||
Point pClient=site.PointToClient(new Point(x,y));
|
||||
m.OnMouseMove(new MouseEventArgs(MouseButtons.Left,0,pClient.X,pClient.Y,0));
|
||||
}
|
||||
else
|
||||
base.OnMouseDragMove(x,y);
|
||||
}
|
||||
|
||||
protected override void OnMouseDragEnd(bool cancel)
|
||||
{
|
||||
if(m_MouseDrag)
|
||||
{
|
||||
this.Control.Capture = false;
|
||||
Cursor.Clip = Rectangle.Empty;
|
||||
}
|
||||
DockSite site=this.Control as DockSite;
|
||||
if(m_MouseDrag && site!=null)
|
||||
{
|
||||
DocumentDockUIManager m=site.GetDocumentUIManager();
|
||||
Point pClient=site.PointToClient(Control.MousePosition);
|
||||
|
||||
IComponentChangeService cc=(IComponentChangeService)GetService(typeof(IComponentChangeService));
|
||||
if(cc!=null)
|
||||
{
|
||||
cc.OnComponentChanging(site,TypeDescriptor.GetProperties(typeof(DockSite))["DocumentDockContainer"]);
|
||||
}
|
||||
|
||||
m.OnMouseUp(new MouseEventArgs(MouseButtons.Left,0,pClient.X,pClient.Y,0));
|
||||
|
||||
if(cc!=null)
|
||||
{
|
||||
cc.OnComponentChanged(site,TypeDescriptor.GetProperties(typeof(DockSite))["DocumentDockContainer"],null,null);
|
||||
}
|
||||
}
|
||||
m_MouseDrag=false;
|
||||
base.OnMouseDragEnd(cancel);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,500 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.50727</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{BDA04B2C-CE5A-4264-8266-EF8ED4A6837D}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>DevComponents.DotNetBar.Design</RootNamespace>
|
||||
<AssemblyName>DevComponents.DotNetBar.Design</AssemblyName>
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>DotNetBarDesignTime.snk</AssemblyOriginatorKeyFile>
|
||||
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
<OldToolsVersion>2.0</OldToolsVersion>
|
||||
<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>TRACE;DEBUG;DOTNETBAR; FRAMEWORK20</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;DOTNETBAR;FRAMEWORK20</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseTrial2005Design|AnyCPU' ">
|
||||
<OutputPath>bin\ReleaseTrial2005Design\</OutputPath>
|
||||
<DefineConstants>TRACE;TRIAL;DOTNETBAR;FRAMEWORK20</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<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>
|
||||
<Compile Include="AdvTree.Design\CellCollectionEditor.cs" />
|
||||
<Compile Include="AdvTree.Design\HostedItemTypeEditor.cs" />
|
||||
<Compile Include="AdvTree.Design\ImageIndexEditor.cs" />
|
||||
<Compile Include="AdvTree.Design\NodeCollectionEditor.cs" />
|
||||
<Compile Include="ApplicationButtonDesigner.cs" />
|
||||
<Compile Include="BarBaseControlDesigner.cs" />
|
||||
<Compile Include="BarDesigner.cs" />
|
||||
<Compile Include="BaseItemDesigner.cs" />
|
||||
<Compile Include="BindingNavigatorExDesigner.cs">
|
||||
</Compile>
|
||||
<Compile Include="BubbleBarDesigner.cs" />
|
||||
<Compile Include="BubbleBarTabCollectionEditor.cs" />
|
||||
<Compile Include="BubbleBarTabDesigner.cs" />
|
||||
<Compile Include="BubbleButtonCollectionEditor.cs" />
|
||||
<Compile Include="ButtonItemEditor.cs" />
|
||||
<Compile Include="ButtonXDesigner.cs" />
|
||||
<Compile Include="CheckedListBoxSelector.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="CheckedListBoxSelector.Designer.cs">
|
||||
<DependentUpon>CheckedListBoxSelector.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ColumnNamesEditor.cs" />
|
||||
<Compile Include="ComponentDesignerWithAction.cs" />
|
||||
<Compile Include="DataMembersSelector.cs" />
|
||||
<Compile Include="Editors.Design\CalculatorDesigner.cs" />
|
||||
<Compile Include="CheckBoxItemDesigner.cs" />
|
||||
<Compile Include="CheckBoxXDesigner.cs" />
|
||||
<Compile Include="ColorPickerButtonDesigner.cs" />
|
||||
<Compile Include="ColorSchemeColorConverter.cs" />
|
||||
<Compile Include="ColumnHeaderCollectionEditor.cs" />
|
||||
<Compile Include="ComboBoxExDesigner.cs" />
|
||||
<Compile Include="ComboItemsEditor.cs" />
|
||||
<Compile Include="ComboTreeActionList.cs" />
|
||||
<Compile Include="ComboTreeDesigner.cs" />
|
||||
<Compile Include="ContextMenuBarDesigner.cs" />
|
||||
<Compile Include="CrumbBarDesigner.cs" />
|
||||
<Compile Include="CrumbBarItemCollectionEditor.cs" />
|
||||
<Compile Include="CrumbBarItemDesigner.cs" />
|
||||
<Compile Include="CrumbBarItemsEditor.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="CustomTypeEditorProvider.cs" />
|
||||
<Compile Include="DateNavigatorDesigner.cs" />
|
||||
<Compile Include="AdvTree.Design\AdvTreeActionList.cs" />
|
||||
<Compile Include="AdvTree.Design\AdvTreeDesigner.cs" />
|
||||
<Compile Include="AdvTree.Design\ColumnHeaderDesigner.cs" />
|
||||
<Compile Include="AdvTree.Design\ElementStyleTypeEditor.cs" />
|
||||
<Compile Include="AdvTree.Design\NodeConnectorTypeEditor.cs" />
|
||||
<Compile Include="AdvTree.Design\NodeContextMenuTypeEditor.cs" />
|
||||
<Compile Include="AdvTree.Design\NodeDesigner.cs" />
|
||||
<Compile Include="DesignerSupport.cs" />
|
||||
<Compile Include="DockContainerItemDesigner.cs" />
|
||||
<Compile Include="DockSiteDesigner.cs" />
|
||||
<Compile Include="DotNetBarManagerDesigner.cs" />
|
||||
<Compile Include="Editors.Design\DateTimeInputDesigner.cs" />
|
||||
<Compile Include="Editors.Design\IpAddressInputDesigner.cs" />
|
||||
<Compile Include="Editors.Design\MonthCalendarAdvDesigner.cs" />
|
||||
<Compile Include="Editors.Design\NumericInputBaseDesigner.cs" />
|
||||
<Compile Include="Editors.Design\TimeSelectorDesigner.cs" />
|
||||
<Compile Include="Editors.Design\VisualControlBaseDesigner.cs" />
|
||||
<Compile Include="ElementStyleClassTypeEditor.cs" />
|
||||
<Compile Include="ElementStyleCollectionEditor.cs" />
|
||||
<Compile Include="ExpandablePanelDesigner.cs" />
|
||||
<Compile Include="ExpandableSplitterDesigner.cs" />
|
||||
<Compile Include="ExplorerBarDesigner.cs" />
|
||||
<Compile Include="ExplorerBarGroupItemDesigner.cs" />
|
||||
<Compile Include="ExplorerBarGroupItemEditor.cs" />
|
||||
<Compile Include="ExplorerBarPanelsEditor.cs" />
|
||||
<Compile Include="FlagEnumEditor.cs" />
|
||||
<Compile Include="FlyoutDesigner.cs" />
|
||||
<Compile Include="GalleryContainerDesigner.cs" />
|
||||
<Compile Include="GalleryGroupCollectionEditor.cs" />
|
||||
<Compile Include="GalleryGroupConverter.cs" />
|
||||
<Compile Include="GalleryGroupTypeEditor.cs" />
|
||||
<Compile Include="GlyphServiceProvider.cs" />
|
||||
<Compile Include="GroupPanelDesigner.cs" />
|
||||
<Compile Include="Helpers.cs" />
|
||||
<Compile Include="ItemContainerDesigner.cs" />
|
||||
<Compile Include="ItemPanelDesigner.cs" />
|
||||
<Compile Include="ItemSelectorTypeEditor.cs" />
|
||||
<Compile Include="LabelXDesigner.cs" />
|
||||
<Compile Include="ListBoxAdvDesigner.cs" />
|
||||
<Compile Include="MaskedTextBoxAdvDesigner.cs" />
|
||||
<Compile Include="Metro\MetroApplicationButtonDesigner.cs" />
|
||||
<Compile Include="Metro\MetroColorThemeEditor.cs" />
|
||||
<Compile Include="Metro\MetroStatusBarDesigner.cs" />
|
||||
<Compile Include="Metro\MetroShellDesigner.cs" />
|
||||
<Compile Include="Metro\MetroTabItemDesigner.cs" />
|
||||
<Compile Include="Metro\MetroTabPanelDesigner.cs" />
|
||||
<Compile Include="Metro\MetroTileFrameDesigner.cs" />
|
||||
<Compile Include="Metro\MetroTilePanelDesigner.cs" />
|
||||
<Compile Include="Metro\MetroToolbarDesigner.cs" />
|
||||
<Compile Include="MicroChartDesigner.cs" />
|
||||
<Compile Include="MicroChartItemDesigner.cs" />
|
||||
<Compile Include="NavigationBarDesigner.cs" />
|
||||
<Compile Include="NavigationPaneDesigner.cs" />
|
||||
<Compile Include="NavigationPanePanelDesigner.cs" />
|
||||
<Compile Include="PageSliderDesigner.cs" />
|
||||
<Compile Include="PageSliderPageDesigner.cs" />
|
||||
<Compile Include="PanelControlDesigner.cs" />
|
||||
<Compile Include="PanelDockContainerDesigner.cs" />
|
||||
<Compile Include="PanelExDesigner.cs" />
|
||||
<Compile Include="ProgressStepsDesigner.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="RadialMenu\RadialMenuActionList.cs" />
|
||||
<Compile Include="RadialMenu\RadialMenuDesigner.cs" />
|
||||
<Compile Include="RadialMenu\RadialMenuItemDesigner.cs" />
|
||||
<Compile Include="RadialMenu\RadialMenuItemEditor.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="RadialMenu\RadialMenuItemEditor.Designer.cs">
|
||||
<DependentUpon>RadialMenuItemEditor.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="RangeSliderDesigner.cs" />
|
||||
<Compile Include="RatingItemDesigner.cs" />
|
||||
<Compile Include="ReflectionHelpers.cs" />
|
||||
<Compile Include="ReflectionImageDesigner.cs" />
|
||||
<Compile Include="ReflectionLabelDesigner.cs" />
|
||||
<Compile Include="RibbonBarDesigner.cs" />
|
||||
<Compile Include="RibbonBarMergeContainerDesigner.cs" />
|
||||
<Compile Include="RibbonClientPanelDesigner.cs" />
|
||||
<Compile Include="RibbonControlDesigner.cs" />
|
||||
<Compile Include="RibbonPanelDesigner.cs" />
|
||||
<Compile Include="RibbonTabItemDesigner.cs" />
|
||||
<Compile Include="RibbonTabItemGroupCollectionEditor.cs" />
|
||||
<Compile Include="RibbonTabItemGroupConverter.cs" />
|
||||
<Compile Include="RibbonTabItemGroupTypeEditor.cs" />
|
||||
<Compile Include="RichTextBoxExDesigner.cs" />
|
||||
<Compile Include="Schedule.Design\CalendarViewDesigner.cs" />
|
||||
<Compile Include="ShapeEditorForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ShapeEditorForm.Designer.cs">
|
||||
<DependentUpon>ShapeEditorForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ShapeTypeEditor.cs" />
|
||||
<Compile Include="ShortcutsDesigner.cs" />
|
||||
<Compile Include="SideBarColorSchemePicker.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="SideBarDesigner.cs" />
|
||||
<Compile Include="SideBarPanelItemDesigner.cs" />
|
||||
<Compile Include="SideBarPanelItemEditor.cs" />
|
||||
<Compile Include="SideBarPanelsEditor.cs" />
|
||||
<Compile Include="SideNavDesigner.cs" />
|
||||
<Compile Include="SimpleBaseItemDesigner.cs" />
|
||||
<Compile Include="SimpleItemDesigner.cs" />
|
||||
<Compile Include="SlidePanelDesigner.cs" />
|
||||
<Compile Include="SliderDesigner.cs" />
|
||||
<Compile Include="SuperTabControl.Design\SuperTabControlDesigner.cs" />
|
||||
<Compile Include="SuperTabControl.Design\SuperTabControlPanelDesigner.cs" />
|
||||
<Compile Include="SuperTabControl.Design\SuperTabControlTabsEditor.cs" />
|
||||
<Compile Include="SuperTabControl.Design\SuperTabItemColorTableEditor.cs" />
|
||||
<Compile Include="SuperTabControl.Design\SuperTabItemDesigner.cs" />
|
||||
<Compile Include="SuperTabControl.Design\SuperTabStripDesigner.cs" />
|
||||
<Compile Include="SuperTabControl.Design\SuperTabStripTabsEditor.cs" />
|
||||
<Compile Include="SuperTooltipDesigner.cs" />
|
||||
<Compile Include="SuperTooltipInfoConverter.cs" />
|
||||
<Compile Include="SuperTooltipInfoEditor.cs" />
|
||||
<Compile Include="SuperTooltipVisualEditor.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="SwitchButtonDesigner.cs" />
|
||||
<Compile Include="SymbolTypeEditor.cs" />
|
||||
<Compile Include="TabControlDesigner.cs" />
|
||||
<Compile Include="TabControlPanelDesigner.cs" />
|
||||
<Compile Include="TabFormItemDesigner.cs" />
|
||||
<Compile Include="TabForm\TabFormControlDesigner.cs" />
|
||||
<Compile Include="TabItemDesigner.cs" />
|
||||
<Compile Include="TabStripDesigner.cs" />
|
||||
<Compile Include="TabStripTabsEditor.cs" />
|
||||
<Compile Include="TextBoxDropDownDesigner.cs" />
|
||||
<Compile Include="TextBoxItemDesigner.cs" />
|
||||
<Compile Include="TextBoxXDesigner.cs" />
|
||||
<Compile Include="TextMarkupEditor.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="TextMarkupUIEditor.cs" />
|
||||
<Compile Include="TimeZoneSelectionEditor.cs" />
|
||||
<Compile Include="TokenEditorDesigner.cs" />
|
||||
<Compile Include="ToolboxControl\ToolboxControlDesigner.cs" />
|
||||
<Compile Include="ToolboxControl\ToolboxGroupDesigner.cs" />
|
||||
<Compile Include="ToolboxControl\ToolboxItemDesigner.cs" />
|
||||
<Compile Include="Validator.Design\HighlighterDesigner.cs" />
|
||||
<Compile Include="Validator.Design\RequiredFieldValidatorConverter.cs" />
|
||||
<Compile Include="Validator.Design\SuperValidatorDesigner.cs" />
|
||||
<Compile Include="Validator.Design\ValidationExpressionEditor.cs" />
|
||||
<Compile Include="Validator.Design\ValidatorEditor.cs" />
|
||||
<Compile Include="WarningBoxDesigner.cs" />
|
||||
<Compile Include="WinApi.cs" />
|
||||
<Compile Include="WizardDesigner.cs" />
|
||||
<Compile Include="WizardPageDesigner.cs" />
|
||||
<Compile Include="WizardPageNavigationControl.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="WizardPageOrderDialog.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Service Include="{94E38DFF-614B-4cbd-B67C-F211BB35CE8B}" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="DotNetBarDesignTime.snk" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SuperTooltipVisualEditor.resx">
|
||||
<DependentUpon>SuperTooltipVisualEditor.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\AddMoreItemsContainer.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\BlankOffice2010HotSilver.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\BlankOffice2010NormalSilver.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\BlankOffice2010PressedSilver.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\BlankStartButtonHot.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\BlankStartButtonHotBlack.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\BlankStartButtonHotSilver.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\BlankStartButtonHotVistaBlack.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\BlankStartButtonNormal.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\BlankStartButtonNormalBlack.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\BlankStartButtonNormalSilver.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\BlankStartButtonNormalVistaBlack.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\BlankStartButtonPressed.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\BlankStartButtonPressedBlack.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\BlankStartButtonPressedSilver.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\BlankStartButtonPressedVistaBlack.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\BlankWin7HotBlue.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\BlankWin7NormalBlue.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\BlankWin7PressedBlue.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\Category.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\CloseButton.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\CollapseTitle.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\ColorPickerButtonImage.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\ColorPickerCustomColors.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\DateReset.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\DefaultNavBarImage.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\DockHintAllSides.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\DockHintBottom.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\DockHintLeft.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\DockHintRight.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\DockHintTab.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\DockHintTop.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\ErrorIcon.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\ExpandTitle.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\FreeText.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\GreenLight.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\ImagePlaceHolder.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\ImagePlaceHolder16x16.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\NavBarConfigure.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\NavBarShowLess.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\NavBarShowMore.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\Note24.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\Note64.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\Pin.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\PinInactive.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\PinPushed.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\PinPushedInactive.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\QatCustomizeItemCombo.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\Rating.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\RibbonOverflow.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SystemImages\Sort.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="CheckedListBoxSelector.resx">
|
||||
<DependentUpon>CheckedListBoxSelector.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="RadialMenu\RadialMenuItemEditor.resx">
|
||||
<SubType>Designer</SubType>
|
||||
<DependentUpon>RadialMenuItemEditor.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="ShapeEditorForm.resx">
|
||||
<DependentUpon>ShapeEditorForm.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="SideBarColorSchemePicker.resx">
|
||||
<DependentUpon>SideBarColorSchemePicker.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="SystemImages\WizardHeaderImage.png" />
|
||||
<EmbeddedResource Include="TextMarkupEditor.resx">
|
||||
<DependentUpon>TextMarkupEditor.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="WizardPageOrderDialog.resx">
|
||||
<DependentUpon>WizardPageOrderDialog.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DevComponents.DotNetBar.Schedule\DevComponents.DotNetBar.Schedule.csproj">
|
||||
<Project>{C25DFA40-9897-47FA-A525-7528C5BE7724}</Project>
|
||||
<Name>DevComponents.DotNetBar.Schedule</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\DotNetBar.csproj">
|
||||
<Project>{36546CE3-335C-4AB6-A2F3-40F8C818BC66}</Project>
|
||||
<Name>DotNetBar</Name>
|
||||
</ProjectReference>
|
||||
</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>
|
||||
<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>
|
||||
-->
|
||||
</Project>
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,113 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms.Design;
|
||||
using DevComponents.Editors;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
public class CalculatorDesigner : ControlDesigner
|
||||
{
|
||||
#region Internal Implementation
|
||||
public override void InitializeNewComponent(System.Collections.IDictionary defaultValues)
|
||||
{
|
||||
Calculator mc = this.Control as Calculator;
|
||||
if (mc != null)
|
||||
{
|
||||
mc.AutoSize = true;
|
||||
}
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
}
|
||||
|
||||
protected override void PreFilterProperties(System.Collections.IDictionary properties)
|
||||
{
|
||||
base.PreFilterProperties(properties);
|
||||
RemoveDescriptors(properties,
|
||||
new String[] { "AutoScrollMargin",
|
||||
"AlwaysDisplayKeyAccelerators",
|
||||
"AutoScroll",
|
||||
"AutoScrollMinSize",
|
||||
"AutoValidate",
|
||||
"BorderStyle",
|
||||
"ForeColor",
|
||||
"DisabledImagesGrayScale",
|
||||
"DispatchShortcuts",
|
||||
"Enabled",
|
||||
"BackColor",
|
||||
"BackgroundImage",
|
||||
"BackgroundImageLayout",
|
||||
"Margin",
|
||||
"MaximumSize",
|
||||
"MinimumSize",
|
||||
"Padding",
|
||||
"RightToLeft",
|
||||
"TabStop",
|
||||
"TabIndex",
|
||||
"UseWaitCursor",
|
||||
"ImeMode" });
|
||||
}
|
||||
private void RemoveDescriptors(System.Collections.IDictionary properties, String[] propNames)
|
||||
{
|
||||
foreach (String propName in propNames)
|
||||
{
|
||||
if (properties.Contains(propName))
|
||||
properties.Remove(propName);
|
||||
}
|
||||
}
|
||||
protected override void PreFilterEvents(System.Collections.IDictionary events)
|
||||
{
|
||||
RemoveDescriptors(events,
|
||||
new string[] {
|
||||
"AutoSizeChanged",
|
||||
"AutoValidate",
|
||||
"BackColorChanged",
|
||||
"BackgroundImageChanged",
|
||||
"BackgroundImageLayoutChanged",
|
||||
"BindingContext",
|
||||
"BackgroundStyle",
|
||||
"ButtonCheckedChanged",
|
||||
"CausesValidationChanged",
|
||||
"ChangeUICues",
|
||||
"ClientSizeChanged",
|
||||
"ContainerControlDeserialize",
|
||||
"ContainerControlSerialize",
|
||||
"ContainerLoadControl",
|
||||
"Enter",
|
||||
"Leave",
|
||||
"ContextMenuStripChanged",
|
||||
"ControlAdded",
|
||||
"ControlRemoved",
|
||||
"CursorChanged",
|
||||
"DefinitionLoaded",
|
||||
"DockChanged",
|
||||
"EnabledChanged",
|
||||
"ExpandedChange",
|
||||
"FontChanged",
|
||||
"ForeColorChanged",
|
||||
"ImeModeChanged",
|
||||
"KeyDown",
|
||||
"KeyPress",
|
||||
"KeyUp",
|
||||
"Layout",
|
||||
"MarginChanged",
|
||||
"PaddingChanged",
|
||||
"Paint",
|
||||
"ParentChanged",
|
||||
"PreviewKeyDown",
|
||||
"RegionChanged",
|
||||
"Scroll",
|
||||
"RightToLeftChanged",
|
||||
"StyleChanged",
|
||||
"SystemColorsChanged",
|
||||
"TabIndexChanged",
|
||||
"TabStopChanged",
|
||||
"TextChanged",
|
||||
"Resize",
|
||||
"Validating",
|
||||
"Validated",
|
||||
"VisibleChanged" });
|
||||
base.PreFilterEvents(events);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
#if FRAMEWORK20
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Windows.Forms.Design;
|
||||
using DevComponents.Editors.DateTimeAdv;
|
||||
using DevComponents.DotNetBar;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
public class DateTimeInputDesigner : VisualControlBaseDesigner
|
||||
{
|
||||
#region Internal Implementation
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the DateTimeInputDesigner class.
|
||||
/// </summary>
|
||||
public DateTimeInputDesigner()
|
||||
{
|
||||
this.AutoResizeHandles = true;
|
||||
}
|
||||
|
||||
public override void InitializeNewComponent(System.Collections.IDictionary defaultValues)
|
||||
{
|
||||
DateTimeInput c = this.Control as DateTimeInput;
|
||||
if (c != null)
|
||||
{
|
||||
c.MonthCalendar.NavigationBackgroundStyle.BackColorSchemePart = eColorSchemePart.PanelBackground;
|
||||
c.MonthCalendar.NavigationBackgroundStyle.BackColor2SchemePart = eColorSchemePart.PanelBackground2;
|
||||
c.MonthCalendar.NavigationBackgroundStyle.BackColorGradientAngle = 90;
|
||||
c.MonthCalendar.CommandsBackgroundStyle.BackColorSchemePart = eColorSchemePart.BarBackground;
|
||||
c.MonthCalendar.CommandsBackgroundStyle.BackColor2SchemePart = eColorSchemePart.BarBackground2;
|
||||
c.MonthCalendar.CommandsBackgroundStyle.BackColorGradientAngle = 90;
|
||||
c.MonthCalendar.CommandsBackgroundStyle.BorderTop = eStyleBorderType.Solid;
|
||||
c.MonthCalendar.CommandsBackgroundStyle.BorderTopColorSchemePart = eColorSchemePart.BarDockedBorder;
|
||||
c.MonthCalendar.CommandsBackgroundStyle.BorderTopWidth = 1;
|
||||
c.ButtonDropDown.Visible = true;
|
||||
c.MonthCalendar.TodayButtonVisible = true;
|
||||
c.MonthCalendar.ClearButtonVisible = true;
|
||||
c.ButtonDropDown.Shortcut = eShortcut.AltDown;
|
||||
c.Style = eDotNetBarStyle.StyleManagerControlled;
|
||||
}
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
}
|
||||
|
||||
public override System.Windows.Forms.Design.SelectionRules SelectionRules
|
||||
{
|
||||
get
|
||||
{
|
||||
SelectionRules rules = base.SelectionRules;
|
||||
if (!this.Control.AutoSize)
|
||||
{
|
||||
rules &= ~(SelectionRules.BottomSizeable | SelectionRules.TopSizeable);
|
||||
}
|
||||
return rules;
|
||||
}
|
||||
}
|
||||
|
||||
private void RemoveDescriptors(System.Collections.IDictionary properties, String[] propNames)
|
||||
{
|
||||
foreach (String propName in propNames)
|
||||
{
|
||||
if (properties.Contains(propName))
|
||||
{
|
||||
if (properties[propName] is PropertyDescriptor)
|
||||
properties[propName] = TypeDescriptor.CreateProperty(this.Component.GetType(), (PropertyDescriptor)properties[propName], new BrowsableAttribute(false));
|
||||
else if (properties[propName] is EventDescriptor)
|
||||
properties[propName] = TypeDescriptor.CreateEvent(this.Component.GetType(), (EventDescriptor)properties[propName], new BrowsableAttribute(false));
|
||||
else
|
||||
properties.Remove(propName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void PreFilterProperties(System.Collections.IDictionary properties)
|
||||
{
|
||||
base.PreFilterProperties(properties);
|
||||
RemoveDescriptors(properties,
|
||||
new String[] { "AllowDrop",
|
||||
"BackColor",
|
||||
"MaximumSize",
|
||||
"MinimumSize",
|
||||
"RightToLeft",
|
||||
"UseWaitCursor",
|
||||
"ImeMode" });
|
||||
}
|
||||
|
||||
protected override void PreFilterEvents(System.Collections.IDictionary events)
|
||||
{
|
||||
RemoveDescriptors(events,
|
||||
new string[] { "BackColorChanged",
|
||||
"BackgroundImageChanged",
|
||||
"BackgroundImageLayoutChanged",
|
||||
"BackgroundStyle",
|
||||
"CausesValidationChanged",
|
||||
"ChangeUICues",
|
||||
"ClientSizeChanged",
|
||||
"Colors",
|
||||
"ContextMenuStripChanged",
|
||||
"ControlAdded",
|
||||
"ControlRemoved",
|
||||
"CursorChanged",
|
||||
"DefinitionLoaded",
|
||||
"DockChanged",
|
||||
"EnabledChanged",
|
||||
"FontChanged",
|
||||
"ForeColorChanged",
|
||||
"ImeModeChanged",
|
||||
"KeyDown",
|
||||
"KeyPress",
|
||||
"KeyUp",
|
||||
"Layout",
|
||||
"MarginChanged",
|
||||
"MonthCalendar",
|
||||
"PaddingChanged",
|
||||
"Paint",
|
||||
"ParentChanged",
|
||||
"PopupClose",
|
||||
"PopupContainerLoad",
|
||||
"PopupContainerUnload",
|
||||
"PopupOpen",
|
||||
"PopupShowing",
|
||||
"RegionChanged",
|
||||
"RightToLeftChanged",
|
||||
"StyleChanged",
|
||||
"SystemColorsChanged",
|
||||
"TabIndexChanged",
|
||||
"TabStopChanged",
|
||||
"Resize",
|
||||
"SizeChanged",
|
||||
"VisibleChanged" });
|
||||
base.PreFilterEvents(events);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
#if FRAMEWORK20
|
||||
using System;
|
||||
using System.Windows.Forms.Design;
|
||||
using System.Text;
|
||||
using DevComponents.Editors;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents designer for IpAddressInput control.
|
||||
/// </summary>
|
||||
public class IpAddressInputDesigner: VisualControlBaseDesigner
|
||||
{
|
||||
#region Private Variables
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the IpAddressInputDesigner class.
|
||||
/// </summary>
|
||||
public IpAddressInputDesigner()
|
||||
{
|
||||
this.AutoResizeHandles = true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
public override void InitializeNewComponent(System.Collections.IDictionary defaultValues)
|
||||
{
|
||||
IpAddressInput c = this.Control as IpAddressInput;
|
||||
if (c != null)
|
||||
{
|
||||
c.AutoOverwrite = true;
|
||||
c.ButtonFreeText.Visible = true;
|
||||
c.ButtonFreeText.Shortcut = DevComponents.DotNetBar.eShortcut.F2;
|
||||
c.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
|
||||
}
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
}
|
||||
|
||||
public override System.Windows.Forms.Design.SelectionRules SelectionRules
|
||||
{
|
||||
get
|
||||
{
|
||||
SelectionRules rules = base.SelectionRules;
|
||||
if (!this.Control.AutoSize)
|
||||
{
|
||||
rules &= ~(SelectionRules.BottomSizeable | SelectionRules.TopSizeable);
|
||||
}
|
||||
return rules;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,45 @@
|
||||
#if FRAMEWORK20
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Windows.Forms.Design;
|
||||
using DevComponents.Editors.DateTimeAdv;
|
||||
using System.Drawing;
|
||||
using DevComponents.DotNetBar.Rendering;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents Windows Forms designer for MonthCalendarAdv control.
|
||||
/// </summary>
|
||||
public class MonthCalendarAdvDesigner : ControlDesigner
|
||||
{
|
||||
#region Private Variables
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
public override void InitializeNewComponent(System.Collections.IDictionary defaultValues)
|
||||
{
|
||||
MonthCalendarAdv mc = this.Control as MonthCalendarAdv;
|
||||
if (mc != null)
|
||||
{
|
||||
mc.BackgroundStyle.Class = ElementStyleClassKeys.MonthCalendarAdvKey;
|
||||
//mc.BackgroundStyle.BackColor = SystemColors.Window;
|
||||
//mc.BackgroundStyle.Border = DevComponents.DotNetBar.eStyleBorderType.Solid;
|
||||
//mc.BackgroundStyle.BorderColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder;
|
||||
//mc.BackgroundStyle.BorderWidth = 1;
|
||||
mc.NavigationBackgroundStyle.BackColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.BarBackground;
|
||||
mc.NavigationBackgroundStyle.BackColor2SchemePart = DevComponents.DotNetBar.eColorSchemePart.BarBackground2;
|
||||
mc.NavigationBackgroundStyle.BackColorGradientAngle = 90;
|
||||
mc.AutoSize = true;
|
||||
}
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
#if FRAMEWORK20
|
||||
using System;
|
||||
using System.Windows.Forms.Design;
|
||||
using System.Text;
|
||||
using DevComponents.DotNetBar;
|
||||
using DevComponents.Editors;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the base designer for the NumericInputBase controls.
|
||||
/// </summary>
|
||||
public class NumericInputBaseDesigner : VisualControlBaseDesigner
|
||||
{
|
||||
#region Private Variables
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the NumericInputBaseDesigner class.
|
||||
/// </summary>
|
||||
public NumericInputBaseDesigner()
|
||||
{
|
||||
this.AutoResizeHandles = true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
public override void InitializeNewComponent(System.Collections.IDictionary defaultValues)
|
||||
{
|
||||
NumericInputBase c = this.Control as NumericInputBase;
|
||||
if (c != null)
|
||||
{
|
||||
c.ShowUpDown = true;
|
||||
c.AutoOverwrite = false;
|
||||
c.ButtonFreeText.Shortcut = eShortcut.F2;
|
||||
}
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
}
|
||||
|
||||
public override System.Windows.Forms.Design.SelectionRules SelectionRules
|
||||
{
|
||||
get
|
||||
{
|
||||
SelectionRules rules = base.SelectionRules;
|
||||
if (!this.Control.AutoSize)
|
||||
{
|
||||
rules &= ~(SelectionRules.BottomSizeable | SelectionRules.TopSizeable);
|
||||
}
|
||||
return rules;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Windows.Forms.Design;
|
||||
using DevComponents.Editors.DateTimeAdv;
|
||||
using System.Drawing;
|
||||
using DevComponents.DotNetBar.Rendering;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
public class TimeSelectorDesigner : ControlDesigner
|
||||
{
|
||||
#region Private Variables
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
public override void InitializeNewComponent(System.Collections.IDictionary defaultValues)
|
||||
{
|
||||
TimeSelector mc = this.Control as TimeSelector;
|
||||
if (mc != null)
|
||||
{
|
||||
mc.BackgroundStyle.Class = ElementStyleClassKeys.ItemPanelKey;
|
||||
mc.AutoSize = true;
|
||||
}
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
}
|
||||
|
||||
protected override void PreFilterProperties(System.Collections.IDictionary properties)
|
||||
{
|
||||
base.PreFilterProperties(properties);
|
||||
RemoveDescriptors(properties,
|
||||
new String[] { "AutoScrollMargin",
|
||||
"AlwaysDisplayKeyAccelerators",
|
||||
"AutoScroll",
|
||||
"AutoScrollMinSize",
|
||||
"DisabledImagesGrayScale",
|
||||
"DispatchShortcuts",
|
||||
"Enabled",
|
||||
"Images",
|
||||
"ImageSize",
|
||||
"ImagesLarge",
|
||||
"ImagesMedium",
|
||||
"KeyTipsFont",
|
||||
"BackColor",
|
||||
"BackgroundImage",
|
||||
"BackgroundImageLayout",
|
||||
"Margin",
|
||||
"MaximumSize",
|
||||
"MinimumSize",
|
||||
"Padding",
|
||||
"RightToLeft",
|
||||
"ShowShortcutKeysInToolTips",
|
||||
"ShowToolTips",
|
||||
"TabStop",
|
||||
"TabIndex",
|
||||
"UseWaitCursor",
|
||||
"ImeMode" });
|
||||
}
|
||||
private void RemoveDescriptors(System.Collections.IDictionary properties, String[] propNames)
|
||||
{
|
||||
foreach (String propName in propNames)
|
||||
{
|
||||
if (properties.Contains(propName))
|
||||
properties.Remove(propName);
|
||||
}
|
||||
}
|
||||
protected override void PreFilterEvents(System.Collections.IDictionary events)
|
||||
{
|
||||
RemoveDescriptors(events,
|
||||
new string[] { "BackColorChanged",
|
||||
"BackgroundImageChanged",
|
||||
"BackgroundImageLayoutChanged",
|
||||
"BackgroundStyle",
|
||||
"ButtonCheckedChanged",
|
||||
"CausesValidationChanged",
|
||||
"ChangeUICues",
|
||||
"ClientSizeChanged",
|
||||
"ContainerControlDeserialize",
|
||||
"ContainerControlSerialize",
|
||||
"ContainerLoadControl",
|
||||
"Enter",
|
||||
"Leave",
|
||||
"ContextMenuStripChanged",
|
||||
"ControlAdded",
|
||||
"ControlRemoved",
|
||||
"CursorChanged",
|
||||
"DefinitionLoaded",
|
||||
"DockChanged",
|
||||
"EnabledChanged",
|
||||
"ExpandedChange",
|
||||
"FontChanged",
|
||||
"ForeColorChanged",
|
||||
"ImeModeChanged",
|
||||
"ItemAdded",
|
||||
"ItemClick",
|
||||
"ItemDoubleClick",
|
||||
"ItemLayoutUpdated",
|
||||
"ItemRemoved",
|
||||
"ItemTextChanged",
|
||||
"KeyDown",
|
||||
"KeyPress",
|
||||
"KeyUp",
|
||||
"Layout",
|
||||
"MarginChanged",
|
||||
"OptionGroupChanging",
|
||||
"PaddingChanged",
|
||||
"Paint",
|
||||
"ParentChanged",
|
||||
"PopupClose",
|
||||
"PopupContainerLoad",
|
||||
"PopupContainerUnload",
|
||||
"PopupOpen",
|
||||
"PopupShowing",
|
||||
"RegionChanged",
|
||||
"Scroll",
|
||||
"RightToLeftChanged",
|
||||
"StyleChanged",
|
||||
"SystemColorsChanged",
|
||||
"TabIndexChanged",
|
||||
"TabStopChanged",
|
||||
"TextChanged",
|
||||
"Resize",
|
||||
"ToolTipShowing",
|
||||
"UserCustomize",
|
||||
"VisibleChanged" });
|
||||
base.PreFilterEvents(events);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#if FRAMEWORK20
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Windows.Forms.Design;
|
||||
using DevComponents.Editors;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents Windows Forms designer for the VisualControlBase control.
|
||||
/// </summary>
|
||||
public class VisualControlBaseDesigner : ControlDesigner
|
||||
{
|
||||
#region Private Variables
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
public override void InitializeNewComponent(System.Collections.IDictionary defaultValues)
|
||||
{
|
||||
VisualControlBase c = this.Control as VisualControlBase;
|
||||
if (c != null)
|
||||
{
|
||||
c.Height = c.PreferredHeight;
|
||||
}
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Collections;
|
||||
using System.Diagnostics;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms.Design;
|
||||
using System.Drawing.Design;
|
||||
using System.Reflection;
|
||||
using DevComponents.DotNetBar.Rendering;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for ContextExMenuTypeEditor.
|
||||
/// </summary>
|
||||
public class ElementStyleClassTypeEditor : System.Drawing.Design.UITypeEditor
|
||||
{
|
||||
private IWindowsFormsEditorService edSvc = null;
|
||||
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
|
||||
{
|
||||
if (context != null
|
||||
&& context.Instance != null
|
||||
&& provider != null)
|
||||
{
|
||||
edSvc = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
|
||||
|
||||
if (edSvc != null)
|
||||
{
|
||||
ListBox lb = new ListBox();
|
||||
lb.SelectedIndexChanged += new EventHandler(this.SelectedChanged);
|
||||
Type t = typeof(ElementStyleClassKeys);
|
||||
FieldInfo[] fields = t.GetFields(BindingFlags.Public | BindingFlags.Static);
|
||||
foreach (FieldInfo pi in fields)
|
||||
{
|
||||
string s = pi.GetValue(null).ToString();
|
||||
lb.Items.Add(s);
|
||||
if (s == value.ToString())
|
||||
lb.SelectedItem = s;
|
||||
}
|
||||
|
||||
edSvc.DropDownControl(lb);
|
||||
if (lb.SelectedItem != null)
|
||||
return lb.SelectedItem.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
private void SelectedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (edSvc != null)
|
||||
edSvc.CloseDropDown();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the editor style used by the EditValue method.
|
||||
/// </summary>
|
||||
/// <param name="context">An ITypeDescriptorContext that can be used to gain additional context information.</param>
|
||||
/// <returns>A UITypeEditorEditStyle value that indicates the style of editor used by EditValue. If the UITypeEditor does not support this method, then GetEditStyle will return None</returns>
|
||||
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
|
||||
{
|
||||
if (context != null && context.Instance != null)
|
||||
{
|
||||
return UITypeEditorEditStyle.DropDown;
|
||||
}
|
||||
return base.GetEditStyle(context);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
#region ElementStyleCollectionEditor
|
||||
/// <summary>
|
||||
/// Support for ElementStyle design-time editor.
|
||||
/// </summary>
|
||||
public class ElementStyleCollectionEditor : System.ComponentModel.Design.CollectionEditor
|
||||
{
|
||||
/// <summary>Creates new instance of the object.</summary>
|
||||
public ElementStyleCollectionEditor(Type type)
|
||||
: base(type)
|
||||
{
|
||||
}
|
||||
protected override Type CreateCollectionItemType()
|
||||
{
|
||||
return typeof(ElementStyle);
|
||||
}
|
||||
protected override Type[] CreateNewItemTypes()
|
||||
{
|
||||
return new Type[] { typeof(ElementStyle) };
|
||||
}
|
||||
protected override object CreateInstance(Type itemType)
|
||||
{
|
||||
object item = base.CreateInstance(itemType);
|
||||
return item;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
public class ExpandablePanelDesigner : PanelExDesigner
|
||||
{
|
||||
#region Internal Implementation
|
||||
|
||||
#if FRAMEWORK20
|
||||
public override void InitializeNewComponent(IDictionary defaultValues)
|
||||
{
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#else
|
||||
public override void OnSetComponentDefaults()
|
||||
{
|
||||
base.OnSetComponentDefaults();
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#endif
|
||||
|
||||
private void SetDesignTimeDefaults()
|
||||
{
|
||||
ExpandablePanel p = this.Control as ExpandablePanel;
|
||||
if (p == null)
|
||||
return;
|
||||
p.ApplyLabelStyle();
|
||||
p.Style.BorderColor.ColorSchemePart = eColorSchemePart.BarDockedBorder;
|
||||
p.Style.Border = eBorderType.SingleLine;
|
||||
p.Style.BackColor1.ColorSchemePart = eColorSchemePart.PanelBackground;
|
||||
p.Style.BackColor2.ColorSchemePart = eColorSchemePart.PanelBackground2;
|
||||
p.Text = "";
|
||||
p.TitlePanel.ApplyPanelStyle();
|
||||
p.HideControlsWhenCollapsed = true;
|
||||
this.ColorSchemeStyle = eDotNetBarStyle.StyleManagerControlled;
|
||||
}
|
||||
|
||||
protected override void PreFilterProperties(IDictionary properties)
|
||||
{
|
||||
base.PreFilterProperties(properties);
|
||||
properties["ColorSchemeStyle"] = TypeDescriptor.CreateProperty(typeof(ExpandablePanelDesigner), (PropertyDescriptor)properties["ColorSchemeStyle"], new Attribute[]
|
||||
{
|
||||
new DefaultValueAttribute(eDotNetBarStyle.Office2003),
|
||||
new BrowsableAttribute(true),
|
||||
new CategoryAttribute("Style"),
|
||||
new DescriptionAttribute("Gets or sets color scheme style.")});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets color scheme style.
|
||||
/// </summary>
|
||||
[Browsable(true), DevCoBrowsable(true), Category("Style"), Description("Gets or sets color scheme style."), DefaultValue(eDotNetBarStyle.Office2003)]
|
||||
public eDotNetBarStyle ColorSchemeStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
ExpandablePanel ep = this.Control as ExpandablePanel;
|
||||
return ep.ColorSchemeStyle;
|
||||
}
|
||||
set
|
||||
{
|
||||
ExpandablePanel ep = this.Control as ExpandablePanel;
|
||||
ep.ColorSchemeStyle = value;
|
||||
IDesignerHost dh = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
if (dh != null && !dh.Loading)
|
||||
{
|
||||
if (Helpers.IsOffice2007Style(value))
|
||||
ep.TitleStyle.Border = eBorderType.RaisedInner;
|
||||
else
|
||||
ep.TitleStyle.Border = eBorderType.SingleLine;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool GetHitTest(System.Drawing.Point pt)
|
||||
{
|
||||
ExpandablePanel p = this.Control as ExpandablePanel;
|
||||
if (p != null)
|
||||
{
|
||||
Point pt2 = p.PointToClient(pt);
|
||||
PanelExTitle titlePanel = p.TitlePanel as PanelExTitle;
|
||||
if (titlePanel != null && titlePanel.ExpandChangeButton!=null && titlePanel.ExpandChangeButton.DisplayRectangle.Contains(pt2))
|
||||
return true;
|
||||
else if (titlePanel != null && titlePanel.ExpandChangeButton!=null)
|
||||
titlePanel.ExpandChangeButton.InternalMouseLeave();
|
||||
|
||||
}
|
||||
return base.GetHitTest(pt);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms.Design;
|
||||
using System.ComponentModel.Design;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents windows forms designer support for ExpandableSplitter control.
|
||||
/// </summary>
|
||||
public class ExpandableSplitterDesigner : ControlDesigner
|
||||
{
|
||||
/// <summary>
|
||||
/// Default constructor.
|
||||
/// </summary>
|
||||
public ExpandableSplitterDesigner() { }
|
||||
|
||||
#if FRAMEWORK20
|
||||
public override void InitializeNewComponent(System.Collections.IDictionary defaultValues)
|
||||
{
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#else
|
||||
public override void OnSetComponentDefaults()
|
||||
{
|
||||
SetDesignTimeDefaults();
|
||||
base.OnSetComponentDefaults();
|
||||
}
|
||||
#endif
|
||||
|
||||
private void SetDesignTimeDefaults()
|
||||
{
|
||||
this.Style = eSplitterStyle.Office2007;
|
||||
((ExpandableSplitter)this.Control).Width = 6;
|
||||
}
|
||||
|
||||
protected override void PreFilterProperties(
|
||||
System.Collections.IDictionary properties)
|
||||
{
|
||||
base.PreFilterProperties(properties);
|
||||
properties["Style"] =
|
||||
TypeDescriptor.CreateProperty(typeof(ExpandableSplitterDesigner),
|
||||
(PropertyDescriptor)properties["Style"],
|
||||
new Attribute[0]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets visual style of the control. Default value is eSplitterStyle.Office2003.
|
||||
/// </summary>
|
||||
[Browsable(true), Category("Appearance"), DefaultValue(eSplitterStyle.Office2003), Description("Indicates visual style of the control.")]
|
||||
public eSplitterStyle Style
|
||||
{
|
||||
get { return ((ExpandableSplitter)this.Control).Style; }
|
||||
set
|
||||
{
|
||||
((ExpandableSplitter)this.Control).Style = value;
|
||||
IDesignerHost dh = GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
if (dh != null && dh.Loading)
|
||||
return;
|
||||
|
||||
((ExpandableSplitter)this.Control).ApplyStyle(value);
|
||||
OnStyleChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnStyleChanged()
|
||||
{
|
||||
ExpandableSplitter splitter = this.Control as ExpandableSplitter;
|
||||
IComponentChangeService change = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (change != null)
|
||||
{
|
||||
change.OnComponentChanging(splitter, TypeDescriptor.GetProperties(typeof(ExpandableSplitter))["Style"]);
|
||||
change.OnComponentChanged(splitter, TypeDescriptor.GetProperties(typeof(ExpandableSplitter))["Style"], null, null);
|
||||
|
||||
change.OnComponentChanging(splitter, TypeDescriptor.GetProperties(typeof(ExpandableSplitter))["BackColor"]);
|
||||
change.OnComponentChanged(splitter, TypeDescriptor.GetProperties(typeof(ExpandableSplitter))["BackColor"], null, null);
|
||||
|
||||
change.OnComponentChanging(splitter, TypeDescriptor.GetProperties(typeof(ExpandableSplitter))["BackColor2"]);
|
||||
change.OnComponentChanged(splitter, TypeDescriptor.GetProperties(typeof(ExpandableSplitter))["BackColor2"], null, null);
|
||||
|
||||
change.OnComponentChanging(splitter, TypeDescriptor.GetProperties(typeof(ExpandableSplitter))["GripLightColor"]);
|
||||
change.OnComponentChanged(splitter, TypeDescriptor.GetProperties(typeof(ExpandableSplitter))["GripLightColor"], null, null);
|
||||
|
||||
change.OnComponentChanging(splitter, TypeDescriptor.GetProperties(typeof(ExpandableSplitter))["GripDarkColor"]);
|
||||
change.OnComponentChanged(splitter, TypeDescriptor.GetProperties(typeof(ExpandableSplitter))["GripDarkColor"], null, null);
|
||||
|
||||
change.OnComponentChanging(splitter, TypeDescriptor.GetProperties(typeof(ExpandableSplitter))["EpxandFillColor"]);
|
||||
change.OnComponentChanged(splitter, TypeDescriptor.GetProperties(typeof(ExpandableSplitter))["ExpandFillColor"], null, null);
|
||||
|
||||
change.OnComponentChanging(splitter, TypeDescriptor.GetProperties(typeof(ExpandableSplitter))["EpxandLineColor"]);
|
||||
change.OnComponentChanged(splitter, TypeDescriptor.GetProperties(typeof(ExpandableSplitter))["ExpandLineColor"], null, null);
|
||||
}
|
||||
}
|
||||
|
||||
private IDesignerHost GetIDesignerHost()
|
||||
{
|
||||
try
|
||||
{
|
||||
IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
return dh;
|
||||
}
|
||||
catch { }
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,259 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Windows.Forms;
|
||||
using System.ComponentModel.Design.Serialization;
|
||||
using System.CodeDom;
|
||||
using System.Drawing;
|
||||
using System.Collections;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for ExplorerBarDesigner.
|
||||
/// </summary>
|
||||
public class ExplorerBarDesigner:BarBaseControlDesigner
|
||||
{
|
||||
#region Internal Implementation
|
||||
public ExplorerBarDesigner():base()
|
||||
{
|
||||
this.EnableItemDragDrop=true;
|
||||
}
|
||||
|
||||
public override void Initialize(IComponent component)
|
||||
{
|
||||
base.Initialize(component);
|
||||
if(!component.Site.DesignMode)
|
||||
return;
|
||||
ExplorerBar bar=this.Control as ExplorerBar;
|
||||
if(bar!=null)
|
||||
bar.SetDesignMode();
|
||||
}
|
||||
|
||||
public override DesignerVerbCollection Verbs
|
||||
{
|
||||
get
|
||||
{
|
||||
DesignerVerb[] verbs = new DesignerVerb[]
|
||||
{
|
||||
new DesignerVerb("Create Group", new EventHandler(OnAddGroup)),
|
||||
new DesignerVerb("Create Button", new EventHandler(OnAddButton))
|
||||
};
|
||||
return new DesignerVerbCollection(verbs);
|
||||
}
|
||||
}
|
||||
|
||||
#if FRAMEWORK20
|
||||
public override void InitializeNewComponent(IDictionary defaultValues)
|
||||
{
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#else
|
||||
public override void OnSetComponentDefaults()
|
||||
{
|
||||
base.OnSetComponentDefaults();
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#endif
|
||||
private void SetDesignTimeDefaults()
|
||||
{
|
||||
if (this.Control is ExplorerBar)
|
||||
{
|
||||
ExplorerBar eb = this.Control as ExplorerBar;
|
||||
eb.ApplyDefaultSettings();
|
||||
//eb.ThemeAware = true;
|
||||
eb.StockStyle = eExplorerBarStockStyle.SystemColors;
|
||||
}
|
||||
}
|
||||
|
||||
protected override BaseItem GetItemContainer()
|
||||
{
|
||||
ExplorerBar bar=this.Control as ExplorerBar;
|
||||
if(bar!=null)
|
||||
return bar.ItemsContainer;
|
||||
return null;
|
||||
}
|
||||
|
||||
protected override void RecalcLayout()
|
||||
{
|
||||
ExplorerBar bar=this.GetItemContainerControl() as ExplorerBar;
|
||||
if(bar!=null)
|
||||
bar.RecalcLayout();
|
||||
}
|
||||
|
||||
protected override void OnSubItemsChanging()
|
||||
{
|
||||
base.OnSubItemsChanging();
|
||||
IComponentChangeService change=this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if(change!=null)
|
||||
{
|
||||
ExplorerBar bar=this.GetItemContainerControl() as ExplorerBar;
|
||||
change.OnComponentChanging(this.Component,TypeDescriptor.GetProperties(bar).Find("Groups",true));
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnSubItemsChanged()
|
||||
{
|
||||
base.OnSubItemsChanged();
|
||||
IComponentChangeService change=this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if(change!=null)
|
||||
{
|
||||
ExplorerBar bar=this.GetItemContainerControl() as ExplorerBar;
|
||||
change.OnComponentChanged(this.Component,TypeDescriptor.GetProperties(bar).Find("Groups",true),null,null);
|
||||
}
|
||||
}
|
||||
|
||||
// /// <summary>
|
||||
// /// Triggered when some other component on the form is removed.
|
||||
// /// </summary>
|
||||
// protected override void ComponentRemoved(object sender, ComponentEventArgs e)
|
||||
// {
|
||||
// base.ComponentRemoved(sender,e);
|
||||
// if(e.Component is ExplorerBarGroupItem)
|
||||
// {
|
||||
// ExplorerBar bar=this.GetItemContainerControl() as ExplorerBar;
|
||||
// if(bar.Groups.Contains(e.Component as BaseItem))
|
||||
// bar.Groups.Remove(e.Component as BaseItem);
|
||||
// DestroySubItems(e.Component as BaseItem);
|
||||
// bar.RecalcLayout();
|
||||
// }
|
||||
// }
|
||||
#endregion
|
||||
|
||||
#region Design-Time Item Creation
|
||||
private void OnAddGroup(object sender, EventArgs e)
|
||||
{
|
||||
IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
DesignerTransaction dt = dh.CreateTransaction();
|
||||
try
|
||||
{
|
||||
CreateGroup();
|
||||
}
|
||||
catch
|
||||
{
|
||||
dt.Cancel();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if(!dt.Canceled)
|
||||
dt.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
private ExplorerBarGroupItem CreateGroup()
|
||||
{
|
||||
ExplorerBar bar=this.Component as ExplorerBar;
|
||||
ExplorerBarGroupItem item=null;
|
||||
IDesignerHost dh=(IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
|
||||
if(bar!=null && dh!=null)
|
||||
{
|
||||
OnSubItemsChanging();
|
||||
try
|
||||
{
|
||||
m_CreatingItem = true;
|
||||
item = dh.CreateComponent(typeof(ExplorerBarGroupItem)) as ExplorerBarGroupItem;
|
||||
if (item == null)
|
||||
return null;
|
||||
item.SetDefaultAppearance();
|
||||
item.Text = "New Group";
|
||||
item.Expanded = true;
|
||||
bar.Groups.Add(item);
|
||||
OnSubItemsChanged();
|
||||
}
|
||||
finally
|
||||
{
|
||||
m_CreatingItem = false;
|
||||
}
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
private void OnAddButton(object sender, EventArgs e)
|
||||
{
|
||||
ExplorerBar bar=this.Component as ExplorerBar;
|
||||
ExplorerBarGroupItem group=null;
|
||||
|
||||
IDesignerHost dh=(IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
ISelectionService selection = (ISelectionService) this.GetService(typeof(ISelectionService));
|
||||
|
||||
DesignerTransaction dt = dh.CreateTransaction();
|
||||
try
|
||||
{
|
||||
if (selection != null && selection.PrimarySelection is ExplorerBarGroupItem)
|
||||
{
|
||||
group = selection.PrimarySelection as ExplorerBarGroupItem;
|
||||
}
|
||||
else if (bar.Groups.Count > 0)
|
||||
{
|
||||
System.Drawing.Point point = bar.PointToClient(Form.MousePosition);
|
||||
if (bar.Bounds.Contains(point))
|
||||
{
|
||||
foreach (BaseItem item in bar.Groups)
|
||||
{
|
||||
if (item.DisplayRectangle.Contains(point))
|
||||
{
|
||||
group = item as ExplorerBarGroupItem;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (group == null)
|
||||
{
|
||||
foreach (BaseItem item in bar.Groups)
|
||||
{
|
||||
if (item.Visible)
|
||||
{
|
||||
group = item as ExplorerBarGroupItem;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (group == null)
|
||||
group = CreateGroup();
|
||||
|
||||
IComponentChangeService change = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (change != null)
|
||||
change.OnComponentChanging(this.Component, TypeDescriptor.GetProperties(group).Find("SubItems", true));
|
||||
try
|
||||
{
|
||||
m_CreatingItem = true;
|
||||
ButtonItem button = dh.CreateComponent(typeof(ButtonItem)) as ButtonItem;
|
||||
if (button == null)
|
||||
return;
|
||||
ExplorerBarGroupItem.SetDesignTimeDefaults(button, group.StockStyle);
|
||||
group.SubItems.Add(button);
|
||||
if (change != null)
|
||||
change.OnComponentChanged(this.Component, TypeDescriptor.GetProperties(group).Find("SubItems", true), null, null);
|
||||
}
|
||||
finally
|
||||
{
|
||||
m_CreatingItem = false;
|
||||
}
|
||||
|
||||
this.RecalcLayout();
|
||||
}
|
||||
catch
|
||||
{
|
||||
dt.Cancel();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if(!dt.Canceled)
|
||||
dt.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool CanDragItem(BaseItem item)
|
||||
{
|
||||
if(item is ExplorerBarGroupItem)
|
||||
return false;
|
||||
return base.CanDragItem(item);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Designer for ExplorerBarGroupItem object.
|
||||
/// </summary>
|
||||
public class ExplorerBarGroupItemDesigner:BaseItemDesigner
|
||||
{
|
||||
protected override void BeforeNewItemAdded(BaseItem item)
|
||||
{
|
||||
base.BeforeNewItemAdded(item);
|
||||
if(item is ButtonItem)
|
||||
ExplorerBarGroupItem.SetDesignTimeDefaults((ButtonItem)item,((ExplorerBarGroupItem)this.Component).StockStyle);
|
||||
}
|
||||
|
||||
protected override void SetDesignTimeDefaults()
|
||||
{
|
||||
if (this.Component is ExplorerBarGroupItem)
|
||||
{
|
||||
ExplorerBarGroupItem e = this.Component as ExplorerBarGroupItem;
|
||||
e.SetDefaultAppearance();
|
||||
e.StockStyle = eExplorerBarStockStyle.SystemColors;
|
||||
}
|
||||
}
|
||||
|
||||
public override System.Collections.ICollection AssociatedComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
System.Collections.ArrayList c=new System.Collections.ArrayList(base.AssociatedComponents);
|
||||
BaseItem container=this.Component as BaseItem;
|
||||
if(container!=null)
|
||||
{
|
||||
foreach(BaseItem item in container.SubItems)
|
||||
c.Add(item);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Collection editor for ExplorerGroupItem.
|
||||
/// </summary>
|
||||
public class ExplorerBarGroupItemEditor:System.ComponentModel.Design.CollectionEditor
|
||||
{
|
||||
public ExplorerBarGroupItemEditor(Type type):base(type)
|
||||
{
|
||||
}
|
||||
protected override Type CreateCollectionItemType()
|
||||
{
|
||||
return typeof(ButtonItem);
|
||||
}
|
||||
protected override object CreateInstance(Type itemType)
|
||||
{
|
||||
object item=base.CreateInstance(itemType);
|
||||
if(item is ButtonItem)
|
||||
{
|
||||
ButtonItem button=item as ButtonItem;
|
||||
ExplorerBarGroupItem.SetDesignTimeDefaults(button,eExplorerBarStockStyle.Custom);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for ComboItemsEditor.
|
||||
/// </summary>
|
||||
public class ExplorerBarPanelsEditor : System.ComponentModel.Design.CollectionEditor
|
||||
{
|
||||
public ExplorerBarPanelsEditor(Type type)
|
||||
: base(type)
|
||||
{
|
||||
}
|
||||
protected override Type CreateCollectionItemType()
|
||||
{
|
||||
return typeof(ExplorerBarGroupItem);
|
||||
}
|
||||
protected override Type[] CreateNewItemTypes()
|
||||
{
|
||||
return new Type[] { typeof(ExplorerBarGroupItem) };
|
||||
}
|
||||
protected override object CreateInstance(Type itemType)
|
||||
{
|
||||
object item = base.CreateInstance(itemType);
|
||||
if (item is ExplorerBarGroupItem)
|
||||
{
|
||||
ExplorerBarGroupItem panel = item as ExplorerBarGroupItem;
|
||||
panel.Text = "New Group";
|
||||
}
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,281 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing.Design;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms.Design;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
// UITypeEditor for flag enums
|
||||
public class FlagEnumUIEditor : UITypeEditor
|
||||
{
|
||||
// The checklistbox
|
||||
private FlagCheckedListBox flagEnumCB;
|
||||
|
||||
public FlagEnumUIEditor()
|
||||
{
|
||||
flagEnumCB = new FlagCheckedListBox();
|
||||
flagEnumCB.BorderStyle = BorderStyle.None;
|
||||
}
|
||||
|
||||
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
|
||||
{
|
||||
if (context != null
|
||||
&& context.Instance != null
|
||||
&& provider != null)
|
||||
{
|
||||
|
||||
IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
|
||||
|
||||
if (edSvc != null)
|
||||
{
|
||||
|
||||
Enum e = (Enum)Convert.ChangeType(value, context.PropertyDescriptor.PropertyType);
|
||||
flagEnumCB.EnumValue = e;
|
||||
edSvc.DropDownControl(flagEnumCB);
|
||||
return flagEnumCB.EnumValue;
|
||||
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
|
||||
{
|
||||
return UITypeEditorEditStyle.DropDown;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#region FlagCheckedListBox
|
||||
internal class FlagCheckedListBox : CheckedListBox
|
||||
{
|
||||
private System.ComponentModel.Container components = null;
|
||||
|
||||
public FlagCheckedListBox()
|
||||
{
|
||||
// This call is required by the Windows.Forms Form Designer.
|
||||
InitializeComponent();
|
||||
|
||||
// TODO: Add any initialization after the InitForm call
|
||||
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (components != null)
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
private void InitializeComponent()
|
||||
{
|
||||
//
|
||||
// FlaggedCheckedListBox
|
||||
//
|
||||
this.CheckOnClick = true;
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
// Adds an integer value and its associated description
|
||||
public FlagCheckedListBoxItem Add(int v, string c)
|
||||
{
|
||||
FlagCheckedListBoxItem item = new FlagCheckedListBoxItem(v, c);
|
||||
Items.Add(item);
|
||||
return item;
|
||||
}
|
||||
|
||||
public FlagCheckedListBoxItem Add(FlagCheckedListBoxItem item)
|
||||
{
|
||||
Items.Add(item);
|
||||
return item;
|
||||
}
|
||||
|
||||
protected override void OnItemCheck(ItemCheckEventArgs e)
|
||||
{
|
||||
base.OnItemCheck(e);
|
||||
|
||||
if (isUpdatingCheckStates)
|
||||
return;
|
||||
|
||||
// Get the checked/unchecked item
|
||||
FlagCheckedListBoxItem item = Items[e.Index] as FlagCheckedListBoxItem;
|
||||
// Update other items
|
||||
UpdateCheckedItems(item, e.NewValue);
|
||||
}
|
||||
|
||||
// Checks/Unchecks items depending on the give bitvalue
|
||||
protected void UpdateCheckedItems(int value)
|
||||
{
|
||||
|
||||
isUpdatingCheckStates = true;
|
||||
|
||||
// Iterate over all items
|
||||
for (int i = 0; i < Items.Count; i++)
|
||||
{
|
||||
FlagCheckedListBoxItem item = Items[i] as FlagCheckedListBoxItem;
|
||||
|
||||
if (item.value == 0)
|
||||
{
|
||||
SetItemChecked(i, value == 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// If the bit for the current item is on in the bitvalue, check it
|
||||
if ((item.value & value) == item.value && item.value != 0)
|
||||
SetItemChecked(i, true);
|
||||
// Otherwise uncheck it
|
||||
else
|
||||
SetItemChecked(i, false);
|
||||
}
|
||||
}
|
||||
|
||||
isUpdatingCheckStates = false;
|
||||
|
||||
}
|
||||
|
||||
// Updates items in the checklistbox
|
||||
// composite = The item that was checked/unchecked
|
||||
// cs = The check state of that item
|
||||
protected void UpdateCheckedItems(FlagCheckedListBoxItem composite, CheckState cs)
|
||||
{
|
||||
|
||||
// If the value of the item is 0, call directly.
|
||||
if (composite.value == 0)
|
||||
UpdateCheckedItems(0);
|
||||
|
||||
|
||||
// Get the total value of all checked items
|
||||
int sum = 0;
|
||||
for (int i = 0; i < Items.Count; i++)
|
||||
{
|
||||
FlagCheckedListBoxItem item = Items[i] as FlagCheckedListBoxItem;
|
||||
|
||||
// If item is checked, add its value to the sum.
|
||||
if (GetItemChecked(i))
|
||||
sum |= item.value;
|
||||
}
|
||||
|
||||
// If the item has been unchecked, remove its bits from the sum
|
||||
if (cs == CheckState.Unchecked)
|
||||
sum = sum & (~composite.value);
|
||||
// If the item has been checked, combine its bits with the sum
|
||||
else
|
||||
sum |= composite.value;
|
||||
|
||||
// Update all items in the checklistbox based on the final bit value
|
||||
UpdateCheckedItems(sum);
|
||||
|
||||
}
|
||||
|
||||
private bool isUpdatingCheckStates = false;
|
||||
|
||||
// Gets the current bit value corresponding to all checked items
|
||||
public int GetCurrentValue()
|
||||
{
|
||||
int sum = 0;
|
||||
|
||||
for (int i = 0; i < Items.Count; i++)
|
||||
{
|
||||
FlagCheckedListBoxItem item = Items[i] as FlagCheckedListBoxItem;
|
||||
|
||||
if (GetItemChecked(i))
|
||||
sum |= item.value;
|
||||
}
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
Type enumType;
|
||||
Enum enumValue;
|
||||
|
||||
// Adds items to the checklistbox based on the members of the enum
|
||||
private void FillEnumMembers()
|
||||
{
|
||||
foreach (string name in Enum.GetNames(enumType))
|
||||
{
|
||||
object val = Enum.Parse(enumType, name);
|
||||
int intVal = (int)Convert.ChangeType(val, typeof(int));
|
||||
|
||||
Add(intVal, name);
|
||||
}
|
||||
}
|
||||
|
||||
// Checks/unchecks items based on the current value of the enum variable
|
||||
private void ApplyEnumValue()
|
||||
{
|
||||
int intVal = (int)Convert.ChangeType(enumValue, typeof(int));
|
||||
UpdateCheckedItems(intVal);
|
||||
|
||||
}
|
||||
|
||||
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]
|
||||
public Enum EnumValue
|
||||
{
|
||||
get
|
||||
{
|
||||
object e = Enum.ToObject(enumType, GetCurrentValue());
|
||||
return (Enum)e;
|
||||
}
|
||||
set
|
||||
{
|
||||
|
||||
Items.Clear();
|
||||
enumValue = value; // Store the current enum value
|
||||
enumType = value.GetType(); // Store enum type
|
||||
FillEnumMembers(); // Add items for enum members
|
||||
ApplyEnumValue(); // Check/uncheck items depending on enum value
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Represents an item in the checklistbox
|
||||
public class FlagCheckedListBoxItem
|
||||
{
|
||||
public FlagCheckedListBoxItem(int v, string c)
|
||||
{
|
||||
value = v;
|
||||
caption = c;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return caption;
|
||||
}
|
||||
|
||||
// Returns true if the value corresponds to a single bit being set
|
||||
public bool IsFlag
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((value & (value - 1)) == 0);
|
||||
}
|
||||
}
|
||||
|
||||
// Returns true if this value is a member of the composite bit value
|
||||
public bool IsMemberFlag(FlagCheckedListBoxItem composite)
|
||||
{
|
||||
return (IsFlag && ((value & composite.value) == value));
|
||||
}
|
||||
|
||||
public int value;
|
||||
public string caption;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
using DevComponents.DotNetBar.Controls;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Text;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
public class FlyoutDesigner : ComponentDesigner
|
||||
{
|
||||
#region Implementation
|
||||
public override void InitializeNewComponent(IDictionary defaultValues)
|
||||
{
|
||||
SetDefaults();
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
|
||||
}
|
||||
|
||||
private void SetDefaults()
|
||||
{
|
||||
IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
if (dh != null)
|
||||
{
|
||||
if (dh.Loading)
|
||||
{
|
||||
dh.LoadComplete += DesignerLoadComplete;
|
||||
return;
|
||||
}
|
||||
Flyout flyout = this.Component as Flyout;
|
||||
if (flyout != null)
|
||||
{
|
||||
System.Windows.Forms.Control parent = dh.RootComponent as System.Windows.Forms.Control;
|
||||
if (parent != null)
|
||||
{
|
||||
flyout.Parent = parent;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void DesignerLoadComplete(object sender, EventArgs e)
|
||||
{
|
||||
IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
if (dh != null)
|
||||
dh.LoadComplete -= DesignerLoadComplete;
|
||||
SetDefaults();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.ComponentModel.Design;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Collections;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents Windows Forms Designer for GalleryContainer object.
|
||||
/// </summary>
|
||||
public class GalleryContainerDesigner : ItemContainerDesigner
|
||||
{
|
||||
public override void Initialize(IComponent component)
|
||||
{
|
||||
base.Initialize(component);
|
||||
|
||||
if (component is GalleryContainer)
|
||||
((GalleryContainer)component).PopupGalleryItem.SetDesignMode(true);
|
||||
}
|
||||
|
||||
protected override void SetDesignTimeDefaults()
|
||||
{
|
||||
GalleryContainer gc = this.Component as GalleryContainer;
|
||||
gc.StretchGallery = true;
|
||||
gc.BackgroundStyle.Class = Rendering.ElementStyleClassKeys.RibbonGalleryContainerKey;
|
||||
base.SetDesignTimeDefaults();
|
||||
}
|
||||
|
||||
protected override void AddNewItem(BaseItem newItem)
|
||||
{
|
||||
GalleryContainer gc = this.Component as GalleryContainer;
|
||||
if (gc != null && !gc.DesignTimeMouseDownPoint.IsEmpty)
|
||||
{
|
||||
if (gc.PopupGalleryButtonBounds.Contains(gc.DesignTimeMouseDownPoint))
|
||||
{
|
||||
gc.DesignTimeMouseDownPoint = Point.Empty;
|
||||
// Add new item to the PopupGalleryItems collection instead of to SubItems...
|
||||
System.ComponentModel.Design.IComponentChangeService change = this.GetService(typeof(System.ComponentModel.Design.IComponentChangeService)) as IComponentChangeService;
|
||||
if (change != null)
|
||||
change.OnComponentChanging(this.Component, TypeDescriptor.GetProperties(this.Component).Find("PopupGalleryItems", true));
|
||||
|
||||
gc.PopupGalleryItems.Add(newItem);
|
||||
|
||||
if (change != null)
|
||||
change.OnComponentChanged(this.Component, TypeDescriptor.GetProperties(this.Component).Find("PopupGalleryItems", true), null, null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
base.AddNewItem(newItem);
|
||||
}
|
||||
|
||||
protected override void NewItemAdded(BaseItem itemAdded)
|
||||
{
|
||||
base.NewItemAdded(itemAdded);
|
||||
GalleryContainer gc = this.Component as GalleryContainer;
|
||||
if (gc != null && gc.SubItems.Contains(itemAdded) && !(gc.Parent is ButtonItem))
|
||||
gc.EnsureVisible(itemAdded);
|
||||
}
|
||||
|
||||
protected override void RecalcLayout()
|
||||
{
|
||||
base.RecalcLayout();
|
||||
GalleryContainer gc = this.Component as GalleryContainer;
|
||||
if (gc.PopupGalleryItem.Expanded && gc.PopupGalleryItem.PopupControl != null)
|
||||
{
|
||||
Control control = gc.PopupGalleryItem.PopupControl;
|
||||
if (control is MenuPanel)
|
||||
((MenuPanel)control).RecalcSize();
|
||||
else if (control is Bar)
|
||||
((Bar)control).RecalcLayout();
|
||||
}
|
||||
}
|
||||
|
||||
public override System.Collections.ICollection AssociatedComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
System.Collections.ArrayList components = new System.Collections.ArrayList();
|
||||
components.AddRange(base.AssociatedComponents);
|
||||
GalleryContainer gc = this.Component as GalleryContainer;
|
||||
if (gc == null)
|
||||
return components;
|
||||
gc.PopupGalleryItems.CopyTo(components);
|
||||
return components;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void ComponentRemoved(ComponentEventArgs e)
|
||||
{
|
||||
if (e.Component is GalleryGroup)
|
||||
{
|
||||
GalleryGroup g = e.Component as GalleryGroup;
|
||||
GalleryContainer c = this.Component as GalleryContainer;
|
||||
if (c != null && c.GalleryGroups.Contains(g))
|
||||
{
|
||||
IComponentChangeService cc = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (cc != null)
|
||||
cc.OnComponentChanging(c, TypeDescriptor.GetProperties(c)["GalleryGroups"]);
|
||||
c.GalleryGroups.Remove(g);
|
||||
if (cc != null)
|
||||
cc.OnComponentChanged(c, TypeDescriptor.GetProperties(c)["GalleryGroups"], null, null);
|
||||
}
|
||||
}
|
||||
base.ComponentRemoved(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for ComboItemsEditor.
|
||||
/// </summary>
|
||||
public class GalleryGroupCollectionEditor : System.ComponentModel.Design.CollectionEditor
|
||||
{
|
||||
public GalleryGroupCollectionEditor(Type type)
|
||||
: base(type)
|
||||
{
|
||||
}
|
||||
protected override Type CreateCollectionItemType()
|
||||
{
|
||||
return typeof(GalleryGroup);
|
||||
}
|
||||
protected override object CreateInstance(Type itemType)
|
||||
{
|
||||
object item = base.CreateInstance(itemType);
|
||||
if (item is GalleryGroup)
|
||||
{
|
||||
GalleryGroup group = item as GalleryGroup;
|
||||
group.Text = group.Name;
|
||||
}
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents converter for GalleryGroup object.
|
||||
/// </summary>
|
||||
public class GalleryGroupConverter : ExpandableObjectConverter
|
||||
{
|
||||
public override bool CanConvertTo(ITypeDescriptorContext context, System.Type destinationType)
|
||||
{
|
||||
if (destinationType == typeof(GalleryGroup))
|
||||
return true;
|
||||
|
||||
return base.CanConvertTo(context, destinationType);
|
||||
}
|
||||
|
||||
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, System.Type destinationType)
|
||||
{
|
||||
if (destinationType == typeof(System.String) && value is GalleryGroup)
|
||||
{
|
||||
|
||||
GalleryGroup g = (GalleryGroup)value;
|
||||
|
||||
return g.Text;
|
||||
}
|
||||
return base.ConvertTo(context, culture, value, destinationType);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Drawing.Design;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms.Design;
|
||||
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents GalleryGroup type editor provided for Windows Forms designer support.
|
||||
/// </summary>
|
||||
public class GalleryGroupTypeEditor : UITypeEditor
|
||||
{
|
||||
private IWindowsFormsEditorService m_EdSvc = null;
|
||||
private const string CREATE_NEW_GROUP = "<Create new group>";
|
||||
|
||||
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
|
||||
{
|
||||
if (context != null && context.Instance != null)
|
||||
{
|
||||
return UITypeEditorEditStyle.DropDown;
|
||||
}
|
||||
return base.GetEditStyle(context);
|
||||
}
|
||||
|
||||
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
|
||||
{
|
||||
|
||||
if (context != null && context.Instance != null && provider != null)
|
||||
{
|
||||
m_EdSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
|
||||
if (m_EdSvc != null)
|
||||
{
|
||||
GalleryGroupCollection groups = null;
|
||||
BaseItem itemToAssign = null;
|
||||
GalleryContainer gallery = null;
|
||||
if (context.Instance is BaseItem)
|
||||
{
|
||||
itemToAssign = (BaseItem)context.Instance;
|
||||
gallery = itemToAssign.Parent as GalleryContainer;
|
||||
if (gallery != null)
|
||||
groups = gallery.GalleryGroups;
|
||||
else
|
||||
{
|
||||
System.Windows.Forms.MessageBox.Show("Item does not belong to the Gallery. Cannot edit groups.");
|
||||
return value;
|
||||
}
|
||||
}
|
||||
if (groups == null && context.Instance != null)
|
||||
System.Windows.Forms.MessageBox.Show("Unknow control using GalleryGroupTypeEditor. Cannot edit groups. [" + context.Instance.ToString() + "]");
|
||||
else if (groups == null)
|
||||
System.Windows.Forms.MessageBox.Show("Unknow control using GalleryGroupTypeEditor. Cannot edit groups. [context instance null]");
|
||||
|
||||
GalleryGroup selectedGroup = gallery.GetGalleryGroup(itemToAssign);
|
||||
ListBox listBox = new ListBox();
|
||||
foreach (GalleryGroup g in groups)
|
||||
{
|
||||
listBox.Items.Add(g);
|
||||
if (g == selectedGroup)
|
||||
listBox.SelectedItem = g;
|
||||
}
|
||||
|
||||
listBox.Items.Add(CREATE_NEW_GROUP);
|
||||
|
||||
listBox.SelectedIndexChanged += new EventHandler(this.SelectedChanged);
|
||||
m_EdSvc.DropDownControl(listBox);
|
||||
if (listBox.SelectedItem is string && listBox.SelectedItem.ToString() == CREATE_NEW_GROUP)
|
||||
value = DesignerSupport.CreateGalleryGroup(gallery, provider);
|
||||
else
|
||||
value = listBox.SelectedItem;
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
private void SelectedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (m_EdSvc != null)
|
||||
m_EdSvc.CloseDropDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Text;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
internal class GlyphServiceProvider : IServiceProvider
|
||||
{
|
||||
private IServiceProvider source;
|
||||
|
||||
public GlyphServiceProvider(IServiceProvider source)
|
||||
{
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
object IServiceProvider.GetService(Type serviceType)
|
||||
{
|
||||
if (serviceType.Equals(typeof(ISelectionService)))
|
||||
return (object)null;
|
||||
return this.source.GetService(serviceType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using DevComponents.DotNetBar.Controls;
|
||||
using System.Collections;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the Windows Forms designer for the GroupPanel control.
|
||||
/// </summary>
|
||||
public class GroupPanelDesigner : System.Windows.Forms.Design.ScrollableControlDesigner
|
||||
{
|
||||
public override DesignerVerbCollection Verbs
|
||||
{
|
||||
get
|
||||
{
|
||||
DesignerVerb[] verbs;
|
||||
verbs = new DesignerVerb[]
|
||||
{
|
||||
new DesignerVerb("Reset Style", new EventHandler(ResetStyle)),
|
||||
};
|
||||
return new DesignerVerbCollection(verbs);
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetStyle(object sender, EventArgs e)
|
||||
{
|
||||
GroupPanel p = this.Control as GroupPanel;
|
||||
if (p == null)
|
||||
return;
|
||||
|
||||
IComponentChangeService change = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (change != null)
|
||||
change.OnComponentChanging(this.Component, null);
|
||||
|
||||
p.SetDefaultPanelStyle();
|
||||
|
||||
if (change != null)
|
||||
change.OnComponentChanged(this.Component, null, null, null);
|
||||
}
|
||||
|
||||
#if FRAMEWORK20
|
||||
public override void InitializeNewComponent(IDictionary defaultValues)
|
||||
{
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#else
|
||||
public override void OnSetComponentDefaults()
|
||||
{
|
||||
base.OnSetComponentDefaults();
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#endif
|
||||
|
||||
private void SetDesignTimeDefaults()
|
||||
{
|
||||
GroupPanel p = this.Control as GroupPanel;
|
||||
if (p == null)
|
||||
return;
|
||||
p.SetDefaultPanelStyle();
|
||||
}
|
||||
|
||||
protected override void OnPaintAdornments(PaintEventArgs pe)
|
||||
{
|
||||
PanelControl p;
|
||||
p = this.Component as PanelControl;
|
||||
if (p.Style.Border == eStyleBorderType.None)
|
||||
this.DrawBorder(pe.Graphics);
|
||||
base.OnPaintAdornments(pe);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws design-time border around the panel when panel does not have one.
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
protected virtual void DrawBorder(Graphics g)
|
||||
{
|
||||
PanelControl panel = this.Control as PanelControl;
|
||||
Color border = SystemColors.ControlDarkDark;
|
||||
Rectangle rClient = this.Control.ClientRectangle;
|
||||
Color backColor = panel.Style.BackColor;
|
||||
|
||||
Helpers.DrawDesignTimeSelection(g, rClient, backColor, border, 1);
|
||||
}
|
||||
|
||||
protected override void WndProc(ref Message m)
|
||||
{
|
||||
if (m.Msg == (int)WinApi.WindowsMessages.WM_NCHITTEST)
|
||||
{
|
||||
GroupPanel gp = this.Control as GroupPanel;
|
||||
if (gp != null)
|
||||
{
|
||||
int x = WinApi.LOWORD(m.LParam);
|
||||
int y = WinApi.HIWORD(m.LParam);
|
||||
Point p = gp.PointToClient(new Point(x, y));
|
||||
if (p.Y<0)
|
||||
{
|
||||
m.Result = new IntPtr((int)WinApi.WindowHitTestRegions.ClientArea);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
base.WndProc(ref m);
|
||||
}
|
||||
}
|
||||
}
|
||||
69
PROMS/DotNetBar Source Code/DotNetBarDesignTime/Helpers.cs
Normal file
69
PROMS/DotNetBar Source Code/DotNetBarDesignTime/Helpers.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.Reflection;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
internal static class Helpers
|
||||
{
|
||||
internal static Bitmap LoadBitmap(string imageName)
|
||||
{
|
||||
DotNetBarResourcesAttribute att = Attribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(DotNetBarResourcesAttribute)) as DotNetBarResourcesAttribute;
|
||||
if (att != null && att.NamespacePrefix != "")
|
||||
{
|
||||
return new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream(att.NamespacePrefix + "." + imageName));
|
||||
}
|
||||
else
|
||||
return new Bitmap(typeof(DevComponents.DotNetBar.DotNetBarManager), imageName);
|
||||
}
|
||||
|
||||
internal static Icon LoadIcon(string imageName)
|
||||
{
|
||||
DotNetBarResourcesAttribute att = Attribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(DotNetBarResourcesAttribute)) as DotNetBarResourcesAttribute;
|
||||
if (att != null && att.NamespacePrefix != "")
|
||||
{
|
||||
return new Icon(Assembly.GetExecutingAssembly().GetManifestResourceStream(att.NamespacePrefix + "." + imageName));
|
||||
}
|
||||
else
|
||||
return new Icon(typeof(DevComponents.DotNetBar.DotNetBarManager), imageName);
|
||||
}
|
||||
|
||||
public static void DrawDesignTimeSelection(Graphics g, Rectangle r, Color backColor, Color border, int penWidth)
|
||||
{
|
||||
if (r.Width <= 0 || r.Height <= 0)
|
||||
return;
|
||||
if (!backColor.IsEmpty && backColor != Color.Transparent)
|
||||
{
|
||||
if ((double)backColor.GetBrightness() < 0.5)
|
||||
border = System.Windows.Forms.ControlPaint.Light(backColor);
|
||||
else
|
||||
border = System.Windows.Forms.ControlPaint.Dark(backColor);
|
||||
}
|
||||
using (Pen pen = new Pen(border, penWidth))
|
||||
{
|
||||
pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
|
||||
r.Width--;
|
||||
r.Height--;
|
||||
g.DrawRectangle(pen, r);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsOffice2007Style(eDotNetBarStyle style)
|
||||
{
|
||||
if (style == eDotNetBarStyle.StyleManagerControlled)
|
||||
style = StyleManager.GetEffectiveStyle();
|
||||
return (style == eDotNetBarStyle.Office2007 || style == eDotNetBarStyle.Office2010 || style == eDotNetBarStyle.Windows7 || StyleManager.IsMetro(style));
|
||||
}
|
||||
|
||||
internal static string GetItemErrorInfo(System.Xml.XmlElement xmlItem)
|
||||
{
|
||||
string s = "";
|
||||
if (xmlItem.HasAttribute("assembly"))
|
||||
s = s + xmlItem.GetAttribute("assembly");
|
||||
if (xmlItem.HasAttribute("class"))
|
||||
s = s + xmlItem.GetAttribute("class");
|
||||
return s;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
using System;
|
||||
using System.ComponentModel.Design;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents Windows Forms Designer for ItemContainer object.
|
||||
/// </summary>
|
||||
public class ItemContainerDesigner:BaseItemDesigner
|
||||
{
|
||||
public override DesignerVerbCollection Verbs
|
||||
{
|
||||
get
|
||||
{
|
||||
DesignerVerb[] verbs;
|
||||
if (this.Component is BaseItem && ((BaseItem)this.Component).ContainerControl is DevComponents.DotNetBar.Metro.MetroTilePanel)
|
||||
{
|
||||
verbs = new DesignerVerb[]
|
||||
{
|
||||
new DesignerVerb("Add Metro Tile", new EventHandler(CreateMetroTile)),
|
||||
new DesignerVerb("Add Label", new EventHandler(CreateLabel))
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
verbs = new DesignerVerb[]
|
||||
{
|
||||
new DesignerVerb("Add Button", new EventHandler(CreateButton)),
|
||||
new DesignerVerb("Add Horizontal Container", new EventHandler(CreateHorizontalContainer)),
|
||||
new DesignerVerb("Add Vertical Container", new EventHandler(CreateVerticalContainer)),
|
||||
new DesignerVerb("Add Scrollable Container", new EventHandler(CreateGallery)),
|
||||
new DesignerVerb("Add Text Box", new EventHandler(CreateTextBox)),
|
||||
new DesignerVerb("Add Combo Box", new EventHandler(CreateComboBox)),
|
||||
new DesignerVerb("Add Label", new EventHandler(CreateLabel)),
|
||||
new DesignerVerb("Add Check Box", new EventHandler(CreateCheckBox)),
|
||||
new DesignerVerb("Add Micro-Chart", new EventHandler(CreateMicroChart)),
|
||||
new DesignerVerb("Add Switch button", new EventHandler(CreateSwitch)),
|
||||
new DesignerVerb("Add Control Container", new EventHandler(CreateControlContainer)),
|
||||
new DesignerVerb("Add Color Picker", new EventHandler(CreateColorPicker)),
|
||||
new DesignerVerb("Add Progress-Bar", new EventHandler(CreateProgressBar)),
|
||||
new DesignerVerb("Add Circular Progress", new EventHandler(CreateCircularProgressItem)),
|
||||
new DesignerVerb("Add Rating Item", new EventHandler(CreateRatingItem)),
|
||||
new DesignerVerb("Add Slider", new EventHandler(CreateSlider)),
|
||||
new DesignerVerb("Add Range Slider", new EventHandler(CreateRangeSlider))
|
||||
#if FRAMEWORK20
|
||||
,new DesignerVerb("Add Month Calendar", new EventHandler(CreateMonthCalendar))
|
||||
,new DesignerVerb("Add Metro Tile", new EventHandler(CreateMetroTile))
|
||||
#endif
|
||||
};
|
||||
}
|
||||
return new DesignerVerbCollection(verbs);
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateVerticalContainer(object sender, EventArgs e)
|
||||
{
|
||||
CreateContainer(eOrientation.Vertical);
|
||||
}
|
||||
|
||||
private void CreateHorizontalContainer(object sender, EventArgs e)
|
||||
{
|
||||
CreateContainer(eOrientation.Horizontal);
|
||||
}
|
||||
|
||||
private void CreateContainer(eOrientation orientation)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_CreatingItem = true;
|
||||
DesignerSupport.CreateItemContainer(this, (BaseItem)this.Component, orientation);
|
||||
this.RecalcLayout();
|
||||
}
|
||||
finally
|
||||
{
|
||||
m_CreatingItem = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,234 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Drawing;
|
||||
using DevComponents.DotNetBar.Rendering;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents Windows Forms Designer for the ItemPanel control.
|
||||
/// </summary>
|
||||
public class ItemPanelDesigner : BarBaseControlDesigner
|
||||
{
|
||||
public ItemPanelDesigner()
|
||||
{
|
||||
this.EnableItemDragDrop=true;
|
||||
}
|
||||
|
||||
public override void Initialize(IComponent component)
|
||||
{
|
||||
base.Initialize(component);
|
||||
if (component == null || component.Site == null || !component.Site.DesignMode)
|
||||
return;
|
||||
|
||||
#if !TRIAL
|
||||
IDesignerHost dh = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
if (dh != null)
|
||||
dh.LoadComplete += new EventHandler(dh_LoadComplete);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if FRAMEWORK20
|
||||
public override void InitializeNewComponent(IDictionary defaultValues)
|
||||
{
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#else
|
||||
public override void OnSetComponentDefaults()
|
||||
{
|
||||
SetDesignTimeDefaults();
|
||||
base.OnSetComponentDefaults();
|
||||
}
|
||||
#endif
|
||||
|
||||
protected virtual void SetDesignTimeDefaults()
|
||||
{
|
||||
ItemPanel panel = this.Control as ItemPanel;
|
||||
panel.LayoutOrientation = eOrientation.Vertical;
|
||||
panel.BackgroundStyle.Class = ElementStyleClassKeys.ItemPanelKey;
|
||||
//panel.BackgroundStyle.Border = eStyleBorderType.Solid;
|
||||
//panel.BackgroundStyle.BorderColor = ColorScheme.GetColor("7F9DB9");
|
||||
//panel.BackgroundStyle.BorderWidth = 1;
|
||||
//panel.BackgroundStyle.PaddingLeft = 1;
|
||||
//panel.BackgroundStyle.PaddingRight = 1;
|
||||
//panel.BackgroundStyle.PaddingTop = 1;
|
||||
//panel.BackgroundStyle.PaddingBottom = 1;
|
||||
//panel.BackgroundStyle.BackColor = Color.White;
|
||||
#if !TRIAL
|
||||
string key = GetLicenseKey();
|
||||
panel.LicenseKey = key;
|
||||
#endif
|
||||
}
|
||||
|
||||
public override DesignerVerbCollection Verbs
|
||||
{
|
||||
get
|
||||
{
|
||||
Bar bar = this.Control as Bar;
|
||||
DesignerVerb[] verbs = null;
|
||||
verbs = new DesignerVerb[]
|
||||
{
|
||||
new DesignerVerb("Add Button", new EventHandler(CreateButton)),
|
||||
new DesignerVerb("Add Horizontal Container", new EventHandler(CreateHorizontalContainer)),
|
||||
new DesignerVerb("Add Vertical Container", new EventHandler(CreateVerticalContainer)),
|
||||
new DesignerVerb("Add Dock Container", new EventHandler(CreateDockContainer)),
|
||||
new DesignerVerb("Add Text Box", new EventHandler(CreateTextBox)),
|
||||
new DesignerVerb("Add Combo Box", new EventHandler(CreateComboBox)),
|
||||
new DesignerVerb("Add Label", new EventHandler(CreateLabel)),
|
||||
new DesignerVerb("Add Color Picker", new EventHandler(CreateColorPicker)),
|
||||
new DesignerVerb("Add Micro-Chart", new EventHandler(CreateMicroChart)),
|
||||
new DesignerVerb("Add Switch Button", new EventHandler(CreateSwitch)),
|
||||
new DesignerVerb("Add Progress bar", new EventHandler(CreateProgressBar)),
|
||||
new DesignerVerb("Add Check box", new EventHandler(CreateCheckBox)),
|
||||
new DesignerVerb("Add WinForms Control Container", new EventHandler(CreateControlContainer)),
|
||||
new DesignerVerb("Add Metro Tile", new EventHandler(CreateMetroTile)),
|
||||
new DesignerVerb("Apply Panel Style", new EventHandler(ApplyPanelStyle)),
|
||||
new DesignerVerb("Apply Default Style", new EventHandler(ApplyDefaultStyle))
|
||||
};
|
||||
return new DesignerVerbCollection(verbs);
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyPanelStyle(object sender, EventArgs e)
|
||||
{
|
||||
ItemPanel p = this.Control as ItemPanel;
|
||||
if (p == null)
|
||||
return;
|
||||
|
||||
IComponentChangeService change = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (change != null)
|
||||
change.OnComponentChanging(this.Component, null);
|
||||
|
||||
ElementStyle bs = p.BackgroundStyle;
|
||||
bs.Reset();
|
||||
|
||||
bs.Border = eStyleBorderType.Solid;
|
||||
bs.BorderWidth = 1;
|
||||
bs.BorderColorSchemePart = eColorSchemePart.PanelBorder;
|
||||
bs.BackColorSchemePart = eColorSchemePart.PanelBackground;
|
||||
bs.BackColor2SchemePart = eColorSchemePart.PanelBackground2;
|
||||
bs.BackColorGradientAngle = 90;
|
||||
|
||||
if (change != null)
|
||||
change.OnComponentChanged(this.Component, null, null, null);
|
||||
}
|
||||
|
||||
private void ApplyDefaultStyle(object sender, EventArgs e)
|
||||
{
|
||||
ItemPanel p = this.Control as ItemPanel;
|
||||
if (p == null)
|
||||
return;
|
||||
|
||||
IComponentChangeService change = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (change != null)
|
||||
change.OnComponentChanging(this.Component, null);
|
||||
|
||||
ElementStyle bs = p.BackgroundStyle;
|
||||
bs.Reset();
|
||||
|
||||
bs.Border = eStyleBorderType.Solid;
|
||||
bs.BorderWidth = 1;
|
||||
bs.BorderColorSchemePart = eColorSchemePart.PanelBorder;
|
||||
bs.BackColor = Color.White;
|
||||
|
||||
if (change != null)
|
||||
change.OnComponentChanged(this.Component, null, null, null);
|
||||
}
|
||||
|
||||
private void CreateDockContainer(object sender, EventArgs e)
|
||||
{
|
||||
CreateDockContainer(this.GetItemContainer());
|
||||
}
|
||||
private void CreateVerticalContainer(object sender, EventArgs e)
|
||||
{
|
||||
CreateContainer(this.GetItemContainer(), eOrientation.Vertical);
|
||||
}
|
||||
|
||||
protected virtual void CreateHorizontalContainer(object sender, EventArgs e)
|
||||
{
|
||||
CreateContainer(this.GetItemContainer(), eOrientation.Horizontal);
|
||||
}
|
||||
|
||||
protected virtual ItemContainer CreateContainer(BaseItem parent, eOrientation orientation)
|
||||
{
|
||||
ItemContainer container = null;
|
||||
m_CreatingItem = true;
|
||||
try
|
||||
{
|
||||
container = DesignerSupport.CreateItemContainer(this, parent, orientation);
|
||||
}
|
||||
finally
|
||||
{
|
||||
m_CreatingItem = false;
|
||||
}
|
||||
this.RecalcLayout();
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
protected virtual ItemDockContainer CreateDockContainer(BaseItem parent)
|
||||
{
|
||||
ItemDockContainer container = null;
|
||||
m_CreatingItem = true;
|
||||
try
|
||||
{
|
||||
container = DesignerSupport.CreateItemDockContainer(this, parent);
|
||||
}
|
||||
finally
|
||||
{
|
||||
m_CreatingItem = false;
|
||||
}
|
||||
this.RecalcLayout();
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
protected override bool GetHitTest(Point pt)
|
||||
{
|
||||
ItemPanel panel = this.Control as ItemPanel;
|
||||
if (panel != null && panel.IsHandleCreated && panel.AutoScroll)
|
||||
{
|
||||
Point p = panel.PointToClient(pt);
|
||||
if (panel.VScrollBar != null && panel.VScrollBar.Bounds.Contains(p))
|
||||
return true;
|
||||
if (panel.HScrollBar != null && panel.HScrollBar.Bounds.Contains(p))
|
||||
return true;
|
||||
|
||||
}
|
||||
return base.GetHitTest(pt);
|
||||
}
|
||||
|
||||
#region Licensing Stuff
|
||||
#if !TRIAL
|
||||
protected 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 dh_LoadComplete(object sender, EventArgs e)
|
||||
{
|
||||
IDesignerHost dh = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
if (dh != null)
|
||||
dh.LoadComplete -= new EventHandler(dh_LoadComplete);
|
||||
|
||||
string key = GetLicenseKey();
|
||||
ItemPanel bar = this.Control as ItemPanel;
|
||||
if (key != "" && bar != null && bar.LicenseKey == "" && bar.LicenseKey != key)
|
||||
TypeDescriptor.GetProperties(bar)["LicenseKey"].SetValue(bar, key);
|
||||
}
|
||||
#endif
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms.Design;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
using DevComponents.DotNetBar.Metro;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Drawing.Design;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
public class ItemSelectorTypeEditor : System.Drawing.Design.UITypeEditor
|
||||
{
|
||||
private IWindowsFormsEditorService edSvc = null;
|
||||
private Type[] _AvailableTypes = new Type[] {
|
||||
typeof(ButtonItem),
|
||||
typeof(CheckBoxItem),
|
||||
typeof(MetroTileItem),
|
||||
typeof(LabelItem)
|
||||
};
|
||||
|
||||
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
|
||||
{
|
||||
if (context != null
|
||||
&& context.Instance != null
|
||||
&& provider != null)
|
||||
{
|
||||
edSvc = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
|
||||
|
||||
if (edSvc != null)
|
||||
{
|
||||
ListBox lb = new ListBox();
|
||||
lb.SelectedIndexChanged += new EventHandler(this.SelectedChanged);
|
||||
|
||||
for (int i = 0; i < _AvailableTypes.Length; i++)
|
||||
{
|
||||
Type itemType = _AvailableTypes[i];
|
||||
lb.Items.Add(itemType.Name);
|
||||
if (value != null && value.GetType() == itemType)
|
||||
lb.SelectedIndex = i;
|
||||
}
|
||||
|
||||
edSvc.DropDownControl(lb);
|
||||
if (lb.SelectedItem != null)
|
||||
{
|
||||
int index = lb.SelectedIndex;
|
||||
if (value == null || _AvailableTypes[index] != value.GetType())
|
||||
{
|
||||
IDesignerHost dh = provider.GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
if (dh != null)
|
||||
{
|
||||
DesignerTransaction trans = dh.CreateTransaction(BarBaseControlDesigner.CreatingItemTransactionDescription);
|
||||
if (value is IComponent)
|
||||
dh.DestroyComponent((IComponent)value);
|
||||
value = dh.CreateComponent(_AvailableTypes[index]);
|
||||
trans.Commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
private void SelectedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (edSvc != null)
|
||||
edSvc.CloseDropDown();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the editor style used by the EditValue method.
|
||||
/// </summary>
|
||||
/// <param name="context">An ITypeDescriptorContext that can be used to gain additional context information.</param>
|
||||
/// <returns>A UITypeEditorEditStyle value that indicates the style of editor used by EditValue. If the UITypeEditor does not support this method, then GetEditStyle will return None</returns>
|
||||
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
|
||||
{
|
||||
if (context != null && context.Instance != null)
|
||||
{
|
||||
return UITypeEditorEditStyle.DropDown;
|
||||
}
|
||||
return base.GetEditStyle(context);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
#if FRAMEWORK20
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Windows.Forms.Design;
|
||||
using System.Collections;
|
||||
using System.Windows.Forms.Design.Behavior;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
public class LabelXDesigner : ControlDesigner
|
||||
{
|
||||
public override System.Collections.IList SnapLines
|
||||
{
|
||||
get
|
||||
{
|
||||
LabelX l = this.Control as LabelX;
|
||||
IList snapLines = base.SnapLines;
|
||||
|
||||
int fontBaseOffset = (int)Math.Floor(l.Font.Size * l.Font.FontFamily.GetCellDescent(l.Font.Style) / l.Font.FontFamily.GetEmHeight(l.Font.Style));
|
||||
if (l.TextLineAlignment == System.Drawing.StringAlignment.Center)
|
||||
{
|
||||
fontBaseOffset = (int)Math.Floor((double)(l.Height - l.Font.Height) / 2) + l.Font.Height-fontBaseOffset;
|
||||
}
|
||||
else if (l.TextLineAlignment == System.Drawing.StringAlignment.Far)
|
||||
{
|
||||
fontBaseOffset = l.Height - fontBaseOffset;
|
||||
}
|
||||
else
|
||||
{
|
||||
fontBaseOffset = l.Font.Height - fontBaseOffset;
|
||||
}
|
||||
|
||||
snapLines.Add(new SnapLine(SnapLineType.Baseline, fontBaseOffset, SnapLinePriority.Medium));
|
||||
return snapLines;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,164 @@
|
||||
using DevComponents.DotNetBar.Rendering;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
public class ListBoxAdvDesigner : BarBaseControlDesigner
|
||||
{
|
||||
public ListBoxAdvDesigner()
|
||||
{
|
||||
this.EnableItemDragDrop = true;
|
||||
}
|
||||
|
||||
public override void Initialize(IComponent component)
|
||||
{
|
||||
base.Initialize(component);
|
||||
if (component == null || component.Site == null || !component.Site.DesignMode)
|
||||
return;
|
||||
|
||||
#if !TRIAL
|
||||
IDesignerHost dh = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
if (dh != null)
|
||||
dh.LoadComplete += new EventHandler(dh_LoadComplete);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if FRAMEWORK20
|
||||
public override void InitializeNewComponent(IDictionary defaultValues)
|
||||
{
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#else
|
||||
public override void OnSetComponentDefaults()
|
||||
{
|
||||
SetDesignTimeDefaults();
|
||||
base.OnSetComponentDefaults();
|
||||
}
|
||||
#endif
|
||||
|
||||
protected virtual void SetDesignTimeDefaults()
|
||||
{
|
||||
ListBoxAdv panel = this.Control as ListBoxAdv;
|
||||
panel.BackgroundStyle.Class = ElementStyleClassKeys.ListBoxAdvKey;
|
||||
panel.AutoScroll = true;
|
||||
#if !TRIAL
|
||||
string key = GetLicenseKey();
|
||||
panel.LicenseKey = key;
|
||||
#endif
|
||||
}
|
||||
|
||||
public override DesignerVerbCollection Verbs
|
||||
{
|
||||
get
|
||||
{
|
||||
Bar bar = this.Control as Bar;
|
||||
DesignerVerb[] verbs = null;
|
||||
verbs = new DesignerVerb[]
|
||||
{
|
||||
new DesignerVerb("Add ListBoxItem", new EventHandler(CreateListBoxItem))
|
||||
};
|
||||
return new DesignerVerbCollection(verbs);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void CreateListBoxItem(object sender, EventArgs e)
|
||||
{
|
||||
OnSubItemsChanging();
|
||||
CreateListBoxItem(this.GetDefaultNewItemContainer());
|
||||
OnSubItemsChanged();
|
||||
}
|
||||
|
||||
protected virtual void CreateListBoxItem(BaseItem parent)
|
||||
{
|
||||
if (parent == null)
|
||||
return;
|
||||
ListBoxAdv listBox = this.Control as ListBoxAdv;
|
||||
IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
if (dh != null)
|
||||
{
|
||||
DesignerTransaction trans = dh.CreateTransaction("Adding new item");
|
||||
try
|
||||
{
|
||||
m_CreatingItem = true;
|
||||
ListBoxItem item = dh.CreateComponent(typeof(ListBoxItem)) as ListBoxItem;
|
||||
if (item == null)
|
||||
return;
|
||||
|
||||
IComponentChangeService cc = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (listBox != null && cc != null)
|
||||
cc.OnComponentChanging(listBox, TypeDescriptor.GetProperties(typeof(ListBoxAdv))["Items"]);
|
||||
item.Text = string.Format("Item {0}", parent.SubItems.Count + 1);
|
||||
listBox.Items.Add(item);
|
||||
|
||||
this.RecalcLayout();
|
||||
|
||||
if (listBox != null && cc != null)
|
||||
cc.OnComponentChanged(listBox, TypeDescriptor.GetProperties(typeof(ListBoxAdv))["Items"], null, null);
|
||||
|
||||
OnitemCreated(item);
|
||||
}
|
||||
catch
|
||||
{
|
||||
trans.Cancel();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!trans.Canceled)
|
||||
trans.Commit();
|
||||
m_CreatingItem = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected override bool GetHitTest(Point pt)
|
||||
{
|
||||
ListBoxAdv panel = this.Control as ListBoxAdv;
|
||||
if (panel != null && panel.IsHandleCreated && panel.AutoScroll)
|
||||
{
|
||||
Point p = panel.PointToClient(pt);
|
||||
if (panel.VScrollBar != null && panel.VScrollBar.Bounds.Contains(p))
|
||||
return true;
|
||||
if (panel.HScrollBar != null && panel.HScrollBar.Bounds.Contains(p))
|
||||
return true;
|
||||
|
||||
}
|
||||
return base.GetHitTest(pt);
|
||||
}
|
||||
|
||||
#region Licensing Stuff
|
||||
#if !TRIAL
|
||||
protected 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 dh_LoadComplete(object sender, EventArgs e)
|
||||
{
|
||||
IDesignerHost dh = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
if (dh != null)
|
||||
dh.LoadComplete -= new EventHandler(dh_LoadComplete);
|
||||
|
||||
string key = GetLicenseKey();
|
||||
ItemPanel bar = this.Control as ItemPanel;
|
||||
if (key != "" && bar != null && bar.LicenseKey == "" && bar.LicenseKey != key)
|
||||
TypeDescriptor.GetProperties(bar)["LicenseKey"].SetValue(bar, key);
|
||||
}
|
||||
#endif
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,251 @@
|
||||
#if FRAMEWORK20
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms.Design;
|
||||
using System.ComponentModel;
|
||||
using DevComponents.DotNetBar.Controls;
|
||||
using System.Collections;
|
||||
using DevComponents.DotNetBar.Rendering;
|
||||
using System.Drawing.Design;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
public class MaskedTextBoxAdvDesigner : ControlDesigner
|
||||
{
|
||||
public override void InitializeNewComponent(IDictionary defaultValues)
|
||||
{
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
MaskedTextBoxAdv control = this.Control as MaskedTextBoxAdv;
|
||||
control.BackgroundStyle.Class = ElementStyleClassKeys.TextBoxBorderKey;
|
||||
control.ButtonClear.Visible = true;
|
||||
control.Height = control.PreferredHeight;
|
||||
control.Text = "";
|
||||
control.Style = eDotNetBarStyle.StyleManagerControlled;
|
||||
}
|
||||
|
||||
public override SelectionRules SelectionRules
|
||||
{
|
||||
get
|
||||
{
|
||||
return (base.SelectionRules & ~(SelectionRules.BottomSizeable | SelectionRules.TopSizeable));
|
||||
}
|
||||
}
|
||||
|
||||
protected override void PreFilterProperties(IDictionary properties)
|
||||
{
|
||||
base.PreFilterProperties(properties);
|
||||
string[] strArray = new string[] { "Text", "PasswordChar" };
|
||||
Attribute[] attributes = new Attribute[0];
|
||||
for (int i = 0; i < strArray.Length; i++)
|
||||
{
|
||||
PropertyDescriptor oldPropertyDescriptor = (PropertyDescriptor)properties[strArray[i]];
|
||||
if (oldPropertyDescriptor != null)
|
||||
{
|
||||
properties[strArray[i]] = TypeDescriptor.CreateProperty(typeof(MaskedTextBoxAdvDesigner), oldPropertyDescriptor, attributes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public char PasswordChar
|
||||
{
|
||||
get
|
||||
{
|
||||
MaskedTextBoxAdv control = this.Control as MaskedTextBoxAdv;
|
||||
if (control.UseSystemPasswordChar)
|
||||
{
|
||||
control.UseSystemPasswordChar = false;
|
||||
char passwordChar = control.PasswordChar;
|
||||
control.UseSystemPasswordChar = true;
|
||||
return passwordChar;
|
||||
}
|
||||
return control.PasswordChar;
|
||||
}
|
||||
set
|
||||
{
|
||||
MaskedTextBoxAdv control = this.Control as MaskedTextBoxAdv;
|
||||
control.PasswordChar = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string Text
|
||||
{
|
||||
get
|
||||
{
|
||||
MaskedTextBoxAdv control = this.Control as MaskedTextBoxAdv;
|
||||
if (string.IsNullOrEmpty(control.Mask))
|
||||
{
|
||||
return control.Text;
|
||||
}
|
||||
return control.MaskedTextProvider.ToString(false, false);
|
||||
}
|
||||
set
|
||||
{
|
||||
MaskedTextBoxAdv control = this.Control as MaskedTextBoxAdv;
|
||||
if (string.IsNullOrEmpty(control.Mask))
|
||||
{
|
||||
control.Text = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool resetOnSpace = control.ResetOnSpace;
|
||||
bool resetOnPrompt = control.ResetOnPrompt;
|
||||
bool skipLiterals = control.SkipLiterals;
|
||||
control.ResetOnSpace = true;
|
||||
control.ResetOnPrompt = true;
|
||||
control.SkipLiterals = true;
|
||||
control.Text = value;
|
||||
control.ResetOnSpace = resetOnSpace;
|
||||
control.ResetOnPrompt = resetOnPrompt;
|
||||
control.SkipLiterals = skipLiterals;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private DesignerActionListCollection _Actions = null;
|
||||
public override DesignerActionListCollection ActionLists
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._Actions == null)
|
||||
{
|
||||
this._Actions = new DesignerActionListCollection();
|
||||
this._Actions.Add(new MaskedTextBoxAdvDesignerActionList(this));
|
||||
}
|
||||
return this._Actions;
|
||||
}
|
||||
}
|
||||
|
||||
public override DesignerVerbCollection Verbs
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._Verbs == null)
|
||||
{
|
||||
this._Verbs = new DesignerVerbCollection();
|
||||
this._Verbs.Add(new DesignerVerb("Set Mask...", new EventHandler(this.OnVerbSetMask)));
|
||||
}
|
||||
return this._Verbs;
|
||||
}
|
||||
}
|
||||
|
||||
private DesignerVerbCollection _Verbs = null;
|
||||
private void OnVerbSetMask(object sender, EventArgs e)
|
||||
{
|
||||
new MaskedTextBoxAdvDesignerActionList(this).SetMask();
|
||||
}
|
||||
}
|
||||
|
||||
public class MaskedTextBoxAdvDesignerActionList : DesignerActionList
|
||||
{
|
||||
// Fields
|
||||
private ITypeDiscoveryService discoverySvc;
|
||||
private IHelpService helpService;
|
||||
private MaskedTextBoxAdv maskedTextBox;
|
||||
private IUIService uiSvc;
|
||||
|
||||
// Methods
|
||||
public MaskedTextBoxAdvDesignerActionList(MaskedTextBoxAdvDesigner designer)
|
||||
: base(designer.Component)
|
||||
{
|
||||
this.maskedTextBox = (MaskedTextBoxAdv)designer.Component;
|
||||
this.discoverySvc = base.GetService(typeof(ITypeDiscoveryService)) as ITypeDiscoveryService;
|
||||
this.uiSvc = base.GetService(typeof(IUIService)) as IUIService;
|
||||
this.helpService = base.GetService(typeof(IHelpService)) as IHelpService;
|
||||
if (this.discoverySvc != null)
|
||||
{
|
||||
IUIService uiSvc = this.uiSvc;
|
||||
}
|
||||
}
|
||||
|
||||
public override DesignerActionItemCollection GetSortedActionItems()
|
||||
{
|
||||
DesignerActionItemCollection items = new DesignerActionItemCollection();
|
||||
items.Add(new DesignerActionMethodItem(this, "SetMask", "Set Mask..."));
|
||||
return items;
|
||||
}
|
||||
|
||||
public void SetMask()
|
||||
{
|
||||
string str = MaskAdvPropertyEditor.EditMask(this.discoverySvc, this.uiSvc, this.maskedTextBox, this.helpService);
|
||||
if (str != null)
|
||||
{
|
||||
PropertyDescriptor descriptor = TypeDescriptor.GetProperties(this.maskedTextBox)["Mask"];
|
||||
if (descriptor != null)
|
||||
{
|
||||
descriptor.SetValue(this.maskedTextBox, str);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class MaskAdvPropertyEditor : UITypeEditor
|
||||
{
|
||||
// Methods
|
||||
internal static string EditMask(ITypeDiscoveryService discoverySvc, IUIService uiSvc, MaskedTextBoxAdv instance, IHelpService helpService)
|
||||
{
|
||||
string mask = null;
|
||||
Type formType = Type.GetType("System.Windows.Forms.Design.MaskDesignerDialog, System.Design, Version= 2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
|
||||
ConstructorInfo ci = formType.GetConstructor(new Type[] { typeof(MaskedTextBox), typeof(IHelpService) });
|
||||
Form form = ci.Invoke(new object[]{instance.MaskedTextBox, helpService}) as Form;
|
||||
|
||||
try
|
||||
{
|
||||
MethodInfo mi = formType.GetMethod("DiscoverMaskDescriptors");
|
||||
mi.Invoke(form, new object[]{discoverySvc});
|
||||
//form.DiscoverMaskDescriptors(discoverySvc);
|
||||
DialogResult result = (uiSvc != null) ? uiSvc.ShowDialog(form) : form.ShowDialog();
|
||||
if (result == DialogResult.OK)
|
||||
{
|
||||
PropertyInfo pi = formType.GetProperty("Mask");
|
||||
mask = (string)pi.GetValue(form, null);
|
||||
pi = formType.GetProperty("ValidatingType");
|
||||
Type validatingType = pi.GetValue(form, null) as Type;
|
||||
//mask = form.Mask;
|
||||
if (validatingType == instance.ValidatingType)
|
||||
{
|
||||
return mask;
|
||||
}
|
||||
instance.ValidatingType = validatingType;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
form.Dispose();
|
||||
}
|
||||
return mask;
|
||||
}
|
||||
|
||||
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
|
||||
{
|
||||
if ((context != null) && (provider != null))
|
||||
{
|
||||
ITypeDiscoveryService discoverySvc = (ITypeDiscoveryService)provider.GetService(typeof(ITypeDiscoveryService));
|
||||
IUIService service = (IUIService)provider.GetService(typeof(IUIService));
|
||||
IHelpService helpService = (IHelpService)provider.GetService(typeof(IHelpService));
|
||||
string str = EditMask(discoverySvc, service, context.Instance as MaskedTextBoxAdv, helpService);
|
||||
if (str != null)
|
||||
{
|
||||
return str;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
|
||||
{
|
||||
return UITypeEditorEditStyle.Modal;
|
||||
}
|
||||
|
||||
public override bool GetPaintValueSupported(ITypeDescriptorContext context)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,257 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel.Design;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
using DevComponents.DotNetBar.Metro;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides designer for MetroAppButton.
|
||||
/// </summary>
|
||||
public class MetroAppButtonDesigner : BaseItemDesigner
|
||||
{
|
||||
#region Internal Implementation
|
||||
protected override DesignerVerb[] GetVerbs()
|
||||
{
|
||||
DesignerVerb[] baseVerbs = base.GetVerbs();
|
||||
int verbsCount = baseVerbs.Length + 1;
|
||||
if (IsBackstageSet) verbsCount = 1;
|
||||
|
||||
bool includeClearSubItems = false;
|
||||
MetroAppButton appButton = this.Component as MetroAppButton;
|
||||
if (appButton != null && appButton.BackstageTab != null && appButton.SubItems.Count > 0)
|
||||
{
|
||||
includeClearSubItems = true;
|
||||
verbsCount++;
|
||||
}
|
||||
|
||||
int verbsOffset = 1;
|
||||
DesignerVerb[] verbs = new DesignerVerb[verbsCount];
|
||||
verbs[0] = new DesignerVerb((IsBackstageSet ? "Remove Backstage" : "Set Backstage"), new EventHandler(CreateBackstageTab));
|
||||
|
||||
if (includeClearSubItems)
|
||||
{
|
||||
verbs[1] = new DesignerVerb("Clear Sub-items", new EventHandler(ClearSubItems));
|
||||
verbsOffset++;
|
||||
}
|
||||
|
||||
if (!IsBackstageSet)
|
||||
{
|
||||
for (int i = 0; i < baseVerbs.Length; i++)
|
||||
{
|
||||
verbs[i + verbsOffset] = baseVerbs[i];
|
||||
}
|
||||
}
|
||||
|
||||
return verbs;
|
||||
}
|
||||
|
||||
private void ClearSubItems(object sender, EventArgs e)
|
||||
{
|
||||
if (MessageBox.Show("Are you sure you want to delete all sub-items?", "DotNetBar Application Button", MessageBoxButtons.YesNo) == DialogResult.No) return;
|
||||
|
||||
IDesignerHost dh = GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
IComponentChangeService cc = GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (dh == null) return;
|
||||
MetroAppButton appButton = (MetroAppButton)this.Component;
|
||||
if (appButton.SubItems.Count == 0) return;
|
||||
|
||||
DesignerTransaction trans = dh.CreateTransaction("Clearing Application Button SubItems");
|
||||
try
|
||||
{
|
||||
cc.OnComponentChanging(appButton, TypeDescriptor.GetProperties(appButton)["SubItems"]);
|
||||
BaseItem[] items = new BaseItem[appButton.SubItems.Count];
|
||||
appButton.SubItems.CopyTo(items, 0);
|
||||
foreach (BaseItem item in items)
|
||||
{
|
||||
appButton.SubItems.Remove(item);
|
||||
dh.DestroyComponent(item);
|
||||
}
|
||||
cc.OnComponentChanged(appButton, TypeDescriptor.GetProperties(appButton)["SubItems"], null, null);
|
||||
}
|
||||
catch
|
||||
{
|
||||
trans.Cancel();
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!trans.Canceled)
|
||||
trans.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsBackstageSet
|
||||
{
|
||||
get
|
||||
{
|
||||
MetroAppButton appButton = (MetroAppButton)this.Component;
|
||||
if (appButton != null && appButton.BackstageTab != null) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateBackstageTab()
|
||||
{
|
||||
IDesignerHost dh = GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
IComponentChangeService cc = GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (dh == null) return;
|
||||
|
||||
MetroAppButton appButton = (MetroAppButton)this.Component;
|
||||
if (appButton.BackstageTab != null)
|
||||
{
|
||||
DesignerTransaction trans1 = dh.CreateTransaction("Removing Backstage tab");
|
||||
try
|
||||
{
|
||||
SuperTabControl backstageTab = appButton.BackstageTab;
|
||||
SetProperty(appButton, "BackstageTab", null);
|
||||
backstageTab.Visible = true;
|
||||
SetProperty(backstageTab, "Location", new System.Drawing.Point(0, 150));
|
||||
SetProperty(backstageTab, "Size", new System.Drawing.Size(250, 350));
|
||||
ISelectionService selection = (ISelectionService)GetService(typeof(ISelectionService));
|
||||
if (selection != null) selection.SetSelectedComponents(new Control[] { backstageTab }, SelectionTypes.Primary);
|
||||
}
|
||||
catch
|
||||
{
|
||||
trans1.Cancel();
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!trans1.Canceled)
|
||||
trans1.Commit();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
DesignerTransaction trans = dh.CreateTransaction("Create Backstage");
|
||||
try
|
||||
{
|
||||
|
||||
if (appButton.Expanded) appButton.Expanded = false;
|
||||
SuperTabControl backstageTab = (SuperTabControl)dh.CreateComponent(typeof(SuperTabControl));
|
||||
SetProperty(appButton, "BackstageTab", backstageTab);
|
||||
|
||||
Control root = dh.RootComponent as Control;
|
||||
if (root != null)
|
||||
{
|
||||
cc.OnComponentChanging(root, TypeDescriptor.GetProperties(root)["Controls"]);
|
||||
root.Controls.Add(backstageTab);
|
||||
cc.OnComponentChanged(root, TypeDescriptor.GetProperties(root)["Controls"], null, null);
|
||||
}
|
||||
SetupBackstageTab(backstageTab, dh);
|
||||
}
|
||||
catch
|
||||
{
|
||||
trans.Cancel();
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!trans.Canceled)
|
||||
trans.Commit();
|
||||
}
|
||||
}
|
||||
private void CreateBackstageTab(object sender, EventArgs e)
|
||||
{
|
||||
CreateBackstageTab();
|
||||
}
|
||||
|
||||
private void SetupBackstageTab(SuperTabControl backstageTab, IDesignerHost dh)
|
||||
{
|
||||
backstageTab.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
backstageTab.ControlBox.Visible = false;
|
||||
backstageTab.ItemPadding.Left = 6;
|
||||
backstageTab.ItemPadding.Right = 4;
|
||||
backstageTab.ItemPadding.Top = 4;
|
||||
backstageTab.ReorderTabsEnabled = false;
|
||||
try
|
||||
{
|
||||
backstageTab.SelectedTabFont = new System.Drawing.Font("Segoe UI", 9.75F);
|
||||
}
|
||||
catch { }
|
||||
backstageTab.SelectedTabIndex = 0;
|
||||
backstageTab.Size = new System.Drawing.Size(614, 315);
|
||||
backstageTab.TabAlignment = DevComponents.DotNetBar.eTabStripAlignment.Left;
|
||||
try
|
||||
{
|
||||
backstageTab.TabFont = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
}
|
||||
catch { }
|
||||
backstageTab.TabHorizontalSpacing = 16;
|
||||
backstageTab.TabStyle = DevComponents.DotNetBar.eSuperTabStyle.Office2010BackstageBlue;
|
||||
backstageTab.TabVerticalSpacing = 8;
|
||||
|
||||
SuperTabControlDesigner tabDesigner = dh.GetDesigner(backstageTab) as SuperTabControlDesigner;
|
||||
if (tabDesigner != null)
|
||||
{
|
||||
ButtonItem button;
|
||||
// Save button
|
||||
button = tabDesigner.CreateButton();
|
||||
SetProperty(button, "Text", "Save");
|
||||
SetProperty(button, "KeyTips", "S");
|
||||
SetProperty(button, "Image", RibbonControlDesigner.LoadImage("Save16.png"));
|
||||
|
||||
// Open
|
||||
button = tabDesigner.CreateButton();
|
||||
SetProperty(button, "Text", "Open");
|
||||
SetProperty(button, "KeyTips", "O");
|
||||
SetProperty(button, "Image", RibbonControlDesigner.LoadImage("Open.png"));
|
||||
|
||||
// Close
|
||||
button = tabDesigner.CreateButton();
|
||||
SetProperty(button, "Text", "Close");
|
||||
SetProperty(button, "KeyTips", "C");
|
||||
SetProperty(button, "Image", RibbonControlDesigner.LoadImage("Close16.png"));
|
||||
|
||||
SuperTabItem tab;
|
||||
tab = tabDesigner.CreateNewTab();
|
||||
SetProperty(tab, "Text", "Recent");
|
||||
SetProperty(tab, "KeyTips", "R");
|
||||
//SetProperty((SuperTabControlPanel)tab.AttachedControl, "BackgroundImage", RibbonControlDesigner.LoadImage("BlueBackstageBgImage.png"));
|
||||
//SetProperty((SuperTabControlPanel)tab.AttachedControl, "BackgroundImagePosition", DevComponents.DotNetBar.eStyleBackgroundImage.BottomRight);
|
||||
|
||||
tab = tabDesigner.CreateNewTab();
|
||||
SetProperty(tab, "Text", "New");
|
||||
SetProperty(tab, "KeyTips", "N");
|
||||
//SetProperty((SuperTabControlPanel)tab.AttachedControl, "BackgroundImage", RibbonControlDesigner.LoadImage("BlueBackstageBgImage.png"));
|
||||
//SetProperty((SuperTabControlPanel)tab.AttachedControl, "BackgroundImagePosition", DevComponents.DotNetBar.eStyleBackgroundImage.BottomRight);
|
||||
|
||||
tab = tabDesigner.CreateNewTab();
|
||||
SetProperty(tab, "Text", "Print");
|
||||
SetProperty(tab, "KeyTips", "P");
|
||||
//SetProperty((SuperTabControlPanel)tab.AttachedControl, "BackgroundImage", RibbonControlDesigner.LoadImage("BlueBackstageBgImage.png"));
|
||||
//SetProperty((SuperTabControlPanel)tab.AttachedControl, "BackgroundImagePosition", DevComponents.DotNetBar.eStyleBackgroundImage.BottomRight);
|
||||
|
||||
tab = tabDesigner.CreateNewTab();
|
||||
SetProperty(tab, "Text", "Help");
|
||||
SetProperty(tab, "KeyTips", "H");
|
||||
SetProperty((SuperTabControlPanel)tab.AttachedControl, "BackgroundImage", RibbonControlDesigner.LoadImage("BlueBackstageBgImage.png"));
|
||||
SetProperty((SuperTabControlPanel)tab.AttachedControl, "BackgroundImagePosition", DevComponents.DotNetBar.eStyleBackgroundImage.BottomRight);
|
||||
|
||||
// Options
|
||||
button = tabDesigner.CreateButton();
|
||||
SetProperty(button, "Text", "Options");
|
||||
SetProperty(button, "KeyTips", "T");
|
||||
SetProperty(button, "Image", RibbonControlDesigner.LoadImage("Options2.png"));
|
||||
|
||||
// Exit
|
||||
button = tabDesigner.CreateButton();
|
||||
SetProperty(button, "Text", "Exit");
|
||||
SetProperty(button, "KeyTips", "X");
|
||||
SetProperty(button, "Image", RibbonControlDesigner.LoadImage("Exit2.png"));
|
||||
}
|
||||
}
|
||||
|
||||
private void SetProperty(object targetObject, string propertyName, object propertyValue)
|
||||
{
|
||||
TypeDescriptor.GetProperties(targetObject)[propertyName].SetValue(targetObject, propertyValue);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms.Design;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing.Design;
|
||||
using DevComponents.DotNetBar.Metro.ColorTables;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design.Metro
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class MetroColorThemeEditor : System.Drawing.Design.UITypeEditor
|
||||
{
|
||||
private IWindowsFormsEditorService edSvc = null;
|
||||
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
|
||||
{
|
||||
if (context != null
|
||||
&& context.Instance != null
|
||||
&& provider != null)
|
||||
{
|
||||
edSvc = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
|
||||
|
||||
if (edSvc != null)
|
||||
{
|
||||
ListBox lb = new ListBox();
|
||||
lb.SelectedIndexChanged += new EventHandler(this.SelectedChanged);
|
||||
MetroColorGeneratorParameters currentParams = (MetroColorGeneratorParameters)value;
|
||||
MetroColorGeneratorParameters[] metroThemes = MetroColorGeneratorParameters.GetAllPredefinedThemes();
|
||||
string selectedTheme = null;
|
||||
foreach (MetroColorGeneratorParameters mt in metroThemes)
|
||||
{
|
||||
lb.Items.Add(mt.ThemeName);
|
||||
if (currentParams.BaseColor == mt.BaseColor && currentParams.CanvasColor == mt.CanvasColor)
|
||||
{
|
||||
lb.SelectedItem = mt.ThemeName;
|
||||
selectedTheme = mt.ThemeName;
|
||||
}
|
||||
}
|
||||
|
||||
edSvc.DropDownControl(lb);
|
||||
if (lb.SelectedItem != null && selectedTheme != (string)lb.SelectedItem)
|
||||
{
|
||||
return metroThemes[lb.SelectedIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
private void SelectedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (edSvc != null)
|
||||
edSvc.CloseDropDown();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the editor style used by the EditValue method.
|
||||
/// </summary>
|
||||
/// <param name="context">An ITypeDescriptorContext that can be used to gain additional context information.</param>
|
||||
/// <returns>A UITypeEditorEditStyle value that indicates the style of editor used by EditValue. If the UITypeEditor does not support this method, then GetEditStyle will return None</returns>
|
||||
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
|
||||
{
|
||||
if (context != null && context.Instance != null)
|
||||
{
|
||||
return UITypeEditorEditStyle.DropDown;
|
||||
}
|
||||
return base.GetEditStyle(context);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,725 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using DevComponents.DotNetBar.Metro;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Windows.Forms;
|
||||
using System.Collections;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
// <summary>
|
||||
/// Represents Windows Forms designer for MetroTab control.
|
||||
/// </summary>
|
||||
public class MetroShellDesigner : BarBaseControlDesigner
|
||||
{
|
||||
#region Private Variables
|
||||
private bool m_QuickAccessToolbarSelected = false;
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
|
||||
public MetroShellDesigner()
|
||||
{
|
||||
this.EnableItemDragDrop = true;
|
||||
this.AcceptExternalControls = false;
|
||||
}
|
||||
|
||||
public override void Initialize(IComponent component)
|
||||
{
|
||||
base.Initialize(component);
|
||||
if (!component.Site.DesignMode)
|
||||
return;
|
||||
MetroShell c = component as MetroShell;
|
||||
if (c != null)
|
||||
{
|
||||
c.SetDesignMode();
|
||||
//this.Expanded = c.Expanded;
|
||||
}
|
||||
this.EnableDragDrop(false);
|
||||
}
|
||||
|
||||
public override bool CanParent(Control control)
|
||||
{
|
||||
if (control is MetroTabPanel && !this.Control.Controls.Contains(control))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public override DesignerVerbCollection Verbs
|
||||
{
|
||||
get
|
||||
{
|
||||
DesignerVerb[] verbs = null;
|
||||
verbs = new DesignerVerb[]
|
||||
{
|
||||
new DesignerVerb("Create Tab", new EventHandler(CreateMetroTab)),
|
||||
new DesignerVerb("Create Button", new EventHandler(CreateButton)),
|
||||
new DesignerVerb("Create Text Box", new EventHandler(CreateTextBox)),
|
||||
new DesignerVerb("Create Combo Box", new EventHandler(CreateComboBox)),
|
||||
new DesignerVerb("Create Label", new EventHandler(CreateLabel)),
|
||||
new DesignerVerb("Create Micro-Chart", new EventHandler(CreateMicroChart)),
|
||||
new DesignerVerb("Create Switch Button", new EventHandler(CreateSwitch)),
|
||||
new DesignerVerb("Create Rating Item", new EventHandler(CreateRatingItem)),};
|
||||
|
||||
return new DesignerVerbCollection(verbs);
|
||||
}
|
||||
}
|
||||
|
||||
private BaseItem GetNewItemContainer()
|
||||
{
|
||||
MetroShell r = this.Control as MetroShell;
|
||||
if (m_QuickAccessToolbarSelected)
|
||||
return r.MetroTabStrip.CaptionContainerItem;
|
||||
else
|
||||
return r.MetroTabStrip.StripContainerItem;
|
||||
}
|
||||
|
||||
protected override void CreateButton(object sender, EventArgs e)
|
||||
{
|
||||
MetroShell r = this.Control as MetroShell;
|
||||
if (r != null)
|
||||
{
|
||||
CreateButton(GetNewItemContainer());
|
||||
}
|
||||
}
|
||||
|
||||
protected override void CreateTextBox(object sender, EventArgs e)
|
||||
{
|
||||
MetroShell r = this.Control as MetroShell;
|
||||
if (r != null)
|
||||
{
|
||||
CreateTextBox(GetNewItemContainer());
|
||||
}
|
||||
}
|
||||
|
||||
protected override void CreateComboBox(object sender, EventArgs e)
|
||||
{
|
||||
MetroShell r = this.Control as MetroShell;
|
||||
if (r != null)
|
||||
{
|
||||
CreateComboBox(GetNewItemContainer());
|
||||
}
|
||||
}
|
||||
|
||||
protected override void CreateLabel(object sender, EventArgs e)
|
||||
{
|
||||
MetroShell r = this.Control as MetroShell;
|
||||
if (r != null)
|
||||
{
|
||||
CreateLabel(GetNewItemContainer());
|
||||
}
|
||||
}
|
||||
|
||||
protected override void CreateColorPicker(object sender, EventArgs e)
|
||||
{
|
||||
MetroShell r = this.Control as MetroShell;
|
||||
if (r != null)
|
||||
{
|
||||
CreateColorPicker(GetNewItemContainer());
|
||||
}
|
||||
}
|
||||
|
||||
protected override void CreateProgressBar(object sender, EventArgs e)
|
||||
{
|
||||
MetroShell r = this.Control as MetroShell;
|
||||
if (r != null)
|
||||
{
|
||||
CreateProgressBar(GetNewItemContainer());
|
||||
}
|
||||
}
|
||||
|
||||
protected override void CreateRatingItem(object sender, EventArgs e)
|
||||
{
|
||||
MetroShell r = this.Control as MetroShell;
|
||||
if (r != null)
|
||||
{
|
||||
CreateRatingItem(GetNewItemContainer());
|
||||
}
|
||||
}
|
||||
|
||||
protected override void CreateSwitch(object sender, EventArgs e)
|
||||
{
|
||||
MetroShell r = this.Control as MetroShell;
|
||||
if (r != null)
|
||||
{
|
||||
CreateSwitch(GetNewItemContainer());
|
||||
}
|
||||
}
|
||||
|
||||
protected override void ComponentChangeComponentAdded(object sender, ComponentEventArgs e)
|
||||
{
|
||||
if (m_AddingItem)
|
||||
{
|
||||
m_AddingItem = false;
|
||||
IComponentChangeService cc = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (cc != null)
|
||||
cc.OnComponentChanging(this.Control, null);
|
||||
this.GetNewItemContainer().SubItems.Add(e.Component as BaseItem);
|
||||
if (cc != null)
|
||||
cc.OnComponentChanged(this.Control, null, null, null);
|
||||
m_InsertItemTransaction.Commit();
|
||||
m_InsertItemTransaction = null;
|
||||
this.RecalcLayout();
|
||||
}
|
||||
}
|
||||
|
||||
protected override ArrayList GetAllAssociatedComponents()
|
||||
{
|
||||
ArrayList c = new ArrayList(base.AssociatedComponents);
|
||||
MetroShell r = this.Control as MetroShell;
|
||||
if (r != null)
|
||||
{
|
||||
AddSubItems(r.MetroTabStrip.StripContainerItem, c);
|
||||
AddSubItems(r.MetroTabStrip.CaptionContainerItem, c);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
public override System.Collections.ICollection AssociatedComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
ArrayList c = new ArrayList(this.BaseAssociatedComponents);
|
||||
MetroShell rc = this.Control as MetroShell;
|
||||
if (rc != null)
|
||||
{
|
||||
foreach (BaseItem item in rc.QuickToolbarItems)
|
||||
{
|
||||
if (!item.SystemItem)
|
||||
c.Add(item);
|
||||
}
|
||||
foreach (BaseItem item in rc.Items)
|
||||
{
|
||||
if (!item.SystemItem)
|
||||
c.Add(item);
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
#if FRAMEWORK20
|
||||
public override void InitializeNewComponent(IDictionary defaultValues)
|
||||
{
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#else
|
||||
public override void OnSetComponentDefaults()
|
||||
{
|
||||
SetDesignTimeDefaults();
|
||||
base.OnSetComponentDefaults();
|
||||
}
|
||||
#endif
|
||||
|
||||
private StyleManager CreateStyleManager()
|
||||
{
|
||||
StyleManager manager = null;
|
||||
|
||||
IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
if (dh != null)
|
||||
{
|
||||
DesignerTransaction trans = dh.CreateTransaction("Create Style Manager");
|
||||
try
|
||||
{
|
||||
manager = dh.CreateComponent(typeof(StyleManager)) as StyleManager;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!trans.Canceled) trans.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
return manager;
|
||||
}
|
||||
private void SetDesignTimeDefaults()
|
||||
{
|
||||
CreateMetroTab("&HOME");
|
||||
CreateMetroTab("&VIEW");
|
||||
StyleManager manager = CreateStyleManager();
|
||||
MetroShell c = this.Control as MetroShell;
|
||||
if (c != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
c.KeyTipsFont = new Font("Tahoma", 7);
|
||||
c.TabStripFont = new System.Drawing.Font("Segoe UI", 10.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
//this.Style = eDotNetBarStyle.StyleManagerControlled;
|
||||
this.CanCustomize = true;
|
||||
c.Size = new Size(200, 154);
|
||||
c.Dock = DockStyle.Top;
|
||||
this.CaptionVisible = true;
|
||||
|
||||
if (manager != null)
|
||||
manager.ManagerStyle = eStyle.Metro;
|
||||
}
|
||||
|
||||
protected override BaseItem GetItemContainer()
|
||||
{
|
||||
MetroShell tab = this.Control as MetroShell;
|
||||
if (tab != null)
|
||||
return tab.MetroTabStrip.GetBaseItemContainer();
|
||||
return null;
|
||||
}
|
||||
|
||||
protected override System.Windows.Forms.Control GetItemContainerControl()
|
||||
{
|
||||
MetroShell tab = this.Control as MetroShell;
|
||||
if (tab != null)
|
||||
return tab.MetroTabStrip;
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Support for popup menu closing.
|
||||
/// </summary>
|
||||
protected override void DesignTimeSelectionChanged(ISelectionService ss)
|
||||
{
|
||||
if (ss == null)
|
||||
return;
|
||||
if (this.Control == null || this.Control.IsDisposed)
|
||||
return;
|
||||
|
||||
if (IsApplicationButtonBackstageControl(ss.PrimarySelection))
|
||||
return;
|
||||
|
||||
base.DesignTimeSelectionChanged(ss);
|
||||
|
||||
MetroShell r = this.Control as MetroShell;
|
||||
if (r == null) return;
|
||||
|
||||
BaseItem container = r.MetroTabStrip.StripContainerItem;
|
||||
if (container == null) return;
|
||||
|
||||
if (ss.PrimarySelection is MetroTabItem)
|
||||
{
|
||||
MetroTabItem item = ss.PrimarySelection as MetroTabItem;
|
||||
if (container.SubItems.Contains(item))
|
||||
{
|
||||
TypeDescriptor.GetProperties(item)["Checked"].SetValue(item, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsApplicationButtonBackstageControl(object primarySelection)
|
||||
{
|
||||
MetroShell tab = this.Control as MetroShell;
|
||||
if (tab == null || !(tab.GetApplicationButton() is MetroAppButton)) return false;
|
||||
MetroAppButton appButton = tab.GetApplicationButton() as MetroAppButton;
|
||||
if (appButton.BackstageTab == null) return false;
|
||||
|
||||
SuperTabControl backstageTab = appButton.BackstageTab;
|
||||
if (primarySelection is BaseItem)
|
||||
{
|
||||
BaseItem item = (BaseItem)primarySelection;
|
||||
if (backstageTab.Tabs.Contains(item)) return true;
|
||||
while (item.Parent != null) item = item.Parent;
|
||||
Control parentControl = item.ContainerControl as Control;
|
||||
if (parentControl == null) return false;
|
||||
return ContainsControl(backstageTab, parentControl);
|
||||
}
|
||||
else if (primarySelection is Control)
|
||||
return ContainsControl(backstageTab, (Control)primarySelection);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool ContainsControl(Control container, Control childControl)
|
||||
{
|
||||
Control parent = childControl;
|
||||
while (parent != null)
|
||||
{
|
||||
if (parent == container) return true;
|
||||
parent = parent.Parent;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Triggered when some other component on the form is removed.
|
||||
/// </summary>
|
||||
protected override void OtherComponentRemoving(object sender, ComponentEventArgs e)
|
||||
{
|
||||
MetroShell r = this.Control as MetroShell;
|
||||
if (r != null)
|
||||
{
|
||||
BaseItem container = r.MetroTabStrip.StripContainerItem;
|
||||
|
||||
if (e.Component is MetroTabItem && container != null && container.SubItems != null &&
|
||||
container.SubItems.Contains(((MetroTabItem)e.Component)))
|
||||
{
|
||||
IDesignerHost dh = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
if (dh != null)
|
||||
dh.DestroyComponent(((MetroTabItem)e.Component).Panel);
|
||||
}
|
||||
}
|
||||
base.OtherComponentRemoving(sender, e);
|
||||
}
|
||||
|
||||
protected override void ComponentRemoved(object sender, ComponentEventArgs e)
|
||||
{
|
||||
MetroShell r = this.Control as MetroShell;
|
||||
if (e.Component is BaseItem && r != null)
|
||||
{
|
||||
BaseItem item = e.Component as BaseItem;
|
||||
if (r.Items.Contains(item))
|
||||
r.Items.Remove(item);
|
||||
else if (r.QuickToolbarItems.Contains(item))
|
||||
r.QuickToolbarItems.Remove(item);
|
||||
DestroySubItems(item);
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool OnMouseDown(ref Message m, MouseButtons button)
|
||||
{
|
||||
m_QuickAccessToolbarSelected = false;
|
||||
|
||||
System.Windows.Forms.Control ctrl = this.GetItemContainerControl();
|
||||
MetroTabStrip strip = ctrl as MetroTabStrip;
|
||||
|
||||
if (strip == null)
|
||||
return base.OnMouseDown(ref m, button);
|
||||
|
||||
Point pos = strip.PointToClient(System.Windows.Forms.Control.MousePosition);
|
||||
if (!strip.ClientRectangle.Contains(pos))
|
||||
return base.OnMouseDown(ref m, button);
|
||||
|
||||
if (button == MouseButtons.Right)
|
||||
{
|
||||
if (strip.QuickToolbarBounds.Contains(pos))
|
||||
m_QuickAccessToolbarSelected = true;
|
||||
return base.OnMouseDown(ref m, button);
|
||||
}
|
||||
|
||||
bool callBase = true;
|
||||
|
||||
if (callBase)
|
||||
return base.OnMouseDown(ref m, button);
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Design-Time Item Creation
|
||||
protected virtual void CreateMetroTab(object sender, EventArgs e)
|
||||
{
|
||||
CreateMetroTab(string.Empty);
|
||||
}
|
||||
|
||||
private void CreateMetroTab(string text)
|
||||
{
|
||||
m_QuickAccessToolbarSelected = false;
|
||||
IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
if (dh != null)
|
||||
{
|
||||
DesignerTransaction trans = dh.CreateTransaction("Creating Metro Tab");
|
||||
IComponentChangeService cc = (IComponentChangeService)GetService(typeof(IComponentChangeService));
|
||||
MetroShell tab = this.Control as MetroShell;
|
||||
try
|
||||
{
|
||||
m_CreatingItem = true;
|
||||
OnSubItemsChanging();
|
||||
MetroTabItem item = dh.CreateComponent(typeof(MetroTabItem)) as MetroTabItem;
|
||||
if (string.IsNullOrEmpty(text))
|
||||
TypeDescriptor.GetProperties(item)["Text"].SetValue(item, item.Name);
|
||||
else
|
||||
TypeDescriptor.GetProperties(item)["Text"].SetValue(item, text);
|
||||
|
||||
MetroTabPanel panel = dh.CreateComponent(typeof(MetroTabPanel)) as MetroTabPanel;
|
||||
TypeDescriptor.GetProperties(panel)["Dock"].SetValue(panel, DockStyle.Fill);
|
||||
//TypeDescriptor.GetProperties(panel)["ColorSchemeStyle"].SetValue(panel, tab.Style);
|
||||
tab.SetTabPanelStyle(panel);
|
||||
|
||||
//panel.Style.BorderBottom = eStyleBorderType.Solid;
|
||||
//TypeDescriptor.GetProperties(panel.Style)["BorderBottom"].SetValue(panel.Style, eStyleBorderType.Solid);
|
||||
|
||||
cc.OnComponentChanging(this.Control, TypeDescriptor.GetProperties(typeof(Control))["Controls"]);
|
||||
this.Control.Controls.Add(panel);
|
||||
panel.SendToBack();
|
||||
cc.OnComponentChanged(this.Control, TypeDescriptor.GetProperties(typeof(Control))["Controls"], null, null);
|
||||
|
||||
TypeDescriptor.GetProperties(item)["Panel"].SetValue(item, panel);
|
||||
|
||||
SimpleItemContainer cont = tab.MetroTabStrip.StripContainerItem;
|
||||
cc.OnComponentChanging(cont, TypeDescriptor.GetProperties(typeof(BaseItem))["SubItems"]);
|
||||
cont.SubItems.Add(item);
|
||||
cc.OnComponentChanged(cont, TypeDescriptor.GetProperties(typeof(BaseItem))["SubItems"], null, null);
|
||||
if (cont.SubItems.Count == 1)
|
||||
TypeDescriptor.GetProperties(item)["Checked"].SetValue(item, true);
|
||||
|
||||
this.RecalcLayout();
|
||||
OnSubItemsChanged();
|
||||
}
|
||||
catch
|
||||
{
|
||||
trans.Cancel();
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!trans.Canceled)
|
||||
trans.Commit();
|
||||
m_CreatingItem = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Shadowing
|
||||
/// <summary>
|
||||
/// Gets or sets whether custom caption and quick access toolbar provided by the control is visible. Default value is false.
|
||||
/// This property should be set to true when control is used on MetroForm.
|
||||
/// </summary>
|
||||
[Browsable(true), DefaultValue(false), Category("Appearance"), Description("Indicates whether custom caption and quick access toolbar provided by the control is visible.")]
|
||||
public bool CaptionVisible
|
||||
{
|
||||
get
|
||||
{
|
||||
MetroShell r = this.Control as MetroShell;
|
||||
return r.CaptionVisible;
|
||||
}
|
||||
set
|
||||
{
|
||||
MetroShell r = this.Control as MetroShell;
|
||||
if (r.CaptionVisible == value) return;
|
||||
r.CaptionVisible = value;
|
||||
|
||||
if (r.CaptionVisible && (
|
||||
r.QuickToolbarItems.Count == 6 && r.QuickToolbarItems[0] is SystemCaptionItem && r.QuickToolbarItems[5] is SystemCaptionItem))
|
||||
{
|
||||
// Add custom items to the toolbar
|
||||
IDesignerHost dh = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
IComponentChangeService cc = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (dh != null && !dh.Loading && cc != null && dh.TransactionDescription != "Paste components")
|
||||
{
|
||||
DesignerTransaction trans = dh.CreateTransaction();
|
||||
try
|
||||
{
|
||||
m_CreatingItem = true;
|
||||
MetroAppButton sb = dh.CreateComponent(typeof(MetroAppButton)) as MetroAppButton;
|
||||
sb.Text = "&File";
|
||||
sb.ShowSubItems = false;
|
||||
sb.CanCustomize = false;
|
||||
sb.AutoExpandOnClick = true;
|
||||
cc.OnComponentChanging(r, TypeDescriptor.GetProperties(r)["QuickToolbarItems"]);
|
||||
sb.ImageFixedSize = new Size(16, 16);
|
||||
r.Items.Insert(0, sb);
|
||||
cc.OnComponentChanged(r, TypeDescriptor.GetProperties(r)["QuickToolbarItems"], null, null);
|
||||
ButtonItem buttonStart = sb;
|
||||
|
||||
ButtonItem b = dh.CreateComponent(typeof(ButtonItem)) as ButtonItem;
|
||||
b.Text = b.Name;
|
||||
cc.OnComponentChanging(r, TypeDescriptor.GetProperties(r)["QuickToolbarItems"]);
|
||||
r.QuickToolbarItems.Add(b, 2);
|
||||
cc.OnComponentChanged(r, TypeDescriptor.GetProperties(r)["QuickToolbarItems"], null, null);
|
||||
|
||||
|
||||
}
|
||||
catch
|
||||
{
|
||||
trans.Cancel();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!trans.Canceled) trans.Commit();
|
||||
m_CreatingItem = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ButtonItem CreateFileButton(IDesignerHost dh, string text, Image image)
|
||||
{
|
||||
ButtonItem button = dh.CreateComponent(typeof(ButtonItem)) as ButtonItem;
|
||||
button.ButtonStyle = DevComponents.DotNetBar.eButtonStyle.ImageAndText;
|
||||
button.Image = image;
|
||||
button.SubItemsExpandWidth = 24;
|
||||
button.Text = text;
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
private ButtonItem CreateMRUButton(IDesignerHost dh, string text)
|
||||
{
|
||||
ButtonItem button = dh.CreateComponent(typeof(ButtonItem)) as ButtonItem;
|
||||
button.Text = text;
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
|
||||
internal static Bitmap LoadImage(string imageName)
|
||||
{
|
||||
string imagesFolder = GetImagesFolder();
|
||||
if (imagesFolder != "")
|
||||
{
|
||||
if (File.Exists(imagesFolder + imageName))
|
||||
return new Bitmap(imagesFolder + imageName);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static string GetImagesFolder()
|
||||
{
|
||||
try
|
||||
{
|
||||
Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.LocalMachine;
|
||||
string path = "";
|
||||
try
|
||||
{
|
||||
if (key != null)
|
||||
key = key.OpenSubKey("Software\\DevComponents\\DotNetBar");
|
||||
if (key != null)
|
||||
path = key.GetValue("InstallationFolder", "").ToString();
|
||||
}
|
||||
finally { if (key != null) key.Close(); }
|
||||
|
||||
if (path != "")
|
||||
{
|
||||
if (path.Substring(path.Length - 1, 1) != "\\")
|
||||
path += "\\";
|
||||
path += "Images\\";
|
||||
return path;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether control can be customized and items added by end-user using context menu to the quick access toolbar.
|
||||
/// Caption of the control must be visible for customization to be enabled. Default value is true.
|
||||
/// </summary>
|
||||
[DefaultValue(true), Browsable(true), Category("Quick Access Toolbar"), Description("Indicates whether control can be customized. Caption must be visible for customization to be fully enabled.")]
|
||||
public bool CanCustomize
|
||||
{
|
||||
get
|
||||
{
|
||||
MetroShell rc = this.Control as MetroShell;
|
||||
return rc.CanCustomize;
|
||||
}
|
||||
set
|
||||
{
|
||||
MetroShell rc = this.Control as MetroShell;
|
||||
rc.CanCustomize = value;
|
||||
|
||||
IDesignerHost dh = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
if (dh != null && !dh.Loading)
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
// Make sure that QatCustomizeItem exists
|
||||
QatCustomizeItem qatCustom = GetQatCustomizeItem(rc);
|
||||
if (qatCustom == null)
|
||||
{
|
||||
DesignerTransaction dt = dh.CreateTransaction("Creating the QAT");
|
||||
try
|
||||
{
|
||||
// Create QatCustomItem...
|
||||
m_CreatingItem = true;
|
||||
qatCustom = dh.CreateComponent(typeof(QatCustomizeItem)) as QatCustomizeItem;
|
||||
qatCustom.BeginGroup = true;
|
||||
IComponentChangeService cc = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (cc != null)
|
||||
cc.OnComponentChanging(rc, TypeDescriptor.GetProperties(rc)["QuickToolbarItems"]);
|
||||
rc.QuickToolbarItems.Add(qatCustom);
|
||||
if (cc != null)
|
||||
cc.OnComponentChanged(rc, TypeDescriptor.GetProperties(rc)["QuickToolbarItems"], null, null);
|
||||
m_CreatingItem = false;
|
||||
this.RecalcLayout();
|
||||
}
|
||||
catch
|
||||
{
|
||||
dt.Cancel();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!dt.Canceled) dt.Commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QatCustomizeItem qatCustom = GetQatCustomizeItem(rc);
|
||||
if (qatCustom != null)
|
||||
{
|
||||
DesignerTransaction dt = dh.CreateTransaction("Removing the QAT");
|
||||
try
|
||||
{
|
||||
IComponentChangeService cc = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (cc != null)
|
||||
cc.OnComponentChanging(rc, TypeDescriptor.GetProperties(rc)["QuickToolbarItems"]);
|
||||
rc.QuickToolbarItems.Remove(qatCustom);
|
||||
if (cc != null)
|
||||
cc.OnComponentChanged(rc, TypeDescriptor.GetProperties(rc)["QuickToolbarItems"], null, null);
|
||||
dh.DestroyComponent(qatCustom);
|
||||
}
|
||||
catch
|
||||
{
|
||||
dt.Cancel();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!dt.Canceled) dt.Commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private QatCustomizeItem GetQatCustomizeItem(MetroShell rc)
|
||||
{
|
||||
QatCustomizeItem qatCustom = null;
|
||||
// Remove QatCustomizeItem if it exists
|
||||
foreach (BaseItem item in rc.QuickToolbarItems)
|
||||
{
|
||||
if (item is QatCustomizeItem)
|
||||
{
|
||||
qatCustom = item as QatCustomizeItem;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return qatCustom;
|
||||
}
|
||||
|
||||
protected override void PreFilterProperties(IDictionary properties)
|
||||
{
|
||||
base.PreFilterProperties(properties);
|
||||
|
||||
properties["CaptionVisible"] = TypeDescriptor.CreateProperty(typeof(MetroShellDesigner), (PropertyDescriptor)properties["CaptionVisible"], new Attribute[]
|
||||
{
|
||||
new DefaultValueAttribute(false),
|
||||
new BrowsableAttribute(true),
|
||||
new CategoryAttribute("Appearance"),
|
||||
new DescriptionAttribute("Indicates whether custom caption and quick access toolbar provided by the control is visible.")});
|
||||
|
||||
properties["CanCustomize"] = TypeDescriptor.CreateProperty(typeof(MetroShellDesigner), (PropertyDescriptor)properties["CanCustomize"], new Attribute[]
|
||||
{
|
||||
new DefaultValueAttribute(true),
|
||||
new BrowsableAttribute(true),
|
||||
new CategoryAttribute("Quick Access Toolbar"),
|
||||
new DescriptionAttribute("Indicates whether control can be customized. Caption must be visible for customization to be fully enabled")});
|
||||
|
||||
//DesignTime.RemoveProperties(properties, new string[] { "AccessibleDescription"
|
||||
// ,"AccessibleName","AccessibleRole","AutoScroll", "AutoScrollMargin", "AutoScrollMinSize",
|
||||
// "BackColor", "BackgroundImage", "BackgroundImageLayout", "DisplayRectangle", "ForeColor",
|
||||
// "MaximumSize", "MinimumSize", "Site","Text","UseWaitCursor", "Cursor","ContextMenuStrip"});
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
using System.Collections;
|
||||
using System.ComponentModel.Design;
|
||||
using DevComponents.DotNetBar.Rendering;
|
||||
using System.Drawing;
|
||||
using DevComponents.DotNetBar.Metro;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
public class MetroStatusBarDesigner : BarBaseControlDesigner
|
||||
{
|
||||
public MetroStatusBarDesigner()
|
||||
{
|
||||
this.EnableItemDragDrop=true;
|
||||
}
|
||||
|
||||
public override void Initialize(IComponent component)
|
||||
{
|
||||
base.Initialize(component);
|
||||
if (component == null || component.Site == null || !component.Site.DesignMode)
|
||||
return;
|
||||
|
||||
#if !TRIAL
|
||||
IDesignerHost dh = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
if (dh != null)
|
||||
dh.LoadComplete += new EventHandler(dh_LoadComplete);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if FRAMEWORK20
|
||||
public override void InitializeNewComponent(IDictionary defaultValues)
|
||||
{
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#else
|
||||
public override void OnSetComponentDefaults()
|
||||
{
|
||||
SetDesignTimeDefaults();
|
||||
base.OnSetComponentDefaults();
|
||||
}
|
||||
#endif
|
||||
|
||||
private void SetDesignTimeDefaults()
|
||||
{
|
||||
MetroStatusBar bar = this.Control as MetroStatusBar;
|
||||
bar.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
try
|
||||
{
|
||||
bar.Font = new System.Drawing.Font("Segoe UI", 10.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
#if !TRIAL
|
||||
string key = GetLicenseKey();
|
||||
bar.LicenseKey = key;
|
||||
#endif
|
||||
}
|
||||
|
||||
public override DesignerVerbCollection Verbs
|
||||
{
|
||||
get
|
||||
{
|
||||
Bar bar = this.Control as Bar;
|
||||
DesignerVerb[] verbs = null;
|
||||
verbs = new DesignerVerb[]
|
||||
{
|
||||
new DesignerVerb("Add Button", new EventHandler(CreateButton)),
|
||||
new DesignerVerb("Add Horizontal Container", new EventHandler(CreateHorizontalContainer)),
|
||||
new DesignerVerb("Add Vertical Container", new EventHandler(CreateVerticalContainer)),
|
||||
new DesignerVerb("Add Slider", new EventHandler(CreateSliderItem)),
|
||||
new DesignerVerb("Add Text Box", new EventHandler(CreateTextBox)),
|
||||
new DesignerVerb("Add Combo Box", new EventHandler(CreateComboBox)),
|
||||
new DesignerVerb("Add Label", new EventHandler(CreateLabel)),
|
||||
new DesignerVerb("Add Color Picker", new EventHandler(CreateColorPicker)),
|
||||
new DesignerVerb("Add Micro-Chart", new EventHandler(CreateMicroChart)),
|
||||
new DesignerVerb("Add Switch Button", new EventHandler(CreateSwitch)),
|
||||
new DesignerVerb("Add Progress bar", new EventHandler(CreateProgressBar)),
|
||||
new DesignerVerb("Add Check box", new EventHandler(CreateCheckBox)),
|
||||
new DesignerVerb("Add WinForms Control Container", new EventHandler(CreateControlContainer))
|
||||
};
|
||||
return new DesignerVerbCollection(verbs);
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateVerticalContainer(object sender, EventArgs e)
|
||||
{
|
||||
CreateContainer(this.GetItemContainer(), eOrientation.Vertical);
|
||||
}
|
||||
|
||||
private void CreateHorizontalContainer(object sender, EventArgs e)
|
||||
{
|
||||
CreateContainer(this.GetItemContainer(), eOrientation.Horizontal);
|
||||
}
|
||||
|
||||
private void CreateContainer(BaseItem parent, eOrientation orientation)
|
||||
{
|
||||
m_CreatingItem = true;
|
||||
try
|
||||
{
|
||||
DesignerSupport.CreateItemContainer(this, parent, orientation);
|
||||
}
|
||||
finally
|
||||
{
|
||||
m_CreatingItem = false;
|
||||
}
|
||||
this.RecalcLayout();
|
||||
}
|
||||
|
||||
#region Licensing Stuff
|
||||
#if !TRIAL
|
||||
private 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 dh_LoadComplete(object sender, EventArgs e)
|
||||
{
|
||||
IDesignerHost dh = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
if (dh != null)
|
||||
dh.LoadComplete -= new EventHandler(dh_LoadComplete);
|
||||
|
||||
string key = GetLicenseKey();
|
||||
MetroStatusBar bar = this.Control as MetroStatusBar;
|
||||
if (key != "" && bar != null && bar.LicenseKey == "" && bar.LicenseKey != key)
|
||||
TypeDescriptor.GetProperties(bar)["LicenseKey"].SetValue(bar, key);
|
||||
}
|
||||
#endif
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel.Design;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents Windows Forms designer for MetroTabItem
|
||||
/// </summary>
|
||||
public class MetroTabItemDesigner : BaseItemDesigner
|
||||
{
|
||||
public override DesignerVerbCollection Verbs
|
||||
{
|
||||
get
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Drawing;
|
||||
using DevComponents.DotNetBar.Metro;
|
||||
using System.Windows.Forms.Design;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
public class MetroTabPanelDesigner : PanelControlDesigner
|
||||
{
|
||||
#region Internal Implementation
|
||||
public override SelectionRules SelectionRules
|
||||
{
|
||||
get { return (SelectionRules.Locked | SelectionRules.Visible); }
|
||||
}
|
||||
|
||||
protected override void SetDesignTimeDefaults()
|
||||
{
|
||||
// RibbonPanel p = this.Control as RibbonPanel;
|
||||
//#if FRAMEWORK20
|
||||
// p.Padding = new System.Windows.Forms.Padding(3, 0, 3, 3);
|
||||
//#else
|
||||
// p.DockPadding.Left = 3;
|
||||
// p.DockPadding.Right = 3;
|
||||
// p.DockPadding.Bottom = 3;
|
||||
//#endif
|
||||
}
|
||||
|
||||
public override DesignerVerbCollection Verbs
|
||||
{
|
||||
get
|
||||
{
|
||||
return new DesignerVerbCollection();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws design-time border around the panel when panel does not have one.
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
protected override void DrawBorder(Graphics g)
|
||||
{
|
||||
MetroTabPanel panel = this.Control as MetroTabPanel;
|
||||
if (panel == null) return;
|
||||
Rectangle r = panel.ClientRectangle;
|
||||
using (Pen pen = new Pen(Color.WhiteSmoke, 1))
|
||||
{
|
||||
pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
|
||||
r.Width--;
|
||||
r.Height--;
|
||||
g.DrawRectangle(pen, r);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel.Design;
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
using System.Collections;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
public class MetroTileFrameDesigner : ComponentDesigner
|
||||
{
|
||||
private static bool SetGenerateMemberProperty(
|
||||
IExtenderListService service,
|
||||
IComponent component,
|
||||
bool value)
|
||||
{
|
||||
IExtenderProvider provider = null;
|
||||
IExtenderProvider[] providers = service.GetExtenderProviders();
|
||||
foreach (IExtenderProvider item in providers)
|
||||
{
|
||||
if (item.GetType().FullName ==
|
||||
"System.ComponentModel.Design.Serialization.CodeDomDesignerLoader+ModifiersExtenderProvider")
|
||||
{
|
||||
provider = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (provider == null) return false;
|
||||
|
||||
MethodInfo methodInfo =
|
||||
provider.GetType().GetMethod(
|
||||
"SetGenerateMember", BindingFlags.Public |
|
||||
BindingFlags.Instance);
|
||||
|
||||
if (methodInfo != null)
|
||||
{
|
||||
methodInfo.Invoke(
|
||||
provider, new object[]
|
||||
{
|
||||
component,
|
||||
value
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void InitializeNewComponent(IDictionary defaultValues)
|
||||
{
|
||||
// no reason to create a member since container has no use aside from logical grouping at design time
|
||||
SetGenerateMemberProperty(
|
||||
(IExtenderListService)GetService(typeof(IExtenderListService)),
|
||||
this.Component,
|
||||
false);
|
||||
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel.Design;
|
||||
using DevComponents.DotNetBar.Rendering;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
public class MetroTilePanelDesigner : ItemPanelDesigner
|
||||
{
|
||||
public override DesignerVerbCollection Verbs
|
||||
{
|
||||
get
|
||||
{
|
||||
Bar bar = this.Control as Bar;
|
||||
DesignerVerb[] verbs = null;
|
||||
verbs = new DesignerVerb[]
|
||||
{
|
||||
new DesignerVerb("Add Metro Tile", new EventHandler(CreateMetroTile)),
|
||||
new DesignerVerb("Add Tile Group", new EventHandler(CreateHorizontalContainer))
|
||||
};
|
||||
return new DesignerVerbCollection(verbs);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void SetDesignTimeDefaults()
|
||||
{
|
||||
ItemPanel panel = this.Control as ItemPanel;
|
||||
panel.BackgroundStyle.Class = ElementStyleClassKeys.MetroTilePanelKey;
|
||||
|
||||
ItemContainer container = CreateContainer(this.GetItemContainer(), eOrientation.Horizontal);
|
||||
container.TitleStyle.Class = ElementStyleClassKeys.MetroTileGroupTitleKey;
|
||||
container.TitleText = "First";
|
||||
//LabelItem label = CreateLabel(container);
|
||||
////label.Width = 530;
|
||||
//label.ContainerNewLineAfter = true;
|
||||
//label.Font = new System.Drawing.Font("Segoe UI Semibold", 27.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
//label.Text = "First";
|
||||
|
||||
CreateMetroTile(container);
|
||||
CreateMetroTile(container);
|
||||
CreateMetroTile(container);
|
||||
CreateMetroTile(container);
|
||||
|
||||
container = CreateContainer(this.GetItemContainer(), eOrientation.Horizontal);
|
||||
container.TitleStyle.Class = ElementStyleClassKeys.MetroTileGroupTitleKey;
|
||||
container.TitleText = "Second";
|
||||
//label = CreateLabel(container);
|
||||
////label.Width = 530;
|
||||
//label.ContainerNewLineAfter = true;
|
||||
//label.Font = new System.Drawing.Font("Segoe UI Semibold", 27.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
//label.Text = "Second";
|
||||
|
||||
CreateMetroTile(container);
|
||||
CreateMetroTile(container);
|
||||
CreateMetroTile(container);
|
||||
CreateMetroTile(container);
|
||||
#if !TRIAL
|
||||
string key = GetLicenseKey();
|
||||
panel.LicenseKey = key;
|
||||
#endif
|
||||
}
|
||||
|
||||
protected override ItemContainer CreateContainer(BaseItem parent, eOrientation orientation)
|
||||
{
|
||||
ItemContainer container = base.CreateContainer(parent, orientation);
|
||||
if (container != null)
|
||||
TypeDescriptor.GetProperties(container)["MultiLine"].SetValue(container, true);
|
||||
return container;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,258 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using DevComponents.DotNetBar.Metro;
|
||||
using System.ComponentModel;
|
||||
using System.Collections;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
class MetroToolbarDesigner : BarBaseControlDesigner
|
||||
{
|
||||
public MetroToolbarDesigner()
|
||||
{
|
||||
this.EnableItemDragDrop=true;
|
||||
this.ShadowProperties["Expanded"] = false;
|
||||
}
|
||||
|
||||
public override void Initialize(IComponent component)
|
||||
{
|
||||
base.Initialize(component);
|
||||
if (component == null || component.Site == null || !component.Site.DesignMode)
|
||||
return;
|
||||
|
||||
#if !TRIAL
|
||||
IDesignerHost dh = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
if (dh != null)
|
||||
dh.LoadComplete += new EventHandler(dh_LoadComplete);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if FRAMEWORK20
|
||||
public override void InitializeNewComponent(IDictionary defaultValues)
|
||||
{
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#else
|
||||
public override void OnSetComponentDefaults()
|
||||
{
|
||||
SetDesignTimeDefaults();
|
||||
base.OnSetComponentDefaults();
|
||||
}
|
||||
#endif
|
||||
|
||||
private void SetDesignTimeDefaults()
|
||||
{
|
||||
MetroToolbar bar = this.Control as MetroToolbar;
|
||||
try
|
||||
{
|
||||
bar.Font = new System.Drawing.Font("Segoe UI", 10.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
#if !TRIAL
|
||||
string key = GetLicenseKey();
|
||||
bar.LicenseKey = key;
|
||||
#endif
|
||||
}
|
||||
|
||||
//protected override BaseItem GetItemContainer()
|
||||
//{
|
||||
// MetroToolbar bar = this.Control as MetroToolbar;
|
||||
// return ((MetroToolbarContainer)bar.GetBaseItemContainer()).MainItemsContainer;
|
||||
//}
|
||||
|
||||
public override DesignerVerbCollection Verbs
|
||||
{
|
||||
get
|
||||
{
|
||||
Bar bar = this.Control as Bar;
|
||||
DesignerVerb[] verbs = null;
|
||||
verbs = new DesignerVerb[]
|
||||
{
|
||||
new DesignerVerb("Add Button", new EventHandler(CreateButton)),
|
||||
new DesignerVerb("Add Horizontal Container", new EventHandler(CreateHorizontalContainer)),
|
||||
new DesignerVerb("Add Vertical Container", new EventHandler(CreateVerticalContainer)),
|
||||
new DesignerVerb("Add Text Box", new EventHandler(CreateTextBox)),
|
||||
new DesignerVerb("Add Combo Box", new EventHandler(CreateComboBox)),
|
||||
new DesignerVerb("Add Label", new EventHandler(CreateLabel)),
|
||||
new DesignerVerb("Add Color Picker", new EventHandler(CreateColorPicker)),
|
||||
new DesignerVerb("Add Micro-Chart", new EventHandler(CreateMicroChart)),
|
||||
new DesignerVerb("Add Switch Button", new EventHandler(CreateSwitch)),
|
||||
new DesignerVerb("Add Progress bar", new EventHandler(CreateProgressBar)),
|
||||
new DesignerVerb("Add Check box", new EventHandler(CreateCheckBox)),
|
||||
new DesignerVerb("Add WinForms Control Container", new EventHandler(CreateControlContainer))
|
||||
};
|
||||
return new DesignerVerbCollection(verbs);
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateVerticalContainer(object sender, EventArgs e)
|
||||
{
|
||||
CreateContainer(this.GetItemContainer(), eOrientation.Vertical);
|
||||
}
|
||||
|
||||
private void CreateHorizontalContainer(object sender, EventArgs e)
|
||||
{
|
||||
CreateContainer(this.GetItemContainer(), eOrientation.Horizontal);
|
||||
}
|
||||
|
||||
private void CreateContainer(BaseItem parent, eOrientation orientation)
|
||||
{
|
||||
m_CreatingItem = true;
|
||||
try
|
||||
{
|
||||
DesignerSupport.CreateItemContainer(this, parent, orientation);
|
||||
}
|
||||
finally
|
||||
{
|
||||
m_CreatingItem = false;
|
||||
}
|
||||
this.RecalcLayout();
|
||||
}
|
||||
|
||||
protected override void OnIsSelectedChanged(bool oldValue, bool newValue)
|
||||
{
|
||||
if (newValue)
|
||||
{
|
||||
MetroToolbar bar = (MetroToolbar)this.Control;
|
||||
if (!this.Expanded && bar.ExpandButtonVisible)
|
||||
{
|
||||
bar.Expanded = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!this.Expanded)
|
||||
{
|
||||
MetroToolbar bar = (MetroToolbar)this.Control;
|
||||
bar.Expanded = false;
|
||||
IComponentChangeService cc = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (cc != null)
|
||||
cc.OnComponentChanged(bar, TypeDescriptor.GetProperties(cc)["Location"], null, null);
|
||||
}
|
||||
}
|
||||
base.OnIsSelectedChanged(oldValue, newValue);
|
||||
}
|
||||
|
||||
protected override void PreFilterProperties(IDictionary properties)
|
||||
{
|
||||
base.PreFilterProperties(properties);
|
||||
properties["Expanded"] = TypeDescriptor.CreateProperty(typeof(MetroToolbarDesigner), (PropertyDescriptor)properties["Expanded"], new Attribute[]
|
||||
{
|
||||
new DefaultValueAttribute(false),
|
||||
new BrowsableAttribute(true),
|
||||
new CategoryAttribute("Layout"),
|
||||
new DescriptionAttribute("Indicates whether control is expanded or not. When control is expanded both main and extra toolbar items are visible.")});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether control is expanded or not. When control is expanded both main and extra toolbar items are visible. When collapsed
|
||||
/// only main items are visible. Default value is false.
|
||||
/// </summary>
|
||||
[DefaultValue(false), Browsable(true), Category("Layout"), Description("Indicates whether control is expanded or not. When control is expanded both main and extra toolbar items are visible.")]
|
||||
public bool Expanded
|
||||
{
|
||||
get { return (bool)ShadowProperties["Expanded"]; }
|
||||
set
|
||||
{
|
||||
// this value is not passed to the actual control at design-time
|
||||
this.ShadowProperties["Expanded"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override System.Collections.ICollection AssociatedComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
ArrayList c = new ArrayList(base.AssociatedComponents);
|
||||
MetroToolbar bar = (MetroToolbar)this.Control;
|
||||
foreach (BaseItem item in bar.Items)
|
||||
{
|
||||
if (item.DesignMode)
|
||||
c.Add(item);
|
||||
}
|
||||
foreach (BaseItem item in bar.ExtraItems)
|
||||
{
|
||||
if (item.DesignMode)
|
||||
c.Add(item);
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
protected override ArrayList GetAllAssociatedComponents()
|
||||
{
|
||||
ArrayList c = new ArrayList(base.AssociatedComponents);
|
||||
MetroToolbar bar = (MetroToolbar)this.Control;
|
||||
BaseItem container = ((MetroToolbarContainer)bar.GetBaseItemContainer()).MainItemsContainer;
|
||||
if (container != null)
|
||||
{
|
||||
AddSubItems(container, c);
|
||||
}
|
||||
container = ((MetroToolbarContainer)bar.GetBaseItemContainer()).ExtraItemsContainer;
|
||||
if (container != null)
|
||||
{
|
||||
AddSubItems(container, c);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
protected override BaseItem GetControlItem(System.Windows.Forms.Control control)
|
||||
{
|
||||
MetroToolbar bar = (MetroToolbar)this.Control;
|
||||
BaseItem parent = ((MetroToolbarContainer)bar.GetBaseItemContainer()).MainItemsContainer;
|
||||
if (parent == null)
|
||||
return null;
|
||||
BaseItem item = GetControlItem(control, parent);
|
||||
if (item != null) return item;
|
||||
|
||||
parent = ((MetroToolbarContainer)bar.GetBaseItemContainer()).ExtraItemsContainer;
|
||||
if (parent == null)
|
||||
return null;
|
||||
item = GetControlItem(control, parent);
|
||||
return item;
|
||||
}
|
||||
|
||||
protected override BaseItem GetDefaultNewItemContainer()
|
||||
{
|
||||
MetroToolbar bar = (MetroToolbar)this.Control;
|
||||
return ((MetroToolbarContainer)bar.GetBaseItemContainer()).MainItemsContainer;
|
||||
}
|
||||
|
||||
#region Licensing Stuff
|
||||
#if !TRIAL
|
||||
private 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 dh_LoadComplete(object sender, EventArgs e)
|
||||
{
|
||||
IDesignerHost dh = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
if (dh != null)
|
||||
dh.LoadComplete -= new EventHandler(dh_LoadComplete);
|
||||
|
||||
string key = GetLicenseKey();
|
||||
MetroToolbar bar = this.Control as MetroToolbar;
|
||||
if (key != "" && bar != null && bar.LicenseKey == "" && bar.LicenseKey != key)
|
||||
TypeDescriptor.GetProperties(bar)["LicenseKey"].SetValue(bar, key);
|
||||
}
|
||||
#endif
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
using System.Collections;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms.Design;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
public class MicroChartDesigner : ControlDesigner
|
||||
{
|
||||
#region Constructor
|
||||
public MicroChartDesigner()
|
||||
{
|
||||
}
|
||||
|
||||
public override void Initialize(IComponent component)
|
||||
{
|
||||
base.Initialize(component);
|
||||
if (!component.Site.DesignMode)
|
||||
return;
|
||||
|
||||
SetDataPointsDefaults();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
#if FRAMEWORK20
|
||||
public override void InitializeNewComponent(IDictionary defaultValues)
|
||||
{
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#else
|
||||
public override void OnSetComponentDefaults()
|
||||
{
|
||||
base.OnSetComponentDefaults();
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#endif
|
||||
|
||||
private void SetDataPointsDefaults()
|
||||
{
|
||||
MicroChart chart = this.Control as MicroChart;
|
||||
if (chart == null)
|
||||
return;
|
||||
chart.DataPoints = MicroChartItemDesigner.GetRandomDataPoints();
|
||||
}
|
||||
private void SetDesignTimeDefaults()
|
||||
{
|
||||
MicroChart chart = this.Control as MicroChart;
|
||||
if (chart == null)
|
||||
return;
|
||||
chart.Style = eDotNetBarStyle.StyleManagerControlled;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
public class MicroChartItemDesigner : BaseItemDesigner
|
||||
{
|
||||
public override void Initialize(System.ComponentModel.IComponent component)
|
||||
{
|
||||
base.Initialize(component);
|
||||
if (component != null && component.Site != null && component.Site.DesignMode)
|
||||
SetDataPointsDefaults();
|
||||
}
|
||||
private void SetDataPointsDefaults()
|
||||
{
|
||||
MicroChartItem item = (MicroChartItem)this.Component;
|
||||
item.DataPoints = GetRandomDataPoints();
|
||||
}
|
||||
|
||||
public override void InitializeExistingComponent(System.Collections.IDictionary defaultValues)
|
||||
{
|
||||
SetDataPointsDefaults();
|
||||
base.InitializeExistingComponent(defaultValues);
|
||||
}
|
||||
|
||||
protected override void SetDesignTimeDefaults()
|
||||
{
|
||||
SetDataPointsDefaults();
|
||||
base.SetDesignTimeDefaults();
|
||||
}
|
||||
|
||||
internal static List<double> GetRandomDataPoints(bool allowNegative)
|
||||
{
|
||||
return GetRandomDataPoints(allowNegative, 12);
|
||||
}
|
||||
internal static List<double> GetRandomDataPoints(bool allowNegative, int pointsToCreate)
|
||||
{
|
||||
List<double> points = new List<double>();
|
||||
Random rnd = new Random((int)DateTime.Now.Ticks);
|
||||
Random rnd2 = new Random();
|
||||
|
||||
for (int i = 0; i < pointsToCreate; i++)
|
||||
{
|
||||
points.Add(allowNegative ? ((rnd2.Next(50) > 25 ? 1 : -1) * rnd.Next(100)) : rnd.Next(100));
|
||||
}
|
||||
|
||||
return points;
|
||||
}
|
||||
internal static List<double> GetRandomDataPoints()
|
||||
{
|
||||
return GetRandomDataPoints(true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,235 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms.Design;
|
||||
using System.Collections;
|
||||
using System.Drawing;
|
||||
using System.ComponentModel.Design;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design.Serialization;
|
||||
using System.CodeDom;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides design time support for NavigationBar control.
|
||||
/// </summary>
|
||||
public class NavigationBarDesigner:BarBaseControlDesigner
|
||||
{
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
public NavigationBarDesigner()
|
||||
{
|
||||
this.EnableItemDragDrop=true;
|
||||
}
|
||||
|
||||
public override void OnSetComponentDefaults()
|
||||
{
|
||||
NavigationBar navbar = this.Control as NavigationBar;
|
||||
if (navbar != null) navbar.Style = eDotNetBarStyle.StyleManagerControlled;
|
||||
base.OnSetComponentDefaults();
|
||||
}
|
||||
|
||||
public override DesignerVerbCollection Verbs
|
||||
{
|
||||
get
|
||||
{
|
||||
DesignerVerb[] verbs;
|
||||
verbs = new DesignerVerb[]
|
||||
{
|
||||
new DesignerVerb("Create New Button", new EventHandler(CreateNewButton)),
|
||||
};
|
||||
return new DesignerVerbCollection(verbs);
|
||||
}
|
||||
}
|
||||
private void CreateNewButton(object sender, EventArgs e)
|
||||
{
|
||||
IDesignerHost dh=(IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
NavigationBar navbar=this.Control as NavigationBar;
|
||||
if(navbar==null || dh==null)
|
||||
return;
|
||||
|
||||
DesignerTransaction dt = dh.CreateTransaction();
|
||||
try
|
||||
{
|
||||
IComponentChangeService change = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (change != null)
|
||||
change.OnComponentChanging(this.Component, null);
|
||||
ButtonItem item = null;
|
||||
try
|
||||
{
|
||||
m_CreatingItem = true;
|
||||
item = dh.CreateComponent(typeof(ButtonItem)) as ButtonItem;
|
||||
item.Text = item.Name;
|
||||
item.OptionGroup = "navBar";
|
||||
item.Image = Helpers.LoadBitmap("SystemImages.DefaultNavBarImage.png");
|
||||
navbar.Items.Add(item);
|
||||
}
|
||||
finally
|
||||
{
|
||||
m_CreatingItem = false;
|
||||
}
|
||||
|
||||
if (navbar.Items.Count == 1)
|
||||
item.Checked = true;
|
||||
navbar.RecalcLayout();
|
||||
|
||||
if (change != null)
|
||||
change.OnComponentChanged(this.Component, null, null, null);
|
||||
}
|
||||
catch
|
||||
{
|
||||
dt.Cancel();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!dt.Canceled) dt.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool OnMouseDown(ref Message m, MouseButtons mb)
|
||||
{
|
||||
if(base.OnMouseDown(ref m, mb))
|
||||
return true;
|
||||
|
||||
NavigationBar navbar=this.GetItemContainerControl() as NavigationBar;
|
||||
if(navbar==null || navbar.IsDisposed || !navbar.SplitterVisible)
|
||||
return false;
|
||||
|
||||
Point pos=navbar.PointToClient(System.Windows.Forms.Control.MousePosition);
|
||||
MouseEventArgs e=new MouseEventArgs(MouseButtons.Left,0,pos.X,pos.Y,0);
|
||||
|
||||
if(m.Msg==WinApi.WM_LBUTTONDOWN)
|
||||
{
|
||||
if(navbar.HitTestSplitter(e.X,e.Y))
|
||||
navbar.SplitterMouseDown(e);
|
||||
if(navbar.IsSplitterMouseDown /*|| navbar.ClientRectangle.Contains(pos)*/)
|
||||
return true;;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override bool OnMouseUp(ref Message m)
|
||||
{
|
||||
NavigationBar navbar=this.GetItemContainerControl() as NavigationBar;
|
||||
if(navbar!=null && !navbar.IsDisposed && navbar.SplitterVisible)
|
||||
{
|
||||
Point pos=navbar.PointToClient(System.Windows.Forms.Control.MousePosition);
|
||||
MouseEventArgs e=new MouseEventArgs(MouseButtons.Left,0,pos.X,pos.Y,0);
|
||||
// Design-time splitter support
|
||||
if(navbar.IsSplitterMouseDown)
|
||||
{
|
||||
navbar.SplitterMouseUp(e);
|
||||
this.OnNavigationBarHeightChanged(navbar.Height);
|
||||
}
|
||||
else
|
||||
navbar.SplitterMouseUp(e);
|
||||
}
|
||||
|
||||
if(base.OnMouseUp(ref m))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected virtual void OnNavigationBarHeightChanged(int newHeight)
|
||||
{
|
||||
// IComponentChangeService change=this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
// if(change!=null)
|
||||
// {
|
||||
// change.OnComponentChanging(this.Control,TypeDescriptor.GetProperties(this.Control).Find("NavigationBarHeight",true));
|
||||
// change.OnComponentChanged(this.Control,TypeDescriptor.GetProperties(this.Control).Find("NavigationBarHeight",true),0,newHeight);
|
||||
// }
|
||||
}
|
||||
|
||||
protected override bool OnMouseMove(ref Message m)
|
||||
{
|
||||
if(base.OnMouseMove(ref m))
|
||||
return true;
|
||||
NavigationBar navbar=this.GetItemContainerControl() as NavigationBar;
|
||||
if(navbar!=null && !navbar.IsDisposed && navbar.SplitterVisible)
|
||||
{
|
||||
Point pos=navbar.PointToClient(System.Windows.Forms.Control.MousePosition);
|
||||
MouseEventArgs e=new MouseEventArgs(System.Windows.Forms.Control.MouseButtons,0,pos.X,pos.Y,0);
|
||||
navbar.SplitterMouseMove(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override bool OnMouseLeave(ref Message m)
|
||||
{
|
||||
if(base.OnMouseLeave(ref m))
|
||||
return true;
|
||||
NavigationBar navbar=this.GetItemContainerControl() as NavigationBar;
|
||||
if(navbar!=null && !navbar.IsDisposed && navbar.SplitterVisible)
|
||||
navbar.SplitterMouseLeave();
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override void OnItemSelected(BaseItem item)
|
||||
{
|
||||
base.OnItemSelected(item);
|
||||
|
||||
if(item is ButtonItem && !((ButtonItem)item).Checked)
|
||||
{
|
||||
ButtonItem button=item as ButtonItem;
|
||||
IComponentChangeService change=this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if(change!=null)
|
||||
change.OnComponentChanging(button,TypeDescriptor.GetProperties(button).Find("Checked",true));
|
||||
button.Checked=true;
|
||||
if(change!=null)
|
||||
change.OnComponentChanged(button,TypeDescriptor.GetProperties(button).Find("Checked",true),null,null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// public class NavigationBarSerializer : CodeDomSerializer
|
||||
// {
|
||||
// public override object Serialize(IDesignerSerializationManager manager, object value)
|
||||
// {
|
||||
// // first, locate and invoke the default serializer for
|
||||
// CodeDomSerializer baseSerializer = (CodeDomSerializer)manager.GetSerializer(
|
||||
// typeof(NavigationBar).BaseType,
|
||||
// typeof(CodeDomSerializer));
|
||||
//
|
||||
// object codeObject = baseSerializer.Serialize(manager, value);
|
||||
//
|
||||
// // now add some custom code
|
||||
// if (codeObject is CodeStatementCollection)
|
||||
// {
|
||||
//
|
||||
// // // add a custom comment to the code.
|
||||
// CodeStatementCollection statements =
|
||||
// (CodeStatementCollection)codeObject;
|
||||
//
|
||||
// // call a custom method.
|
||||
// CodeExpression targetObject =
|
||||
// base.SerializeToReferenceExpression(manager, value);
|
||||
// if(targetObject != null)
|
||||
// {
|
||||
//
|
||||
// CodeMethodInvokeExpression methodCall =
|
||||
// new CodeMethodInvokeExpression(targetObject, "RecalcLayout");
|
||||
// statements.Add(methodCall);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// // finally, return the statements that have been created
|
||||
// return codeObject;
|
||||
// }
|
||||
//
|
||||
// /// The default serializer can handle the deserialization just fine. We override this
|
||||
// /// because it is an abstract member.
|
||||
// /// </summary>
|
||||
// public override object Deserialize(IDesignerSerializationManager manager, object codeDomObject)
|
||||
// {
|
||||
// // delegate straight through to the default serializer
|
||||
// //
|
||||
// CodeDomSerializer baseSerializer = (CodeDomSerializer)manager.GetSerializer(typeof(NavigationBar).BaseType, typeof(CodeDomSerializer));
|
||||
//
|
||||
// return baseSerializer.Deserialize(manager, codeDomObject);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,237 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms.Design;
|
||||
using System.Collections;
|
||||
using System.Drawing;
|
||||
using System.ComponentModel.Design;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for NavigationPaneDesigner.
|
||||
/// </summary>
|
||||
public class NavigationPaneDesigner:NavigationBarDesigner
|
||||
{
|
||||
public override void Initialize(IComponent component)
|
||||
{
|
||||
base.Initialize(component);
|
||||
if(!component.Site.DesignMode)
|
||||
return;
|
||||
NavigationPane pane=this.Control as NavigationPane;
|
||||
if(pane!=null)
|
||||
pane.SetDesignMode();
|
||||
}
|
||||
public override DesignerVerbCollection Verbs
|
||||
{
|
||||
get
|
||||
{
|
||||
DesignerVerb[] verbs;
|
||||
verbs = new DesignerVerb[]
|
||||
{
|
||||
new DesignerVerb("Create New Pane", new EventHandler(CreateNewPane)),
|
||||
};
|
||||
return new DesignerVerbCollection(verbs);
|
||||
}
|
||||
}
|
||||
|
||||
#if FRAMEWORK20
|
||||
public override void InitializeNewComponent(IDictionary defaultValues)
|
||||
{
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#else
|
||||
public override void OnSetComponentDefaults()
|
||||
{
|
||||
base.OnSetComponentDefaults();
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#endif
|
||||
|
||||
private void SetDesignTimeDefaults()
|
||||
{
|
||||
CreateNewPane();
|
||||
NavigationPane pane = this.Control as NavigationPane;
|
||||
pane.Style = eDotNetBarStyle.StyleManagerControlled;
|
||||
}
|
||||
|
||||
private void CreateNewPane(object sender, EventArgs e)
|
||||
{
|
||||
CreateNewPane();
|
||||
}
|
||||
|
||||
private void CreateNewPane()
|
||||
{
|
||||
IDesignerHost dh=(IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
NavigationPane navPane=this.Control as NavigationPane;
|
||||
if(navPane==null || dh==null)
|
||||
return;
|
||||
|
||||
DesignerTransaction dt = dh.CreateTransaction();
|
||||
try
|
||||
{
|
||||
IComponentChangeService change = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (change != null)
|
||||
change.OnComponentChanging(this.Component, null);
|
||||
|
||||
ButtonItem item = null;
|
||||
try
|
||||
{
|
||||
m_CreatingItem = true;
|
||||
item = dh.CreateComponent(typeof(ButtonItem)) as ButtonItem;
|
||||
item.Text = item.Name;
|
||||
item.OptionGroup = "navBar";
|
||||
item.Image = Helpers.LoadBitmap("SystemImages.DefaultNavBarImage.png");
|
||||
}
|
||||
finally
|
||||
{
|
||||
m_CreatingItem = false;
|
||||
}
|
||||
|
||||
NavigationPanePanel panel = dh.CreateComponent(typeof(NavigationPanePanel)) as NavigationPanePanel;
|
||||
panel.ParentItem = item;
|
||||
navPane.Items.Add(item);
|
||||
navPane.Controls.Add(panel);
|
||||
panel.Dock = DockStyle.Fill;
|
||||
panel.SendToBack();
|
||||
panel.ApplyPanelStyle();
|
||||
panel.ColorSchemeStyle = navPane.Style;
|
||||
if (Helpers.IsOffice2007Style(navPane.Style))
|
||||
panel.ColorScheme = navPane.NavigationBar.GetColorScheme();
|
||||
panel.Style.BackColor2.ColorSchemePart = eColorSchemePart.None;
|
||||
panel.Style.Border = eBorderType.None;
|
||||
panel.Style.BorderColor.ColorSchemePart = eColorSchemePart.PanelBorder;
|
||||
|
||||
if (navPane.Items.Count == 1)
|
||||
item.Checked = true;
|
||||
navPane.RecalcLayout();
|
||||
if (change != null)
|
||||
change.OnComponentChanged(this.Component, null, null, null);
|
||||
|
||||
if (change != null)
|
||||
{
|
||||
change.OnComponentChanging(panel, null);
|
||||
change.OnComponentChanged(panel, null, null, null);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
dt.Cancel();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!dt.Canceled) dt.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CanParent(Control c)
|
||||
{
|
||||
if(c is NavigationPanePanel)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override BaseItem GetItemContainer()
|
||||
{
|
||||
NavigationPane bar=this.Control as NavigationPane;
|
||||
if(bar!=null)
|
||||
return bar.NavigationBar.GetBaseItemContainer();
|
||||
return null;
|
||||
}
|
||||
|
||||
protected override System.Windows.Forms.Control GetItemContainerControl()
|
||||
{
|
||||
NavigationPane bar=this.Control as NavigationPane;
|
||||
if(bar!=null)
|
||||
return bar.NavigationBar;
|
||||
return null;
|
||||
}
|
||||
/// <summary>
|
||||
/// Triggered when some other component on the form is removed.
|
||||
/// </summary>
|
||||
protected override void OtherComponentRemoving(object sender, ComponentEventArgs e)
|
||||
{
|
||||
base.OtherComponentRemoving(sender,e);
|
||||
|
||||
NavigationPane bar=this.Component as NavigationPane;
|
||||
if(bar==null || bar.IsDisposed)
|
||||
return;
|
||||
|
||||
IDesignerHost dh=(IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
if(dh==null)
|
||||
return;
|
||||
IComponentChangeService cc = (IComponentChangeService)GetService(typeof(IComponentChangeService));
|
||||
|
||||
// Check is any of the buttons or panel that we host
|
||||
if(!m_InternalRemoving && e.Component is BaseItem && dh.TransactionDescription.StartsWith("Delete "))
|
||||
{
|
||||
ButtonItem item = e.Component as ButtonItem;
|
||||
if (item != null)
|
||||
{
|
||||
NavigationPanePanel panel = bar.GetPanel(item);
|
||||
if (panel != null && dh != null)
|
||||
{
|
||||
DesignerTransaction dt = dh.CreateTransaction("Removing associated NavigationPanePanel");
|
||||
panel.ParentItem = null;
|
||||
if (cc != null) cc.OnComponentChanging(bar, TypeDescriptor.GetProperties(bar)["Controls"]);
|
||||
bar.Controls.Remove(panel);
|
||||
if (cc != null) cc.OnComponentChanged(bar, TypeDescriptor.GetProperties(bar)["Controls"], null, null);
|
||||
dh.DestroyComponent(panel);
|
||||
dt.Commit();
|
||||
bar.RecalcLayout();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(!m_InternalRemoving && e.Component is NavigationPanePanel)
|
||||
{
|
||||
if(bar.Controls.Contains(e.Component as NavigationPanePanel))
|
||||
{
|
||||
NavigationPanePanel navpane=e.Component as NavigationPanePanel;
|
||||
if (navpane.ParentItem != null)
|
||||
{
|
||||
BaseItem item = navpane.ParentItem;
|
||||
navpane.ParentItem = null;
|
||||
if (cc != null) cc.OnComponentChanging(bar, TypeDescriptor.GetProperties(bar)["Items"]);
|
||||
bar.Items.Remove(item);
|
||||
if (cc != null) cc.OnComponentChanged(bar, TypeDescriptor.GetProperties(bar)["Items"], null, null);
|
||||
dh.DestroyComponent(item);
|
||||
}
|
||||
bar.RecalcLayout();
|
||||
}
|
||||
}
|
||||
|
||||
if (bar.CheckedButton == null && bar.Items.Count > 0 && bar.Items[0] is ButtonItem)
|
||||
{
|
||||
ButtonItem buttonItem = (ButtonItem)bar.Items[0];
|
||||
buttonItem.Checked = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void PreFilterProperties(IDictionary properties)
|
||||
{
|
||||
base.PreFilterProperties(properties);
|
||||
properties["Expanded"] = TypeDescriptor.CreateProperty(typeof(NavigationPaneDesigner), (PropertyDescriptor)properties["Expanded"], new Attribute[]
|
||||
{
|
||||
new DefaultValueAttribute(true),
|
||||
new BrowsableAttribute(true),
|
||||
new CategoryAttribute("Title"),
|
||||
new DescriptionAttribute("Indicates whether navigation pane can be collapsed.")});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether navigation pane is expanded. Default value is true.
|
||||
/// When control is collapsed it is reduced in size so it consumes less space.
|
||||
/// </summary>
|
||||
[Browsable(true), Category("Title"), DefaultValue(true), Description("Indicates whether navigation pane can be collapsed.")]
|
||||
public bool Expanded
|
||||
{
|
||||
get { return (bool)ShadowProperties["Expanded"]; }
|
||||
set
|
||||
{
|
||||
// this value is not passed to the actual control at design-time
|
||||
this.ShadowProperties["Expanded"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Windows.Forms.Design;
|
||||
using System.Collections;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Designer for Navigation Pane Panel.
|
||||
/// </summary>
|
||||
public class NavigationPanePanelDesigner:PanelExDesigner
|
||||
{
|
||||
public override SelectionRules SelectionRules
|
||||
{
|
||||
get{return (SelectionRules.Locked | SelectionRules.Visible);}
|
||||
}
|
||||
|
||||
#if FRAMEWORK20
|
||||
public override void InitializeNewComponent(IDictionary defaultValues)
|
||||
{
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#else
|
||||
public override void OnSetComponentDefaults()
|
||||
{
|
||||
base.OnSetComponentDefaults();
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#endif
|
||||
private void SetDesignTimeDefaults()
|
||||
{
|
||||
PanelEx p = this.Control as PanelEx;
|
||||
if (p == null)
|
||||
return;
|
||||
p.ApplyPanelStyle();
|
||||
p.Style.BackColor2.ColorSchemePart = eColorSchemePart.None;
|
||||
p.Text = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,218 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using DevComponents.DotNetBar.Controls;
|
||||
using System.Collections;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
public class PageSliderDesigner : System.Windows.Forms.Design.ControlDesigner
|
||||
{
|
||||
public override void Initialize(IComponent component)
|
||||
{
|
||||
base.Initialize(component);
|
||||
if (!component.Site.DesignMode)
|
||||
return;
|
||||
|
||||
IComponentChangeService cc = (IComponentChangeService)GetService(typeof(IComponentChangeService));
|
||||
if (cc != null)
|
||||
{
|
||||
cc.ComponentRemoved += new ComponentEventHandler(this.OnComponentRemoved);
|
||||
}
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
IComponentChangeService cc = (IComponentChangeService)GetService(typeof(IComponentChangeService));
|
||||
if (cc != null)
|
||||
{
|
||||
cc.ComponentRemoved -= new ComponentEventHandler(this.OnComponentRemoved);
|
||||
}
|
||||
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private void OnComponentRemoved(object sender, ComponentEventArgs e)
|
||||
{
|
||||
if (e.Component is PageSliderPage)
|
||||
{
|
||||
PageSliderPage page = e.Component as PageSliderPage;
|
||||
PageSlider slider = this.Control as PageSlider;
|
||||
|
||||
if (page != null && slider.Controls.Contains(page))
|
||||
{
|
||||
IComponentChangeService cc = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (cc != null)
|
||||
cc.OnComponentChanging(slider, TypeDescriptor.GetProperties(slider)["Controls"]);
|
||||
|
||||
slider.Controls.Remove(page);
|
||||
|
||||
if (cc != null)
|
||||
cc.OnComponentChanged(slider, TypeDescriptor.GetProperties(slider)["Controls"], null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void DoDefaultAction()
|
||||
{
|
||||
}
|
||||
|
||||
public override DesignerVerbCollection Verbs
|
||||
{
|
||||
get
|
||||
{
|
||||
DesignerVerb[] verbs = null;
|
||||
verbs = new DesignerVerb[]
|
||||
{
|
||||
new DesignerVerb("Create Page", new EventHandler(CreatePage)),
|
||||
new DesignerVerb("Delete Page", new EventHandler(DeletePage)),
|
||||
new DesignerVerb("Next Page", new EventHandler(NextPage)),
|
||||
new DesignerVerb("Previous Page", new EventHandler(PreviousPage))
|
||||
};
|
||||
return new DesignerVerbCollection(verbs);
|
||||
}
|
||||
}
|
||||
|
||||
#if FRAMEWORK20
|
||||
public override void InitializeNewComponent(IDictionary defaultValues)
|
||||
{
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#else
|
||||
public override void OnSetComponentDefaults()
|
||||
{
|
||||
base.OnSetComponentDefaults();
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#endif
|
||||
|
||||
private void SetDesignTimeDefaults()
|
||||
{
|
||||
}
|
||||
|
||||
private void CreatePage(object sender, EventArgs e)
|
||||
{
|
||||
IDesignerHost dh = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
IComponentChangeService cc = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
ISelectionService ss = this.GetService(typeof(ISelectionService)) as ISelectionService;
|
||||
|
||||
CreatePage(this.Control as PageSlider, dh, cc, ss);
|
||||
}
|
||||
|
||||
internal static PageSliderPage CreatePage(PageSlider parent, IDesignerHost dh, IComponentChangeService cc, ISelectionService ss)
|
||||
{
|
||||
DesignerTransaction dt = dh.CreateTransaction();
|
||||
PageSliderPage page = null;
|
||||
try
|
||||
{
|
||||
page = dh.CreateComponent(typeof(PageSliderPage)) as PageSliderPage;
|
||||
|
||||
if (cc != null)
|
||||
cc.OnComponentChanging(parent, TypeDescriptor.GetProperties(parent)["Controls"]);
|
||||
parent.Controls.Add(page);
|
||||
if (cc != null)
|
||||
cc.OnComponentChanged(parent, TypeDescriptor.GetProperties(parent)["Controls"], null, null);
|
||||
|
||||
if (ss != null)
|
||||
ss.SetSelectedComponents(new PageSliderPage[] { page }, SelectionTypes.Replace);
|
||||
|
||||
TypeDescriptor.GetProperties(parent)["SelectedPage"].SetValue(parent, page);
|
||||
}
|
||||
catch
|
||||
{
|
||||
dt.Cancel();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!dt.Canceled)
|
||||
dt.Commit();
|
||||
}
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
private void DeletePage(object sender, EventArgs e)
|
||||
{
|
||||
IDesignerHost dh = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
IComponentChangeService cc = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
PageSlider w = this.Control as PageSlider;
|
||||
if (w == null)
|
||||
return;
|
||||
DeletePage(w.SelectedPage, dh, cc);
|
||||
}
|
||||
|
||||
internal static void DeletePage(PageSliderPage page, IDesignerHost dh, IComponentChangeService cc)
|
||||
{
|
||||
if (page == null || !(page.Parent is PageSlider))
|
||||
return;
|
||||
|
||||
PageSlider slider = (PageSlider)page.Parent;
|
||||
|
||||
DesignerTransaction dt = dh.CreateTransaction("Deleting page");
|
||||
|
||||
try
|
||||
{
|
||||
if (cc != null)
|
||||
cc.OnComponentChanging(slider, TypeDescriptor.GetProperties(slider)["Controls"]);
|
||||
|
||||
slider.Controls.Remove(page);
|
||||
|
||||
if (cc != null)
|
||||
cc.OnComponentChanged(slider, TypeDescriptor.GetProperties(slider)["Controls"], null, null);
|
||||
|
||||
dh.DestroyComponent(page);
|
||||
}
|
||||
catch
|
||||
{
|
||||
dt.Cancel();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!dt.Canceled)
|
||||
dt.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
private void NextPage(object sender, EventArgs e)
|
||||
{
|
||||
SelectNextPage(this.Control as PageSlider);
|
||||
}
|
||||
|
||||
private void PreviousPage(object sender, EventArgs e)
|
||||
{
|
||||
SelectPreviousPage(this.Control as PageSlider);
|
||||
}
|
||||
|
||||
internal static bool SelectNextPage(PageSlider slider)
|
||||
{
|
||||
if (slider == null)
|
||||
return false;
|
||||
if (slider.PageCount > 0)
|
||||
{
|
||||
if (slider.SelectedPageIndex < slider.PageCount - 1)
|
||||
slider.SelectedPageIndex++;
|
||||
else
|
||||
slider.SelectedPageIndex = 0;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
internal static bool SelectPreviousPage(PageSlider slider)
|
||||
{
|
||||
if (slider == null)
|
||||
return false;
|
||||
if (slider.PageCount > 0)
|
||||
{
|
||||
if (slider.SelectedPageIndex > 0)
|
||||
slider.SelectedPageIndex--;
|
||||
else
|
||||
slider.SelectedPageIndex = slider.PageCount - 1;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms.Design;
|
||||
using DevComponents.DotNetBar.Controls;
|
||||
using System.ComponentModel.Design;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
public class PageSliderPageDesigner : ScrollableControlDesigner
|
||||
{
|
||||
#region Internal Implementation
|
||||
public override DesignerVerbCollection Verbs
|
||||
{
|
||||
get
|
||||
{
|
||||
DesignerVerb[] verbs = null;
|
||||
verbs = new DesignerVerb[]
|
||||
{
|
||||
new DesignerVerb("Move Forward", new EventHandler(MovePageForward)),
|
||||
new DesignerVerb("Move Backward", new EventHandler(MovePageBackward)),
|
||||
new DesignerVerb("Make First", new EventHandler(MakeFirstPage)),
|
||||
new DesignerVerb("Make Last", new EventHandler(MakeLastPage))
|
||||
};
|
||||
return new DesignerVerbCollection(verbs);
|
||||
}
|
||||
}
|
||||
|
||||
private void MovePageTo(PageSliderPage page, PageSlider slider, int newIndex)
|
||||
{
|
||||
IDesignerHost dh = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
IComponentChangeService cc = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
ISelectionService ss = this.GetService(typeof(ISelectionService)) as ISelectionService;
|
||||
|
||||
DesignerTransaction dt = dh.CreateTransaction("Moving page");
|
||||
if (cc != null)
|
||||
cc.OnComponentChanging(slider, TypeDescriptor.GetProperties(slider)["Controls"]);
|
||||
slider.Controls.SetChildIndex(page, newIndex);
|
||||
if (cc != null)
|
||||
cc.OnComponentChanged(slider, TypeDescriptor.GetProperties(slider)["Controls"], null, null);
|
||||
dt.Commit();
|
||||
}
|
||||
private void MovePageForward(object sender, EventArgs e)
|
||||
{
|
||||
PageSliderPage page = this.Control as PageSliderPage;
|
||||
if (page == null) return;
|
||||
PageSlider slider = page.Parent as PageSlider;
|
||||
if (slider == null) return;
|
||||
int newIndex = slider.Controls.IndexOf(page);
|
||||
if (newIndex < slider.PageCount - 1)
|
||||
newIndex++;
|
||||
else
|
||||
newIndex = 0;
|
||||
|
||||
MovePageTo(page, slider, newIndex);
|
||||
}
|
||||
private void MovePageBackward(object sender, EventArgs e)
|
||||
{
|
||||
PageSliderPage page = this.Control as PageSliderPage;
|
||||
if (page == null) return;
|
||||
PageSlider slider = page.Parent as PageSlider;
|
||||
if (slider == null) return;
|
||||
int newIndex = slider.Controls.IndexOf(page);
|
||||
if (newIndex > 0)
|
||||
newIndex--;
|
||||
else
|
||||
newIndex = slider.PageCount - 1;
|
||||
|
||||
MovePageTo(page, slider, newIndex);
|
||||
}
|
||||
private void MakeFirstPage(object sender, EventArgs e)
|
||||
{
|
||||
PageSliderPage page = this.Control as PageSliderPage;
|
||||
if (page == null) return;
|
||||
PageSlider slider = page.Parent as PageSlider;
|
||||
if (slider == null) return;
|
||||
MovePageTo(page, slider, 0);
|
||||
}
|
||||
private void MakeLastPage(object sender, EventArgs e)
|
||||
{
|
||||
PageSliderPage page = this.Control as PageSliderPage;
|
||||
if (page == null) return;
|
||||
PageSlider slider = page.Parent as PageSlider;
|
||||
if (slider == null) return;
|
||||
MovePageTo(page, slider, slider.PageCount - 1);
|
||||
}
|
||||
public override SelectionRules SelectionRules
|
||||
{
|
||||
get { return SelectionRules.Locked; }
|
||||
}
|
||||
|
||||
protected override void OnPaintAdornments(PaintEventArgs pe)
|
||||
{
|
||||
PageSliderPage p;
|
||||
p = this.Component as PageSliderPage;
|
||||
if (p != null)
|
||||
{
|
||||
this.DrawBorder(pe.Graphics);
|
||||
}
|
||||
base.OnPaintAdornments(pe);
|
||||
}
|
||||
|
||||
|
||||
private void DrawBorder(Graphics g)
|
||||
{
|
||||
PageSliderPage panel = this.Control as PageSliderPage;
|
||||
Color border = SystemColors.ControlDarkDark;
|
||||
Rectangle rClient = this.Control.ClientRectangle;
|
||||
Color backColor = Color.Empty;
|
||||
|
||||
Helpers.DrawDesignTimeSelection(g, rClient, backColor, border, 1);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms.Design;
|
||||
using System.Collections;
|
||||
using System.Drawing;
|
||||
using System.ComponentModel.Design;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Windows Forms Designer for PanelControl
|
||||
/// </summary>
|
||||
public class PanelControlDesigner : System.Windows.Forms.Design.ScrollableControlDesigner
|
||||
{
|
||||
public override DesignerVerbCollection Verbs
|
||||
{
|
||||
get
|
||||
{
|
||||
DesignerVerb[] verbs;
|
||||
verbs = new DesignerVerb[]
|
||||
{
|
||||
new DesignerVerb("Apply Panel Style", new EventHandler(ApplyPanelStyle)),
|
||||
new DesignerVerb("Apply Button Style", new EventHandler(ApplyButtonStyle)),
|
||||
new DesignerVerb("Apply Label Style", new EventHandler(ApplyLabelStyle))
|
||||
};
|
||||
return new DesignerVerbCollection(verbs);
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyPanelStyle(object sender, EventArgs e)
|
||||
{
|
||||
PanelControl p = this.Control as PanelControl;
|
||||
if (p == null)
|
||||
return;
|
||||
|
||||
IComponentChangeService change = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (change != null)
|
||||
change.OnComponentChanging(this.Component, null);
|
||||
|
||||
p.ApplyPanelStyle();
|
||||
|
||||
if (change != null)
|
||||
change.OnComponentChanged(this.Component, null, null, null);
|
||||
}
|
||||
|
||||
private void ApplyButtonStyle(object sender, EventArgs e)
|
||||
{
|
||||
PanelControl p = this.Control as PanelControl;
|
||||
if (p == null)
|
||||
return;
|
||||
|
||||
IComponentChangeService change = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (change != null)
|
||||
change.OnComponentChanging(this.Component, null);
|
||||
|
||||
p.ApplyButtonStyle();
|
||||
|
||||
if (change != null)
|
||||
change.OnComponentChanged(this.Component, null, null, null);
|
||||
}
|
||||
|
||||
private void ApplyLabelStyle(object sender, EventArgs e)
|
||||
{
|
||||
PanelControl p = this.Control as PanelControl;
|
||||
if (p == null)
|
||||
return;
|
||||
|
||||
IComponentChangeService change = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (change != null)
|
||||
change.OnComponentChanging(this.Component, null);
|
||||
|
||||
p.ApplyLabelStyle();
|
||||
|
||||
if (change != null)
|
||||
change.OnComponentChanged(this.Component, null, null, null);
|
||||
}
|
||||
#if FRAMEWORK20
|
||||
public override void InitializeNewComponent(IDictionary defaultValues)
|
||||
{
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#else
|
||||
public override void OnSetComponentDefaults()
|
||||
{
|
||||
base.OnSetComponentDefaults();
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#endif
|
||||
|
||||
protected virtual void SetDesignTimeDefaults()
|
||||
{
|
||||
PanelControl p = this.Control as PanelControl;
|
||||
if (p == null)
|
||||
return;
|
||||
p.ApplyPanelStyle();
|
||||
p.CanvasColor = SystemColors.Control;
|
||||
}
|
||||
|
||||
protected override void OnPaintAdornments(PaintEventArgs pe)
|
||||
{
|
||||
PanelControl p = this.Component as PanelControl;
|
||||
if (p != null && p.Style.Border == eStyleBorderType.None)
|
||||
this.DrawBorder(pe.Graphics);
|
||||
base.OnPaintAdornments(pe);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws design-time border around the panel when panel does not have one.
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
protected virtual void DrawBorder(Graphics g)
|
||||
{
|
||||
PanelControl panel = this.Control as PanelControl;
|
||||
Color border = SystemColors.ControlDarkDark;
|
||||
Rectangle rClient = this.Control.ClientRectangle;
|
||||
Color backColor = panel.Style.BackColor;
|
||||
|
||||
Helpers.DrawDesignTimeSelection(g, rClient, backColor, border, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Windows.Forms.Design;
|
||||
using System.Collections;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
#region PanelDockContainerDesigner
|
||||
/// <summary>
|
||||
/// Designer for Tab Control Panel.
|
||||
/// </summary>
|
||||
public class PanelDockContainerDesigner:PanelExDesigner
|
||||
{
|
||||
public override SelectionRules SelectionRules
|
||||
{
|
||||
get{return (SelectionRules.Locked | SelectionRules.Visible);}
|
||||
}
|
||||
#if FRAMEWORK20
|
||||
public override void InitializeNewComponent(IDictionary defaultValues)
|
||||
{
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#else
|
||||
public override void OnSetComponentDefaults()
|
||||
{
|
||||
base.OnSetComponentDefaults();
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#endif
|
||||
|
||||
private void SetDesignTimeDefaults()
|
||||
{
|
||||
PanelDockContainer p = this.Control as PanelDockContainer;
|
||||
if (p == null)
|
||||
return;
|
||||
p.ApplyLabelStyle();
|
||||
p.Text = "";
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user