Exemple #1
0
 // 鼠标按钮按下选中文本
 private void mouseDownSelectText()
 {
     if (MouseButtons.Left.Equals(MouseDownButton)) // 点击的左键
     {
         Point p = MouseDownLocation;
         if (p.X < 0)
         {
             p.X = 0;
         }
         if (p.Y < 0)
         {
             p.Y = 0;
         }
         int mouseIndex = this.GetCharIndexFromPosition(p);
         int selIndex   = this.SelectionStart;
         if (KeysDown.Equals(Keys.ShiftKey)) // 按下了shift
         {
             if (mouseIndex < selIndex)
             {
                 this.SelectionStart = mouseIndex;
             }
             else
             {
                 this.SelectionStart = SelectionStart;
             }
             this.SelectionLength = Math.Abs(mouseIndex - selIndex);
         }
         else
         {
             if (isMouseEnterSelectText(p) /*|| SelectionLength == 0*/)
             {
                 ControlsUtils.AsynchronousMethod(this, 120, new EventHandler((object sender1, EventArgs e1) => {
                     if (!Cursor.Equals(selectTextDragCur) && MouseDownButton.Equals(MouseButtons.None))
                     {
                         SelectionLength = 0;
                         SelectionStart  = mouseIndex;
                     }
                 }));
             }
             else
             {
                 SelectionLength = 0;
                 SelectionStart  = mouseIndex;
             }
         }
     }
 }
Exemple #2
0
 // 开启或关闭鼠标选中文本的拖放
 private void diIsSelectTextDrag()
 {
     // 判断是否要启用拖放操作
     ControlsUtils.AsynchronousMethod(this, 100, new EventHandler((object sender1, EventArgs e1) => {
         Point p = MouseDownLocation;
         if (p.X < 0)
         {
             p.X = 0;
         }
         if (p.Y < 0)
         {
             p.Y = 0;
         }
         if (MouseDownButton.Equals(MouseButtons.Left) && isMouseEnterSelectText(p))
         {
             Cursor = selectTextDragCur;
         }
         ;
     }));
 }