DotNet 4.8.1 build of DotNetBar

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

View File

@@ -0,0 +1,178 @@
namespace DevComponents.Instrumentation.Design
{
partial class FormatStringDropDown
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this._CbxFmtType = new System.Windows.Forms.ComboBox();
this._LbFmtType = new System.Windows.Forms.Label();
this._LbPrecision = new System.Windows.Forms.Label();
this._LbSample = new System.Windows.Forms.Label();
this._TbSample = new System.Windows.Forms.TextBox();
this._LbDescription = new System.Windows.Forms.Label();
this._TbCustom = new System.Windows.Forms.TextBox();
this._TbPrecision = new System.Windows.Forms.TextBox();
this._BtnOk = new System.Windows.Forms.Button();
this._BtnCancel = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// _CbxFmtType
//
this._CbxFmtType.FormattingEnabled = true;
this._CbxFmtType.Location = new System.Drawing.Point(95, 17);
this._CbxFmtType.Name = "_CbxFmtType";
this._CbxFmtType.Size = new System.Drawing.Size(223, 21);
this._CbxFmtType.TabIndex = 0;
this._CbxFmtType.SelectedIndexChanged += new System.EventHandler(this.CbxFmtType_SelectedIndexChanged);
this._CbxFmtType.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.MyPreviewKeyDown);
//
// _LbFmtType
//
this._LbFmtType.AutoSize = true;
this._LbFmtType.Location = new System.Drawing.Point(20, 20);
this._LbFmtType.Name = "_LbFmtType";
this._LbFmtType.Size = new System.Drawing.Size(69, 13);
this._LbFmtType.TabIndex = 1;
this._LbFmtType.Text = "Format Type:";
//
// _LbPrecision
//
this._LbPrecision.AutoSize = true;
this._LbPrecision.Location = new System.Drawing.Point(20, 44);
this._LbPrecision.Name = "_LbPrecision";
this._LbPrecision.Size = new System.Drawing.Size(53, 13);
this._LbPrecision.TabIndex = 2;
this._LbPrecision.Text = "Precision:";
//
// _LbSample
//
this._LbSample.AutoSize = true;
this._LbSample.Location = new System.Drawing.Point(20, 70);
this._LbSample.Name = "_LbSample";
this._LbSample.Size = new System.Drawing.Size(45, 13);
this._LbSample.TabIndex = 4;
this._LbSample.Text = "Sample:";
//
// _TbSample
//
this._TbSample.BackColor = System.Drawing.SystemColors.Info;
this._TbSample.ForeColor = System.Drawing.Color.Black;
this._TbSample.Location = new System.Drawing.Point(95, 70);
this._TbSample.Name = "_TbSample";
this._TbSample.Size = new System.Drawing.Size(223, 20);
this._TbSample.TabIndex = 5;
this._TbSample.Text = "1234.56";
this._TbSample.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.MyPreviewKeyDown);
this._TbSample.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.TextBoxKeyPress);
//
// _LbDescription
//
this._LbDescription.Location = new System.Drawing.Point(15, 97);
this._LbDescription.Name = "_LbDescription";
this._LbDescription.Size = new System.Drawing.Size(391, 125);
this._LbDescription.TabIndex = 6;
this._LbDescription.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// _TbCustom
//
this._TbCustom.Location = new System.Drawing.Point(95, 44);
this._TbCustom.Name = "_TbCustom";
this._TbCustom.Size = new System.Drawing.Size(223, 20);
this._TbCustom.TabIndex = 7;
this._TbCustom.Visible = false;
this._TbCustom.TextChanged += new System.EventHandler(this.MyTextChanged);
this._TbCustom.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.MyPreviewKeyDown);
//
// _TbPrecision
//
this._TbPrecision.Location = new System.Drawing.Point(95, 44);
this._TbPrecision.Name = "_TbPrecision";
this._TbPrecision.Size = new System.Drawing.Size(223, 20);
this._TbPrecision.TabIndex = 8;
this._TbPrecision.Visible = false;
this._TbPrecision.TextChanged += new System.EventHandler(this.MyTextChanged);
this._TbPrecision.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.MyPreviewKeyDown);
//
// _BtnOk
//
this._BtnOk.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this._BtnOk.Location = new System.Drawing.Point(336, 26);
this._BtnOk.Name = "_BtnOk";
this._BtnOk.Size = new System.Drawing.Size(61, 23);
this._BtnOk.TabIndex = 9;
this._BtnOk.Text = "Ok";
this._BtnOk.UseVisualStyleBackColor = true;
this._BtnOk.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.MyPreviewKeyDown);
this._BtnOk.Click += new System.EventHandler(this.BtnOk_Click);
//
// _BtnCancel
//
this._BtnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this._BtnCancel.Location = new System.Drawing.Point(336, 55);
this._BtnCancel.Name = "_BtnCancel";
this._BtnCancel.Size = new System.Drawing.Size(61, 23);
this._BtnCancel.TabIndex = 10;
this._BtnCancel.Text = "Cancel";
this._BtnCancel.UseVisualStyleBackColor = true;
this._BtnCancel.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.MyPreviewKeyDown);
this._BtnCancel.Click += new System.EventHandler(this.BtnCancel_Click);
//
// FormatStringDropDown
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this._BtnCancel);
this.Controls.Add(this._BtnOk);
this.Controls.Add(this._TbPrecision);
this.Controls.Add(this._LbDescription);
this.Controls.Add(this._TbSample);
this.Controls.Add(this._LbSample);
this.Controls.Add(this._LbPrecision);
this.Controls.Add(this._LbFmtType);
this.Controls.Add(this._CbxFmtType);
this.Controls.Add(this._TbCustom);
this.Name = "FormatStringDropDown";
this.Size = new System.Drawing.Size(418, 222);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.ComboBox _CbxFmtType;
private System.Windows.Forms.Label _LbFmtType;
private System.Windows.Forms.Label _LbPrecision;
private System.Windows.Forms.Label _LbSample;
private System.Windows.Forms.TextBox _TbSample;
private System.Windows.Forms.Label _LbDescription;
private System.Windows.Forms.TextBox _TbCustom;
private System.Windows.Forms.TextBox _TbPrecision;
private System.Windows.Forms.Button _BtnOk;
private System.Windows.Forms.Button _BtnCancel;
}
}

View File

