Configurator.Net: Added heading visualisation

git-svn-id: https://arducopter.googlecode.com/svn/trunk@1734 f9c3cf11-9bcb-44bc-f272-b75c42450872
This commit is contained in:
mandrolic 2011-02-28 22:01:48 +00:00
parent bf37f35567
commit 44ae403508
5 changed files with 397 additions and 10 deletions

View File

@ -87,6 +87,12 @@
<Compile Include="Views\controls\CircularIndicatorControl.Designer.cs"> <Compile Include="Views\controls\CircularIndicatorControl.Designer.cs">
<DependentUpon>CircularIndicatorControl.cs</DependentUpon> <DependentUpon>CircularIndicatorControl.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Views\controls\CompassControl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Views\controls\CompassControl.Designer.cs">
<DependentUpon>CompassControl.cs</DependentUpon>
</Compile>
<Compile Include="Views\controls\PropControl.cs"> <Compile Include="Views\controls\PropControl.cs">
<SubType>Component</SubType> <SubType>Component</SubType>
</Compile> </Compile>
@ -247,6 +253,9 @@
<EmbeddedResource Include="Views\controls\CircularIndicatorControl.resx"> <EmbeddedResource Include="Views\controls\CircularIndicatorControl.resx">
<DependentUpon>CircularIndicatorControl.cs</DependentUpon> <DependentUpon>CircularIndicatorControl.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Views\controls\CompassControl.resx">
<DependentUpon>CompassControl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Views\controls\PropControl.resx"> <EmbeddedResource Include="Views\controls\PropControl.resx">
<DependentUpon>PropControl.cs</DependentUpon> <DependentUpon>PropControl.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>

View File

