Exemplo n.º 1
0
 private void DrillSaveXML()
 {
     try
     {
         if (saveFileDialog1.ShowDialog() == DialogResult.OK)
         {
             XmlHandler xmlHandler = new XmlHandler(this, saveFileDialog1.FileName);
             xmlHandler.TreeViewToXml(treeView1, saveFileDialog1.FileName);
         }
     }
     catch
     {
     }
 }
Exemplo n.º 2
0
        private void DrillOpenXML()
        {
            try
            {
                if (openFileDialog2.ShowDialog() == DialogResult.OK)
                {
                    this.BeginInvoke((ThreadStart)delegate()
                    {
                        XmlHandler xmlHandler = new XmlHandler(this, openFileDialog2.FileName);
                        xmlHandler.XmlToTreeView(openFileDialog2.FileName, treeView1);

                        // dodac zapis danych bezposrednio do ListOfDrills a nie treeView1
                        TreeNode treeNode = treeView1.TopNode;
                        string[] temp;
                        ListOfDrills.Clear();
                        ListOfDrillsTemp.Clear();

                        toolStripProgressBar1.Visible = true;
                        toolStripProgressBar1.Maximum = treeView1.Nodes.Count;
                        toolStripProgressBar1.Value = 0;
                        toolStripStatusLabel1.Visible = true;
                        toolStripStatusLabel1.Text = "otwory : " + "0 / " + treeView1.Nodes.Count;

                        for (int i = 0; i < treeView1.Nodes.Count; i++)
                        {
                            // x
                            treeNode = treeNode.FirstNode;
                            temp = treeNode.Text.Split(':', '"');
                            temp[1] = Regex.Replace(temp[1], @"\s+", "");
                            drill.x = (long)(Convert.ToDouble(temp[1]) * 5);

                            // y
                            treeNode = treeNode.NextNode;
                            temp = treeNode.Text.Split(':', '"');
                            temp[1] = Regex.Replace(temp[1], @"\s+", "");
                            drill.y = (long)(Convert.ToDouble(temp[1]) * 5);

                            // diam
                            treeNode = treeNode.NextNode;
                            temp = treeNode.Text.Split(':', '"');
                            drill.diameter = Convert.ToDouble(Regex.Replace(temp[1], @"\s+", ""));

                            // ID
                            treeNode = treeNode.NextNode;
                            temp = treeNode.Text.Split(':', '"');
                            drill.ID = Convert.ToInt16(Regex.Replace(temp[1], @"\s+", ""));
                            treeNode = treeNode.Parent.NextNode;

                            // dodanie otworow do list
                            ListOfDrills.Add(drill);
                            ListOfDrillsTemp.Add(drill);

                            toolStripProgressBar1.Value++;
                            toolStripStatusLabel1.Text = "otwory : " + toolStripProgressBar1.Value.ToString() + " / " + treeView1.Nodes.Count;
                        }

                        //SortowanieOtworow();
                        TreeFillNode(ListOfDrillsTemp);
                        plytka_wygenerowana = true;
                        kalibracjaToolStripMenuItem.Enabled = true;

                        // wylaczenie eventu
                        this.ListaOtworowListBox.ItemCheck -= new System.Windows.Forms.ItemCheckEventHandler(this.DrillListBox_ItemCheck);

                        // nowa lista otworow
                        otwory = DrillDiamList();

                        // sortowanie otworow, od najmniejszego
                        otwory = DrillSortList(otwory);

                        DrillFillList(otwory);

                        DrillListBox_ItemCheck();

                        this.ListaOtworowListBox.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.DrillListBox_ItemCheck);
                    });
                }
            }
            catch
            {
            }
        }