@@ -0,0 +1,322 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Windows.Forms.Design;
using DevComponents.DotNetBarKnobControl.Design.Properties;
namespace DevComponents.Instrumentation.Design
{
[ToolboxItem(false)]
public partial class FormatStringDropDown : UserControl
{
#region Private variables
private string _FormatString;
private bool _EscapePressed;
private IWindowsFormsEditorService _EditorService;
private ITypeDescriptorContext _Context;
private string[] _Items = new string[] {
"Custom",
"Currency",
"Decimal",
"Fixed-point",
"General",
"Hexadecimal",
"Number",
"Percent",
"Scientific"};
private Format[] _Formats = new Format[] {
new Format("", (string)(Resources.ResourceManager.GetObject("CustomDesc"))),
new Format("C", (string)(Resources.ResourceManager.GetObject("CurrencyDesc"))),
new Format("D", (string)(Resources.ResourceManager.GetObject("DecimalDesc"))),
new Format("F", (string)(Resources.ResourceManager.GetObject("FixedPointDesc"))),
new Format("G", (string)(Resources.ResourceManager.GetObject("GeneralDesc"))),
new Format("X", (string)(Resources.ResourceManager.GetObject("HexadecimalDesc"))),
new Format("N", (string)(Resources.ResourceManager.GetObject("NumericDesc"))),
new Format("P", (string)(Resources.ResourceManager.GetObject("PercentDesc"))),
new Format("E", (string)(Resources.ResourceManager.GetObject("ExponentialDesc")))};
#endregion
public FormatStringDropDown()
{
InitFormatList();
}
public FormatStringDropDown(string formatString,
IWindowsFormsEditorService editorService, ITypeDescriptorContext context)
{
_FormatString = formatString;
_EditorService = editorService;
_Context = context;
InitFormatList();
BackColor = SystemColors.Control;
}
#region InitFormatList
private void InitFormatList()
{
InitializeComponent();
_CbxFmtType.DrawMode = DrawMode.OwnerDrawFixed;
_CbxFmtType.DrawItem += CbxFmtType_DrawItem;
_CbxFmtType.Items.AddRange(_Items);
_CbxFmtType.SelectedIndex = 3;
}
#endregion
#region Public properties
#region FormatString
public string FormatString
{
get { return (_FormatString); }
set
{
_FormatString = value;
_Context.OnComponentChanging();
_Context.PropertyDescriptor.SetValue(_Context.Instance, value);
_Context.OnComponentChanged();
Invalidate();
}
}
#endregion
#region EditorService
public IWindowsFormsEditorService EditorService
{
get { return (_EditorService); }
set { _EditorService = value; }
}
#endregion
#region EscapePressed
public bool EscapePressed
{
get { return (_EscapePressed); }
set { _EscapePressed = value; }
}
#endregion
#endregion
#region CbxFmtType_DrawItem
void CbxFmtType_DrawItem(object sender, DrawItemEventArgs e)
{
e.DrawBackground();
if (e.Index == 0)
{
e.Graphics.DrawLine(Pens.Gainsboro, new Point(e.Bounds.Left, e.Bounds.Bottom - 1),
new Point(e.Bounds.Right, e.Bounds.Bottom - 1));
}
TextRenderer.DrawText(e.Graphics, _CbxFmtType.Items[e.Index].ToString(),
_CbxFmtType.Font, e.Bounds, _CbxFmtType.ForeColor, TextFormatFlags.Left);
e.DrawFocusRectangle();
}
#endregion
#region TextBoxKeyPress
private void TextBoxKeyPress(object sender, KeyPressEventArgs e)
{
e.Handled = true;
}
#endregion
#region CbxFmtType_SelectedIndexChanged
private void CbxFmtType_SelectedIndexChanged(object sender, EventArgs e)
{
if ((uint)_CbxFmtType.SelectedIndex < _Formats.Length)
{
Format fmt = _Formats[_CbxFmtType.SelectedIndex];
_LbDescription.Text = fmt.Description;
UpdateSample();
}
else
{
_TbSample.Text = "";
_LbDescription.Text = "";
}
}
#endregion
#region UpdateSample
private void UpdateSample()
{
if (_CbxFmtType.SelectedIndex == 0)
{
_TbCustom.Visible = true;
_TbPrecision.Visible = false;
_LbPrecision.Text = @"Format String:";
UpdateCustomSample();
}
else if (_CbxFmtType.SelectedIndex > 0)
{
_TbPrecision.Visible = true;
_TbCustom.Visible = false;
_LbPrecision.Text = @"Precision:";
UpdateNumericSample();
}
}
#endregion
#region UpdateCustomSample
private void UpdateCustomSample()
{
_FormatString = _TbCustom.Text;
try
{
_TbSample.Text = String.Format("{0:" + _FormatString + "}", 1234567890);
}
catch
{
_TbSample.Text = @"Invalid Format String.";
}
}
#endregion
#region UpdateNumericSample
private void UpdateNumericSample()
{
Format fmt = _Formats[_CbxFmtType.SelectedIndex];
try
{
int precision = GetPrecision();
_FormatString = fmt.FormatCode + precision.ToString();
_TbSample.Text = String.Format("{0:" + _FormatString + "}", 1234567890);
}
catch
{
_TbSample.Text = @"Invalid Format String.";
}
}
#endregion
#region GetPrecision
private int GetPrecision()
{
int precision;
if (int.TryParse(_TbPrecision.Text, out precision))
return (precision < 0 ? 0 : precision > 99 ? 99 : precision);
return (0);
}
#endregion
#region MyTextChanged
private void MyTextChanged(object sender, EventArgs e)
{
UpdateSample();
}
#endregion
#region BtnOk_Click
private void BtnOk_Click(object sender, EventArgs e)
{
_EditorService.CloseDropDown();
}
#endregion
#region BtnCancel_Click
private void BtnCancel_Click(object sender, EventArgs e)
{
_EscapePressed = true;
_EditorService.CloseDropDown();
}
#endregion
#region MyPreviewKeyDown
private void MyPreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
if (e.KeyCode == Keys.Escape)
_EscapePressed = true;
}
#endregion
#region Format
private class Format
{
#region Private variables
private string _FormatCode;
private string _Description;
#endregion
public Format(string formatCode, string description)
{
_FormatCode = formatCode;
_Description = description;
}
#region Public properties
public string FormatCode
{
get { return (_FormatCode); }
}
public string Description
{
get { return (_Description); }
}
#endregion
}
#endregion
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

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

View File

@@ -0,0 +1,738 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Drawing;
using System.Reflection;
using System.Resources;
using System.Windows.Forms;
using DevComponents.DotNetBarKnobControl.Design.Properties;
namespace DevComponents.Instrumentation.Design
{
public class GaugeCollectionEditor : CollectionEditor
{
#region Private variables
private ListBox _ListBox;
private GaugeItem _GaugeItem;
private GaugeItem _LastGaugeItem;
private PropertyGrid _PropertyGrid;
private Button _AddButton;
private Button _RemButton;
private Button _CopyButton;
private ToolTip _ToolTip;
private List<GaugeItem> _RemovedItems;
#endregion
public GaugeCollectionEditor(Type type)
: base(type)
{
}
#region Private properties
#region RemovedItems
private List<GaugeItem> RemovedItems
{
get
{
if (_RemovedItems == null)
_RemovedItems = new List<GaugeItem>();
return (_RemovedItems);
}
}
#endregion
#endregion
#region CreateCollectionForm
protected override CollectionForm CreateCollectionForm()
{
CollectionForm collectionForm = base.CreateCollectionForm();
_GaugeItem = null;
if (collectionForm.Controls[0] is TableLayoutPanel)
{
TableLayoutPanel tlpf = collectionForm.Controls["overArchingTableLayoutPanel"] as TableLayoutPanel;
if (tlpf != null)
{
TableLayoutPanel tlp2 = tlpf.Controls["addRemoveTableLayoutPanel"] as TableLayoutPanel;
if (tlp2 != null)
{
_RemButton = tlp2.Controls["removeButton"] as Button;
if (_RemButton != null)
_RemButton.Click += GaugeCollectionEditor_RemoveClick;
_AddButton = tlp2.Controls["addButton"] as Button;
if (_AddButton != null)
{
_AddButton.Click += GaugeCollectionEditor_AddClick;
AddCopyButton(collectionForm);
}
}
_ListBox = tlpf.Controls["listbox"] as ListBox;
if (_ListBox != null)
_ListBox.SelectedIndexChanged += ListBox_SelectedIndexChanged;
_PropertyGrid = tlpf.Controls["propertyBrowser"] as PropertyGrid;
if (_PropertyGrid != null)
_PropertyGrid.HelpVisible = true;
}
}
return (collectionForm);
}
#endregion
#region CancelChanges
protected override void CancelChanges()
{
if (_RemovedItems != null)
{
foreach (GaugeItem gi in _RemovedItems)
gi.Visible = true;
}
base.CancelChanges();
}
#endregion
#region CopyButton support
#region AddCopyButton
private void AddCopyButton(CollectionForm collectionForm)
{
_CopyButton = new Button();
_CopyButton.Size = new Size(23, 24);
_CopyButton.Enabled = false;
_CopyButton.Click += CopyButton_Click;
ResourceManager rm = Resources.ResourceManager;
_CopyButton.Image = (Image)rm.GetObject("Copy");
collectionForm.Controls.Add(_CopyButton);
_CopyButton.Location = new Point(208, 85);
_CopyButton.BringToFront();
_ToolTip = new ToolTip();
_ToolTip.SetToolTip(_CopyButton, "Clone the selected item");
}
#endregion
#region CopyButton_Click
#region CopyButton_Click
void CopyButton_Click(object sender, EventArgs e)
{
if (_GaugeItem != null)
{
if (_GaugeItem is GaugeCircularScale)
CopyCircularScale(_GaugeItem as GaugeCircularScale);
else if (_GaugeItem is GaugeLinearScale)
CopyLinearScale(_GaugeItem as GaugeLinearScale);
else if (_GaugeItem is GaugeSection)
CopySection(_GaugeItem as GaugeSection);
else if (_GaugeItem is GaugeRange)
CopyRange(_GaugeItem as GaugeRange);
else if (_GaugeItem is GaugeCustomLabel)
CopyLabel(_GaugeItem as GaugeCustomLabel);
else if (_GaugeItem is GaugePointer)
CopyPointer(_GaugeItem as GaugePointer);
else if (_GaugeItem is NumericRange)
CopyNumericRange(_GaugeItem as NumericRange);
else if (_GaugeItem is StateRange)
CopyStateRange(_GaugeItem as StateRange);
}
}
#endregion
#region CopyCircularScale
private void CopyCircularScale(GaugeCircularScale scale)
{
if (_AddButton != null)
{
_AddButton.PerformClick();
GaugeCircularScaleCollection css = scale.GaugeControl.CircularScales;
GaugeCircularScale clone = css[css.Count - 1];
scale.CopyToItem(clone);
}
}
#endregion
#region CopyLinearScale
private void CopyLinearScale(GaugeLinearScale scale)
{
if (_AddButton != null)
{
_AddButton.PerformClick();
GaugeLinearScaleCollection lss = scale.GaugeControl.LinearScales;
GaugeLinearScale clone = lss[lss.Count - 1];
scale.CopyToItem(clone);
}
}
#endregion
#region CopySection
private void CopySection(GaugeSection section)
{
if (_AddButton != null)
{
_AddButton.PerformClick();
GaugeSectionCollection sc = section.Scale.Sections;
GaugeSection clone = sc[sc.Count - 1];
section.CopyToItem(clone);
}
}
#endregion
#region CopyRange
private void CopyRange(GaugeRange range)
{
if (_AddButton != null)
{
_AddButton.PerformClick();
GaugeRangeCollection rc = range.Scale.Ranges;
GaugeRange clone = rc[rc.Count - 1];
range.CopyToItem(clone);
}
}
#endregion
#region CopyLabel
private void CopyLabel(GaugeCustomLabel label)
{
if (_AddButton != null)
{
_AddButton.PerformClick();
GaugeCustomLabelCollection lc = label.Scale.CustomLabels;
GaugeCustomLabel clone = lc[lc.Count - 1];
label.CopyToItem(clone);
}
}
#endregion
#region CopyPointer
private void CopyPointer(GaugePointer pointer)
{
if (_AddButton != null)
{
_AddButton.PerformClick();
GaugePointerCollection pc = pointer.Scale.Pointers;
GaugePointer clone = pc[pc.Count - 1];
pointer.CopyToItem(clone);
}
}
#endregion
#region CopyNumericRange
private void CopyNumericRange(NumericRange range)
{
if (_AddButton != null)
{
_AddButton.PerformClick();
NumericRangeCollection pc = range.NumericIndicator.Ranges;
NumericRange clone = pc[pc.Count - 1];
range.CopyToItem(clone);
}
}
#endregion
#region CopyStateRange
private void CopyStateRange(StateRange range)
{
if (_AddButton != null)
{
_AddButton.PerformClick();
StateRangeCollection pc = range.StateIndicator.Ranges;
StateRange clone = pc[pc.Count - 1];
range.CopyToItem(clone);
}
}
#endregion
#endregion
#endregion
#region ListBox_SelectedIndexChanged
void ListBox_SelectedIndexChanged(object sender, EventArgs e)
{
if (_ListBox.SelectedItem != null)
{
PropertyInfo p = _ListBox.SelectedItem.GetType().GetProperty("Value");
_LastGaugeItem = _GaugeItem;
_GaugeItem = (GaugeItem)p.GetValue(_ListBox.SelectedItem, null);
_CopyButton.Enabled = true;
}
else
{
_CopyButton.Enabled = false;
}
}
#endregion
#region GaugeCollectionEditor_AddClick
void GaugeCollectionEditor_AddClick(object sender, EventArgs e)
{
if (_GaugeItem != null)
{
if (_GaugeItem is GaugeCircularScale)
InitializeNewCircularScale(_GaugeItem as GaugeCircularScale);
else if (_GaugeItem is GaugeLinearScale)
InitializeNewLinearScale(_GaugeItem as GaugeLinearScale);
else if (_GaugeItem is GaugeSection)
InitializeNewSection(_GaugeItem as GaugeSection);
else if (_GaugeItem is GaugeRange)
InitializeNewRange(_GaugeItem as GaugeRange);
else if (_GaugeItem is GaugeCustomLabel)
InitializeNewCustomLabel(_GaugeItem as GaugeCustomLabel);
else if (_GaugeItem is GaugePointer)
InitializeNewPointer(_GaugeItem as GaugePointer);
else if (_GaugeItem is NumericRange)
InitializeNewNumericRange(_GaugeItem as NumericRange);
else if (_GaugeItem is StateRange)
InitializeNewStateRange(_GaugeItem as StateRange);
}
}
#region InitializeNewScale
#region InitializeNewCircularScale
private void InitializeNewCircularScale(GaugeCircularScale scale)
{
scale.Name = GetScaleName(scale);
GaugeSection section = new GaugeSection(scale);
section.Name = GetSectionName(scale);
section.FillColor = new GradientFillColor(Color.CornflowerBlue);
scale.Sections.Add(section);
}
#region GetScaleName
private string GetScaleName(GaugeCircularScale scale)
{
for (int i = 1; i < 100; i++)
{
string s = "Scale" + i.ToString();
if (scale.GaugeControl.CircularScales[s] == null)
return (s);
}
return (null);
}
#endregion
#endregion
#region InitializeNewLinearScale
private void InitializeNewLinearScale(GaugeLinearScale scale)
{
scale.Orientation = GetDefaultOrientation(scale);
scale.Name = GetScaleName(scale);
GaugeSection section = new GaugeSection(scale);
section.Name = GetSectionName(scale);
section.FillColor = new GradientFillColor(Color.CornflowerBlue);
scale.Sections.Add(section);
}
#region GetDefaultOrientation
private Orientation GetDefaultOrientation(GaugeLinearScale scale)
{
foreach (GaugeLinearScale gls in scale.GaugeControl.LinearScales)
{
if (gls != scale)
return (gls.Orientation);
}
return (scale.GaugeControl.Width > scale.GaugeControl.Height
? Orientation.Horizontal : Orientation.Vertical);
}
#endregion
#region GetScaleName
private string GetScaleName(GaugeLinearScale scale)
{
for (int i = 1; i < 100; i++)
{
string s = "Scale" + i.ToString();
if (scale.GaugeControl.LinearScales[s] == null)
return (s);
}
return (null);
}
#endregion
#endregion
#endregion
#region InitializeNewSection
#region InitializeNewSection
private void InitializeNewSection(GaugeSection section)
{
section.StartValue = section.Scale.MinValue;
section.EndValue = section.Scale.MinValue + (section.Scale.MajorTickMarks.Interval * 2);
section.Name = GetSectionName(section.Scale);
section.FillColor = new GradientFillColor(Color.Lime);
}
#endregion
#region GetSectionName
private string GetSectionName(GaugeScale scale)
{
for (int i = 1; i < 100; i++)
{
string s = "Section" + i.ToString();
if (scale.Sections[s] == null)
return (s);
}
return (null);
}
#endregion
#endregion
#region InitializeNewRange
#region InitializeNewRange
private void InitializeNewRange(GaugeRange range)
{
range.EndValue = range.Scale.MaxValue;
range.StartValue = range.EndValue - range.Scale.MajorTickMarks.Interval * 3;
range.Name = GetRangeName(range.Scale);
range.FillColor = new GradientFillColor(Color.Lime, Color.Red);
range.FillColor.BorderColor = Color.Black;
range.FillColor.BorderWidth = 1;
}
#endregion
#region GetRangeName
private string GetRangeName(GaugeScale scale)
{
for (int i = 1; i < 100; i++)
{
string s = "Range" + i.ToString();
if (scale.Ranges[s] == null)
return (s);
}
return (null);
}
#endregion
#endregion
#region InitializeNewCustomLabel
#region InitializeNewCustomLabel
private void InitializeNewCustomLabel(GaugeCustomLabel label)
{
label.Value = label.Scale.MinValue;
label.Name = GetLabelName(label.Scale);
}
#endregion
#region GetLabelName
private string GetLabelName(GaugeScale scale)
{
for (int i = 1; i < 100; i++)
{
string s = "Label" + i.ToString();
if (scale.CustomLabels[s] == null)
return (s);
}
return (null);
}
#endregion
#endregion
#region InitializeNewPointer
#region InitializeNewPointer
private void InitializeNewPointer(GaugePointer pointer)
{
pointer.Style = (pointer.Scale is GaugeCircularScale)
? PointerStyle.Needle : PointerStyle.Marker;
pointer.Name = GetPointerName(pointer.Scale);
pointer.FillColor = new GradientFillColor(Color.WhiteSmoke, Color.Red);
pointer.FillColor.BorderColor = Color.DimGray;
pointer.FillColor.BorderWidth = 1;
Color color1 = Color.FromArgb(100, 60, 60, 60);
pointer.ThermoBackColor = new GradientFillColor(color1);
pointer.ThermoBackColor.BorderColor = Color.Black;
pointer.ThermoBackColor.BorderWidth = 1;
}
#endregion
#region GetPointerName
private string GetPointerName(GaugeScale scale)
{
for (int i = 1; i < 100; i++)
{
string s = "Pointer" + i.ToString();
if (scale.Pointers[s] == null)
return (s);
}
return (null);
}
#endregion
#endregion
#endregion
#region InitializeNewNumericRange
#region InitializeNewNumericRange
private void InitializeNewNumericRange(NumericRange range)
{
range.StartValue = 500;
range.EndValue = 1000;
range.Name = GetNumericRangeName(range.NumericIndicator);
range.DigitColor = Color.Red;
range.DigitDimColor = Color.FromArgb(94, 0, 0);
range.DecimalColor = range.DigitColor;
range.DecimalDimColor = range.DigitDimColor;
}
#endregion
#region GetNumericRangeName
private string GetNumericRangeName(NumericIndicator indicator)
{
for (int i = 1; i < 100; i++)
{
string s = "Range" + i.ToString();
if (indicator.Ranges[s] == null)
return (s);
}
return (null);
}
#endregion
#endregion
#region InitializeNewStateRange
#region InitializeNewStateRange
private void InitializeNewStateRange(StateRange range)
{
range.StartValue = 500;
range.EndValue = 1000;
range.Name = GetStateRangeName(range.StateIndicator);
}
#endregion
#region GetStateRangeName
private string GetStateRangeName(StateIndicator indicator)
{
for (int i = 1; i < 100; i++)
{
string s = "Range" + i.ToString();
if (indicator.Ranges[s] == null)
return (s);
}
return (null);
}
#endregion
#endregion
#region GaugeCollectionEditor_RemoveClick
void GaugeCollectionEditor_RemoveClick(object sender, EventArgs e)
{
if (_LastGaugeItem != null)
{
RemovedItems.Add(_LastGaugeItem);
_LastGaugeItem.Visible = false;
_LastGaugeItem = null;
}
else if (_GaugeItem != null)
{
RemovedItems.Add(_GaugeItem);
_GaugeItem.Visible = false;
_GaugeItem = null;
}
}
#endregion
}
#region CollectionChangedEventArgs
/// <summary>
/// CollectionChangedEventArgs
/// </summary>
public class CollectionChangedEventArgs : EventArgs
{
#region Private variables
private List<object> _NewList;
#endregion
public CollectionChangedEventArgs(List<object> newList)
{
_NewList = newList;
}
#region Public properties
/// <summary>
/// Gets the selected NewList
/// </summary>
public List<object> NewList
{
get { return (_NewList); }
}
#endregion
}
#endregion
}

View File

@@ -0,0 +1,332 @@
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Drawing.Design;
using System.Windows.Forms;
using DevComponents.DotNetBarKnobControl.Design;
namespace DevComponents.Instrumentation.Design
{
public class GaugeControlActionList : DesignerActionList
{
#region Private variables
private GaugeControl _GaugeControl;
#endregion
/// <summary>
/// GaugeControlActionList
/// </summary>
/// <param name="gaugeControl">Associated GaugeControl</param>
public GaugeControlActionList(GaugeControl gaugeControl)
: base(gaugeControl)
{
_GaugeControl = gaugeControl;
}
#region Public properties
/// <summary>
/// Gets or sets the FrameStyle
/// </summary>
public GaugeFrameStyle FrameStyle
{
get { return (_GaugeControl.Frame.Style); }
set { GetFramePropertyByName("Style").SetValue(_GaugeControl.Frame, value); }
}
/// <summary>
/// Gets or sets the Glass Effect
/// </summary>
public bool AddGlassEffect
{
get { return (_GaugeControl.Frame.AddGlassEffect); }
set { GetFramePropertyByName("AddGlassEffect").SetValue(_GaugeControl.Frame, value); }
}
/// <summary>
/// Gets or sets the frame inner bevel size
/// </summary>
[Editor(typeof(HalfRadiusRangeValueEditor), typeof(UITypeEditor))]
public float InnerBevel
{
get { return (_GaugeControl.Frame.InnerBevel); }
set { GetFramePropertyByName("InnerBevel").SetValue(_GaugeControl.Frame, value); }
}
/// <summary>
/// Gets or sets the frame outer bevel size
/// </summary>
[Editor(typeof(HalfRadiusRangeValueEditor), typeof(UITypeEditor))]
public float OuterBevel
{
get { return (_GaugeControl.Frame.OuterBevel); }
set { GetFramePropertyByName("OuterBevel").SetValue(_GaugeControl.Frame, value); }
}
/// <summary>
/// Gets or sets the RoundRectangleArc size
/// </summary>
[Editor(typeof(HalfRadiusRangeValueEditor), typeof(UITypeEditor))]
public float RoundRectangleArc
{
get { return (_GaugeControl.Frame.RoundRectangleArc); }
set { GetFramePropertyByName("RoundRectangleArc").SetValue(_GaugeControl.Frame, value); }
}
#endregion
#region GetPropertyByName
/// <summary>
/// Gets the property via the given name
/// </summary>
/// <param name="propName">Property name</param>
/// <returns>PropertyDescriptor</returns>
private PropertyDescriptor GetPropertyByName(string propName)
{
PropertyDescriptor prop =
TypeDescriptor.GetProperties(_GaugeControl)[propName];
if (prop == null)
throw new ArgumentException("Matching property not found.", propName);
return (prop);
}
#endregion
#region GetFramePropertyByName
/// <summary>
/// Gets the Frame property via the given name
/// </summary>
/// <param name="propName">Property name</param>
/// <returns>PropertyDescriptor</returns>
private PropertyDescriptor GetFramePropertyByName(string propName)
{
PropertyDescriptor prop =
TypeDescriptor.GetProperties(_GaugeControl.Frame)[propName];
if (prop == null)
throw new ArgumentException("Matching property not found.", propName);
return (prop);
}
#endregion
#region GetSortedActionItems
/// <summary>
/// Gets the SortedActionItems
/// </summary>
/// <returns>DesignerActionItemCollection</returns>
public override DesignerActionItemCollection GetSortedActionItems()
{
DesignerActionItemCollection items = new DesignerActionItemCollection();
items.Add(new DesignerActionMethodItem(this, "AddCircularScale", "Add Circular Scale", "Scale"));
items.Add(new DesignerActionMethodItem(this, "AddHLinearScale", "Add Horizontal Linear Scale", "Scale"));
items.Add(new DesignerActionMethodItem(this, "AddVLinearScale", "Add Vertical Linear Scale", "Scale"));
items.Add(new DesignerActionHeaderItem("Gauge Frame"));
items.Add(new DesignerActionPropertyItem("FrameStyle", "Style",
"Gauge Frame", "Sets the frame Style."));
items.Add(new DesignerActionPropertyItem("InnerBevel", "Inner Bevel",
"Gauge Frame", "Sets the frame inner bevel size."));
items.Add(new DesignerActionPropertyItem("OuterBevel", "Outer Bevel",
"Gauge Frame", "Sets the frame outer bevel size."));
items.Add(new DesignerActionPropertyItem("RoundRectangleArc", "Round Rectangle Arc",
"Gauge Frame", "Sets the rectangle corner arc."));
items.Add(new DesignerActionTextItem(
"Frame sizes are measured as a\n" +
"percentage of the width/height of the Gauge", "Gauge Frame"));
return (items);
}
#endregion
#region AddCircularScale
/// <summary>
/// Adds a CircularScale
/// </summary>
public void AddCircularScale()
{
GaugeCircularScale scale = NewCircularScale();
_GaugeControl.CircularScales.Add(scale);
GaugePropertyGrid prop = new GaugePropertyGrid();
prop.SelectedObject = scale;
DialogResult result = prop.ShowDialog();
if (result != DialogResult.OK)
_GaugeControl.CircularScales.Remove(scale);
}
#region NewCircularScale
private GaugeCircularScale NewCircularScale()
{
GaugeCircularScale scale = new GaugeCircularScale(_GaugeControl);
scale.Name = GetScaleName(scale);
GaugeSection section = new GaugeSection(scale);
section.Name = GetSectionName(scale);
section.FillColor = new GradientFillColor(Color.CornflowerBlue);
scale.Sections.Add(section);
return (scale);
}
#endregion
#endregion
#region AddHLinearScale
/// <summary>
/// Adds a Horizontal LinearScale
/// </summary>
public void AddHLinearScale()
{
GaugeLinearScale scale = NewLinearScale(Orientation.Horizontal);
_GaugeControl.LinearScales.Add(scale);
GaugePropertyGrid prop = new GaugePropertyGrid();
prop.SelectedObject = scale;
DialogResult result = prop.ShowDialog();
if (result != DialogResult.OK)
_GaugeControl.LinearScales.Remove(scale);
}
#endregion
#region AddVLinearScale
/// <summary>
/// Adds a Vertical LinearScale
/// </summary>
public void AddVLinearScale()
{
GaugeLinearScale scale = NewLinearScale(Orientation.Vertical);
_GaugeControl.LinearScales.Add(scale);
GaugePropertyGrid prop = new GaugePropertyGrid();
prop.SelectedObject = scale;
DialogResult result = prop.ShowDialog();
if (result != DialogResult.OK)
_GaugeControl.LinearScales.Remove(scale);
}
#endregion
#region NewLinearScale
private GaugeLinearScale NewLinearScale(Orientation orientation)
{
GaugeLinearScale scale = new GaugeLinearScale(_GaugeControl);
scale.Orientation = orientation;
scale.Name = GetScaleName(scale);
scale.MinPin.EndOffset = .028f;
scale.MaxPin.EndOffset = .028f;
GaugeSection section = new GaugeSection(scale);
section.Name = GetSectionName(scale);
section.FillColor = new GradientFillColor(Color.CornflowerBlue);
scale.Sections.Add(section);
return (scale);
}
#endregion
#region GetScaleName
private string GetScaleName(GaugeCircularScale scale)
{
for (int i = 1; i < 100; i++)
{
string s = "Scale" + i.ToString();
if (scale.GaugeControl.CircularScales[s] == null)
return (s);
}
return (null);
}
private string GetScaleName(GaugeLinearScale scale)
{
for (int i = 1; i < 100; i++)
{
string s = "Scale" + i.ToString();
if (scale.GaugeControl.LinearScales[s] == null)
return (s);
}
return (null);
}
#endregion
#region GetSectionName
private string GetSectionName(GaugeScale scale)
{
for (int i = 1; i < 100; i++)
{
string s = "Section" + i.ToString();
if (scale.Sections[s] == null)
return (s);
}
return (null);
}
#endregion
#region GetDefaultOrientation
private Orientation GetDefaultOrientation(GaugeLinearScale scale)
{
foreach (GaugeLinearScale gls in scale.GaugeControl.LinearScales)
{
if (gls != scale)
return (gls.Orientation);
}
return (scale.GaugeControl.Width > scale.GaugeControl.Height
? Orientation.Horizontal : Orientation.Vertical);
}
#endregion
}
}

View File

@@ -0,0 +1,337 @@
using System;
using System.ComponentModel.Design;
using System.Drawing;
using System.Reflection;
using System.Resources;
using System.Windows.Forms;
using DevComponents.DotNetBarKnobControl.Design.Properties;
namespace DevComponents.Instrumentation.Design
{
public class GaugeItemCollectionEditor : CollectionEditor
{
#region Private variables
private ListBox _ListBox;
private GaugeItem _CopyItem;
private GaugeItem _GaugeItem;
private GaugeItem _LastGaugeItem;
private PropertyGrid _PropertyGrid;
private ToolStripItem _AddTextItem;
private ToolStripItem _AddImageItem;
private ToolStripItem _AddDigitalIndicatorItem;
private ToolStripItem _AddMechanicalIndicatorItem;
private ToolStripItem _AddStateIndicatorItem;
private Button _CopyButton;
private ToolTip _ToolTip;
#endregion
public GaugeItemCollectionEditor(Type type)
: base(type)
{
_CopyItem = null;
}
#region CreateCollectionForm
protected override CollectionForm CreateCollectionForm()
{
CollectionForm collectionForm = base.CreateCollectionForm();
if (collectionForm.Controls[0] is TableLayoutPanel)
{
TableLayoutPanel tlpf = collectionForm.Controls["overArchingTableLayoutPanel"] as TableLayoutPanel;
if (tlpf != null)
{
TableLayoutPanel tlp2 = tlpf.Controls["addRemoveTableLayoutPanel"] as TableLayoutPanel;
if (tlp2 != null)
{
Button btn = tlp2.Controls["removeButton"] as Button;
if (btn != null)
btn.Click += GaugeCollectionEditor_RemoveClick;
btn = tlp2.Controls["addButton"] as Button;
if (btn != null)
{
_AddTextItem = btn.ContextMenuStrip.Items[0];
_AddImageItem = btn.ContextMenuStrip.Items[1];
_AddDigitalIndicatorItem = btn.ContextMenuStrip.Items[2];
_AddMechanicalIndicatorItem = btn.ContextMenuStrip.Items[3];
_AddStateIndicatorItem = btn.ContextMenuStrip.Items[4];
AddCopyButton(collectionForm);
}
}
_ListBox = tlpf.Controls["listbox"] as ListBox;
if (_ListBox != null)
_ListBox.SelectedIndexChanged += ListBox_SelectedIndexChanged;
_PropertyGrid = tlpf.Controls["propertyBrowser"] as PropertyGrid;
if (_PropertyGrid != null)
_PropertyGrid.HelpVisible = true;
}
}
return (collectionForm);
}
#endregion
#region CreateInstance
protected override object CreateInstance(Type itemType)
{
if (itemType == typeof(DigitalIndicator))
{
NumericIndicator ind = (NumericIndicator)
base.CreateInstance(typeof(NumericIndicator));
ind.Style = NumericIndicatorStyle.Digital16Segment;
ind.BackColor.BorderWidth = 3;
ind.BackColor.BorderColor = Color.Gray;
ind.BackColor.Color1 = Color.Black;
ind.DigitColor = Color.Red;
ind.DigitDimColor = Color.FromArgb(94, 0, 0);
ind.DecimalColor = Color.Lime;
ind.DecimalDimColor = Color.FromArgb(0, 94, 0);
ind.Size = new SizeF(.4f, .08f);
return (ind);
}
if (itemType == typeof(MechanicalIndicator))
{
NumericIndicator ind = (NumericIndicator)
base.CreateInstance(typeof(NumericIndicator));
ind.BackColor.BorderWidth = 1;
ind.BackColor.BorderColor = Color.Black;
ind.BackColor.Color1 = Color.Gray;
ind.BackColor.Color2 = Color.White;
ind.BackColor.GradientFillType = GradientFillType.HorizontalCenter;
ind.SeparatorColor.BorderWidth = 1;
ind.SeparatorColor.BorderColor = Color.Gray;
ind.SeparatorColor.Color1 = Color.LightGray;
ind.SeparatorColor.Color2 = Color.DimGray;
ind.SeparatorColor.GradientFillType = GradientFillType.HorizontalCenter;
ind.Size = new SizeF(.4f, .08f);
return (ind);
}
if (itemType == typeof(StateIndicator))
{
StateIndicator ind = (StateIndicator)
base.CreateInstance(typeof(StateIndicator));
ind.EmptyString = "";
return (ind);
}
return (base.CreateInstance(itemType));
}
#endregion
#region CopyButton support
#region AddCopyButton
private void AddCopyButton(CollectionForm collectionForm)
{
_CopyButton = new Button();
_CopyButton.Size = new Size(23, 24);
_CopyButton.Enabled = false;
_CopyButton.Click += CopyButton_Click;
ResourceManager rm = Resources.ResourceManager;
_CopyButton.Image = (Image)rm.GetObject("Copy");
collectionForm.Controls.Add(_CopyButton);
_CopyButton.Location = new Point(208, 85);
_CopyButton.BringToFront();
_ToolTip = new ToolTip();
_ToolTip.SetToolTip(_CopyButton, "Clone the selected item");
}
#endregion
#region CopyButton_Click
void CopyButton_Click(object sender, EventArgs e)
{
if (_GaugeItem != null)
{
_CopyItem = _GaugeItem;
if (_GaugeItem is GaugeText)
_AddTextItem.PerformClick();
else if (_GaugeItem is GaugeImage)
_AddImageItem.PerformClick();
else if (_GaugeItem is NumericIndicator)
{
if (((NumericIndicator) _GaugeItem).Style == NumericIndicatorStyle.Mechanical)
_AddMechanicalIndicatorItem.PerformClick();
else
_AddDigitalIndicatorItem.PerformClick();
}
else if (_GaugeItem is StateIndicator)
_AddStateIndicatorItem.PerformClick();
}
}
#endregion
#endregion
#region ListBox_SelectedIndexChanged
void ListBox_SelectedIndexChanged(object sender, EventArgs e)
{
if (_ListBox.SelectedItem != null)
{
PropertyInfo p = _ListBox.SelectedItem.GetType().GetProperty("Value");
_LastGaugeItem = _GaugeItem;
_GaugeItem = (GaugeItem)p.GetValue(_ListBox.SelectedItem, null);
if (_CopyItem != null)
{
if (_GaugeItem is GaugeText)
CopyGaugeText(_LastGaugeItem as GaugeText, _GaugeItem as GaugeText);
else if (_GaugeItem is GaugeImage)
CopyGaugeImage(_LastGaugeItem as GaugeImage, _GaugeItem as GaugeImage);
else if (_GaugeItem is NumericIndicator)
CopyGaugeNumericIndicator(_LastGaugeItem as NumericIndicator, _GaugeItem as NumericIndicator);
else if (_GaugeItem is StateIndicator)
CopyGaugeStateIndicator(_LastGaugeItem as StateIndicator, _GaugeItem as StateIndicator);
_CopyItem = null;
}
_CopyButton.Enabled = true;
}
else
{
_CopyButton.Enabled = false;
}
}
#endregion
#region CopyGaugeText
private void CopyGaugeText(GaugeText gt, GaugeText clone)
{
if (gt != null && clone != null)
gt.CopyToItem(clone);
}
#endregion
#region CopyGaugeImage
private void CopyGaugeImage(GaugeImage gi, GaugeImage clone)
{
if (gi != null && clone != null)
gi.CopyToItem(clone);
}
#endregion
#region CopyGaugeNumericIndicator
private void CopyGaugeNumericIndicator(NumericIndicator gi, NumericIndicator clone)
{
if (gi != null && clone != null)
gi.CopyToItem(clone);
}
#endregion
#region CopyGaugeStateIndicator
private void CopyGaugeStateIndicator(StateIndicator gi, StateIndicator clone)
{
if (gi != null && clone != null)
gi.CopyToItem(clone);
}
#endregion
#region CreateCollectionItemType
protected override Type CreateCollectionItemType()
{
return typeof(GaugeText);
}
#endregion
#region CreateNewItemTypes
protected override Type[] CreateNewItemTypes()
{
return new Type[]
{
typeof(GaugeText),
typeof(GaugeImage),
typeof(DigitalIndicator),
typeof(MechanicalIndicator),
typeof(StateIndicator),
};
}
private class DigitalIndicator : NumericIndicator
{
}
private class MechanicalIndicator : NumericIndicator
{
}
#endregion
#region GaugeCollectionEditor_RemoveClick
void GaugeCollectionEditor_RemoveClick(object sender, EventArgs e)
{
if (_LastGaugeItem != null)
{
_LastGaugeItem.Visible = false;
_LastGaugeItem = null;
}
else if (_GaugeItem != null)
{
_GaugeItem.Visible = false;
_GaugeItem = null;
}
}
#endregion
}
}

View File

@@ -0,0 +1,95 @@
namespace DevComponents.DotNetBarKnobControl.Design
{
partial class GaugePropertyGrid
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 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.propertyGrid1 = new System.Windows.Forms.PropertyGrid();
this._BtnOk = new System.Windows.Forms.Button();
this._BtnCancel = new System.Windows.Forms.Button();
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(0, 0);
this.propertyGrid1.Name = "propertyGrid1";
this.propertyGrid1.Size = new System.Drawing.Size(386, 408);
this.propertyGrid1.TabIndex = 0;
//
// _BtnOk
//
this._BtnOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this._BtnOk.DialogResult = System.Windows.Forms.DialogResult.OK;
this._BtnOk.Location = new System.Drawing.Point(214, 427);
this._BtnOk.Name = "_BtnOk";
this._BtnOk.Size = new System.Drawing.Size(75, 23);
this._BtnOk.TabIndex = 1;
this._BtnOk.Text = "Ok";
this._BtnOk.UseVisualStyleBackColor = true;
//
// _BtnCancel
//
this._BtnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this._BtnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this._BtnCancel.Location = new System.Drawing.Point(295, 427);
this._BtnCancel.Name = "_BtnCancel";
this._BtnCancel.Size = new System.Drawing.Size(75, 23);
this._BtnCancel.TabIndex = 2;
this._BtnCancel.Text = "Cancel";
this._BtnCancel.UseVisualStyleBackColor = true;
//
// GaugePropertyGrid
//
this.AcceptButton = this._BtnOk;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this._BtnCancel;
this.ClientSize = new System.Drawing.Size(384, 462);
this.Controls.Add(this._BtnCancel);
this.Controls.Add(this._BtnOk);
this.Controls.Add(this.propertyGrid1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "GaugePropertyGrid";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "GaugePropertyGrid";
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.PropertyGrid propertyGrid1;
private System.Windows.Forms.Button _BtnOk;
private System.Windows.Forms.Button _BtnCancel;
}
}

View File

@@ -0,0 +1,22 @@
using System.Windows.Forms;
namespace DevComponents.DotNetBarKnobControl.Design
{
public partial class GaugePropertyGrid : Form
{
public GaugePropertyGrid()
{
InitializeComponent();
}
#region Public properties
public object SelectedObject
{
get { return (propertyGrid1.SelectedObject); }
set { propertyGrid1.SelectedObject = value; }
}
#endregion
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,335 @@
namespace DevComponents.DotNetBarKnobControl.Design
{
partial class GaugeStyleDialog
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 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()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(GaugeStyleDialog));
this.label1 = new System.Windows.Forms.Label();
this.cbVThermometer = new System.Windows.Forms.CheckBox();
this.cbVMultiBars = new System.Windows.Forms.CheckBox();
this.cbV2Scales = new System.Windows.Forms.CheckBox();
this.cbVertical = new System.Windows.Forms.CheckBox();
this.cbHThermometer = new System.Windows.Forms.CheckBox();
this.cbHMultiBars = new System.Windows.Forms.CheckBox();
this.cbH2Scales = new System.Windows.Forms.CheckBox();
this.cbHorizontal = new System.Windows.Forms.CheckBox();
this.cbCTopMeter = new System.Windows.Forms.CheckBox();
this.cbCBottomMeter = new System.Windows.Forms.CheckBox();
this.cbCInsetScale = new System.Windows.Forms.CheckBox();
this.cbC2Scales = new System.Windows.Forms.CheckBox();
this.cbCircular = new System.Windows.Forms.CheckBox();
this.btnOk = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.BackColor = System.Drawing.SystemColors.ControlLight;
this.label1.Dock = System.Windows.Forms.DockStyle.Bottom;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.Location = new System.Drawing.Point(0, 547);
this.label1.Name = "label1";
this.label1.Padding = new System.Windows.Forms.Padding(10, 0, 0, 0);
this.label1.Size = new System.Drawing.Size(736, 55);
this.label1.TabIndex = 4;
this.label1.Text = "Please select your starting Scale template";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// cbVThermometer
//
this.cbVThermometer.Appearance = System.Windows.Forms.Appearance.Button;
this.cbVThermometer.AutoCheck = false;
this.cbVThermometer.AutoSize = true;
this.cbVThermometer.Image = ((System.Drawing.Image)(resources.GetObject("cbVThermometer.Image")));
this.cbVThermometer.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
this.cbVThermometer.Location = new System.Drawing.Point(545, 335);
this.cbVThermometer.Name = "cbVThermometer";
this.cbVThermometer.Size = new System.Drawing.Size(164, 181);
this.cbVThermometer.TabIndex = 40;
this.cbVThermometer.Text = "Thermometer";
this.cbVThermometer.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.cbVThermometer.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
this.cbVThermometer.UseVisualStyleBackColor = true;
this.cbVThermometer.Click += new System.EventHandler(this.CbCheckedChanged);
//
// cbVMultiBars
//
this.cbVMultiBars.Appearance = System.Windows.Forms.Appearance.Button;
this.cbVMultiBars.AutoCheck = false;
this.cbVMultiBars.AutoSize = true;
this.cbVMultiBars.Image = ((System.Drawing.Image)(resources.GetObject("cbVMultiBars.Image")));
this.cbVMultiBars.Location = new System.Drawing.Point(373, 335);
this.cbVMultiBars.Name = "cbVMultiBars";
this.cbVMultiBars.Size = new System.Drawing.Size(164, 181);
this.cbVMultiBars.TabIndex = 39;
this.cbVMultiBars.Text = "Multiple Bars";
this.cbVMultiBars.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.cbVMultiBars.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
this.cbVMultiBars.UseVisualStyleBackColor = true;
this.cbVMultiBars.Click += new System.EventHandler(this.CbCheckedChanged);
//
// cbV2Scales
//
this.cbV2Scales.Appearance = System.Windows.Forms.Appearance.Button;
this.cbV2Scales.AutoCheck = false;
this.cbV2Scales.AutoSize = true;
this.cbV2Scales.Image = ((System.Drawing.Image)(resources.GetObject("cbV2Scales.Image")));
this.cbV2Scales.Location = new System.Drawing.Point(201, 335);
this.cbV2Scales.Name = "cbV2Scales";
this.cbV2Scales.Size = new System.Drawing.Size(164, 181);
this.cbV2Scales.TabIndex = 38;
this.cbV2Scales.Text = "2 Scales";
this.cbV2Scales.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.cbV2Scales.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
this.cbV2Scales.UseVisualStyleBackColor = true;
this.cbV2Scales.Click += new System.EventHandler(this.CbCheckedChanged);
//
// cbVertical
//
this.cbVertical.Appearance = System.Windows.Forms.Appearance.Button;
this.cbVertical.AutoCheck = false;
this.cbVertical.AutoSize = true;
this.cbVertical.Image = ((System.Drawing.Image)(resources.GetObject("cbVertical.Image")));
this.cbVertical.Location = new System.Drawing.Point(29, 335);
this.cbVertical.Name = "cbVertical";
this.cbVertical.Size = new System.Drawing.Size(164, 181);
this.cbVertical.TabIndex = 37;
this.cbVertical.Text = "Vertical";
this.cbVertical.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.cbVertical.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
this.cbVertical.UseVisualStyleBackColor = true;
this.cbVertical.Click += new System.EventHandler(this.CbCheckedChanged);
//
// cbHThermometer
//
this.cbHThermometer.Appearance = System.Windows.Forms.Appearance.Button;
this.cbHThermometer.AutoCheck = false;
this.cbHThermometer.AutoSize = true;
this.cbHThermometer.Image = ((System.Drawing.Image)(resources.GetObject("cbHThermometer.Image")));
this.cbHThermometer.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.cbHThermometer.Location = new System.Drawing.Point(545, 216);
this.cbHThermometer.Name = "cbHThermometer";
this.cbHThermometer.Size = new System.Drawing.Size(166, 113);
this.cbHThermometer.TabIndex = 36;
this.cbHThermometer.Text = "Thermometer";
this.cbHThermometer.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.cbHThermometer.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
this.cbHThermometer.UseVisualStyleBackColor = true;
this.cbHThermometer.Click += new System.EventHandler(this.CbCheckedChanged);
//
// cbHMultiBars
//
this.cbHMultiBars.Appearance = System.Windows.Forms.Appearance.Button;
this.cbHMultiBars.AutoCheck = false;
this.cbHMultiBars.AutoSize = true;
this.cbHMultiBars.Image = ((System.Drawing.Image)(resources.GetObject("cbHMultiBars.Image")));
this.cbHMultiBars.Location = new System.Drawing.Point(373, 216);
this.cbHMultiBars.Name = "cbHMultiBars";
this.cbHMultiBars.Size = new System.Drawing.Size(166, 113);
this.cbHMultiBars.TabIndex = 35;
this.cbHMultiBars.Text = "Multiple Bars";
this.cbHMultiBars.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.cbHMultiBars.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
this.cbHMultiBars.UseVisualStyleBackColor = true;
this.cbHMultiBars.Click += new System.EventHandler(this.CbCheckedChanged);
//
// cbH2Scales
//
this.cbH2Scales.Appearance = System.Windows.Forms.Appearance.Button;
this.cbH2Scales.AutoCheck = false;
this.cbH2Scales.AutoSize = true;
this.cbH2Scales.Image = ((System.Drawing.Image)(resources.GetObject("cbH2Scales.Image")));
this.cbH2Scales.Location = new System.Drawing.Point(201, 216);
this.cbH2Scales.Name = "cbH2Scales";
this.cbH2Scales.Size = new System.Drawing.Size(166, 113);
this.cbH2Scales.TabIndex = 34;
this.cbH2Scales.Text = "2 Scales";
this.cbH2Scales.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.cbH2Scales.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
this.cbH2Scales.UseVisualStyleBackColor = true;
this.cbH2Scales.Click += new System.EventHandler(this.CbCheckedChanged);
//
// cbHorizontal
//
this.cbHorizontal.Appearance = System.Windows.Forms.Appearance.Button;
this.cbHorizontal.AutoCheck = false;
this.cbHorizontal.AutoSize = true;
this.cbHorizontal.Image = ((System.Drawing.Image)(resources.GetObject("cbHorizontal.Image")));
this.cbHorizontal.Location = new System.Drawing.Point(29, 216);
this.cbHorizontal.Name = "cbHorizontal";
this.cbHorizontal.Size = new System.Drawing.Size(166, 113);
this.cbHorizontal.TabIndex = 33;
this.cbHorizontal.Text = "Horizontal";
this.cbHorizontal.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.cbHorizontal.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
this.cbHorizontal.UseVisualStyleBackColor = true;
this.cbHorizontal.Click += new System.EventHandler(this.CbCheckedChanged);
//
// cbCTopMeter
//
this.cbCTopMeter.Appearance = System.Windows.Forms.Appearance.Button;
this.cbCTopMeter.AutoCheck = false;
this.cbCTopMeter.AutoSize = true;
this.cbCTopMeter.Image = ((System.Drawing.Image)(resources.GetObject("cbCTopMeter.Image")));
this.cbCTopMeter.Location = new System.Drawing.Point(545, 27);
this.cbCTopMeter.Name = "cbCTopMeter";
this.cbCTopMeter.Size = new System.Drawing.Size(166, 88);
this.cbCTopMeter.TabIndex = 32;
this.cbCTopMeter.Text = "Top Meter";
this.cbCTopMeter.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.cbCTopMeter.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
this.cbCTopMeter.UseVisualStyleBackColor = true;
this.cbCTopMeter.Click += new System.EventHandler(this.CbCheckedChanged);
//
// cbCBottomMeter
//
this.cbCBottomMeter.Appearance = System.Windows.Forms.Appearance.Button;
this.cbCBottomMeter.AutoCheck = false;
this.cbCBottomMeter.AutoSize = true;
this.cbCBottomMeter.Image = ((System.Drawing.Image)(resources.GetObject("cbCBottomMeter.Image")));
this.cbCBottomMeter.Location = new System.Drawing.Point(545, 122);
this.cbCBottomMeter.Name = "cbCBottomMeter";
this.cbCBottomMeter.Size = new System.Drawing.Size(166, 88);
this.cbCBottomMeter.TabIndex = 31;
this.cbCBottomMeter.Text = "Bottom Meter";
this.cbCBottomMeter.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.cbCBottomMeter.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
this.cbCBottomMeter.UseVisualStyleBackColor = true;
this.cbCBottomMeter.Click += new System.EventHandler(this.CbCheckedChanged);
//
// cbCInsetScale
//
this.cbCInsetScale.Appearance = System.Windows.Forms.Appearance.Button;
this.cbCInsetScale.AutoCheck = false;
this.cbCInsetScale.AutoSize = true;
this.cbCInsetScale.Image = ((System.Drawing.Image)(resources.GetObject("cbCInsetScale.Image")));
this.cbCInsetScale.Location = new System.Drawing.Point(373, 27);
this.cbCInsetScale.Name = "cbCInsetScale";
this.cbCInsetScale.Size = new System.Drawing.Size(166, 183);
this.cbCInsetScale.TabIndex = 30;
this.cbCInsetScale.Text = "Inset Scale";
this.cbCInsetScale.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.cbCInsetScale.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
this.cbCInsetScale.UseVisualStyleBackColor = true;
this.cbCInsetScale.Click += new System.EventHandler(this.CbCheckedChanged);
//
// cbC2Scales
//
this.cbC2Scales.Appearance = System.Windows.Forms.Appearance.Button;
this.cbC2Scales.AutoCheck = false;
this.cbC2Scales.AutoSize = true;
this.cbC2Scales.Image = ((System.Drawing.Image)(resources.GetObject("cbC2Scales.Image")));
this.cbC2Scales.Location = new System.Drawing.Point(201, 27);
this.cbC2Scales.Name = "cbC2Scales";
this.cbC2Scales.Size = new System.Drawing.Size(166, 183);
this.cbC2Scales.TabIndex = 29;
this.cbC2Scales.Text = "2 Scales";
this.cbC2Scales.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.cbC2Scales.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
this.cbC2Scales.UseVisualStyleBackColor = true;
this.cbC2Scales.Click += new System.EventHandler(this.CbCheckedChanged);
//
// cbCircular
//
this.cbCircular.Appearance = System.Windows.Forms.Appearance.Button;
this.cbCircular.AutoCheck = false;
this.cbCircular.AutoSize = true;
this.cbCircular.Checked = true;
this.cbCircular.CheckState = System.Windows.Forms.CheckState.Checked;
this.cbCircular.Image = ((System.Drawing.Image)(resources.GetObject("cbCircular.Image")));
this.cbCircular.Location = new System.Drawing.Point(29, 27);
this.cbCircular.Name = "cbCircular";
this.cbCircular.Size = new System.Drawing.Size(166, 183);
this.cbCircular.TabIndex = 28;
this.cbCircular.Text = "Circular";
this.cbCircular.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.cbCircular.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
this.cbCircular.UseVisualStyleBackColor = true;
this.cbCircular.Click += new System.EventHandler(this.CbCheckedChanged);
//
// btnOk
//
this.btnOk.DialogResult = System.Windows.Forms.DialogResult.OK;
this.btnOk.Location = new System.Drawing.Point(634, 563);
this.btnOk.Name = "btnOk";
this.btnOk.Size = new System.Drawing.Size(75, 23);
this.btnOk.TabIndex = 41;
this.btnOk.Text = "Select";
this.btnOk.UseVisualStyleBackColor = true;
//
// GaugeStyleDialog
//
this.AcceptButton = this.btnOk;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(736, 602);
this.ControlBox = false;
this.Controls.Add(this.btnOk);
this.Controls.Add(this.cbVThermometer);
this.Controls.Add(this.cbVMultiBars);
this.Controls.Add(this.cbV2Scales);
this.Controls.Add(this.cbVertical);
this.Controls.Add(this.cbHThermometer);
this.Controls.Add(this.cbHMultiBars);
this.Controls.Add(this.cbH2Scales);
this.Controls.Add(this.cbHorizontal);
this.Controls.Add(this.cbCTopMeter);
this.Controls.Add(this.cbCBottomMeter);
this.Controls.Add(this.cbCInsetScale);
this.Controls.Add(this.cbC2Scales);
this.Controls.Add(this.cbCircular);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "GaugeStyleDialog";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Initial Gauge Style";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.CheckBox cbVThermometer;
private System.Windows.Forms.CheckBox cbVMultiBars;
private System.Windows.Forms.CheckBox cbV2Scales;
private System.Windows.Forms.CheckBox cbVertical;
private System.Windows.Forms.CheckBox cbHThermometer;
private System.Windows.Forms.CheckBox cbHMultiBars;
private System.Windows.Forms.CheckBox cbH2Scales;
private System.Windows.Forms.CheckBox cbHorizontal;
private System.Windows.Forms.CheckBox cbCTopMeter;
private System.Windows.Forms.CheckBox cbCBottomMeter;
private System.Windows.Forms.CheckBox cbCInsetScale;
private System.Windows.Forms.CheckBox cbC2Scales;
private System.Windows.Forms.CheckBox cbCircular;
private System.Windows.Forms.Button btnOk;
}
}

View File

@@ -0,0 +1,60 @@
using System;
using System.Windows.Forms;
namespace DevComponents.DotNetBarKnobControl.Design
{
public partial class GaugeStyleDialog : Form
{
#region Private variables
private CheckBox _CheckedBox;
private DateTime _LastClick;
#endregion
public GaugeStyleDialog()
{
InitializeComponent();
_CheckedBox = cbCircular;
}
#region Public properties
public string CbSelected
{
get { return (_CheckedBox.Name); }
}
#endregion
#region CbCheckedChanged
private void CbCheckedChanged(object sender, EventArgs e)
{
CheckBox cb = sender as CheckBox;
if (cb != null)
{
if (_CheckedBox != cb)
{
_CheckedBox.Checked = false;
_CheckedBox = cb;
_CheckedBox.Checked = true;
}
else
{
TimeSpan ts = DateTime.Now - _LastClick;
if (ts.TotalMilliseconds < SystemInformation.DoubleClickTime)
btnOk.PerformClick();
}
}
_LastClick = DateTime.Now;
}
#endregion
}
}

View File

@@ -0,0 +1,183 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{37FBFDB8-C2D4-400F-A7EF-3CCA9258D805}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DevComponents.DotNetBarKnobControl.Design</RootNamespace>
<AssemblyName>DevComponents.Instrumentation.Design</AssemblyName>
<StartupObject>
</StartupObject>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>KnobControlDesignTime.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseTrial|AnyCPU' ">
<OutputPath>..\bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release2005|AnyCPU' ">
<OutputPath>..\bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseTrial2005|AnyCPU' ">
<OutputPath>..\bin\Release\</OutputPath>
<DefineConstants>TRACE;TRIAL</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="GaugeControlActionList.cs" />
<Compile Include="GaugeControlDesigner.cs" />
<Compile Include="FormatStringDropDown.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="FormatStringDropDown.Designer.cs">
<DependentUpon>FormatStringDropDown.cs</DependentUpon>
</Compile>
<Compile Include="FormatStringEditor.cs" />
<Compile Include="GaugeCollectionEditor.cs" />
<Compile Include="GaugeItemCollectionEditor.cs" />
<Compile Include="LocationDropDown.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="LocationDropDown.Designer.cs">
<DependentUpon>LocationDropDown.cs</DependentUpon>
</Compile>
<Compile Include="LocationEditor.cs" />
<Compile Include="PivotPointDropDown.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="PivotPointDropDown.Designer.cs">
<DependentUpon>PivotPointDropDown.cs</DependentUpon>
</Compile>
<Compile Include="PivotPointEditor.cs" />
<Compile Include="RangeValueDropDown.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="RangeValueDropDown.Designer.cs">
<DependentUpon>RangeValueDropDown.cs</DependentUpon>
</Compile>
<Compile Include="RangeValueEditor.cs" />
<Compile Include="SizeDropDown.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="SizeDropDown.Designer.cs">
<DependentUpon>SizeDropDown.cs</DependentUpon>
</Compile>
<Compile Include="SizeEditor.cs" />
<Compile Include="GaugePropertyGrid.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="GaugePropertyGrid.Designer.cs">
<DependentUpon>GaugePropertyGrid.cs</DependentUpon>
</Compile>
<Compile Include="KnobControlActionList.cs" />
<Compile Include="KnobControlDesigner.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="GaugeStyleDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="GaugeStyleDialog.Designer.cs">
<DependentUpon>GaugeStyleDialog.cs</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Design" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<None Include="KnobControlDesignTime.snk" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DevComponents.Instrumentation.csproj">
<Project>{3084E369-3D7B-4918-958F-2776DA03E6BC}</Project>
<Name>DevComponents.Instrumentation</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="FormatStringDropDown.resx">
<DependentUpon>FormatStringDropDown.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="LocationDropDown.resx">
<DependentUpon>LocationDropDown.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="PivotPointDropDown.resx">
<DependentUpon>PivotPointDropDown.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="RangeValueDropDown.resx">
<DependentUpon>RangeValueDropDown.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="SizeDropDown.resx">
<DependentUpon>SizeDropDown.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="GaugePropertyGrid.resx">
<SubType>Designer</SubType>
<DependentUpon>GaugePropertyGrid.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<SubType>Designer</SubType>
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="GaugeStyleDialog.resx">
<SubType>Designer</SubType>
<DependentUpon>GaugeStyleDialog.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\Copy.png" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,175 @@
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
namespace DevComponents.Instrumentation.Design
{
public class KnobControlActionList : DesignerActionList
{
#region Private variables
private KnobControl _KnobControl;
#endregion
/// <summary>
/// KnobControlActionList
/// </summary>
/// <param name="knobControl">Associated KnobControl</param>
public KnobControlActionList(KnobControl knobControl)
: base(knobControl)
{
_KnobControl = knobControl;
}
#region Public properties
/// <summary>
/// Gets or sets the KnobStyle
/// </summary>
public eKnobStyle KnobStyle
{
get { return (_KnobControl.KnobStyle); }
set { GetPropertyByName("KnobStyle").SetValue(_KnobControl, value); }
}
/// <summary>
/// Gets or sets the MinValue
/// </summary>
public decimal MinValue
{
get { return (_KnobControl.MinValue); }
set { GetPropertyByName("MinValue").SetValue(_KnobControl, value); }
}
/// <summary>
/// Gets or sets the MaxValue
/// </summary>
public decimal MaxValue
{
get { return (_KnobControl.MaxValue); }
set { GetPropertyByName("MaxValue").SetValue(_KnobControl, value); }
}
/// <summary>
/// Gets or sets the StartAngle
/// </summary>
public int StartAngle
{
get { return (_KnobControl.StartAngle); }
set { GetPropertyByName("StartAngle").SetValue(_KnobControl, value); }
}
/// <summary>
/// Gets or sets the SweepAngle
/// </summary>
public int SweepAngle
{
get { return (_KnobControl.SweepAngle); }
set { GetPropertyByName("SweepAngle").SetValue(_KnobControl, value); }
}
/// <summary>
/// Gets or sets the MaxValue
/// </summary>
public decimal MajorTickAmount
{
get { return (_KnobControl.MajorTickAmount); }
set { GetPropertyByName("MajorTickAmount").SetValue(_KnobControl, value); }
}
/// <summary>
/// Gets or sets the MinorTickAmount
/// </summary>
public decimal MinorTickAmount
{
get { return (_KnobControl.MinorTickAmount); }
set { GetPropertyByName("MinorTickAmount").SetValue(_KnobControl, value); }
}
#endregion
#region GetPropertyByName
/// <summary>
/// Gets the property via the given name
/// </summary>
/// <param name="propName">Property name</param>
/// <returns>PropertyDescriptor</returns>
private PropertyDescriptor GetPropertyByName(string propName)
{
PropertyDescriptor prop =
TypeDescriptor.GetProperties(_KnobControl)[propName];
if (prop == null)
throw new ArgumentException("Matching property not found.", propName);
return (prop);
}
#endregion
#region GetSortedActionItems
/// <summary>
/// Gets the SortedActionItems
/// </summary>
/// <returns>DesignerActionItemCollection</returns>
public override DesignerActionItemCollection GetSortedActionItems()
{
DesignerActionItemCollection items = new DesignerActionItemCollection();
items.Add(new DesignerActionPropertyItem("KnobStyle", "Knob Style",
"", "Sets the Knob Style."));
items.Add(new DesignerActionHeaderItem("Value Range"));
items.Add(new DesignerActionHeaderItem("Angle Range"));
items.Add(new DesignerActionPropertyItem("MinValue", "Minimum Value",
"Value Range", "Sets the minimum value permitted for the Knob value."));
items.Add(new DesignerActionPropertyItem("MaxValue", "Maximum Value",
"Value Range", "Sets the maximum value permitted for the Knob value."));
items.Add(new DesignerActionPropertyItem("MajorTickAmount", "MajorTick Amount",
"Value Range", "Sets the interval amount between major tick marks."));
items.Add(new DesignerActionPropertyItem("MinorTickAmount", "MinorTick Amount",
"Value Range", "Sets the interval amount between minor tick marks."));
items.Add(new DesignerActionPropertyItem("StartAngle", "Starting Angle",
"Angle Range", "Sets the Start angle."));
items.Add(new DesignerActionPropertyItem("SweepAngle", "Sweep Angle",
"Angle Range", "Sets the Sweep angle."));
items.Add(new DesignerActionMethodItem(this, "ReverseSweepAngle", "Reverse SweepAngle", "Angle Range"));
items.Add(new DesignerActionTextItem(
"SweepAngle can be positive or negative, denoting \n" +
"clockwise or counter-clockwise rotation, respectively", "Angle Range"));
return (items);
}
#endregion
#region ReverseSweepAngle
/// <summary>
/// Reverses the start and end angles for the control
/// </summary>
public void ReverseSweepAngle()
{
int angle = (StartAngle + SweepAngle) % 360;
if (angle < 0)
angle += 360;
StartAngle = angle;
SweepAngle = -SweepAngle;
}
#endregion
}
}

View File

@@ -0,0 +1,126 @@
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Windows.Forms.Design;
using DevComponents.Instrumentation;
namespace DevComponents.Instrumentation.Design
{
/// <summary>
/// KnobControlDesigner
/// </summary>
public class KnobControlDesigner : ControlDesigner
{
#region Private variables
private KnobControl _KnobControl;
private DesignerActionListCollection _ActionLists;
#endregion
#region Initialize
/// <summary>
/// Initializes our designer
/// </summary>
/// <param name="component"></param>
public override void Initialize(IComponent component)
{
base.Initialize(component);
if (component.Site.DesignMode == true)
_KnobControl = component as KnobControl;
}
#endregion
#region Verbs
/// <summary>
/// Creates our verb collection
/// </summary>
public override DesignerVerbCollection Verbs
{
get
{
DesignerVerb[] verbs = new DesignerVerb[]
{
new DesignerVerb("KnobStyle 1", SetStyle1),
new DesignerVerb("KnobStyle 2", SetStyle2),
new DesignerVerb("KnobStyle 3", SetStyle3),
new DesignerVerb("KnobStyle 4", SetStyle4),
};
return (new DesignerVerbCollection(verbs));
}
}
#endregion
#region SetStyle
/// <summary>
/// Sets the control to Style1
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected virtual void SetStyle1(object sender, EventArgs e)
{
_KnobControl.KnobStyle = eKnobStyle.Style1;
}
/// <summary>
/// Sets the control to Style2
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected virtual void SetStyle2(object sender, EventArgs e)
{
_KnobControl.KnobStyle = eKnobStyle.Style2;
}
/// <summary>
/// Sets the control to Style3
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected virtual void SetStyle3(object sender, EventArgs e)
{
_KnobControl.KnobStyle = eKnobStyle.Style3;
}
/// <summary>
/// Sets the control to Style4
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected virtual void SetStyle4(object sender, EventArgs e)
{
_KnobControl.KnobStyle = eKnobStyle.Style4;
}
#endregion
#region ActionLists
/// <summary>
/// Gets our DesignerActionListCollection list
/// </summary>
public override DesignerActionListCollection ActionLists
{
get
{
if (_ActionLists == null)
{
_ActionLists = new DesignerActionListCollection();
_ActionLists.Add(new KnobControlActionList(_KnobControl));
}
return (_ActionLists);
}
}
#endregion
}
}

View File

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

View File

@@ -0,0 +1,248 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using System.Windows.Forms.Design;
namespace DevComponents.Instrumentation.Design
{
[ToolboxItem(false)]
public partial class LocationDropDown : UserControl
{
#region Constants
private const int DotRadius = 4;
#endregion
#region Private variables
private PointF _PivotPoint;
private Rectangle _DotBounds;
private Rectangle _FrameBounds;
private Point _Center;
private bool _InFrame;
private bool _InPivotDot;
private bool _PivotMoving;
private bool _EscapePressed;
private IWindowsFormsEditorService _EditorService;
private ITypeDescriptorContext _Context;
#endregion
public LocationDropDown(PointF value,
IWindowsFormsEditorService editorService, ITypeDescriptorContext context)
{
Initialize();
_EditorService = editorService;
_Context = context;
PivotPoint = value;
}
public LocationDropDown()
{
Initialize();
}
#region Initialize
private void Initialize()
{
InitializeComponent();
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
}
#endregion
#region Public properties
#region EditorService
public IWindowsFormsEditorService EditorService
{
get { return (_EditorService); }
set { _EditorService = value; }
}
#endregion
#region EscapePressed
public bool EscapePressed
{
get { return (_EscapePressed); }
set { _EscapePressed = value; }
}
#endregion
#region PivotPoint
public PointF PivotPoint
{
get { return (_PivotPoint); }
set
{
_PivotPoint = value;
RecalcLayout();
Invalidate();
_Context.OnComponentChanging();
_Context.PropertyDescriptor.SetValue(_Context.Instance, value);
_Context.OnComponentChanged();
}
}
#endregion
#endregion
#region RecalcLayout
private void RecalcLayout()
{
int n = Math.Min(Bounds.Width - 4, Bounds.Height - 4);
_FrameBounds = new Rectangle(2, 2, n, n);
_FrameBounds.X = (Bounds.Width - n) / 2;
_FrameBounds.Y = (Bounds.Height - n) / 2;
int x = _FrameBounds.X + (int)(_PivotPoint.X * _FrameBounds.Width);
int y = _FrameBounds.Y + (int)(_PivotPoint.Y * _FrameBounds.Height);
_DotBounds = new Rectangle(x - DotRadius, y - DotRadius,
DotRadius * 2, DotRadius * 2);
_Center = new Point(_FrameBounds.X + _FrameBounds.Width / 2,
_FrameBounds.Y + _FrameBounds.Height / 2);
}
#endregion
#region Paint support
#region OnPaint
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Graphics g = e.Graphics;
g.SmoothingMode = SmoothingMode.AntiAlias;
RecalcLayout();
g.DrawLine(Pens.Red, new Point(_FrameBounds.X, _Center.Y),
new Point(_FrameBounds.Right, _Center.Y));
g.DrawLine(Pens.Red, new Point(_Center.X, _FrameBounds.Y),
new Point(_Center.X, _FrameBounds.Bottom));
DrawPivotDot(g);
}
#endregion
#region DrawPivotDot
private void DrawPivotDot(Graphics g)
{
g.FillEllipse(Brushes.SkyBlue, _DotBounds);
g.DrawEllipse(Pens.DimGray, _DotBounds);
}
#endregion
#endregion
#region Mouse support
#region OnMouseMove
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
_InFrame = (_FrameBounds.Contains(e.Location) == true);
if (_PivotMoving == true && _InFrame == true)
{
PivotPoint = new PointF(
(float)(e.X - _FrameBounds.X) / _FrameBounds.Width,
(float)(e.Y - _FrameBounds.Y) / _FrameBounds.Height);
}
_InPivotDot = (_DotBounds.Contains(e.Location) == true);
Cursor = (_InPivotDot == true) ? Cursors.Hand : Cursors.Default;
}
#endregion
#region OnMouseLeave
protected override void OnMouseLeave(EventArgs e)
{
base.OnMouseLeave(e);
_InFrame = false;
_InPivotDot = false;
}
#endregion
#region OnMouseDown
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
if (e.Button == MouseButtons.Left)
{
if (_InPivotDot == true)
_PivotMoving = true;
}
}
#endregion
#region OnMouseUp
protected override void OnMouseUp(MouseEventArgs e)
{
base.OnMouseUp(e);
_PivotMoving = false;
_InFrame = (_FrameBounds.Contains(e.Location) == true);
_InPivotDot = (_DotBounds.Contains(e.Location) == true);
}
#endregion
#endregion
#region PivotPointDropDown_PreviewKeyDown
private void PivotPointDropDown_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
if (e.KeyCode == Keys.Escape)
_EscapePressed = true;
}
#endregion
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

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