@ -73,6 +73,7 @@
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.textBox14 = new System.Windows.Forms.TextBox(); this.textBox14 = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label();
this.compassControl1 = new ArducopterConfigurator.Views.controls.CompassControl();
((System.ComponentModel.ISupportInitialize)(this.FlightDataVmBindingSource)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.FlightDataVmBindingSource)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
@ -431,7 +432,7 @@
// //
this.button2.DataBindings.Add(new System.Windows.Forms.Binding("Tag", this.FlightDataVmBindingSource, "RefreshCalibrationOffsetsCommand", true)); this.button2.DataBindings.Add(new System.Windows.Forms.Binding("Tag", this.FlightDataVmBindingSource, "RefreshCalibrationOffsetsCommand", true));
this.button2.Image = ((System.Drawing.Image)(resources.GetObject("button2.Image"))); this.button2.Image = ((System.Drawing.Image)(resources.GetObject("button2.Image")));
this.button2.Location = new System.Drawing.Point(311, 214); this.button2.Location = new System.Drawing.Point(304, 139);
this.button2.Name = "button2"; this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(26, 26); this.button2.Size = new System.Drawing.Size(26, 26);
this.button2.TabIndex = 46; this.button2.TabIndex = 46;
@ -441,7 +442,7 @@
// //
this.button1.DataBindings.Add(new System.Windows.Forms.Binding("Tag", this.FlightDataVmBindingSource, "UpdateCalibrationOffsetsCommand", true)); this.button1.DataBindings.Add(new System.Windows.Forms.Binding("Tag", this.FlightDataVmBindingSource, "UpdateCalibrationOffsetsCommand", true));
this.button1.Image = ((System.Drawing.Image)(resources.GetObject("button1.Image"))); this.button1.Image = ((System.Drawing.Image)(resources.GetObject("button1.Image")));
this.button1.Location = new System.Drawing.Point(311, 185); this.button1.Location = new System.Drawing.Point(304, 110);
this.button1.Name = "button1"; this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(26, 26); this.button1.Size = new System.Drawing.Size(26, 26);
this.button1.TabIndex = 45; this.button1.TabIndex = 45;
@ -451,7 +452,7 @@
// //
this.button3.DataBindings.Add(new System.Windows.Forms.Binding("Tag", this.FlightDataVmBindingSource, "CalculateCalibrationOffsetsCommand", true)); this.button3.DataBindings.Add(new System.Windows.Forms.Binding("Tag", this.FlightDataVmBindingSource, "CalculateCalibrationOffsetsCommand", true));
this.button3.Image = ((System.Drawing.Image)(resources.GetObject("button3.Image"))); this.button3.Image = ((System.Drawing.Image)(resources.GetObject("button3.Image")));
this.button3.Location = new System.Drawing.Point(311, 156); this.button3.Location = new System.Drawing.Point(304, 81);
this.button3.Name = "button3"; this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(26, 26); this.button3.Size = new System.Drawing.Size(26, 26);
this.button3.TabIndex = 47; this.button3.TabIndex = 47;
@ -461,7 +462,7 @@
// label11 // label11
// //
this.label11.AutoSize = true; this.label11.AutoSize = true;
this.label11.Location = new System.Drawing.Point(343, 163); this.label11.Location = new System.Drawing.Point(336, 88);
this.label11.Name = "label11"; this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(78, 13); this.label11.Size = new System.Drawing.Size(78, 13);
this.label11.TabIndex = 48; this.label11.TabIndex = 48;
@ -470,7 +471,7 @@
// label12 // label12
// //
this.label12.AutoSize = true; this.label12.AutoSize = true;
this.label12.Location = new System.Drawing.Point(343, 192); this.label12.Location = new System.Drawing.Point(336, 117);
this.label12.Name = "label12"; this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(84, 13); this.label12.Size = new System.Drawing.Size(84, 13);
this.label12.TabIndex = 49; this.label12.TabIndex = 49;
@ -479,7 +480,7 @@
// label13 // label13
// //
this.label13.AutoSize = true; this.label13.AutoSize = true;
this.label13.Location = new System.Drawing.Point(343, 223); this.label13.Location = new System.Drawing.Point(336, 148);
this.label13.Name = "label13"; this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(96, 13); this.label13.Size = new System.Drawing.Size(96, 13);
this.label13.TabIndex = 50; this.label13.TabIndex = 50;
@ -612,29 +613,44 @@
// //
// textBox14 // textBox14
// //
this.textBox14.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.textBox14.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.textBox14.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.FlightDataVmBindingSource, "CompassHeadingDegrees", true, System.Windows.Forms.DataSourceUpdateMode.OnValidation, null, "N0")); this.textBox14.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.FlightDataVmBindingSource, "CompassHeadingDegrees", true, System.Windows.Forms.DataSourceUpdateMode.OnValidation, null, "N0"));
this.textBox14.Enabled = false; this.textBox14.Enabled = false;
this.textBox14.Location = new System.Drawing.Point(102, 244); this.textBox14.Location = new System.Drawing.Point(264, 222);
this.textBox14.Name = "textBox14"; this.textBox14.Name = "textBox14";
this.textBox14.ReadOnly = true; this.textBox14.ReadOnly = true;
this.textBox14.Size = new System.Drawing.Size(35, 20); this.textBox14.Size = new System.Drawing.Size(35, 13);
this.textBox14.TabIndex = 58; this.textBox14.TabIndex = 58;
this.textBox14.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; this.textBox14.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
// //
// label2 // label2
// //
this.label2.AutoSize = true; this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(44, 246); this.label2.Location = new System.Drawing.Point(255, 205);
this.label2.Name = "label2"; this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(47, 13); this.label2.Size = new System.Drawing.Size(47, 13);
this.label2.TabIndex = 59; this.label2.TabIndex = 59;
this.label2.Text = "Heading"; this.label2.Text = "Heading";
// //
// compassControl1
//
this.compassControl1.BarBackgroundDark = System.Drawing.Color.FromArgb(((int)(((byte)(199)))), ((int)(((byte)(200)))), ((int)(((byte)(201)))));
this.compassControl1.BarBackgroundLight = System.Drawing.Color.WhiteSmoke;
this.compassControl1.BarBorderColor = System.Drawing.Color.Black;
this.compassControl1.BarDark = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(68)))), ((int)(((byte)(202)))));
this.compassControl1.BarLight = System.Drawing.Color.LightBlue;
this.compassControl1.DataBindings.Add(new System.Windows.Forms.Binding("Value", this.FlightDataVmBindingSource, "CompassHeadingDegrees", true));
this.compassControl1.Location = new System.Drawing.Point(308, 192);
this.compassControl1.Name = "compassControl1";
this.compassControl1.Size = new System.Drawing.Size(50, 50);
this.compassControl1.TabIndex = 0;
this.compassControl1.Value = 90;
//
// FlightDataView // FlightDataView
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.compassControl1);
this.Controls.Add(this.label2); this.Controls.Add(this.label2);
this.Controls.Add(this.textBox14); this.Controls.Add(this.textBox14);
this.Controls.Add(this.label1); this.Controls.Add(this.label1);
@ -731,5 +747,6 @@
private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox textBox14; private System.Windows.Forms.TextBox textBox14;
private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label2;
private ArducopterConfigurator.Views.controls.CompassControl compassControl1;
} }
} }

View File

@ -0,0 +1,45 @@
namespace ArducopterConfigurator.Views.controls
{
partial class CompassControl
{
/// <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();
//
// CirularIndicatorControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Name = "CirularIndicatorControl";
this.Size = new System.Drawing.Size(50, 50);
this.ResumeLayout(false);
}
#endregion
}
}

View File

