Example #1
0
        private void button8_Click_1(object sender, EventArgs e)
        {
            Skeleton sk = new Skeleton();

            listBox1.Items.Clear();
            Data_Form df = new Data_Form();

            df.ShowDialog();
            if (df.DialogResult == DialogResult.OK)
            {
                sk = (Skeleton)XML_Worker.Read_from_string(typeof(Skeleton), df.readed_xml);
                Bitmap bm = new Bitmap(sk.Size.X, sk.Size.Y);
                foreach (Skeleton.cell sc in sk.list_of_cell)
                {
                    foreach (Skeleton.node sn in sc.list_of_node)
                    {
                        bm.SetPixel(sn.x, sn.y, Color.White);
                    }
                }
                ibReader.Image = new Image <Gray, byte>(bm);
                int i = 0;
                current_skelet_loaded = sk;
                foreach (Skeleton.cell c in current_skelet_loaded.list_of_cell)
                {
                    i++;
                    listBox1.Items.Add(i);
                }

                toolStripStatusLabel1.Text = "XML считан из базы данных";
            }
        }
Example #2
0
        private Skeleton Read_path()
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.Filter           = "XML files (*.xml)|*.xml";
            openFileDialog1.FilterIndex      = 1;
            openFileDialog1.RestoreDirectory = true;
            Skeleton sk = new Skeleton();

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    sk = (Skeleton)XML_Worker.Read_from_xml(typeof(Skeleton), openFileDialog1.FileName);
                    Bitmap bm = new Bitmap(sk.Size.X, sk.Size.Y);
                    foreach (Skeleton.cell sc in sk.list_of_cell)
                    {
                        foreach (Skeleton.node sn in sc.list_of_node)
                        {
                            bm.SetPixel(sn.x, sn.y, Color.White);
                        }
                    }
                    ibReader.Image             = new Image <Gray, byte>(bm);
                    toolStripStatusLabel1.Text = "Прочитан XML файл: " + openFileDialog1.FileName;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                }
            }
            return(sk);
        }
Example #3
0
        private void Save_to_DataBase()
        {
            Save_to_DB_Form stdb = new Save_to_DB_Form();

            stdb.ShowDialog();
            if (stdb.DialogResult == DialogResult.OK)
            {
                string   xml_data = XML_Worker.Save_to_xml_string(typeof(Skeleton), current_skelet_loaded);
                DBWorker dbw      = new DBWorker();
                dbw.saveXml_to_database(stdb.textBox1.Text, stdb.textBox2.Text, xml_data);
            }
        }
Example #4
0
        private void Save_to_File()
        {
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();

            saveFileDialog1.Filter           = "XML files (*.xml)|*.xml";
            saveFileDialog1.FilterIndex      = 1;
            saveFileDialog1.RestoreDirectory = true;
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                // тут надо вставить костыль для элементов меньше 4 пикселей

                XML_Worker.Save_to_xml_file(typeof(Skeleton), current_skelet_loaded, saveFileDialog1.FileName);
                toolStripStatusLabel1.Text = "Скелет сохранен в " + saveFileDialog1.FileName;
            }
        }
Example #5
0
        private void button4_Click(object sender, EventArgs e)
        {
            Structure s = new Structure();

            s.list_of_elements  = ocr.GetElements();
            s.list_of_relations = ocr.GetRelations();
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();

            saveFileDialog1.Filter           = "XML files (*.xml)|*.xml";
            saveFileDialog1.FilterIndex      = 1;
            saveFileDialog1.RestoreDirectory = true;
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                XML_Worker.Save_to_xml_file(typeof(Structure), s, saveFileDialog1.FileName);
            }
        }
Example #6
0
        private void button7_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.Filter           = "XML files (*.xml)|*.xml";
            openFileDialog1.FilterIndex      = 1;
            openFileDialog1.RestoreDirectory = true;
            Structure s = new Structure();

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    s = (Structure)XML_Worker.Read_from_xml(typeof(Structure), openFileDialog1.FileName);
                    foreach (Element el in s.list_of_elements)
                    {
                        ocr.AddElement(el);
                    }
                    foreach (Relation r in s.list_of_relations)
                    {
                        if (r.itRel())
                        {
                            int numelem1 = -1, numrel1 = -1;
                            for (int i = 0; i < ocr.GetCountOfElements(); i++)
                            {
                                if ((ocr.GetElement(i).Coordinate.X == r.GetElem(1).Coordinate.X) && (ocr.GetElement(i).Coordinate.Y == r.GetElem(1).Coordinate.Y))
                                {
                                    numelem1 = i;
                                }
                            }
                            for (int i = 0; i < ocr.GetCountOfRelations(); i++)
                            {
                                if ((ocr.GetRelation(i).Coordinate.X == r.GetRel().Coordinate.X) && (ocr.GetRelation(i).Coordinate.Y == r.GetRel().Coordinate.Y))
                                {
                                    numrel1 = i;
                                }
                            }
                            ocr.AddRelation(new Relation(ocr.GetRelation(numrel1), ocr.GetElement(numelem1), r.Coordinate.X, r.Coordinate.Y));
                        }
                        else
                        {
                            int numelem1 = -1, numelem2 = -1;
                            for (int i = 0; i < ocr.GetCountOfElements(); i++)
                            {
                                if ((ocr.GetElement(i).Coordinate.X == r.GetElem(1).Coordinate.X) && (ocr.GetElement(i).Coordinate.Y == r.GetElem(1).Coordinate.Y))
                                {
                                    numelem1 = i;
                                }
                                if ((ocr.GetElement(i).Coordinate.X == r.GetElem(2).Coordinate.X) && (ocr.GetElement(i).Coordinate.Y == r.GetElem(2).Coordinate.Y))
                                {
                                    numelem2 = i;
                                }
                            }
                            ocr.AddRelation(new Relation(ocr.GetElement(numelem1), ocr.GetElement(numelem2), r.Coordinate.X, r.Coordinate.Y));
                        }
                        ocr.SetRelationParametrs(ocr.GetCountOfRelations() - 1, r);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                }
            }
        }