3_A

an object providing a rectangular area which can be moved and resized using the mouse

header

3_A assignament

Request

Create an object providing a rectangular area which can be moved and resized using the mouse. This area will hold our future charts and graphics.

My Solution

Code in C#

Main Form:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
  public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {

        }

        bool allowResize = false;
        bool allowMove = false;
        private void resizaileBox_MouseUp(object sender, MouseEventArgs e)
        {
            allowResize = false;
            allowMove = false;
        }

        private void resizaileBox_MouseMove(object sender, MouseEventArgs e)
        {
            if (allowResize)
            {
                this.panel1.Height = resizaileBox.Top + e.Y;
                this.panel1.Width = resizaileBox.Left + e.X;
            }
            if (allowMove)
            {
                this.panel1.Location = new Point(this.panel1.Location.X + e.X, this.panel1.Location.Y + e.Y);
                

                
            }
        }

        private void resizaileBox_Click(object sender, EventArgs e)
        {

        }

        private void resizaileBox_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right) allowResize = true;
            else allowMove = true;
        }

       

    }
  
comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy