Ejemplo n.º 1
0
        public static void AddVertexFromSave(string name, Point location)
        {
            Temp = new Edge();

            Button button = new Button();

            button.Size                  = new Size(50, 50);
            button.Location              = location;
            button.BackColor             = Color.Transparent;
            button.FlatStyle             = FlatStyle.Flat;
            button.BackgroundImage       = Properties.Resources.sircle;
            button.BackgroundImageLayout = ImageLayout.Zoom;
            button.Text                  = name;
            button.ForeColor             = Color.White;
            if (name.Length <= 2)
            {
                button.Font = new Font(button.Font.Name, 14);
            }
            else
            {
                button.Font = new Font(button.Font.Name, 8);
            }

            button.MouseClick += AddEdge;
            button.MouseDown  += GDEXControl.RemoveEdges;

            GDEXControl.AddVertex(name.Trim(), new Point(location.X, location.Y), button);
            buttonsList.Add(button);

            Program.form1.Invoke(new Action(() =>
            {
                Program.form1.panel1.Controls.Add(button);
            }));
            GUI.UpdateGUI(); // for windows < 10
        }
Ejemplo n.º 2
0
        public static void AddVertex(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                Temp = new Edge();

                int _localX = CursorX;
                int _localY = CursorY;
                using (dialoge form = new dialoge())
                {
                    form.Text = "Введите имя вершины";
                    DialogResult result = form.ShowDialog();
                    if (result == DialogResult.OK)
                    {
                        if (GDEXControl.dex.graph.Find(x => x.name == form.value) != null)
                        {
                            MessageBox.Show("Такая вершина уже существует!", "Ошибка", MessageBoxButtons.OK);
                            return;
                        }

                        Button button = new Button();
                        button.Size                  = new Size(50, 50);
                        button.Location              = new Point(_localX - button.Size.Width / 2, _localY - button.Size.Height / 2);
                        button.BackColor             = Color.Transparent;
                        button.FlatStyle             = FlatStyle.Flat;
                        button.BackgroundImage       = Properties.Resources.sircle;
                        button.BackgroundImageLayout = ImageLayout.Zoom;
                        button.Text                  = form.value;
                        button.ForeColor             = Color.White;
                        if (form.value.Length <= 2)
                        {
                            button.Font = new Font(button.Font.Name, 14);
                        }
                        else
                        {
                            button.Font = new Font(button.Font.Name, 8);
                        }

                        button.MouseClick += AddEdge;
                        button.MouseDown  += GDEXControl.RemoveEdges;

                        GDEXControl.AddVertex(form.value.Trim(), new Point(_localX, _localY), button);
                        buttonsList.Add(button);

                        Program.form1.Invoke(new Action(() =>
                        {
                            Program.form1.panel1.Controls.Add(button);
                        }));
                    }
                }
                GUI.UpdateGUI(); // for windows < 10
            }
        }