示例#1
0
文件: Form1.cs 项目: Geiko/WinForms
 private void MouseDownHandler(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         label = new MyStatic();
         label.Location = new Point(e.X, e.Y);
     }
 }
示例#2
0
文件: Form1.cs 项目: Geiko/WinForms
        public void SetRect(out MyStatic rect, MouseEventArgs e)
        {
            int left;
            if (this.label.Location.X < e.X)
                left = this.label.Location.X;
            else left = e.X;
            int upper;
            if (this.label.Location.Y < e.Y)
                upper = this.label.Location.Y;
            else upper = e.Y;

            int width = Math.Abs(e.X - this.label.Location.X);
            int height = Math.Abs(e.Y - this.label.Location.Y);

            rect = new MyStatic();
            rect.Location = new Point(left, upper);
            rect.Size = new Size(width, height);
        }