Exemple #1
0
        public override void OnMouseUp(Designer designer, System.Windows.Forms.MouseEventArgs e)
        {
            //如果是区域选择,选中在此区域的对像
            if (selectmode == SelectionMode.NetSelection)
            {
                designer.Items.SelectInRectangle(designer.SelectRectangle);
                selectmode = SelectionMode.None;
                designer.IsDrawSelectRectangle = false;
            }
            //如果是改变大小则结束改变
            if (resizeObject != null)
            {
                resizeObject.Normalize();

                //如果改变对像的尺寸大小
                if (designer.SelectDrawText != null && (resizeObject.GetType().Name == designer.SelectDrawText.GetType().Name))
                {
                    Rectangle rectangle = DrawRectangle.GetNormalizedRectangle((resizeObject as DrawText).Rectangle);
                    designer.textBox.Location = new Point(rectangle.X + 8, rectangle.Y + 7);
                    designer.textBox.Size     = new Size(rectangle.Width - 10, rectangle.Height - 10);
                    // designer.textBox.Focus();
                    //设置当前选中的文本编辑器
                    //在多个编辑切换时,可以知道当前编辑的是哪一个
                }

                resizeObject = null;
            }
            designer.Capture = false;
            designer.Refresh();
        }
Exemple #2
0
 private void Designer_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     //如果是鼠标左键和当前工具是"选择"才执行显示属性或编辑(文本)操作
     if (e.Button == MouseButtons.Left && (activeTool.GetType().Name == typeof(ToolSelector).Name))
     {
         //由于在鼠标点击时控制了鼠标工作区域,如果是双击则不需要控制
         //恢复鼠标的工作区域
         Cursor.Clip = tempCursorPos;
         if (this.Items != null && this.Items.Count > 0)
         {
             //取消所有选择
             this.Items.UnSelectAll();
             int          count = this.Items.Count;
             DrawItemBase item  = null;
             for (int i = 0; i < count; i++)
             {
                 //检查是否有选中的对像
                 if (this.Items[i].HitTest(new Point(e.X, e.Y)) == 0)
                 {
                     item          = this.Items[i]; //获取选中的对像
                     item.Selected = true;          //设置为选中状态
                     //如果绑定了显示属性事件则触发事件
                     if (OnShowProperityInfo != null)
                     {
                         OnShowProperityInfo(item);
                     }
                     //如果是文本编辑则显示出textbox
                     if (item.GetType().Name == typeof(DrawText).Name)
                     {
                         DrawText dt = item as DrawText;
                         textBox.Location = new Point(dt.Rectangle.X + 8, dt.Rectangle.Y + 7);
                         textBox.Size     = new Size(dt.Rectangle.Width - 14, dt.Rectangle.Height - 14);
                         textBox.Font     = dt.TextFont;
                         textBox.Text     = dt.TextValue;
                         textBox.Focus();
                         textBox.Enabled = true;
                         textBox.Visible = true;
                     }
                     this.Refresh();
                     break;
                 }
             }
         }
     }
 }