|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
namespace CarControl
{
partial class Car
{
// Private variables for storing the values at the wheels etc.
private string m_FloatFormat = "F2";
private double m_FrontL = 0;
private double m_FrontR = 0;
private double m_RearL = 0;
private double m_RearR = 0;
/*
* These are public properties, they are there to make the values read/writeable by
* external code, also can perform validation etc, in this instance once the property
* is set it redraws the control by calling the Invalidate method.
*/
public string FloatFormat
{
get { return this.m_FloatFormat; }
set
{
this.m_FloatFormat = value;
this.Invalidate();
}
}
public double FrontL
{
get { return this.m_FrontL; }
set
{
this.m_FrontL = value;
this.Invalidate();
}
}
public double FrontR
{
get { return this.m_FrontR; }
set
{
this.m_FrontR = value;
this.Invalidate();
}
}
public double RearL
{
get { return this.m_RearL; }
set
{
this.m_RearL = value;
this.Invalidate();
}
}
public double RearR
{
get { return this.m_RearR; }
set
{
this.m_RearR = value;
this.Invalidate();
}
}
/*
* These properties do not use the private variables but calculate themselves from
* the other properties (when they are accessed), thus eliminating the need to update
* multiple variables. They are hidden from the .NET PropertyGrid by the
* Browsable(false) attribute.
*/
#region Calculated
[Browsable(false)]
public double Cross1
{
get { return (this.FrontL + this.RearR); }
}
[Browsable(false)]
public double Cross2
{
get { return (this.FrontR + this.RearL); }
}
[Browsable(false)]
public double Front
{
get { return (this.FrontL + this.FrontR); }
}
[Browsable(false)]
public double Back
{
get { return (this.RearL + this.RearR); }
}
[Browsable(false)]
public double Total
{
get { return (this.FrontL + this.FrontR + this.RearL + this.RearR); }
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Ed is a student who due to a form of cancer (now clear) took a year out before going to Imperial College, London to study Electronic Engineering.
His interests include shooting (clay-pigeon (shotgun), air-rifle and rifle), playing with his three labradors (Sandy, Rosie and Tundra), programming (most experienced in C# and C, although those are not the only ones), walking (has completed Gold Duke of Edinburgh's Award), playing games and reading.
He lives in two places on a 57 acre farm in West Waleswith the rest of the family during the holidays; and Greater London during term time.
Languages and Technologies: C#, C, VB6, VB.NET, XAML, (X)HTML, CSS, XSLT, Assembler (PIC), ASP.NET, WPF, Windows.Forms, ASP, VBScript, JavaScript, Pascal / Delphi, XML
Current Stuff:
1st Year MEng Electronics Engineering (Imperial College, London)