EDN Admin
Well-known member
hi,
i will be using this code to bind my combobox(buildmachinecombobox):
<pre>DataSet dsmachine = new DataSet();[/code]
<br/>
<pre> public void PopulatebuildmachineXMLFile()
{
dsmachine.Clear();
dsmachine.ReadXml(@"C:GUIbuild.xml");
DataView dvmachine = dsmachine.Tables["machine"].DefaultView;
buildmachinecombobox.ItemsSource = dvmachine; //Sets the collection of items from which to populate
buildmachinecombobox.DisplayMemberPath = "value"; //Sets the path within an item to use for display
}[/code]
the build.xml looks like this:
<pre><build>
<machine>
<value>1</value>
</machine>
<machine>
<value>2</value>
</machine>
</build>[/code]
The thing about this application is that users will always edit the xml file instead of the code(to remove hardcoding). Therefore, if there is any new machines, users will edit the xml file and a new machine tag will be added into the xml file. For example,
if there is a machine 3 to be added, the xml file will look like this:
<pre><build><br/><br/> <machine><br/><br/> <value>1</value><br/><br/> </machine><br/><br/> <machine><br/><br/> <value>2</value><br/><br/> </machine><br/><br/> <machine><br/><br/> <value>3</value><br/><br/> </machine><br/><br/><br/></build>[/code]
I will be using the above example to populate another combobox called buildstreamcombobox. The portion of the build.xml file for buildstreamcombobox:
<pre><build>
<stream>
<value>6.0</value>
</stream>
<stream>
<value>6.1</value>
</stream>
<stream>
<value>6.2</value>
</stream>
</build>[/code]
<br/>
Then, if they select these twocombo box, upon a button click, they are suppose to open another xml file(checkout.xml) to obtain a command. This command is then executed. I used linq parsing to execute this command. This is how it is done for now:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; private <span style="color:Blue; void tab1nextButton_Click(<span style="color:Blue; object sender, RoutedEventArgs e)<br/> {<br/> <span style="color:Blue; var x = XElement.Load(<span style="color:#A31515; @"C:GUICheckout.xml");<br/> <span style="color:Blue; if (BuildmachineComboBox.SelectedIndex == 0 && BuildstreamComBoBox.SelectedIndex ==0)<br/> {<br/> <span style="color:Blue; var xElement = x.Element(<span style="color:#A31515; "buildmachine1").Element(<span style="color:#A31515; "checkout1");<br/> <span style="color:Blue; var p = <span style="color:Blue; new Process<br/> {<br/> StartInfo = <span style="color:Blue; new ProcessStartInfo(xElement.Attribute(<span style="color:#A31515; "exe").Value, xElement.Attribute(<span style="color:#A31515; "folder").Value)<br/> };<br/> p.Start();<br/> }<br/><br/> <span style="color:Blue; if (BuildmachineComboBox.SelectedIndex == 0 BuildstreamComBoBox.SelectedIndex ==1)<br/> {<br/> <span style="color:Blue; var xElement = x.Element(<span style="color:#A31515; "buildmachine1").Element(<span style="color:#A31515; "checkout2");<br/> <span style="color:Blue; var p = <span style="color:Blue; new Process<br/> {<br/> StartInfo = <span style="color:Blue; new ProcessStartInfo(xElement.Attribute(<span style="color:#A31515; "exe").Value, xElement.Attribute(<span style="color:#A31515; "folder").Value)<br/> };<br/> p.Start();<br/> }<br/> <span style="color:Blue; if (BuildmachineComboBox.SelectedIndex == 1 && Buildstream5ComboBox.SelectedIndex == 1)<br/> {<br/> <span style="color:Blue; var xElement = x.Element(<span style="color:#A31515; "buildmachine2").Element(<span style="color:#A31515; "checkout3");<br/> <span style="color:Blue; var p = <span style="color:Blue; new Process<br/> {<br/> StartInfo = <span style="color:Blue; new ProcessStartInfo(xElement.Attribute(<span style="color:#A31515; "exe").Value, xElement.Attribute(<span style="color:#A31515; "folder").Value)<br/> };<br/> p.Start();<br/> }<br/> }
[/code]
<br/>
The checkout.xml looks like this:
<pre> <buildmachine1>
<checkout1 exe="wco" folder=-f -R "C:/Work/6.70_Extensions/release/SASE Lab Tools/ANT Builds/"/>
<checkout2 exe="wco" folder=-f -R "C:/Work/7.00_Extensions/release/SASE Lab Tools/ANT Builds/"/>
</buildmachine1>
<buildmachine2>
<checkout3 exe="wco" folder=-f -R "C:/Work/7.10.00_Tip/release/SASE Lab Tools/ANT Builds/"/>
</buildmachine2>[/code]
<br/>
So because everything is done by using xml file, i cant possibly assign the combobox selected value ie this line:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; if (BuildmachineComboBox.SelectedIndex == 0 && BuildstreamComBoBox.SelectedIndex ==0)
[/code]
This is because my machines and streams always changes if the users edit the build.xml and the above would always need to be altered to suit the needs.
Anybody has any idea how to solve this issue?
View the full article
i will be using this code to bind my combobox(buildmachinecombobox):
<pre>DataSet dsmachine = new DataSet();[/code]
<br/>
<pre> public void PopulatebuildmachineXMLFile()
{
dsmachine.Clear();
dsmachine.ReadXml(@"C:GUIbuild.xml");
DataView dvmachine = dsmachine.Tables["machine"].DefaultView;
buildmachinecombobox.ItemsSource = dvmachine; //Sets the collection of items from which to populate
buildmachinecombobox.DisplayMemberPath = "value"; //Sets the path within an item to use for display
}[/code]
the build.xml looks like this:
<pre><build>
<machine>
<value>1</value>
</machine>
<machine>
<value>2</value>
</machine>
</build>[/code]
The thing about this application is that users will always edit the xml file instead of the code(to remove hardcoding). Therefore, if there is any new machines, users will edit the xml file and a new machine tag will be added into the xml file. For example,
if there is a machine 3 to be added, the xml file will look like this:
<pre><build><br/><br/> <machine><br/><br/> <value>1</value><br/><br/> </machine><br/><br/> <machine><br/><br/> <value>2</value><br/><br/> </machine><br/><br/> <machine><br/><br/> <value>3</value><br/><br/> </machine><br/><br/><br/></build>[/code]
I will be using the above example to populate another combobox called buildstreamcombobox. The portion of the build.xml file for buildstreamcombobox:
<pre><build>
<stream>
<value>6.0</value>
</stream>
<stream>
<value>6.1</value>
</stream>
<stream>
<value>6.2</value>
</stream>
</build>[/code]
<br/>
Then, if they select these twocombo box, upon a button click, they are suppose to open another xml file(checkout.xml) to obtain a command. This command is then executed. I used linq parsing to execute this command. This is how it is done for now:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; private <span style="color:Blue; void tab1nextButton_Click(<span style="color:Blue; object sender, RoutedEventArgs e)<br/> {<br/> <span style="color:Blue; var x = XElement.Load(<span style="color:#A31515; @"C:GUICheckout.xml");<br/> <span style="color:Blue; if (BuildmachineComboBox.SelectedIndex == 0 && BuildstreamComBoBox.SelectedIndex ==0)<br/> {<br/> <span style="color:Blue; var xElement = x.Element(<span style="color:#A31515; "buildmachine1").Element(<span style="color:#A31515; "checkout1");<br/> <span style="color:Blue; var p = <span style="color:Blue; new Process<br/> {<br/> StartInfo = <span style="color:Blue; new ProcessStartInfo(xElement.Attribute(<span style="color:#A31515; "exe").Value, xElement.Attribute(<span style="color:#A31515; "folder").Value)<br/> };<br/> p.Start();<br/> }<br/><br/> <span style="color:Blue; if (BuildmachineComboBox.SelectedIndex == 0 BuildstreamComBoBox.SelectedIndex ==1)<br/> {<br/> <span style="color:Blue; var xElement = x.Element(<span style="color:#A31515; "buildmachine1").Element(<span style="color:#A31515; "checkout2");<br/> <span style="color:Blue; var p = <span style="color:Blue; new Process<br/> {<br/> StartInfo = <span style="color:Blue; new ProcessStartInfo(xElement.Attribute(<span style="color:#A31515; "exe").Value, xElement.Attribute(<span style="color:#A31515; "folder").Value)<br/> };<br/> p.Start();<br/> }<br/> <span style="color:Blue; if (BuildmachineComboBox.SelectedIndex == 1 && Buildstream5ComboBox.SelectedIndex == 1)<br/> {<br/> <span style="color:Blue; var xElement = x.Element(<span style="color:#A31515; "buildmachine2").Element(<span style="color:#A31515; "checkout3");<br/> <span style="color:Blue; var p = <span style="color:Blue; new Process<br/> {<br/> StartInfo = <span style="color:Blue; new ProcessStartInfo(xElement.Attribute(<span style="color:#A31515; "exe").Value, xElement.Attribute(<span style="color:#A31515; "folder").Value)<br/> };<br/> p.Start();<br/> }<br/> }
[/code]
<br/>
The checkout.xml looks like this:
<pre> <buildmachine1>
<checkout1 exe="wco" folder=-f -R "C:/Work/6.70_Extensions/release/SASE Lab Tools/ANT Builds/"/>
<checkout2 exe="wco" folder=-f -R "C:/Work/7.00_Extensions/release/SASE Lab Tools/ANT Builds/"/>
</buildmachine1>
<buildmachine2>
<checkout3 exe="wco" folder=-f -R "C:/Work/7.10.00_Tip/release/SASE Lab Tools/ANT Builds/"/>
</buildmachine2>[/code]
<br/>
So because everything is done by using xml file, i cant possibly assign the combobox selected value ie this line:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; if (BuildmachineComboBox.SelectedIndex == 0 && BuildstreamComBoBox.SelectedIndex ==0)
[/code]
This is because my machines and streams always changes if the users edit the build.xml and the above would always need to be altered to suit the needs.
Anybody has any idea how to solve this issue?
View the full article