Beispiel #1
0
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            if (controls == false && simdilik < 12)
            {
                x++;
                simdilik++;
                btn           = new ovalbutton();
                btn.Text      = Convert.ToString(simdilik);//x+1
                btn.Name      = "graf" + x.ToString();
                btn.Location  = new Point(a, b);
                btn.Width     = 40;
                btn.Height    = 40;
                btn.AutoSize  = true;
                btn.FlatStyle = FlatStyle.Flat;
                btn.FlatAppearance.BorderColor        = Color.Black;
                btn.FlatAppearance.MouseDownBackColor = Color.Pink;
                btn.FlatAppearance.MouseOverBackColor = Color.DeepSkyBlue;
                btn.BackColor = Color.FromArgb(238, 201, 0);//Color.Orange;//238 201 0
                btn.FlatAppearance.BorderSize = 0;
                btn.Click += new EventHandler(this.button_click);
                btn.Font   = new Font("Tahoma", 14F, FontStyle.Bold);
                ForeColor  = Color.Black;
                pictureBox1.Controls.Add(btn);

                lbl           = new Label();
                lbl.Text      = (simdilik).ToString();//x+1
                lbl.Name      = (x + 1).ToString();
                lbl.Location  = new Point(lx + 5, 5);
                lbl.Font      = new Font("Tahoma", 14F, FontStyle.Bold);
                lbl.AutoSize  = true;
                lbl.Parent    = tabPage1;
                lbl.BackColor = Color.Transparent;

                lbl           = new Label();
                lbl.Text      = (simdilik).ToString();//x+1
                lbl.Name      = (x + 1).ToString();
                lbl.Location  = new Point(5, lx + 5);
                lbl.Font      = new Font("Tahoma", 14F, FontStyle.Bold);
                lbl.AutoSize  = true;
                lbl.Parent    = tabPage1;
                lbl.BackColor = Color.Transparent;
                lx           += 40;
            }
            else if (simdilik >= 12 && nodecntrl == false)
            {
                MessageBox.Show("Bu programda maximum node sayısı 12 olarak belirlenmiştir...");
                nodecntrl = true;
            }
        }
Beispiel #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            label1.Parent          = panel1;
            label1.BackColor       = Color.Transparent;
            label1.Text            = "Minimum Spanning Tree Algoritmalası";
            label1.ForeColor       = Color.FromArgb(252, 253, 205); //.White;///Color.FromArgb(252, 253, 205);
            tabPage1.BackColor     = Color.FromArgb(255, 149, 1);   //Color.FromArgb(19, 130, 175);
            textBox2.BackColor     = Color.FromArgb(255, 149, 1);   //Color.FromArgb(245, 146, 81);
            radioButton1.Checked   = true;
            checkBox1.Checked      = true;
            radioButton1.ForeColor = Color.FromArgb(252, 253, 205);
            radioButton2.ForeColor = Color.FromArgb(252, 253, 205); //Color.FromArgb(255, 149, 1);
            FormBorderStyle        = FormBorderStyle.None;
            BackColor        = Color.FromArgb(255, 149, 1);         // Color.FromArgb(123, 193, 68);
            panel1.BackColor = Color.FromArgb(42, 61, 81);
            panel2.BackColor = Color.FromArgb(42, 61, 81);
            panel3.BackColor = Color.FromArgb(42, 61, 81);
            panel4.BackColor = Color.FromArgb(42, 61, 81);

            ovl_btn          = new ovalbutton();
            ovl_btn.Text     = "X";
            ovl_btn.Name     = "kapat" + 1;
            ovl_btn.Location = new Point(727, 0);
            ovl_btn.Width    = 20;
            //ovl_btn.Height = 20;
            ovl_btn.AutoSize  = true;
            ovl_btn.FlatStyle = FlatStyle.Flat;
            ovl_btn.BackColor = Color.Transparent;
            ovl_btn.Parent    = panel1;
            ovl_btn.FlatAppearance.BorderSize = 0;
            ovl_btn.Click    += new EventHandler(this.ovl_btn_Click);
            ovl_btn.ForeColor = Color.White;//Color.FromArgb(123, 193, 68);
            ovl_btn.FlatAppearance.MouseDownBackColor = Color.OrangeRed;
            ovl_btn.FlatAppearance.MouseOverBackColor = Color.Red;
            ovl_btn.Font = new Font("Tahoma", 14F, FontStyle.Bold);
            ovl_btn.Dock = DockStyle.Right;
            panel1.Controls.Add(ovl_btn);
        }
