[VC++ 2005] Projektoptimerung

the incredible Leitman

Erfahrenes Mitglied
Hallo zusammen ;)

Ich habe jetzt (vor allem dank der großartigen Hilfe in diesem Forum) eine Zeit lang mit meinen Controls arbeiten können!

Jetzt bin ich eigentlich mit meinen Controls soweit fertig, dass ich sie verwenden kann!
Jedoch hab ich nicht so die Mega Erfahrung, was Code GuideLines und derartige Dinge betrifft,
wäre euch echt verbunden, wenn ihr, falls ihr mal etwas Zeit hab, euch meinen Code anseht und Kritik abgebt, was ich anders / besser / effizienter machen könnte...

Die Funktionalität ist bereits da, was ich jetzt nur noch brauche, sind Code Optimierungen ;)

grid_control.h
C++:
namespace ZLSControls
{
	delegate void MyEventHandler();

	public ref class GridControl abstract
	{
	private:

		Pen ^ m_pen;
		int m_xpos,m_ypos;
		int m_width,m_height;
		System::Drawing::Color m_fgcolor;
		System::Drawing::Font ^m_font;

	public:
		
		GridControl()
			:m_xpos(0),m_ypos(0),m_width(0),m_height(0),m_fgcolor(Color::Black),
			m_font(gcnew System::Drawing::Font(L"Microsoft Sans Serif",
				8.25F, System::Drawing::FontStyle::Regular, 
				System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0)))
		{
			m_pen = gcnew Pen(Color::FromArgb(0xFFEEDD33),3.0);
		}

		GridControl(int i_xpos,int i_ypos,int i_width,int i_height)
			:m_xpos(i_xpos),m_ypos(i_ypos),m_width(i_width),m_height(i_height),m_fgcolor(Color::Black),
			m_font(gcnew System::Drawing::Font(L"Microsoft Sans Serif",
				8.25F, System::Drawing::FontStyle::Regular, 
				System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0)))
		{
			m_pen = gcnew Pen(Color::FromArgb(0xFFEEDD33),3.0);
		}

		virtual void Paint(Graphics ^g) sealed
		{
			g->TranslateTransform((float)m_xpos,(float)m_ypos);
			try
			{
				OnPaint(gcnew PaintEventArgs(g,Rectangle(m_xpos,m_ypos,m_width,m_height)));
			}
			finally
			{
				g->TranslateTransform(-(float)m_xpos,-(float)m_ypos);
			}
		}

		property int X
		{
			virtual int get() sealed
			{
				return m_xpos;
			}

			virtual void set(int value) sealed
			{
				m_xpos = value;
			}
		}

		property int Y
		{
			virtual int get() sealed
			{
				return m_ypos;
			}

			virtual void set(int value) sealed
			{
				m_ypos = value;
			}
		}

		property int Width
		{
			virtual int get() sealed
			{
				return m_width;
			}

			virtual void set(int value) sealed
			{
				m_width = value;
			}
		}

		property int Height
		{
			virtual int get() sealed
			{
				return m_height;
			}

			virtual void set(int value) sealed
			{
				m_height = value;
			}
		}

		property System::Drawing::Size Size
		{
			virtual System::Drawing::Size get() sealed
			{
				return System::Drawing::Size(m_width,m_height);
			}

			virtual void set(System::Drawing::Size value) sealed
			{
				m_width = value.Width;
				m_height = value.Height;
			}
		}

		property System::Drawing::Point Location
		{
			virtual System::Drawing::Point get() sealed
			{
				return System::Drawing::Point(m_xpos,m_ypos);
			}

			virtual void set(System::Drawing::Point value) sealed
			{
				m_xpos = value.X;
				m_ypos = value.Y;
			}
		}

		property System::Drawing::Rectangle Bounds
		{
			virtual System::Drawing::Rectangle get() sealed
			{
				return Rectangle(m_xpos,m_ypos,m_width,m_height);
			}

			virtual void set(System::Drawing::Rectangle value) sealed
			{
				m_xpos = value.X;
				m_ypos = value.Y;
				m_width = value.Width;
				m_height = value.Height;
			}
		}

		property System::Drawing::Color ForeColor
		{
			virtual System::Drawing::Color get() sealed
			{
				return m_fgcolor;
			}

			virtual void set(System::Drawing::Color value) sealed
			{
				m_fgcolor = value;
			}
		}

		property System::Drawing::Font ^Font
		{
			virtual System::Drawing::Font ^ get() sealed
			{
				return (System::Drawing::Font^)m_font->Clone();
			}

			virtual void set(System::Drawing::Font ^value) sealed
			{
				m_font = (System::Drawing::Font^)value->Clone();
			}
		}

		event MyEventHandler ^ OnInvalidate;

		virtual void Invalidate() sealed
		{
			OnInvalidate();
		}

	protected:
		virtual void OnPaint(PaintEventArgs ^args) abstract;
	};
}