@ -0,0 +1,196 @@
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace ArducopterConfigurator.Views.controls
{
/// <summary>
/// </summary>
[ToolboxBitmap(typeof(System.Windows.Forms.ProgressBar))]
public partial class CompassControl : UserControl
{
public static readonly Color preSweepLight = Color.FromArgb(102, 144, 252);
public static readonly Color preSweepDark = Color.FromArgb(40, 68, 202);
public static readonly Color PreBorderColor = Color.DarkGray;
public static readonly Color PreBarBaseDark = Color.FromArgb(199, 200, 201);
public static readonly Color PreBarBaseLight = Color.WhiteSmoke;
private Color _sweepLightColour = preSweepLight;
private Color _sweepDarkColour = preSweepDark;
private Color _borderColor = PreBorderColor;
private Color _barBgLightColour = PreBarBaseLight;
private Color _barBgDarkColor = PreBarBaseDark;
private float _borderWidth = 1.0F;
private int _val = 50;
public CompassControl()
{
SetStyle(ControlStyles.OptimizedDoubleBuffer |
ControlStyles.AllPaintingInWmPaint |
ControlStyles.UserPaint |
ControlStyles.ResizeRedraw, true);
InitializeComponent();
Width = 50;
Height = 50;
}
/// <summary>
/// Raises the <see cref="E:System.Windows.Forms.Control.Paint"></see> event.
/// </summary>
/// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs"></see> that contains the event data.</param>
protected override void OnPaint(PaintEventArgs e)
{
var g = e.Graphics;
g.SmoothingMode = SmoothingMode.AntiAlias;
g.Clear(BackColor);
var bmp = GenerateBitmap(Width, Height);
g.DrawImage(bmp, 0, 0);
}
private void GenerateCircle(Graphics g, float x, float y, float width, float height, int heading)
{
var outerRect = new RectangleF(x, y, width, height);
// Fill the background of the whole control
using (var bg = new SolidBrush(BackColor))
g.FillRectangle(bg, outerRect);
// Fill the background of the circle
var circleRect = outerRect;
circleRect.Inflate((_borderWidth/-2), (_borderWidth/-2));
using (var white = new LinearGradientBrush(outerRect, _barBgLightColour, _barBgDarkColor, 0F))
{
g.FillEllipse(white, circleRect);
}
var gp = new GraphicsPath();
gp.AddEllipse(circleRect);
var pgb = new PathGradientBrush(gp);
pgb.CenterPoint = new PointF(circleRect.Width/2, circleRect.Height/2);
pgb.CenterColor = _sweepDarkColour;
pgb.SurroundColors = new[] {_sweepLightColour};
heading = (heading + 270 -5) %360;
g.FillPie(pgb, circleRect.Left, circleRect.Top, circleRect.Width, circleRect.Height, heading, 10);
pgb.Dispose();
using (var borderPen = new Pen(_borderColor, _borderWidth))
{
g.DrawEllipse(borderPen, circleRect);
}
}
private Bitmap GenerateBitmap(int width, int height)
{
var bmp = new Bitmap(width, height);
using (var g1 = Graphics.FromImage(bmp))
{
GenerateCircle(g1, 0.0F, 0.0F, width, height, _val);
}
return bmp;
}
/// <summary>
/// Gets or sets the width of the border.
/// </summary>
/// <value>The width of the border.</value>
[System.ComponentModel.Description("Gets or sets the with of the borders")]
[System.ComponentModel.DefaultValue(1.0f)]
[System.ComponentModel.RefreshProperties(System.ComponentModel.RefreshProperties.Repaint)]
public float BarBorderWidth
{
get { return _borderWidth; }
set { _borderWidth = value; Refresh(); }
}
/// <summary>
/// Gets or sets the bar background light.
/// </summary>
/// <value>The bar background light.</value>
[System.ComponentModel.Description("Gets or sets the lighter background color")]
[System.ComponentModel.RefreshProperties(System.ComponentModel.RefreshProperties.Repaint)]
public Color BarBackgroundLight
{
get { return _barBgLightColour; }
set { _barBgLightColour = value; Refresh(); }
}
/// <summary>
/// Gets or sets the bar background dark.
/// </summary>
/// <value>The bar background dark.</value>
[System.ComponentModel.Description("Gets or sets the darker background color")]
[System.ComponentModel.RefreshProperties(System.ComponentModel.RefreshProperties.Repaint)]
public Color BarBackgroundDark
{
get { return _barBgDarkColor; }
set { _barBgDarkColor = value; Refresh(); }
}
/// <summary>
/// Gets or sets the bar light.
/// </summary>
/// <value>The bar light.</value>
[System.ComponentModel.Description("Gets or sets the light bar color")]
[System.ComponentModel.RefreshProperties(System.ComponentModel.RefreshProperties.Repaint)]
public Color BarLight
{
get { return _sweepLightColour; }
set { _sweepLightColour = value; Refresh(); }
}
/// <summary>
/// Gets or sets the bar dark.
/// </summary>
/// <value>The bar dark.</value>
[System.ComponentModel.Description("Gets or sets the dark bar color")]
[System.ComponentModel.RefreshProperties(System.ComponentModel.RefreshProperties.Repaint)]
public Color BarDark
{
get { return _sweepDarkColour; }
set { _sweepDarkColour = value; Refresh(); }
}
/// <summary>
/// Gets or sets the color of the border.
/// </summary>
/// <value>The color of the border.</value>
[System.ComponentModel.Description("The border color")]
[System.ComponentModel.RefreshProperties(System.ComponentModel.RefreshProperties.Repaint)]
public Color BarBorderColor
{
get { return _borderColor; }
set { _borderColor = value; Refresh(); }
}
[System.ComponentModel.Description("Gets or sets the Value")]
[System.ComponentModel.RefreshProperties(System.ComponentModel.RefreshProperties.Repaint)]
public int Value
{
get { return _val; }
set
{
if (_val != value)
{
_val = value;
Refresh();
}
}
}
}
}

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>