Exemplo n.º 1
0
        private void addButton_Click(object sender, EventArgs e)
        {
            MetalBar partTemplate = new MetalBar(rawMats[selectedRMIndex]);
            double len;
            double fiO;
            double laO;
            Double.TryParse(partLengthText.Text.ToString(), out len);
            Double.TryParse(partLeftOText.Text.ToString(), out fiO);
            Double.TryParse(partRightOText.Text.ToString(), out laO);
            partTemplate.length = len;
            partTemplate.firstOffset = fiO;
            partTemplate.lastOffset = laO;

            int quan;
            Int32.TryParse(quantityText.Text.ToString(), out quan);

            Bundle nextBund = new Bundle(partNameText.Text.ToString(),
                                        partTemplate, quan);
            cutAgenda.Add(nextBund);
            displayCutList();
        }
Exemplo n.º 2
0
 private void writeBundleAsElement(XmlTextWriter xw, Bundle bund)
 {
     xw.WriteStartElement("Bundle");
     //next we write the name of the bundle.
     xw.WriteStartElement("PartName");
     xw.WriteString(bund.partname);
     xw.WriteEndElement();
     //next we get the number of parts in the bundle
     xw.WriteStartElement("Quantity");
     xw.WriteString(bund.quantity.ToString());
     xw.WriteEndElement();
     //next we write down the part specs.
     xw.WriteStartElement("PartSpecs");
     //Type
     xw.WriteStartElement("Type");
     xw.WriteString(bund.metaltype.type);
     xw.WriteEndElement();
     //Holes
     xw.WriteStartElement("Holes");
     xw.WriteString(bund.metaltype.holes.ToString());
     xw.WriteEndElement();
     //Length
     xw.WriteStartElement("Length");
     xw.WriteString(bund.metaltype.length.ToString());
     xw.WriteEndElement();
     //First offset
     xw.WriteStartElement("FirstOffset");
     xw.WriteString(bund.metaltype.firstOffset.ToString());
     xw.WriteEndElement();
     //Last offset
     xw.WriteStartElement("LastOffset");
     xw.WriteString(bund.metaltype.lastOffset.ToString());
     xw.WriteEndElement();
     //holedist
     xw.WriteStartElement("Holes");
     xw.WriteString(bund.metaltype.holeDist.ToString());
     xw.WriteEndElement();
     //finish out the "part" element.
     xw.WriteEndElement();
     //Finish out the "bundle" element.
     xw.WriteEndElement();
 }
Exemplo n.º 3
0
        private void loadCutListToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.DefaultExt = ".xml";
            dlg.Filter = "XML documents (.xml)|*.xml";
            dlg.InitialDirectory = Application.StartupPath;

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                XmlDocument xDoc = new XmlDocument();
                xDoc.Load(dlg.FileName);
                cutAgenda.Clear();
                sawCutList.Items.Clear();

                XmlNode verify = xDoc.SelectSingleNode("/CutList");
                if (verify == null)
                {
                    closeProgram(); //failure event. I suppose closing the program is dramatic enough
                }
                XmlNodeList nodli = xDoc.SelectNodes("/CutList/Bundle");
                foreach (XmlNode node in nodli)
                {
                    Bundle nextBund = new Bundle();

                    //Get part name. This should be the first property.
                    nextBund.partname = node.ChildNodes.Item(0).InnerText;
                    string quan = node.ChildNodes.Item(1).InnerText;
                    int quant;
                    Int32.TryParse(quan, out quant);
                    nextBund.quantity = quant;
                    //Now we're done with the non metal bar parts in the bundle.
                    MetalBar nextMB = new MetalBar();
                    XmlNode savedTemplate = node.SelectSingleNode("PartSpecs");

                    //Get type. This is already a string so no converstion needed.
                    nextMB.type = savedTemplate.ChildNodes.Item(0).InnerText;
                    //Get holes. Convert to boolean from string.
                    string hol = savedTemplate.ChildNodes.Item(1).InnerText;
                    bool holes;
                    Boolean.TryParse(hol, out holes);
                    nextMB.holes = holes;
                    //Get legnth. Convert to double from string.
                    string len = savedTemplate.ChildNodes.Item(2).InnerText;
                    double length;
                    Double.TryParse(len, out length);
                    nextMB.length = length;
                    //Get first offest. Convert to double from string.
                    string fiO = savedTemplate.ChildNodes.Item(3).InnerText;
                    double firstOff;
                    Double.TryParse(fiO, out firstOff);
                    nextMB.firstOffset = firstOff;
                    //Get last offset. Convert to double from string.
                    string laO = savedTemplate.ChildNodes.Item(4).InnerText;
                    double lastOff;
                    Double.TryParse(laO, out lastOff);
                    nextMB.lastOffset = lastOff;
                    //Get hole distance. Convert to double from string.
                    string hoD = savedTemplate.ChildNodes.Item(5).InnerText;
                    double holeDist;
                    Double.TryParse(hoD, out holeDist);
                    nextMB.holeDist = holeDist;

                    nextBund.metaltype = nextMB;

                    cutAgenda.Add(nextBund);
                }
                displayCutList();
            }

                displayRMList();
                //If we load a nonblank list, enable the button.
                if (rawMatList.Items.Count > 0)
                {
                    cutPartsButton.Enabled = true;
                }
        }