ZLSControls_BaseClass.h
C++:
/*-------------------------------------------------------------------------------------------------
                                © 2006 by RDCS

    Projektname     : ZLS v3.0
    Modulname       : ZLSControlBaseClass.h
    Directory       : d:\zls\vis
    Author/Ersteller: RDCS/Leithner, RDCS/Kanovsky
    Erstellungsdatum: 2006-08-02

    Beschreibung: 
    HeaderFile für Basisklasse zur Ableitung aller ZLS Controls (Version 3)

    -------------------------------------------------------------------------------------------------*/
#pragma once

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;


#include "grid_control.h"

namespace ZLSControls 
{

	/// <summary>
	/// Summary for ZLSControlBaseClass
	/// </summary>
	public ref class ZLSControlBaseClass : public ZLSControls::GridControl
	//public ref class ZLSControlBaseClass : public Windows::Forms::Control
	{
	private: 
	// private members
		int m_id;
		int m_baid;
		int m_sidL;	// sender ID on the left side
		int m_sidR;	// sender ID on the right side
		int m_fweidL; // ZLSElement ID left
		int m_fweidR; // ZLSElement ID right
		int m_gridPositionRow;
		int m_gridPositionColumn;
		int m_layerPosition;
		int m_gridWidth;
		int m_gridHeight;
		float m_elementBreadth; // Default 5
		bool m_ctrlLocked;
		bool m_textVisible;
		bool m_stumpL;
		bool m_stumpR;
		bool m_initKey;
		bool m_destination; // true = end, false = begin  // Default = true
	
		System::Drawing::Color m_elementColor;	// Default black
		System::Drawing::Color m_elementLockColor;	// Default Red
		System::Drawing::Color m_elementStateColor;	// green/blue for State:reserved
	
		// for ZLSControl Text
		System::Windows::Forms::Label^  m_label1; 

	public:
	// public members
		enum class Resolution
			{
				res16 = 0, // 16*16 px
				res20 = 1, // 20*20 px
				res24 = 3  // 24*24 px
			};
		Resolution m_resolution;

		enum class DrawState
			{
				thin = 0, // thin
				straightBold = 1, // straight line bold
				bendBold = 2, // bend bold
				allBold = 3, // all bold
				thinLockedColored = 4, // Element locked colored @ state 1
				straightBoldLockedColored = 5, // Element locked colored @ state 2
				bendBoldLockedColored = 6, // Element locked colored @ state 3
				allBoldLockedColored = 7, // Element locked colored @ state 4
				thinLockedHatched = 8, // Element locked hatched @ state 1
				straightBoldLockedHatched = 9, // Element locked hatched @ state 2
				bendBoldLockedHatched = 10, // Element locked hatched @ state 3
				allBoldLockedHatched = 11,  // Element locked hatched @ state 4
				straightToBend = 12,
				bendToStraight = 13,
				straightToBendLockedColored = 14,
				bendToStraightLockedColored = 15,
				straightToBendHatchedColored = 16,
				bendToStraightHatchedColored = 17
			};
		DrawState m_drawState;

		enum class CtrlState
			{
				free = 0, // track section is free
				reserved = 1, // track section is reserved by another train
				busy = 2 // track section is busy at the moment
				//locked = 3	// track section is locked
			};
		CtrlState m_ctrlState;

		enum class FlankState
			{
				unused = 0,
				straight = 1,
				bend = 2,
				both = 3
			};
		FlankState m_flankState;
		
		enum class Alignment
			{
				TopLeft = 0,
				TopCenter = 1,
				TopRight = 2,
				MiddleLeft = 3,
				MiddleCenter = 4,
				MiddleRight = 5,
				BottomLeft = 6,
				BottomCenter = 7,
				BottomRight = 8
			};
		Alignment m_textAlign;

		enum class CtrlType
			{
				electric = 0,
				manual = 1,
				key = 2,
				fallBack = 3,
				remote = 4
			};
		CtrlType m_ctrlType;


	public:
	// public Methods
		// ZLSControlBaseClass Constructor
		ZLSControlBaseClass(int i_gridWidth,int i_gridHeight);

		void InitializeComponent(void);
		
		virtual void OnPaint(PaintEventArgs ^args) override
		{
		}

	protected:
		virtual int grid_field_width() sealed;

		virtual int grid_field_height() sealed;

	// Properties:
	public:
		[
			Category("ZLSControl Size"),
			Description("Elongation Factor for the height of the Control. Is multiplied with the Height"),
			DefaultValue(1)
		]
		property float ZLSElongationHeightFactor
		{
			void set (float value)
			{
				this->ZLSGridHeight *= value;
				//this->ZLSGridHeight = (float)Math::Round(value * ZLSGridHeight);

				this->Size = System::Drawing::Size(Convert::ToInt32(m_gridWidth*grid_field_width()),Convert::ToInt32(m_gridHeight*grid_field_height()));

				this->ZLSControls::ZLSControlBaseClass::ZLSTextAlignment::set(m_textAlign);
				Invalidate();
			}
		}

	public:
		[
			Category("ZLSControl Size"),
			Description("Elongation Factor for the width of the Control. Is multiplied with the Width"),
			DefaultValue(1)
		]
		property float ZLSElongationWidthFactor
		{
			void set (float value)
			{
				this->ZLSGridWidth *= value;
	
				this->Size = System::Drawing::Size(Convert::ToInt32(m_gridWidth*grid_field_width()),Convert::ToInt32(m_gridHeight*grid_field_height()));

				this->ZLSControls::ZLSControlBaseClass::ZLSTextAlignment::set(m_textAlign);
				Invalidate();
			}
		}

	public:
		[
			Category("ZLSControl Size"),
			Description("Specifies the mode for setting the size of the ZLSControl"),
			DefaultValue(Resolution::res16)
		]
		property Resolution ZLSResolution
		{
			Resolution get()
			{
				return this->m_resolution;
			}
			void set(Resolution value)
			{
				this->m_resolution = value;

				switch(m_resolution)
				{
					case ZLSControls::ZLSControlBaseClass::Resolution::res16:
						this->Size = System::Drawing::Size(this->m_gridWidth*16, this->m_gridHeight*16);
						break;
					case ZLSControls::ZLSControlBaseClass::Resolution::res20:
						this->Size = System::Drawing::Size(this->m_gridWidth*20, this->m_gridHeight*20);
						break;
					case ZLSControls::ZLSControlBaseClass::Resolution::res24:
						this->Size = System::Drawing::Size(this->m_gridWidth*24, this->m_gridHeight*24);
						break;
				}
				this->ZLSControls::ZLSControlBaseClass::ZLSTextAlignment::set(m_textAlign);
				Invalidate();
			}
		}

	public:
		[
			Category("ZLSControl Size"),
			Description("The Width of the ZLSControl in the grid")
		]
		property int ZLSGridWidth
		{
			int get()
			{
				return this->m_gridWidth;
			}
			void set(int value)
			{
				this->m_gridWidth = value;
				this->Width = m_gridWidth * grid_field_width();
			}
		}

	public:
		[
			Category("ZLSControl Size"),
			Description("The Width of the ZLSControl in the grid")
		]
		property int ZLSGridHeight
		{
			int get()
			{
				return this->m_gridHeight;
			}
			void set(int value)
			{
				this->m_gridHeight = value;
				this->Height = m_gridHeight * grid_field_height();
			}
		}

	public:
		[
			Category("ZLSControl Position"),
			Description("The Row Position of the ZLSControl in the grid")
		]
		property int ZLSGridPositionRow
		{
			int get()
			{
				return this->m_gridPositionRow;
			}
			void set(int value)
			{
				this->m_gridPositionRow = value;
				Invalidate();
			}
		}

	public:
		[
			Category("ZLSControl Position"),
			Description("The Column Position of the ZLSControl in the grid")
		]
		property int ZLSGridPositionColumn
		{
			int get()
			{
				return this->m_gridPositionColumn;
			}
			void set(int value)
			{
				this->m_gridPositionColumn = value;
				Invalidate();
			}
		}

	public:
		[
			Category("ZLSControl Colors"),
			Description("The color of this component"),
			DefaultValue("System::Drawing::Color::Black")
		]
		property System::Drawing::Color ZLSElementColor
		{
			System::Drawing::Color get()
			{
				return this->m_elementColor;
			}
			void set(System::Drawing::Color value)
			{
				this->m_elementColor = value;
				Invalidate();
			}

		}

	public:
		[
			Category("ZLSControl Colors"),
			Description("The color of this component, if its locked"),
			DefaultValue("Red")
		]
		property System::Drawing::Color ZLSElementLockColor
		{
			System::Drawing::Color get()
			{
				return this->m_elementLockColor;
			}
			void set(System::Drawing::Color value)
			{
				this->m_elementLockColor = value;
				Invalidate();
			}
		}

	public:
		[
			Category("ZLSControl Colors"),
			Description("specifies the color of this component, if its reserved"),
			DefaultValue("System::Drawing::Color::Blue")
		]
		property System::Drawing::Color ZLSElementStateColor
		// Blue or Green, depends on m_destination
		{
			System::Drawing::Color get()
			{
				return this->m_elementStateColor;
			}
			void set(System::Drawing::Color value)
			{
				this->m_elementStateColor = value;
				Invalidate();
			}
		}

	public:
		[
			Category("ZLSControl Text"),
			Description("The text of the ZLSControl"),
			DefaultValue(L"Text")
		]
		property System::String^ ZLSText
		{
			System::String^ get()
			{
				return this->m_label1->Text;
			}
			void set(System::String^ value)
			{
				this->m_label1->Text = value;
				this->ZLSTextAlignment::set(m_textAlign);
				Invalidate();
			}
		}

	public:
		[
			Category("ZLSControl Text"),
			Description("Sets, if the Text is visible"),
			DefaultValue(false)
		]
		property bool ZLSTextVisible
		{
			bool get()
			{
				//return this->m_label1->Visible;
				return this->m_textVisible;
			}
			void set(bool value)
			{
				//this->m_label1->Visible = value;
				this->m_textVisible = value;
			}
		}

	public:
		[
			Category("ZLSControl Text"),
			Description("Set the Location of the Text")
		]
		property System::Drawing::Point ZLSTextLocation
		{
			System::Drawing::Point get()
			{
				return this->m_label1->Location;
			}
			void set(System::Drawing::Point value)
			{
				this->m_label1->Location = value;
				this->Invalidate();
			}
		}

		public:
		[
			Category("ZLSControl Text"),
			Description("Set the Alignment of the Text")
		]
		property Alignment ZLSTextAlignment
		{
			Alignment get()
			{
				return this->m_textAlign;
			}
			void set(Alignment value)
			{
				this->m_textAlign = value;

				switch(m_textAlign)
				{
					case ZLSControls::ZLSControlBaseClass::Alignment::TopLeft:
						this->m_label1->Location = System::Drawing::Point(0,-2);
						break;
					case ZLSControls::ZLSControlBaseClass::Alignment::TopCenter:
						this->m_label1->Location = System::Drawing::Point((this->Width-this->m_label1->Width)/2,-2);
						break;
					case ZLSControls::ZLSControlBaseClass::Alignment::TopRight:
						this->m_label1->Location = System::Drawing::Point(this->Width-this->m_label1->Width,-2);
						break;
					case ZLSControls::ZLSControlBaseClass::Alignment::MiddleLeft:
						this->m_label1->Location = System::Drawing::Point(0,(this->Height-this->m_label1->Height)/2);
						break;
					case ZLSControls::ZLSControlBaseClass::Alignment::MiddleCenter:
						this->m_label1->Location = System::Drawing::Point((this->Width-this->m_label1->Width)/2,(this->Height-this->m_label1->Height)/2);
						break;
					case ZLSControls::ZLSControlBaseClass::Alignment::MiddleRight:
						this->m_label1->Location = System::Drawing::Point(this->Width-this->m_label1->Width,(this->Height-this->m_label1->Height)/2);
						break;
					case ZLSControls::ZLSControlBaseClass::Alignment::BottomLeft:
						this->m_label1->Location = System::Drawing::Point(0,this->Height-this->m_label1->Height+2);
						break;
					case ZLSControls::ZLSControlBaseClass::Alignment::BottomCenter:
						this->m_label1->Location = System::Drawing::Point((this->Width-this->m_label1->Width)/2,this->Height-this->m_label1->Height+2);
						break;
					case ZLSControls::ZLSControlBaseClass::Alignment::BottomRight:
						this->m_label1->Location = System::Drawing::Point(this->Width-this->m_label1->Width,this->Height-this->m_label1->Height+2);
						break;
				}
				this->Invalidate();
			}
		}

/*	public:
		[
			Category("ZLSControl Text"),
			Description("Set the background color of the text") // = TRANSPARENT
		]
		property System::Drawing::Color ZLSTextBackColor
		{
			System::Drawing::Color get()
			{
				return this->m_label1->BackColor;
			}
			void set(System::Drawing::Color value)
			{
				this->m_label1->BackColor = value;
				this->Invalidate();
			}
		}*/

/*	public:
		[
			Category("ZLSControl Text"),
			Description("Set the font of the text") // = FORE COLOR
		]
		property System::Drawing::Font^ ZLSTextFont
		{
			System::Drawing::Font^ get()
			{
				return this->m_label1->Font;
			}
			void set(System::Drawing::Font^ value)
			{
				this->m_label1->Font = value;
				this->Invalidate();
			}
		}*/

	public:
		[
			Category("ZLSControl States"),
			Description("Sets if the track section is busy, free, or reserved"),
			DefaultValue(CtrlState::free)
		]
		property CtrlState ZLSCtrlState
		{
			CtrlState get()
			{
				return this->m_ctrlState;
			}
			void set(CtrlState value)
			{
				this->m_ctrlState = value;

				switch(m_ctrlState)
				{
					case ZLSControls::ZLSControlBaseClass::CtrlState::free:
						ZLSControls::ZLSControlBaseClass::ZLSElementColor::set(System::Drawing::Color::Black);
						break;
					case ZLSControls::ZLSControlBaseClass::CtrlState::reserved:
						ZLSControls::ZLSControlBaseClass::ZLSElementColor::set(ZLSControls::ZLSControlBaseClass::ZLSElementStateColor::get());
						break;
					case ZLSControls::ZLSControlBaseClass::CtrlState::busy:
						ZLSControls::ZLSControlBaseClass::ZLSElementColor::set(System::Drawing::Color::Red);
						break;
					/*case ZLSControls::ZLSControlBaseClass::CtrlState::locked:
						ZLSControls::ZLSControlBaseClass::ZLSElementColor::set(System::Drawing::Color::Black);
						break;*/
				}
				Invalidate();
			}
		}

	public:
		[
			Category("ZLSControl States"),
			Description("Specifies, the Status of the Control"),
			DefaultValue(FlankState::unused)
		]
		property FlankState ZLSFlankState
		{
			FlankState get()
			{
				return this->m_flankState;
			}
			void set(FlankState value)
			{
				this->m_flankState = value;

				switch(m_flankState)
				{
					case ZLSControls::ZLSControlBaseClass::FlankState::unused:
						if(m_ctrlLocked == true)
							ZLSControls::ZLSControlBaseClass::ZLSDrawState::set(DrawState::thinLockedColored);
						else
							ZLSControls::ZLSControlBaseClass::ZLSDrawState::set(DrawState::thin);
						break;
					case ZLSControls::ZLSControlBaseClass::FlankState::straight:
						if(m_ctrlLocked == true)
							ZLSControls::ZLSControlBaseClass::ZLSDrawState::set(DrawState::straightBoldLockedColored);
						else
							ZLSControls::ZLSControlBaseClass::ZLSDrawState::set(DrawState::straightBold);
						break;
					case ZLSControls::ZLSControlBaseClass::FlankState::bend:
						if(m_ctrlLocked == true)
							ZLSControls::ZLSControlBaseClass::ZLSDrawState::set(DrawState::bendBoldLockedColored);
						else
							ZLSControls::ZLSControlBaseClass::ZLSDrawState::set(DrawState::bendBold);
						break;

					case ZLSControls::ZLSControlBaseClass::FlankState::both:
						if(m_ctrlLocked == true)
							ZLSControls::ZLSControlBaseClass::ZLSDrawState::set(DrawState::allBoldLockedColored);
						else
							ZLSControls::ZLSControlBaseClass::ZLSDrawState::set(DrawState::allBold);
						break;
				}

				Invalidate();
			}
		}

	public:
		[
			Category("ZLSControl States"),
			Description("Specifies, how the Control has to look like"),
			DefaultValue(DrawState::thin)
		]
		property DrawState ZLSDrawState
		{
			DrawState get()
			{
				return this->m_drawState;
			}
			void set(DrawState value)
			{
				this->m_drawState = value;
				Invalidate();
			}
		}

	public:
		[
			Category("ZLSControl States"),
			Description("Specifies, if the ZLSControl is locked"),
			DefaultValue(false)
		]
		property bool ZLSControlIsLocked
		{
			bool get()
			{
				return this->m_ctrlLocked;
			}
			void set(bool value)
			{
				this->m_ctrlLocked = value;

				ZLSControls::ZLSControlBaseClass::ZLSFlankState::set(m_flankState);
				
				/*switch(m_flankState)
				{
					case ZLSControls::ZLSControlBaseClass::FlankState::unused:
						ZLSControls::ZLSControlBaseClass::ZLSDrawState::set(DrawState::thin);
						break;
					case ZLSControls::ZLSControlBaseClass::FlankState::straight:
						ZLSControls::ZLSControlBaseClass::ZLSDrawState::set(DrawState::straightBold);
						break;
					case ZLSControls::ZLSControlBaseClass::FlankState::bend:
						ZLSControls::ZLSControlBaseClass::ZLSDrawState::set(DrawState::bendBold);
						break;

					case ZLSControls::ZLSControlBaseClass::FlankState::both:
						ZLSControls::ZLSControlBaseClass::ZLSDrawState::set(DrawState::allBold);
						break;
				}*/

				Invalidate();
			}
		}

	public:
		[
			Category("ZLSControl ID"),
			Description("Specifies the ID of the ZLSControl"),
			DefaultValue(0)
		]
		property int ZLSControlID
		{
			int get()
			{
				return this->m_id;
			}
			void set(int value)
			{
				try
				{
					if (value < 0)
					value = value*-1;

					this->m_id = value;
					// The Invalidate method invokes the OnPaint method
					Invalidate();
				}
				catch (System::Exception^ e)
				{
					this->m_id = 0;
					MessageBox::Show("Control konnte nicht gezeichnet werden!" + e);
					// Error handling
				}
			}
		}

	public:
		[
			Category("ZLSControl ID"),
			Description("The BAID of the ZLSControl"),
			DefaultValue(0)
		]
		property int ZLSBAID
		{
			int get()
			{
				return this->m_baid;
			}
			void set(int value)
			{
				if (value < 0)
				value = value*-1;

				this->m_baid = value;
			}
		}

	public:
		[
			Category("ZLSControl ID"),
			Description("The ID of the left sender"),
			DefaultValue(0)
		]
		property int ZLSSIDL
		{
			int get()
			{
				return this->m_sidL;
			}
			void set(int value)
			{
				if (value < 0)
				value = value*-1;

				this->m_sidL = value;
			}
		}

	public:
		[
			Category("ZLSControl ID"),
			Description("The ID of the right sender"),
			DefaultValue(0)
		]
		property int ZLSSIDR
		{
			int get()
			{
				return this->m_sidR;
			}
			void set(int value)
			{
				if (value < 0)
				value = value*-1;

				this->m_sidR = value;
			}
		}

	public:
		[
			Category("ZLSControl ID"),
			Description("The ID of the right ZLSElement"),
			DefaultValue(0)
		]
		property int ZLSFWEIDR
		{
			int get()
			{
				return this->m_fweidR;
			}
			void set(int value)
			{
				if (value < 0)
				value = value*-1;

				this->m_fweidR = value;
			}
		}

	public:
		[
			Category("ZLSControl ID"),
			Description("The ID of the left ZLSElement"),
			DefaultValue(0)
		]
		property int ZLSFWEIDL
		{
			int get()
			{
				return this->m_fweidL;
			}
			void set(int value)
			{
				if (value < 0)
				value = value*-1;

				this->m_fweidL = value;
			}
		}

	public:
		[
			Category("ZLSControl Properties"),
			Description("Sets the Breadth of the ZLSControl"),
			DefaultValue(5)
		]
		property float ZLSElementBreadth
		{
			float get()
			{
				return this->m_elementBreadth;
			}
			void set(float value)
			{
				this->m_elementBreadth = value;
				Invalidate();
			}
		}

	public:
		[
			Category("ZLSControl Properties"),
			Description("set if the rail is a stump on the left side")
		]
		property bool ZLSIsStumpLeft
		{
			bool get()
			{
				return this->m_stumpL;
			}
			void set(bool value)
			{
				this->m_stumpL = value;
				Invalidate();
			}
		}

		public:
		[
			Category("ZLSControl Properties"),
			Description("set if the rail is a stump on the right side")
		]
		property bool ZLSIsStumpRight
		{
			bool get()
			{
				return this->m_stumpR;
			}
			void set(bool value)
			{
				this->m_stumpR = value;
				Invalidate();
			}
		}

	public:
		[
			Category("ZLSControl Position"),
			Description("specifies in which Layer the ZLSControl is set"),
			DefaultValue(1)
		]
		property int ZLSLayerPosition
		{
			int get()
			{
				return this->m_layerPosition;
			}
			void set(int value)
			{
				this->m_layerPosition = value;
				Invalidate();
			}
		}

		
	public:
		[
			Category("ZLSControl Properties"),
			Description("The ZLSControl Type")
		]
		property CtrlType ZLSControlType
		{
			CtrlType get()
			{
				return this->m_ctrlType;
			}
			void set(CtrlType value)
			{
				this->m_ctrlType = value;

				if (m_ctrlType == ZLSControls::ZLSControlBaseClass::CtrlType::key)
					m_initKey = true;
			}
		}

	public:
		[
			Category("ZLSControl Properties"),
			Description("Specifies the Destination of the Train. true is end, false is start"),
			DefaultValue(true)
		]
		property bool ZLSDestinationIsEnd
		{
			bool get()
			{
				return this->m_destination;
			}
			void set(bool value)
			{
				this->m_destination = value;

				if(m_destination == false)
					ZLSControls::ZLSControlBaseClass::ZLSElementStateColor::set(System::Drawing::Color::Blue);
				else
					ZLSControls::ZLSControlBaseClass::ZLSElementStateColor::set(System::Drawing::Color::Green);

				ZLSControls::ZLSControlBaseClass::ZLSCtrlState::set(m_ctrlState);
			}
		}

	//ZLSBaseClass Destructor
	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~ZLSControlBaseClass()
		{
			if (components)
			{
				delete components;
			}
		}

	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>
		System::ComponentModel::Container ^components;

#pragma 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>

#pragma endregion
	};
}

hm... zuviel...

2.Post:
 
Zurück