View File

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

View File

@@ -0,0 +1,425 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using System.Windows.Forms.Design;
namespace DevComponents.Instrumentation.Design
{
[ToolboxItem(false)]
public partial class PivotPointDropDown : UserControl
{
#region Constants
private const int DotRadius = 4;
private const int ScaleWidth = 3;
private const float BevelInside = .035f;
private const float BevelOutside = .05f;
private const float RoundRectangleArc = .125f;
#endregion
#region Private variables
private GaugeFrameStyle _Style;
private PointF _PivotPoint;
private Rectangle _DotBounds;
private Rectangle _FrameBounds;
private Rectangle _ScaleBounds;
private float _ScaleRadius;
private float _StartAngle;
private float _SweepAngle;
private bool _InFrame;
private bool _InPivotDot;
private bool _PivotMoving;
private bool _EscapePressed;
private IWindowsFormsEditorService _EditorService;
private ITypeDescriptorContext _Context;
#endregion
public PivotPointDropDown(PointF value, GaugeFrameStyle style,
float scaleRadius, float startAngle, float sweepAngle,
IWindowsFormsEditorService editorService, ITypeDescriptorContext context)
{
_Style = style;
_ScaleRadius = scaleRadius;
_StartAngle = startAngle;
_SweepAngle = sweepAngle;
_ScaleRadius = Math.Max(_ScaleRadius, .07f);
Initialize();
_EditorService = editorService;
_Context = context;
PivotPoint = value;
}
public PivotPointDropDown()
{
Initialize();
}
#region Initialize
private void Initialize()
{
InitializeComponent();
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
}
#endregion
#region Public properties
#region EditorService
public IWindowsFormsEditorService EditorService
{
get { return (_EditorService); }
set { _EditorService = value; }
}
#endregion
#region EscapePressed
public bool EscapePressed
{
get { return (_EscapePressed); }
set { _EscapePressed = value; }
}
#endregion
#region PivotPoint
public PointF PivotPoint
{
get { return (_PivotPoint); }
set
{
_PivotPoint = value;
RecalcLayout();
Invalidate();
_Context.OnComponentChanging();
_Context.PropertyDescriptor.SetValue(_Context.Instance, value);
_Context.OnComponentChanged();
}
}
#endregion
#endregion
#region RecalcLayout
private void RecalcLayout()
{
int n = Math.Min(Bounds.Width - 4, Bounds.Height - 4);
_FrameBounds = new Rectangle(2, 2, n, n);
_FrameBounds.X = (Bounds.Width - n) / 2;
_FrameBounds.Y = (Bounds.Height - n) / 2;
int radius = (int)(n * _ScaleRadius);
_ScaleBounds.Width = radius * 2;
_ScaleBounds.Height = radius * 2;
int x = _FrameBounds.X + (int)(_PivotPoint.X * _FrameBounds.Width);
int y = _FrameBounds.Y + (int)(_PivotPoint.Y * _FrameBounds.Height);
_ScaleBounds.X = x - radius;
_ScaleBounds.Y = y - radius;
_DotBounds = new Rectangle(x - DotRadius, y - DotRadius, DotRadius * 2, DotRadius * 2);
}
#endregion
#region Paint support
#region OnPaint
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Graphics g = e.Graphics;
g.SmoothingMode = SmoothingMode.AntiAlias;
RecalcLayout();
DrawFrame(g);
DrawScale(g);
DrawPivotDot(g);
}
#endregion
#region DrawFrame
private void DrawFrame(Graphics g)
{
switch (_Style)
{
case GaugeFrameStyle.Circular:
DrawCircularFrame(g);
break;
case GaugeFrameStyle.Rectangular:
DrawRectangularFrame(g);
break;
case GaugeFrameStyle.RoundedRectangular:
DrawRoundedRectFrame(g);
break;
default:
DrawBlankFrame(g);
break;
}
}
#region DrawCircularFrame
private void DrawCircularFrame(Graphics g)
{
using (LinearGradientBrush br = new LinearGradientBrush(_FrameBounds, Color.WhiteSmoke, Color.Gray, 45))
g.FillEllipse(br, _FrameBounds);
int bevelIn = (int)(_FrameBounds.Width * BevelInside);
int bevelOut = (int)(_FrameBounds.Width * BevelOutside);
Rectangle r = _FrameBounds;
r.Inflate(-bevelOut, -bevelOut);
using (LinearGradientBrush br = new LinearGradientBrush(r, Color.Silver, Color.Gray, 45 + 180))
g.FillEllipse(br, r);
r.Inflate(-bevelIn, -bevelIn);
using (LinearGradientBrush br = new LinearGradientBrush(r, Color.Silver, Color.LightGray, 45))
g.FillEllipse(br, r);
}
#endregion
#region DrawRectangularFrame
private void DrawRectangularFrame(Graphics g)
{
using (LinearGradientBrush br = new LinearGradientBrush(_FrameBounds, Color.WhiteSmoke, Color.Gray, 45))
g.FillRectangle(br, _FrameBounds);
int bevelIn = (int)(_FrameBounds.Width * BevelInside);
int bevelOut = (int)(_FrameBounds.Width * BevelOutside);
Rectangle r = _FrameBounds;
r.Inflate(-bevelOut, -bevelOut);
using (LinearGradientBrush br = new LinearGradientBrush(r, Color.Silver, Color.Gray, 45 + 180))
g.FillRectangle(br, r);
r.Inflate(-bevelIn, -bevelIn);
using (LinearGradientBrush br = new LinearGradientBrush(r, Color.Silver, Color.LightGray, 45))
g.FillRectangle(br, r);
}
#endregion
#region DrawRoundedRectFrame
private void DrawRoundedRectFrame(Graphics g)
{
using (GraphicsPath path = GetRoundRectPath(_FrameBounds))
{
using (LinearGradientBrush br = new LinearGradientBrush(_FrameBounds, Color.WhiteSmoke, Color.Gray, 45))
g.FillPath(br, path);
}
int bevelIn = (int)(_FrameBounds.Width * BevelInside);
int bevelOut = (int)(_FrameBounds.Width * BevelOutside);
Rectangle r = _FrameBounds;
r.Inflate(-bevelOut, -bevelOut);
using (GraphicsPath path = GetRoundRectPath(r))
{
using (LinearGradientBrush br = new LinearGradientBrush(r, Color.Silver, Color.Gray, 45 + 180))
g.FillPath(br, path);
}
r.Inflate(-bevelIn, -bevelIn);
using (GraphicsPath path = GetRoundRectPath(r))
{
using (LinearGradientBrush br = new LinearGradientBrush(r, Color.Silver, Color.LightGray, 45))
g.FillPath(br, path);
}
}
#region GetRoundRectPath
private GraphicsPath GetRoundRectPath(Rectangle r)
{
GraphicsPath path = new GraphicsPath();
int m = Math.Min(r.Width, r.Height);
int n = (int)(m * RoundRectangleArc * 2) + 1;
Rectangle t = new Rectangle(r.Right - n, r.Bottom - n, n, n);
path.AddArc(t, 0, 90);
t.X = r.X;
path.AddArc(t, 90, 90);
t.Y = r.Y;
path.AddArc(t, 180, 90);
t.X = r.Right - n;
path.AddArc(t, 270, 90);
path.CloseAllFigures();
return (path);
}
#endregion
#endregion
#region DrawBlankFrame
private void DrawBlankFrame(Graphics g)
{
using (Brush br = new SolidBrush(Color.LightGray))
g.FillRectangle(br, _FrameBounds);
g.DrawRectangle(Pens.DimGray, _FrameBounds);
}
#endregion
#endregion
#region DrawScale
private void DrawScale(Graphics g)
{
using (Brush br = new SolidBrush(Color.CornflowerBlue))
{
using (Pen pen = new Pen(br, ScaleWidth))
g.DrawArc(pen, _ScaleBounds, _StartAngle, _SweepAngle);
}
}
#endregion
#region DrawPivotDot
private void DrawPivotDot(Graphics g)
{
g.FillEllipse(Brushes.SkyBlue, _DotBounds);
g.DrawEllipse(Pens.DimGray, _DotBounds);
}
#endregion
#endregion
#region Mouse support
#region OnMouseMove
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
_InFrame = (_FrameBounds.Contains(e.Location) == true);
if (_PivotMoving == true && _InFrame == true)
{
PivotPoint = new PointF(
(float)(e.X - _FrameBounds.X) / _FrameBounds.Width,
(float)(e.Y - _FrameBounds.Y) / _FrameBounds.Height);
}
_InPivotDot = (_DotBounds.Contains(e.Location) == true);
Cursor = (_InPivotDot == true) ? Cursors.Hand : Cursors.Default;
}
#endregion
#region OnMouseLeave
protected override void OnMouseLeave(EventArgs e)
{
base.OnMouseLeave(e);
_InFrame = false;
_InPivotDot = false;
}
#endregion
#region OnMouseDown
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
if (e.Button == MouseButtons.Left)
{
if (_InPivotDot == true)
_PivotMoving = true;
}
}
#endregion
#region OnMouseUp
protected override void OnMouseUp(MouseEventArgs e)
{
base.OnMouseUp(e);
_PivotMoving = false;
_InFrame = (_FrameBounds.Contains(e.Location) == true);
_InPivotDot = (_DotBounds.Contains(e.Location) == true);
}
#endregion
#endregion
#region PivotPointDropDown_PreviewKeyDown
private void PivotPointDropDown_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
if (e.KeyCode == Keys.Escape)
_EscapePressed = true;
}
#endregion
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,65 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Design;
using System.Windows.Forms.Design;
namespace DevComponents.Instrumentation.Design
{
public class PivotPointEditor : UITypeEditor
{
#region GetEditStyle
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
{
return (UITypeEditorEditStyle.DropDown);
}
#endregion
#region GetPaintValueSupported
public override bool GetPaintValueSupported(ITypeDescriptorContext context)
{
return (false);
}
#endregion
#region EditValue
public override object EditValue(
ITypeDescriptorContext context, IServiceProvider provider, object value)
{
if (provider != null)
{
IWindowsFormsEditorService editorService =
provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
if (editorService != null)
{
GaugeCircularScale scale = context.Instance as GaugeCircularScale;
if (scale != null)
{
PivotPointDropDown pv = new PivotPointDropDown((PointF) value, scale.GaugeControl.Frame.Style,
scale.Radius, scale.StartAngle, scale.SweepAngle, editorService, context);
pv.EscapePressed = false;
editorService.DropDownControl(pv);
if (pv.EscapePressed == true)
context.PropertyDescriptor.SetValue(context.Instance, value);
else
return (pv.PivotPoint);
}
}
}
return (base.EditValue(context, provider, value));
}
#endregion
}
}

