Click here to Skip to main content
11,797,355 members (80,121 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="Green" TextColor="LightGray" Bold="Yes" Italic="No" TextSize="10" />
  <MaxControlStates Value="8" />
  <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" v4="0" v5="0" v6="0" v7="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" />
  <Element Type="OGCVisualElement" Name="Weather" HorizX="0" HorizY="0" VertX="0" VertY="0">
    <State Name="Weather" FileName="Weather" FileExt="gif" />
    <State Name="Sunny" FileName="Sunny" FileExt="gif" />
    <State Name="Raining" FileName="Raining" FileExt="gif" />
    <State Name="Mixed" FileName="Mixed" FileExt="gif" />
    <StateTransition v0="5" v1="6" v2="7" v3="4" v4="5" v5="6" v6="7" v7="4" />
  <Element Type="OGCComboBox" Name="ComboBoxWeather" HorizX="420" HorizY="150" VertX="280" VertY="470" Width="100" Height="10">
    <State Name="Weather:______" />
    <State Name="Sunny" />
    <State Name="Raining" />
    <State Name="Mixed" />
    <StateTransition m0_0="4" m0_1="5" m0_2="6" m0_3="7" m1_0="4" m1_1="5" m1_2="6" m1_3="7" m2_0="4" m2_1="5" m2_2="6" m2_3="7" m3_0="4" m3_1="5" m3_2="6" m3_3="7" m4_0="4" m4_1="5" m4_2="6" m4_3="7" m5_0="4" m5_1="5" m5_2="6" m5_3="7" m6_0="4" m6_1="5" m6_2="6" m6_3="7" m7_0="4" m7_1="5" m7_2="6" m7_3="7" />
  <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" />
  <ControlStatesMatrixElement ControlState="4" Element="6" Value="0" />
  <ControlStatesMatrixElement ControlState="5" Element="6" Value="1" />
  <ControlStatesMatrixElement ControlState="6" Element="6" Value="2" />
  <ControlStatesMatrixElement ControlState="7" Element="6" Value="3" />
  <ControlStatesMatrixElement ControlState="4" Element="7" Value="0" />
  <ControlStatesMatrixElement ControlState="5" Element="7" Value="1" />
  <ControlStatesMatrixElement ControlState="6" Element="7" Value="2" />
  <ControlStatesMatrixElement ControlState="7" Element="7" 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