Click here to Skip to main content
11,796,394 members (70,893 online)
Click here to Skip to main content
Add your own
alternative version

An XML- and State Machine-based Design of a WinForms Control

, 1 Dec 2002 73.5K 1K 45
Usage of state machine and comprehensive XML description of control helps its user to considerably simplify control handling code.
<?xml version="1.0" encoding="utf-8"?>
<OGControl Name="Map" InitDockStyle="Bottom" DockStyle="Top" BackColor="LightGray" Width="394" Height="424" CaptionHeight="16" Rotate="No" ResourcePath="res\\" ActiveCursor="Hand.cur">
  <CaptionStyle BackColor="DarkGreen" TextColor="LightGray" Bold="Yes" Italic="No" TextSize="10" />
  <MaxControlStates Value="4" />
  <InitControlState Value="0" />
  <Element Type="OGCVisualElement" Name="" HorizX="0" HorizY="-11" VertX="0" VertY="-11">
    <State Name="Map" FileName="Baltia" FileExt="jpg" />
    <StateTransition v0="0" v1="0" v2="0" v3="0" />
  <Element Type="OGCVisualElement" Name="ESTONIA" HorizX="0" HorizY="-11" VertX="0" VertY="-11">
    <State Name="Non-Selected" FileName="Estonia0" FileExt="gif" />
    <State Name="Selected" FileName="Estonia1" FileExt="gif" />
    <StateTransition v0="1" v1="1" v2="1" v3="1" v4="1" v5="1" v6="1" v7="1" />
  <Element Type="OGCVisualElement" Name="LATVIA" HorizX="0" HorizY="-11" VertX="0" VertY="-11">
    <State Name="Non-Selected" FileName="Latvia0" FileExt="gif" />
    <State Name="Selected" FileName="Latvia1" FileExt="gif" />
    <StateTransition v0="2" v1="2" v2="2" v3="2" v4="2" v5="2" v6="2" v7="2" />
  <Element Type="OGCVisualElement" Name="LITHUANIA" HorizX="0" HorizY="-11" VertX="0" VertY="-11">
    <State Name="Non-Selected" FileName="Lithuania0" FileExt="gif" />
    <State Name="Selected" FileName="Lithuania1" FileExt="gif" />
    <StateTransition v0="3" v1="3" v2="3" v3="3" v4="3" v5="3" v6="3" v7="3" />
  <Element Type="OGCComboBox" Name="ComboBoxCountry" HorizX="420" HorizY="30" VertX="30" VertY="470" Width="100" Height="10">
    <State Name="Country:______" />
    <State Name="Estonia" />
    <State Name="Latvia" />
    <State Name="Lithuania" />
    <StateTransition m0_0="0" m0_1="1" m0_2="2" m0_3="3" m1_0="0" m1_1="1" m1_2="2" m1_3="3" m2_0="0" m2_1="1" m2_2="2" m2_3="3" m3_0="0" m3_1="1" m3_2="2" m3_3="3" m4_0="0" m4_1="1" m4_2="2" m4_3="3" m5_0="0" m5_1="1" m5_2="2" m5_3="3" m6_0="0" m6_1="1" m6_2="2" m6_3="3" m7_0="0" m7_1="1" m7_2="2" m7_3="3" />
  <Element Type="OGCVisualElement" Name="Country Flag" HorizX="420" HorizY="70" VertX="150" VertY="470">
    <State Name="Country" FileName="NoFlag" FileExt="gif" />
    <State Name="Estonia" FileName="EstoniaFlag" FileExt="gif" />
    <State Name="Latvia" FileName="LatviaFlag" FileExt="gif" />
    <State Name="Lithuania" FileName="LithuaniaFlag" FileExt="gif" />
  <ControlStatesMatrixElement ControlState="0" Element="1" Value="0" />
  <ControlStatesMatrixElement ControlState="0" Element="2" Value="0" />
  <ControlStatesMatrixElement ControlState="0" Element="3" Value="0" />
  <ControlStatesMatrixElement ControlState="0" Element="4" Value="0" />
  <ControlStatesMatrixElement ControlState="0" Element="5" Value="0" />
  <ControlStatesMatrixElement ControlState="1" Element="1" Value="1" />
  <ControlStatesMatrixElement ControlState="1" Element="2" Value="0" />
  <ControlStatesMatrixElement ControlState="1" Element="3" Value="0" />
  <ControlStatesMatrixElement ControlState="1" Element="4" Value="1" />
  <ControlStatesMatrixElement ControlState="1" Element="5" Value="1" />
  <ControlStatesMatrixElement ControlState="2" Element="1" Value="0" />
  <ControlStatesMatrixElement ControlState="2" Element="2" Value="1" />
  <ControlStatesMatrixElement ControlState="2" Element="3" Value="0" />
  <ControlStatesMatrixElement ControlState="2" Element="4" Value="2" />
  <ControlStatesMatrixElement ControlState="2" Element="5" Value="2" />
  <ControlStatesMatrixElement ControlState="3" Element="1" Value="0" />
  <ControlStatesMatrixElement ControlState="3" Element="2" Value="0" />
  <ControlStatesMatrixElement ControlState="3" Element="3" Value="1" />
  <ControlStatesMatrixElement ControlState="3" Element="4" Value="3" />
  <ControlStatesMatrixElement ControlState="3" Element="5" Value="3" />

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.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Igor Ladnik
Israel Israel

  • Nov 2010: Code Project Contests - Windows Azure Apps - Winner
  • Feb 2011: Code Project Contests - Windows Azure Apps - Grand Prize Winner

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.151002.1 | Last Updated 2 Dec 2002
Article Copyright 2002 by Igor Ladnik
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid