private void newObjectMenuItem_Click(object sender, EventArgs e)
        {
            Panel t = new Panel();
            t.Parent = pictureBox;
            t.BackColor = Color.Blue;
            // t.BorderStyle = BorderStyle.FixedSingle;
 
            Button u = new Button();
            u.Parent = t;
            u.BackColor = SystemColors.Control;
            u.Left = 8;
            u.Top = 8;
 
            t.MouseDown += area_MouseDown;
            t.MouseMove += area_MouseMove;
            t.MouseUp += area_MouseUp;
        }
 
        private bool q = false;
 
        private void area_MouseDown (object sender, MouseEventArgs e)
        {
            Panel t = (Panel)sender;
            q = true;
            X0 = e.X;
            Y0 = e.Y;
            if (e.Button == MouseButtons.Middle)
            {
                if (Control.ModifierKeys == Keys.Control)
                {
                    colorDialog1.Color = t.BackColor;
                    if (colorDialog1.ShowDialog() == DialogResult.OK)
                        t.BackColor = colorDialog1.Color;
                }
                else
                {
                }
            }
        }
 
        private void area_MouseMove (object sender, MouseEventArgs e)
        {
            Panel t = (Panel) sender;
            if (q)
            {
                if (e.Button == MouseButtons.Left)
                {
                    t.Left += e.X - X0;
                    t.Top += e.Y - Y0;
                }
                else if (e.Button == MouseButtons.Right)
                {
                    t.Width += e.X - X0;
                    t.Height += e.Y - Y0;
                    X0 = e.X;
                    Y0 = e.Y;
                }
            }
        }
 
        private void area_MouseUp (object sender, MouseEventArgs e)
        {
            q = false;
        }
 
kresleni2.txt · Last modified: 2013/10/29 13:06 by 147.32.8.115
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki