Пример #1
0
 protected override void OnClick(EventArgs e)
 {
     if (isCanEdit && this.DesignMode == false && bHasDrag == false)
     {
         if ((Control.ModifierKeys & Keys.Control) == Keys.Control && isDrawing == false)
         {
             isDrawing = true;
             if (this.GetChildAtPoint(this.PointToClient(Control.MousePosition)) == null)
             {
                 foreach (Control c in this.Controls)
                 {
                     if (c.Text.Trim() == "" &&
                         c.Tag != null &&
                         c.Tag.ToString() == "Auto")
                     {
                         this.Controls.Remove(c);
                     }
                 }
                 EmrAddTextBox text = new EmrAddTextBox();
                 text.Name     = System.DateTime.Now.Ticks.ToString();
                 text.Font     = this.Font;
                 text.Width    = text.InitWidth;
                 text.Visible  = true;
                 text.Tag      = "Auto";
                 text.Location = this.PointToClient(Control.MousePosition);
                 this.Controls.Add(text);
                 text.Focus();
                 text.LostFocus += new EventHandler(text_LostFocus);
             }
         }
     }
     base.OnClick(e);
 }
Пример #2
0
 protected override void OnMouseUp(System.Windows.Forms.MouseEventArgs e)
 {
     if (isCanEdit && this.DesignMode == false && bHasDrag == false)
     {
         if (e.Button == MouseButtons.Right && e.Clicks == 1 && isDrawing == false)
         {
             isDrawing = true;
             if (this.GetChildAtPoint(new Point(e.X, e.Y)) == null)
             {
                 foreach (Control c in this.Controls)
                 {
                     if (c.Text.Trim() == "" &&
                         c.Tag != null &&
                         c.Tag.ToString() == "Auto")
                     {
                         this.Controls.Remove(c);
                     }
                 }
                 EmrAddTextBox text = new EmrAddTextBox();
                 text.Name     = System.DateTime.Now.Ticks.ToString();
                 text.Font     = this.Font;
                 text.Width    = text.InitWidth;
                 text.Visible  = true;
                 text.Tag      = "Auto";
                 text.Location = new Point(e.X, e.Y);
                 this.Controls.Add(text);
                 text.Focus();
                 text.LostFocus += new EventHandler(text_LostFocus);
             }
         }
     }
     if (isMovingControls)
     {
         base.Refresh();
     }
     isDrawing        = false;
     isMovingControls = false;
     b           = false;
     bHasDrag    = false;
     this.Cursor = Cursors.Default;
 }