Beispiel #3
0
        void button_click(object sender, EventArgs e)
        {
            if (controls == true)
            {
                int    t = 0, t2 = 0;
                string kelime;
                btn = sender as ovalbutton;
                if (tut != btn.Name && IsMouseDown == true)
                {
                    kelime = btn.Name;
                    kelime = kelime.Remove(0, 4);//graf
                    int k2 = Convert.ToInt16(kelime);
                    if (matrix[k, k2] == 0)
                    {
                        t  = (k + 1) + k2 * (x + 1);
                        t2 = (k2 + 1) + k * (x + 1);
                        try
                        {
                            Control m_butn  = this.Controls.Find("my" + t.ToString(), true)[0] as Control;
                            Control m_butn2 = this.Controls.Find("my" + t2.ToString(), true)[0] as Control;
                            m_butn.Text  = 1.ToString();
                            m_butn2.Text = 1.ToString();

                            matrix[k, k2] = 1;
                            matrix[k2, k] = 1;
                            IsMouseDown   = false;
                            LineList DrawLine = new LineList();
                            DrawLine.X1 = m_StartX;
                            DrawLine.Y1 = m_StartY;
                            DrawLine.X2 = btn.Location.X + 20;
                            DrawLine.Y2 = btn.Location.Y + 20;
                            MyLines.Add(DrawLine);
                            pictureBox1.Invalidate();

                            int lbl_ort_X = (m_StartX + btn.Location.X + 20) / 2;
                            int lbl_ort_Y = (m_StartY + btn.Location.Y + 20) / 2;


                            lbl           = new Label();
                            lbl.Text      = 1.ToString();
                            lbl.Name      = "g_lbl" + k + "," + k2;
                            lbl.Location  = new Point(lbl_ort_X, lbl_ort_Y);
                            lbl.Font      = new Font("Tahoma", 11F, FontStyle.Bold);
                            lbl.AutoSize  = true;
                            lbl.Parent    = pictureBox1;
                            lbl.BackColor = Color.Transparent;
                        }
                        catch (Exception es)
                        {
                            MessageBox.Show("LÜTFEN MATRİX'i OLUŞTURMADAN GRAF BAĞLANTISI KURMAYIN" + es.ToString());
                        }
                    }
                    else
                    {
                        matrix[k, k2] += 1;
                        matrix[k2, k] += 1;
                        t              = (k + 1) + k2 * (x + 1);
                        t2             = (k2 + 1) + k * (x + 1);
                        try
                        {
                            Control m_butn  = this.Controls.Find("my" + t.ToString(), true)[0] as Control;
                            Control m_butn2 = this.Controls.Find("my" + t2.ToString(), true)[0] as Control;
                            m_butn.Text  = matrix[k, k2].ToString();
                            m_butn2.Text = matrix[k, k2].ToString();

                            IsMouseDown = false;
                            LineList DrawLine = new LineList();
                            DrawLine.X1 = m_StartX;
                            DrawLine.Y1 = m_StartY;
                            DrawLine.X2 = btn.Location.X + 20;
                            DrawLine.Y2 = btn.Location.Y + 20;
                            MyLines.Add(DrawLine);
                            pictureBox1.Invalidate();

                            try
                            {
                                Control labelss = this.Controls.Find("g_lbl" + k + "," + k2, true)[0] as Control;
                                labelss.Text = matrix[k, k2].ToString();
                            }
                            catch (Exception eses)
                            {
                                Control labelss = this.Controls.Find("g_lbl" + k2 + "," + k, true)[0] as Control;
                                labelss.Text = matrix[k, k2].ToString();
                                //MessageBox.Show(eses.ToString());
                            }
                        }
                        catch (Exception esss)
                        {
                            MessageBox.Show(esss.ToString());
                        }
                    }
                }
                else
                {
                    IsMouseDown       = true;
                    tut               = btn.Name;
                    m_StartX          = btn.Location.X + 20;
                    m_StartY          = btn.Location.Y + 20;
                    m_CurX            = btn.Location.X;
                    m_CurY            = btn.Location.Y;
                    StartDownLocation = btn.Location;
                    kelime            = btn.Name;
                    kelime            = kelime.Remove(0, 4);//graf
                    k = Convert.ToInt16(kelime);
                }
            }
        }