View File

@@ -0,0 +1,171 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.4952
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace DevComponents.DotNetBarKnobControl.Design.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DevComponents.DotNetBarKnobControl.Design.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
internal static System.Drawing.Bitmap Copy {
get {
object obj = ResourceManager.GetObject("Copy", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized string similar to The currency (&quot;C&quot;) format specifier converts a number to a string that represents a currency amount.
///
///The precision specifier indicates the desired number of decimal places in the result string..
/// </summary>
internal static string CurrencyDesc {
get {
return ResourceManager.GetString("CurrencyDesc", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Characters that can be used to create custom numeric format strings:
///
///&apos;0&apos; - Zero placeholder, &apos;#&apos; - Digit placeholder, &apos;.&apos; - Decimal point, &apos;,&apos; - Group separator and number scaling , &apos;%&apos; - Percentage, &apos;E0&apos; - Scientific notation, &apos;\&apos; - Escape character, &apos;;&apos; - Section separator.
///
///All other characters are copied to the output string as literals in the position they appear..
/// </summary>
internal static string CustomDesc {
get {
return ResourceManager.GetString("CustomDesc", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to The decimal (&quot;D&quot;) format specifier converts a number to a string of decimal digits (0-9), prefixed by a minus sign if the number is negative. This format is supported only for integral types.
///
///The precision specifier indicates the minimum number of digits desired in the resulting string. If required, the number is padded with zeros to its left to produce the number of digits given by the precision specifier. If no precision specifier is specified, the default is the minimum value required to represent th [rest of string was truncated]&quot;;.
/// </summary>
internal static string DecimalDesc {
get {
return ResourceManager.GetString("DecimalDesc", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to The exponential or Scientific (&quot;E&quot;) format specifier converts a number to a string of the form &quot;-d.ddd…E+ddd&quot; or &quot;-d.ddd…e+ddd&quot;, where each &quot;d&quot; indicates a digit (0-9). The string starts with a minus sign if the number is negative. Exactly one digit always precedes the decimal point.
///
///The precision specifier indicates the desired number of digits after the decimal point. If the precision specifier is omitted, a default of six digits after the decimal point is used..
/// </summary>
internal static string ExponentialDesc {
get {
return ResourceManager.GetString("ExponentialDesc", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to The fixed-point (&quot;F&quot;) format specifier converts a number to a string of the form &quot;-ddd.ddd…&quot; where each &quot;d&quot; indicates a digit (0-9). The string starts with a minus sign if the number is negative.
///
///The precision specifier indicates the desired number of decimal places..
/// </summary>
internal static string FixedPointDesc {
get {
return ResourceManager.GetString("FixedPointDesc", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to The general (&quot;G&quot;) format specifier converts a number to the most compact of either fixed-point or scientific notation, depending on the type of the number and whether a precision specifier is present.
///
///The precision specifier defines the maximum number of significant digits that can appear in the result string..
/// </summary>
internal static string GeneralDesc {
get {
return ResourceManager.GetString("GeneralDesc", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to The hexadecimal (&quot;X&quot;) format specifier converts a number to a string of hexadecimal digits. This format is supported only for integral types.
///
///The precision specifier indicates the minimum number of digits desired in the resulting string. If required, the number is padded with zeros to its left to produce the number of digits given by the precision specifier..
/// </summary>
internal static string HexadecimalDesc {
get {
return ResourceManager.GetString("HexadecimalDesc", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to The numeric (&quot;N&quot;) format specifier converts a number to a string of the form &quot;-d,ddd,ddd.ddd…&quot;, where &quot;-&quot; indicates a negative number symbol if required, &quot;d&quot; indicates a digit (0-9), &quot;,&quot; indicates a group separator, and &quot;.&quot; indicates a decimal point symbol.
///
///The precision specifier indicates the desired number of decimal places..
/// </summary>
internal static string NumericDesc {
get {
return ResourceManager.GetString("NumericDesc", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to The percent (&quot;P&quot;) format specifier multiplies a number by 100 and converts it to a string that represents a percentage.
///
///The precision specifier indicates the desired number of decimal places..
/// </summary>
internal static string PercentDesc {
get {
return ResourceManager.GetString("PercentDesc", resourceCulture);
}
}
}
}

View File

@@ -0,0 +1,171 @@
<?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>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="Copy" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Copy.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="CurrencyDesc" xml:space="preserve">
<value>The currency ("C") format specifier converts a number to a string that represents a currency amount.
The precision specifier indicates the desired number of decimal places in the result string.</value>
</data>
<data name="CustomDesc" xml:space="preserve">
<value>Characters that can be used to create custom numeric format strings:
'0' - Zero placeholder, '#' - Digit placeholder, '.' - Decimal point, ',' - Group separator and number scaling , '%' - Percentage, 'E0' - Scientific notation, '\' - Escape character, ';' - Section separator.
All other characters are copied to the output string as literals in the position they appear.</value>
</data>
<data name="DecimalDesc" xml:space="preserve">
<value>The decimal ("D") format specifier converts a number to a string of decimal digits (0-9), prefixed by a minus sign if the number is negative. This format is supported only for integral types.
The precision specifier indicates the minimum number of digits desired in the resulting string. If required, the number is padded with zeros to its left to produce the number of digits given by the precision specifier. If no precision specifier is specified, the default is the minimum value required to represent the integer without leading zeros.</value>
</data>
<data name="ExponentialDesc" xml:space="preserve">
<value>The exponential or Scientific ("E") format specifier converts a number to a string of the form "-d.ddd…E+ddd" or "-d.ddd…e+ddd", where each "d" indicates a digit (0-9). The string starts with a minus sign if the number is negative. Exactly one digit always precedes the decimal point.
The precision specifier indicates the desired number of digits after the decimal point. If the precision specifier is omitted, a default of six digits after the decimal point is used.</value>
</data>
<data name="FixedPointDesc" xml:space="preserve">
<value>The fixed-point ("F") format specifier converts a number to a string of the form "-ddd.ddd…" where each "d" indicates a digit (0-9). The string starts with a minus sign if the number is negative.
The precision specifier indicates the desired number of decimal places.</value>
</data>
<data name="GeneralDesc" xml:space="preserve">
<value>The general ("G") format specifier converts a number to the most compact of either fixed-point or scientific notation, depending on the type of the number and whether a precision specifier is present.
The precision specifier defines the maximum number of significant digits that can appear in the result string.</value>
</data>
<data name="HexadecimalDesc" xml:space="preserve">
<value>The hexadecimal ("X") format specifier converts a number to a string of hexadecimal digits. This format is supported only for integral types.
The precision specifier indicates the minimum number of digits desired in the resulting string. If required, the number is padded with zeros to its left to produce the number of digits given by the precision specifier.</value>
</data>
<data name="NumericDesc" xml:space="preserve">
<value>The numeric ("N") format specifier converts a number to a string of the form "-d,ddd,ddd.ddd…", where "-" indicates a negative number symbol if required, "d" indicates a digit (0-9), "," indicates a group separator, and "." indicates a decimal point symbol.
The precision specifier indicates the desired number of decimal places.</value>
</data>
<data name="PercentDesc" xml:space="preserve">
<value>The percent ("P") format specifier multiplies a number by 100 and converts it to a string that represents a percentage.
The precision specifier indicates the desired number of decimal places.</value>
</data>
</root>

View File

@@ -0,0 +1,105 @@
namespace DevComponents.Instrumentation.Design
{
partial class RangeValueDropDown
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this._TrackBar = new System.Windows.Forms.TrackBar();
this._LabelValue = new System.Windows.Forms.Label();
this._LabelMin = new System.Windows.Forms.Label();
this._LabelMax = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this._TrackBar)).BeginInit();
this.SuspendLayout();
//
// _TrackBar
//
this._TrackBar.AutoSize = false;
this._TrackBar.Dock = System.Windows.Forms.DockStyle.Fill;
this._TrackBar.Location = new System.Drawing.Point(0, 0);
this._TrackBar.Name = "_TrackBar";
this._TrackBar.Size = new System.Drawing.Size(186, 40);
this._TrackBar.TabIndex = 0;
this._TrackBar.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this._TrackBar_PreviewKeyDown);
this._TrackBar.ValueChanged += new System.EventHandler(this.TrackBar_ValueChanged);
//
// _LabelValue
//
this._LabelValue.AutoEllipsis = true;
this._LabelValue.Location = new System.Drawing.Point(59, 21);
this._LabelValue.Name = "_LabelValue";
this._LabelValue.Size = new System.Drawing.Size(69, 16);
this._LabelValue.TabIndex = 1;
this._LabelValue.Text = "Value";
this._LabelValue.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// _LabelMin
//
this._LabelMin.AutoEllipsis = true;
this._LabelMin.ForeColor = System.Drawing.SystemColors.ControlDarkDark;
this._LabelMin.Location = new System.Drawing.Point(3, 21);
this._LabelMin.Name = "_LabelMin";
this._LabelMin.Size = new System.Drawing.Size(50, 16);
this._LabelMin.TabIndex = 2;
this._LabelMin.Text = "Min";
this._LabelMin.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
//
// _LabelMax
//
this._LabelMax.AutoEllipsis = true;
this._LabelMax.ForeColor = System.Drawing.SystemColors.ControlDarkDark;
this._LabelMax.Location = new System.Drawing.Point(134, 21);
this._LabelMax.Name = "_LabelMax";
this._LabelMax.Size = new System.Drawing.Size(52, 16);
this._LabelMax.TabIndex = 3;
this._LabelMax.Text = "Max";
this._LabelMax.TextAlign = System.Drawing.ContentAlignment.BottomRight;
//
// RangeValueDropDown
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this._LabelMax);
this.Controls.Add(this._LabelMin);
this.Controls.Add(this._LabelValue);
this.Controls.Add(this._TrackBar);
this.Name = "RangeValueDropDown";
this.Size = new System.Drawing.Size(186, 40);
((System.ComponentModel.ISupportInitialize)(this._TrackBar)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.TrackBar _TrackBar;
private System.Windows.Forms.Label _LabelValue;
private System.Windows.Forms.Label _LabelMin;
private System.Windows.Forms.Label _LabelMax;
}
}

View File

@@ -0,0 +1,154 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Windows.Forms.Design;
namespace DevComponents.Instrumentation.Design
{
[ToolboxItem(false)]
public partial class RangeValueDropDown : UserControl
{
#region Private variables
private float _Value;
private bool _EscapePressed;
private IWindowsFormsEditorService _EditorService;
private ITypeDescriptorContext _Context;
#endregion
public RangeValueDropDown(float value, float minimum, float maximum,
IWindowsFormsEditorService editorService, ITypeDescriptorContext context)
{
InitializeComponent();
_EditorService = editorService;
_Context = context;
if (value < minimum)
{
if ((minimum * 1000 > Int16.MinValue) && (minimum * 1000 < Int16.MaxValue))
minimum = value;
}
if (value > maximum)
{
if ((maximum * 1000 > Int16.MinValue) && (maximum * 1000 < Int16.MaxValue))
maximum = value;
}
_TrackBar.Minimum = (int)(minimum * 1000);
_TrackBar.Maximum = (int)(maximum * 1000);
_TrackBar.SmallChange = _TrackBar.Maximum / 100;
_TrackBar.LargeChange = _TrackBar.Maximum / 10;
_TrackBar.TickFrequency = _TrackBar.LargeChange;
_TrackBar.Value = (int)(value * 1000);
_LabelMin.Text = String.Format("{0:f}", minimum);
_LabelMax.Text = String.Format("{0:f}", maximum);
Value = value;
}
public RangeValueDropDown()
{
InitializeComponent();
}
#region DefaultSize
protected override Size DefaultSize
{
get { return new Size(186, 40); }
}
#endregion
#region Public properties
#region EditorService
public IWindowsFormsEditorService EditorService
{
get { return (_EditorService); }
set { _EditorService = value; }
}
#endregion
#region EscapePressed
public bool EscapePressed
{
get { return (_EscapePressed); }
set { _EscapePressed = value; }
}
#endregion
#region Value
public float Value
{
get { return (_Value); }
set
{
_Value = value;
_LabelValue.Text = String.Format("{0:f3}", value);
_LabelValue.Update();
_Context.OnComponentChanging();
_Context.PropertyDescriptor.SetValue(_Context.Instance, value);
_Context.OnComponentChanged();
}
}
#endregion
#endregion
#region OnResize
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
int width = _TrackBar.Width;
int dx = width / 3;
_LabelMin.Width = dx;
_LabelMax.Width = dx;
_LabelValue.Width = dx;
_LabelValue.Location = new Point((width - dx) / 2, _LabelValue.Location.Y);
_LabelMax.Location = new Point(width - dx, _LabelMax.Location.Y);
}
#endregion
#region _TrackBar_ValueChanged
private void TrackBar_ValueChanged(object sender, EventArgs e)
{
Value = ((float)_TrackBar.Value) / 1000;
}
#endregion
#region _TrackBar_PreviewKeyDown
private void _TrackBar_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
if (e.KeyCode == Keys.Escape)
_EscapePressed = true;
}
#endregion
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,218 @@
using System;
using System.ComponentModel;
using System.Drawing.Design;
using System.Windows.Forms.Design;
namespace DevComponents.Instrumentation.Design
{
public class RangeValueEditor : UITypeEditor
{
#region Private variables
private const float MinValue = 0;
private const float MaxValue = 1;
#endregion
#region Public properties
public virtual float Minimum
{
get { return (MinValue); }
}
public virtual float Maximum
{
get { return (MaxValue); }
}
#endregion
#region GetEditStyle
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
{
return (UITypeEditorEditStyle.DropDown);
}
#endregion
#region GetPaintValueSupported
public override bool GetPaintValueSupported(ITypeDescriptorContext context)
{
return (false);
}
#endregion
#region EditValue
public override object EditValue(
ITypeDescriptorContext context, IServiceProvider provider, object value)
{
if (provider != null)
{
IWindowsFormsEditorService editorService =
provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
if (editorService != null)
{
RangeValueDropDown rv = new
RangeValueDropDown((float)value, Minimum, Maximum, editorService, context);
rv.EscapePressed = false;
editorService.DropDownControl(rv);
if (rv.EscapePressed == true)
context.PropertyDescriptor.SetValue(context.Instance, value);
else
return (rv.Value);
}
}
return (base.EditValue(context, provider, value));
}
#endregion
}
#region AngleRangeValueEditor
public class AngleRangeValueEditor : RangeValueEditor
{
#region Public properties
public override float Maximum
{
get { return (360); }
}
#endregion
}
#endregion
#region RadiusRangeValueEditor
public class RadiusRangeValueEditor : RangeValueEditor
{
#region Public properties
public override float Maximum
{
get { return (.5f); }
}
#endregion
}
#endregion
#region WidthRangeValueEditor
public class WidthRangeValueEditor : RangeValueEditor
{
#region Public properties
public override float Maximum
{
get { return (.3f); }
}
#endregion
}
#endregion
#region CapWidthRangeValueEditor
public class CapWidthRangeValueEditor : RangeValueEditor
{
#region Public properties
public override float Maximum
{
get { return (1f); }
}
#endregion
}
#endregion
#region OffsetRangeValueEditor
public class OffsetRangeValueEditor : RangeValueEditor
{
#region Public properties
public override float Maximum
{
get { return (.3f); }
}
public override float Minimum
{
get { return (-.3f); }
}
#endregion
}
#endregion
#region OffsetRangeValueEditor
public class OffsetPosRangeValueEditor : RangeValueEditor
{
#region Public properties
public override float Maximum
{
get { return (.9f); }
}
public override float Minimum
{
get { return (0f); }
}
#endregion
}
#endregion
#region WidthMaxRangeValueEditor
public class WidthMaxRangeValueEditor : RangeValueEditor
{
#region Public properties
public override float Maximum
{
get { return (1f); }
}
#endregion
}
#endregion
#region HalfRadiusRangeValueEditor
public class HalfRadiusRangeValueEditor : RangeValueEditor
{
#region Public properties
public override float Maximum
{
get { return (.5f); }
}
#endregion
}
#endregion
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 663 B

View File

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

View File

@@ -0,0 +1,242 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using System.Windows.Forms.Design;
namespace DevComponents.Instrumentation.Design
{
[ToolboxItem(false)]
public partial class SizeDropDown : UserControl
{
#region Constants
private const int DotRadius = 4;
#endregion
#region Private variables
private SizeF _Size;
private Rectangle _DotBounds;
private Rectangle _FrameBounds;
private Rectangle _DotRect;
private bool _InFrame;
private bool _InSizeDot;
private bool _PivotMoving;
private bool _EscapePressed;
private IWindowsFormsEditorService _EditorService;
private ITypeDescriptorContext _Context;
#endregion
public SizeDropDown(SizeF value,
IWindowsFormsEditorService editorService, ITypeDescriptorContext context)
{
Initialize();
_EditorService = editorService;
_Context = context;
_Size = value;
}
public SizeDropDown()
{
Initialize();
}
#region Initialize
private void Initialize()
{
InitializeComponent();
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
}
#endregion
#region Public properties
#region EditorService
public IWindowsFormsEditorService EditorService
{
get { return (_EditorService); }
set { _EditorService = value; }
}
#endregion
#region EscapePressed
public bool EscapePressed
{
get { return (_EscapePressed); }
set { _EscapePressed = value; }
}
#endregion
#region PivotPoint
public SizeF Syze
{
get { return (_Size); }
set
{
_Size = value;
RecalcLayout();
Invalidate();
_Context.OnComponentChanging();
_Context.PropertyDescriptor.SetValue(_Context.Instance, value);
_Context.OnComponentChanged();
}
}
#endregion
#endregion
#region RecalcLayout
private void RecalcLayout()
{
int n = Math.Min(Bounds.Width - 4, Bounds.Height - 4);
_FrameBounds = new Rectangle(2, 2, n, n);
_FrameBounds.X = (Bounds.Width - n) / 2;
_FrameBounds.Y = (Bounds.Height - n) / 2;
int x = _FrameBounds.X + (int)(_Size.Width * _FrameBounds.Width);
int y = _FrameBounds.Y + (int)(_Size.Height * _FrameBounds.Height);
_DotBounds = new Rectangle(x - DotRadius, y - DotRadius,
DotRadius * 2, DotRadius * 2);
_DotRect = new Rectangle(0, 0, x, y);
}
#endregion
#region Paint support
#region OnPaint
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Graphics g = e.Graphics;
g.SmoothingMode = SmoothingMode.AntiAlias;
RecalcLayout();
g.DrawRectangle(Pens.Red, _DotRect);
DrawPivotDot(g);
}
#endregion
#region DrawPivotDot
private void DrawPivotDot(Graphics g)
{
g.FillEllipse(Brushes.SkyBlue, _DotBounds);
g.DrawEllipse(Pens.DimGray, _DotBounds);
}
#endregion
#endregion
#region Mouse support
#region OnMouseMove
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
_InFrame = (_FrameBounds.Contains(e.Location) == true);
if (_PivotMoving == true && _InFrame == true)
{
Syze = new SizeF(
(float)(e.X - _FrameBounds.X) / _FrameBounds.Width,
(float)(e.Y - _FrameBounds.Y) / _FrameBounds.Height);
}
_InSizeDot = (_DotBounds.Contains(e.Location) == true);
Cursor = (_InSizeDot == true) ? Cursors.Hand : Cursors.Default;
}
#endregion
#region OnMouseLeave
protected override void OnMouseLeave(EventArgs e)
{
base.OnMouseLeave(e);
_InFrame = false;
_InSizeDot = false;
}
#endregion
#region OnMouseDown
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
if (e.Button == MouseButtons.Left)
{
if (_InSizeDot == true)
_PivotMoving = true;
}
}
#endregion
#region OnMouseUp
protected override void OnMouseUp(MouseEventArgs e)
{
base.OnMouseUp(e);
_PivotMoving = false;
_InFrame = (_FrameBounds.Contains(e.Location) == true);
_InSizeDot = (_DotBounds.Contains(e.Location) == true);
}
#endregion
#endregion
#region PivotPointDropDown_PreviewKeyDown
private void PivotPointDropDown_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
if (e.KeyCode == Keys.Escape)
_EscapePressed = true;
}
#endregion
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

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