예제 #1
0
 private void cbFromBase_Click(object sender, EventArgs e)
 {
     DBConnector DBConnect = new DBConnector();
     List<string> names = DBConnect.loadPolygonsList();
     cbFromBase.Items.Clear();
     foreach (string s in names)
     {
         cbFromBase.Items.Add(s);
     }
 }
예제 #2
0
        private void btGetFromDB_Click(object sender, EventArgs e)
        {
            if (ImgEditor.Polygs.Count == 2) {  MessageBox.Show("Вначале объедините существующие полигоны"); return;}

            if (cbFromBase.SelectedIndex!=-1)
            {
                DBConnector DBConnect = new DBConnector();

                string name = cbFromBase.SelectedItem.ToString();

                Polygon poly = DBConnect.GetPolygonByName(name);

                //g.Clear(Color.White);
                Graphics g = ImgEditor.GetGraphics();
                poly.Paint(g);
                ImgEditor.ReDraw();

                ImgEditor.Polygs.Add(poly);
                ImgEditor.CurPolygon = poly;
            }
            else
            {
                MessageBox.Show("Выберите полигон");
                cbFromBase.Focus();
            }
        }
예제 #3
0
        private void btSaveToDB_Click(object sender, EventArgs e)
        {
            if (ImgEditor.CurPolygon == null) {MessageBox.Show("Полигон не выбран"); return;}
            if (txtSaveName.Text != "")
            {
                DBConnector DBConnect = new DBConnector();

                string name = txtSaveName.Text;
                if (DBConnect.PolygonExists(name))
                {
                    DialogResult result = MessageBox.Show("Полигон с этим именем существует. Перезаписать?",
                            "Important Question",
                            MessageBoxButtons.YesNo);
                    if (result == System.Windows.Forms.DialogResult.No) return;
                    DBConnect.DeletePolygonByName(name);
                }
                DBConnect.SavePolygon(ImgEditor.CurPolygon, name);
                txtSaveName.Text = "";
            }
            else
            {
                MessageBox.Show("Введите имя полигона");
                txtSaveName.Focus();
            }
        }