Click here to Skip to main content
15,896,524 members
Articles / Programming Languages / C#

The Application Automation Layer - Using XML to generate Menus

Rate me:
Please Sign up or sign in to vote.
4.81/5 (56 votes)
5 May 200313 min read 238.8K   2.6K   194  
Exploring the issues of menu management as specified externally via an XML file, in the context of status bars, toolbars, and events.
<NewDataSet>
  <Form>
    <Name>SDI1</Name>
    <Caption>SDI Form</Caption>
    <ControlSetName>Test</ControlSetName>
    <FormDimensions>
      <XorWidth>10</XorWidth>
      <YorHeight>10</YorHeight>
    </FormDimensions>
    <FormDimensions>
      <XorWidth>720</XorWidth>
      <YorHeight>600</YorHeight>
    </FormDimensions>
  </Form>
  <Form>
    <Name>MDI1</Name>
    <Caption>MDI Form</Caption>
    <DataDomainName>MDIForm</DataDomainName>
    <ControlSetName>MDIParentForm</ControlSetName>
    <FormDimensions>
      <XorWidth>10</XorWidth>
      <YorHeight>400</YorHeight>
    </FormDimensions>
    <FormDimensions>
      <XorWidth>500</XorWidth>
      <YorHeight>300</YorHeight>
    </FormDimensions>
  </Form>
  <Form>
    <Name>TabPage1</Name>
    <Caption>Page 1</Caption>
    <ControlSetName>TB1CtrlSet</ControlSetName>
    <FormDimensions />
  </Form>
  <Form>
    <Name>TabPage2</Name>
    <Caption>Page 2</Caption>
    <ControlSetName>TB2CtrlSet</ControlSetName>
    <FormDimensions />
  </Form>
  <Form>
    <Name>MDIChild1</Name>
    <Caption>Child 1</Caption>
    <DataDomainName>Child1</DataDomainName>
    <ControlSetName>MDICtrlSet</ControlSetName>
    <FormDimensions>
      <XorWidth>10</XorWidth>
      <YorHeight>10</YorHeight>
    </FormDimensions>
    <FormDimensions>
      <XorWidth>200</XorWidth>
      <YorHeight>200</YorHeight>
    </FormDimensions>
  </Form>
  <Form>
    <Name>MDIChild2</Name>
    <Caption>Child 2</Caption>
    <DataDomainName>Child2</DataDomainName>
    <ControlSetName>MDICtrlSet</ControlSetName>
    <FormDimensions>
      <XorWidth>220</XorWidth>
      <YorHeight>20</YorHeight>
    </FormDimensions>
    <FormDimensions>
      <XorWidth>200</XorWidth>
      <YorHeight>200</YorHeight>
    </FormDimensions>
  </Form>
  <ControlSet>
    <Name>MDIParentForm</Name>
    <ControlInfo>
      <Name>sb1</Name>
      <Control>STATUSBAR</Control>
      <ControlDimensions>
        <XorWidth>0</XorWidth>
        <YorHeight>0</YorHeight>
      </ControlDimensions>
      <ControlDimensions>
        <XorWidth>0</XorWidth>
        <YorHeight>0</YorHeight>
      </ControlDimensions>
      <Header>
        <Name>MenuHelp</Name>
        <Width>0</Width>
      </Header>
      <Header>
        <Name>AutoUpdate1</Name>
        <Width>100</Width>
        <Options>ddd, MMM d yyyy</Options>
      </Header>
      <Header>
        <Name>AutoUpdate2</Name>
        <Width>100</Width>
        <Options>hh:mm:ss tt</Options>
      </Header>
    </ControlInfo>
    <ControlInfo>
      <Name>tb1</Name>
      <Control>ToolBar</Control>
      <ControlDimensions>
        <XorWidth>0</XorWidth>
        <YorHeight>0</YorHeight>
      </ControlDimensions>
      <ControlDimensions>
        <XorWidth>0</XorWidth>
        <YorHeight>0</YorHeight>
      </ControlDimensions>
      <Header>
        <Name>tb1</Name>
        <ColumnInfo>
          <CI_Icon>tileH.ico</CI_Icon>
          <CI_Caption>Tile H</CI_Caption>
          <Association>TileH</Association>
        </ColumnInfo>
        <ColumnInfo>
          <CI_Icon>tileV.ico</CI_Icon>
          <CI_Caption>Tile V</CI_Caption>
          <Association>TileV</Association>
        </ColumnInfo>
        <ColumnInfo>
          <CI_Icon>cascade.ico</CI_Icon>
          <CI_Caption>Cascade</CI_Caption>
          <Association>Cascade</Association>
        </ColumnInfo>
        <ColumnInfo>
          <CI_Icon>new.ico</CI_Icon>
          <CI_Caption>New</CI_Caption>
        </ColumnInfo>
        <ColumnInfo>
          <CI_Icon>open.ico</CI_Icon>
          <CI_Caption>Open</CI_Caption>
        </ColumnInfo>
        <ColumnInfo>
          <CI_Icon>save.ico</CI_Icon>
          <CI_Caption>Save</CI_Caption>
        </ColumnInfo>
        <ColumnInfo>
          <CI_Icon>exit.ico</CI_Icon>
          <CI_Caption>Exit</CI_Caption>
          <Association>Exit</Association>
        </ColumnInfo>
      </Header>
    </ControlInfo>
  </ControlSet>
  <ControlSet>
    <Name>Test</Name>
    <ControlInfo>
      <Name>label1</Name>
      <Control>Label</Control>
      <Caption>A Label</Caption>
      <Justification>Center</Justification>
      <ControlDimensions>
        <XorWidth>10</XorWidth>
        <YorHeight>10</YorHeight>
      </ControlDimensions>
      <ControlDimensions>
        <XorWidth>100</XorWidth>
        <YorHeight>15</YorHeight>
      </ControlDimensions>
      <Header />
    </ControlInfo>
    <ControlInfo>
      <Name>ed1</Name>
      <Control>EditBox</Control>
      <VarName>edVar</VarName>
      <RW>Read-Write</RW>
      <Tooltip>An edit box.</Tooltip>
      <ControlDimensions>
        <XorWidth>110</XorWidth>
        <YorHeight>10</YorHeight>
      </ControlDimensions>
      <ControlDimensions>
        <XorWidth>100</XorWidth>
        <YorHeight>20</YorHeight>
      </ControlDimensions>
      <Header />
    </ControlInfo>
    <ControlInfo>
      <Name>cb1</Name>
      <Control>ComboBox</Control>
      <VarName>cbIdx</VarName>
      <ListName>cbList</ListName>
      <RW>Read-Write</RW>
      <Tooltip>A combo box.</Tooltip>
      <ControlDimensions>
        <XorWidth>10</XorWidth>
        <YorHeight>25</YorHeight>
      </ControlDimensions>
      <ControlDimensions>
        <XorWidth>100</XorWidth>
        <YorHeight>200</YorHeight>
      </ControlDimensions>
      <Header>
        <Name>ID</Name>
        <Width>0</Width>
      </Header>
      <Header>
        <Name>Data</Name>
        <Width>0</Width>
        <Visible>true</Visible>
      </Header>
    </ControlInfo>
    <ControlInfo>
      <Name>lb1</Name>
      <Control>ListBox</Control>
      <VarName>lbIdx</VarName>
      <ListName>lbList</ListName>
      <RW>Read-Write</RW>
      <Tooltip>A list box.</Tooltip>
      <ControlDimensions>
        <XorWidth>110</XorWidth>
        <YorHeight>40</YorHeight>
      </ControlDimensions>
      <ControlDimensions>
        <XorWidth>100</XorWidth>
        <YorHeight>150</YorHeight>
      </ControlDimensions>
      <Header>
        <Name>ID</Name>
        <Width>0</Width>
      </Header>
      <Header />
      <Header>
        <Name>Name</Name>
        <Width>0</Width>
        <Visible>true</Visible>
      </Header>
    </ControlInfo>
    <ControlInfo>
      <Name>lv1</Name>
      <Control>ListView</Control>
      <VarName>lvIdx</VarName>
      <ListName>lvList</ListName>
      <RW>Read-Write</RW>
      <Tooltip>A list view.</Tooltip>
      <ControlDimensions>
        <XorWidth>215</XorWidth>
        <YorHeight>25</YorHeight>
      </ControlDimensions>
      <ControlDimensions>
        <XorWidth>225</XorWidth>
        <YorHeight>150</YorHeight>
      </ControlDimensions>
      <Header>
        <Name>ID</Name>
        <Width>0</Width>
        <Justification>Left</Justification>
      </Header>
      <Header>
        <Name>First Name</Name>
        <Width>100</Width>
        <Justification>Left</Justification>
        <Visible>true</Visible>
      </Header>
      <Header>
        <Name>Last Name</Name>
        <Width>100</Width>
        <Justification>Left</Justification>
        <Visible>true</Visible>
      </Header>
    </ControlInfo>
    <ControlInfo>
      <Name>btn1</Name>
      <Control>Button</Control>
      <Caption>Button</Caption>
      <Tooltip>A button.</Tooltip>
      <ControlDimensions>
        <XorWidth>10</XorWidth>
        <YorHeight>220</YorHeight>
      </ControlDimensions>
      <ControlDimensions>
        <XorWidth>80</XorWidth>
        <YorHeight>25</YorHeight>
      </ControlDimensions>
      <Header />
    </ControlInfo>
    <ControlInfo>
      <Name>rb1</Name>
      <Control>RadioButton</Control>
      <Caption>Radio 1</Caption>
      <VarName>rbIdx</VarName>
      <RW>Read-Write</RW>
      <Parent>gb1</Parent>
      <Tooltip>A radio button.</Tooltip>
      <ControlDimensions>
        <XorWidth>10</XorWidth>
        <YorHeight>15</YorHeight>
      </ControlDimensions>
      <ControlDimensions>
        <XorWidth>100</XorWidth>
        <YorHeight>20</YorHeight>
      </ControlDimensions>
      <Header />
    </ControlInfo>
    <ControlInfo>
      <Name>rb2</Name>
      <Control>RadioButton</Control>
      <Caption>Radio 2</Caption>
      <RW>Read-Write</RW>
      <Parent>gb1</Parent>
      <ControlDimensions>
        <XorWidth>10</XorWidth>
        <YorHeight>35</YorHeight>
      </ControlDimensions>
      <ControlDimensions>
        <XorWidth>100</XorWidth>
        <YorHeight>20</YorHeight>
      </ControlDimensions>
      <Header />
    </ControlInfo>
    <ControlInfo>
      <Name>ck1</Name>
      <Control>CheckBox</Control>
      <Caption>Check 1</Caption>
      <VarName>ckFlag</VarName>
      <RW>Read-Write</RW>
      <Parent>gb1</Parent>
      <Tooltip>A checkbox.</Tooltip>
      <ControlDimensions>
        <XorWidth>10</XorWidth>
        <YorHeight>55</YorHeight>
      </ControlDimensions>
      <ControlDimensions>
        <XorWidth>100</XorWidth>
        <YorHeight>20</YorHeight>
      </ControlDimensions>
      <Header />
    </ControlInfo>
    <ControlInfo>
      <Name>gb1</Name>
      <Control>GroupBox</Control>
      <Caption>Group Box</Caption>
      <ControlDimensions>
        <XorWidth>150</XorWidth>
        <YorHeight>220</YorHeight>
      </ControlDimensions>
      <ControlDimensions>
        <XorWidth>200</XorWidth>
        <YorHeight>100</YorHeight>
      </ControlDimensions>
      <Header />
    </ControlInfo>
    <ControlInfo>
      <Name>rb3</Name>
      <Control>RadioButton</Control>
      <Caption>Radio Button 3</Caption>
      <Parent>gb1</Parent>
      <ControlDimensions>
        <XorWidth>10</XorWidth>
        <YorHeight>75</YorHeight>
      </ControlDimensions>
      <ControlDimensions>
        <XorWidth>100</XorWidth>
        <YorHeight>20</YorHeight>
      </ControlDimensions>
      <Header />
    </ControlInfo>
    <ControlInfo>
      <Name>gb2</Name>
      <Control>GroupBox</Control>
      <Caption>Group Box 2</Caption>
      <ControlDimensions>
        <XorWidth>360</XorWidth>
        <YorHeight>220</YorHeight>
      </ControlDimensions>
      <ControlDimensions>
        <XorWidth>200</XorWidth>
        <YorHeight>100</YorHeight>
      </ControlDimensions>
      <Header />
    </ControlInfo>
    <ControlInfo>
      <Name>rb4</Name>
      <Control>RadioButton</Control>
      <Caption>RB4</Caption>
      <Parent>gb2</Parent>
      <ControlDimensions>
        <XorWidth>10</XorWidth>
        <YorHeight>15</YorHeight>
      </ControlDimensions>
      <ControlDimensions>
        <XorWidth>100</XorWidth>
        <YorHeight>20</YorHeight>
      </ControlDimensions>
      <Header />
    </ControlInfo>
    <ControlInfo>
      <Name>rb5</Name>
      <Control>RadioButton</Control>
      <Caption>RB5</Caption>
      <Parent>gb2</Parent>
      <ControlDimensions>
        <XorWidth>10</XorWidth>
        <YorHeight>35</YorHeight>
      </ControlDimensions>
      <ControlDimensions>
        <XorWidth>100</XorWidth>
        <YorHeight>20</YorHeight>
      </ControlDimensions>
      <Header />
    </ControlInfo>
    <ControlInfo>
      <Name>tc1</Name>
      <Control>TabControl</Control>
      <ControlDimensions>
        <XorWidth>10</XorWidth>
        <YorHeight>350</YorHeight>
      </ControlDimensions>
      <ControlDimensions>
        <XorWidth>300</XorWidth>
        <YorHeight>200</YorHeight>
      </ControlDimensions>
      <Header>
        <Name>TabPage1</Name>
      </Header>
      <Header>
        <Name>TabPage2</Name>
      </Header>
    </ControlInfo>
    <ControlInfo>
      <Name>sb1</Name>
      <Control>STATUSBAR</Control>
      <ControlDimensions>
        <XorWidth>0</XorWidth>
        <YorHeight>0</YorHeight>
      </ControlDimensions>
      <ControlDimensions>
        <XorWidth>0</XorWidth>
        <YorHeight>0</YorHeight>
      </ControlDimensions>
      <Header>
        <Name>MenuHelp</Name>
        <Width>0</Width>
      </Header>
      <Header>
        <Name>AutoUpdate1</Name>
        <Width>100</Width>
        <Options>ddd, MMM d yyyy</Options>
      </Header>
      <Header>
        <Name>AutoUpdate2</Name>
        <Width>100</Width>
        <Options>hh:mm:ss tt</Options>
      </Header>
    </ControlInfo>
    <ControlInfo>
      <Name>ol1</Name>
      <Control>OutlookBar</Control>
      <ControlDimensions>
        <XorWidth>575</XorWidth>
        <YorHeight>0</YorHeight>
      </ControlDimensions>
      <ControlDimensions>
        <XorWidth>120</XorWidth>
        <YorHeight>400</YorHeight>
      </ControlDimensions>
      <Header>
        <Name>Check In/Out</Name>
        <ColumnInfo>
          <CI_Icon>checkIn.ico</CI_Icon>
          <CI_Caption>Check In</CI_Caption>
        </ColumnInfo>
        <ColumnInfo>
          <CI_Icon>checkOut.ico</CI_Icon>
          <CI_Caption>Check Out</CI_Caption>
        </ColumnInfo>
        <ColumnInfo>
          <CI_Icon>vipCheckIn.ico</CI_Icon>
          <CI_Caption>VIP Check In</CI_Caption>
        </ColumnInfo>
      </Header>
      <Header>
        <Name>Status</Name>
        <ColumnInfo>
          <CI_Icon>stage.ico</CI_Icon>
          <CI_Caption>Stage</CI_Caption>
        </ColumnInfo>
        <ColumnInfo>
          <CI_Icon>vipRoom.ico</CI_Icon>
          <CI_Caption>VIP Room</CI_Caption>
        </ColumnInfo>
        <ColumnInfo>
          <CI_Icon>booths.ico</CI_Icon>
          <CI_Caption>Booths</CI_Caption>
        </ColumnInfo>
      </Header>
      <Header>
        <Name>Specials</Name>
        <ColumnInfo>
          <CI_Icon>clock.ico</CI_Icon>
          <CI_Caption>Event History</CI_Caption>
        </ColumnInfo>
        <ColumnInfo>
          <CI_Icon>specials.ico</CI_Icon>
          <CI_Caption>Specials</CI_Caption>
        </ColumnInfo>
      </Header>
    </ControlInfo>
  </ControlSet>
  <ControlSet>
    <Name>TB1CtrlSet</Name>
    <ControlInfo>
      <Name>lbl1</Name>
      <Control>Label</Control>
      <Caption>Page 1</Caption>
      <ControlDimensions>
        <XorWidth>10</XorWidth>
        <YorHeight>10</YorHeight>
      </ControlDimensions>
      <ControlDimensions>
        <XorWidth>100</XorWidth>
        <YorHeight>15</YorHeight>
      </ControlDimensions>
      <Header />
    </ControlInfo>
  </ControlSet>
  <ControlSet>
    <Name>TB2CtrlSet</Name>
    <ControlInfo>
      <Name>lbl1</Name>
      <Control>Label</Control>
      <Caption>Page 2</Caption>
      <ControlDimensions>
        <XorWidth>10</XorWidth>
        <YorHeight>10</YorHeight>
      </ControlDimensions>
      <ControlDimensions>
        <XorWidth>100</XorWidth>
        <YorHeight>15</YorHeight>
      </ControlDimensions>
      <Header />
    </ControlInfo>
  </ControlSet>
  <ControlSet>
    <Name>MDICtrlSet</Name>
    <ControlInfo>
      <Name>s1</Name>
      <Control>Label</Control>
      <Caption>Name:</Caption>
      <ControlDimensions>
        <XorWidth>10</XorWidth>
        <YorHeight>12</YorHeight>
      </ControlDimensions>
      <ControlDimensions>
        <XorWidth>50</XorWidth>
        <YorHeight>15</YorHeight>
      </ControlDimensions>
      <Header />
    </ControlInfo>
    <ControlInfo>
      <Name>ed1</Name>
      <Control>EditBox</Control>
      <VarName>edName</VarName>
      <ControlDimensions>
        <XorWidth>60</XorWidth>
        <YorHeight>10</YorHeight>
      </ControlDimensions>
      <ControlDimensions>
        <XorWidth>100</XorWidth>
        <YorHeight>20</YorHeight>
      </ControlDimensions>
      <Header />
    </ControlInfo>
  </ControlSet>
</NewDataSet>

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.

License

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


Written By
Architect Interacx
United States United States
Blog: https://marcclifton.wordpress.com/
Home Page: http://www.marcclifton.com
Research: http://www.higherorderprogramming.com/
GitHub: https://github.com/cliftonm

All my life I have been passionate about architecture / software design, as this is the cornerstone to a maintainable and extensible application. As such, I have enjoyed exploring some crazy ideas and discovering that they are not so crazy after all. I also love writing about my ideas and seeing the community response. As a consultant, I've enjoyed working in a wide range of industries such as aerospace, boatyard management, remote sensing, emergency services / data management, and casino operations. I've done a variety of pro-bono work non-profit organizations related to nature conservancy, drug recovery and women's health.

Comments and Discussions