/// <summary> /// /// </summary> /// <param name="edittool"></param> public void AfterEditObjects(IEditTool edittool) { edittool.Finished(); if (m_undoBuffer.CanCapture) { m_undoBuffer.AddCommand(new EditCommandEditTool(edittool)); } }
/// <summary> /// 选择左侧工具?? /// </summary> /// <param name="editid"></param> public void CommandEdit(string editid) { CommandEscape(); m_model.ClearSelectedObjects(); m_commandType = eCommandType.edit; m_editToolId = editid; m_editTool = m_model.GetEditTool(m_editToolId); UpdateCursor(); }
/// <summary> /// 取消当前工具选择??? /// </summary> public void CommandEscape() { bool dirty = (m_newObject != null) || (m_snappoint != null); m_newObject = null; m_snappoint = null; if (m_editTool != null) { m_editTool.Finished(); } m_editTool = null; m_commandType = eCommandType.select; m_moveHelper.HandleCancelMove(); m_nodeMoveHelper.HandleCancelMove(); DoInvalidate(dirty); UpdateCursor(); }
protected override void OnMouseDown(MouseEventArgs e) { m_mousedownPoint = new PointF(e.X, e.Y); // used when panning m_dragOffset = new PointF(0,0); if (e.Button == System.Windows.Forms.MouseButtons.Right) CommandEscape(); UnitPoint mousepoint = ToUnit(m_mousedownPoint); if (m_snappoint != null) mousepoint = m_snappoint.SnapPoint; if (m_commandType == eCommandType.editNode) { bool handled = false; if (m_nodeMoveHelper.HandleMouseDown(mousepoint, ref handled)) { FinishNodeEdit(); base.OnMouseDown(e); return; } } if (m_commandType == eCommandType.select) { bool handled = false; if (m_nodeMoveHelper.HandleMouseDown(mousepoint, ref handled)) { m_commandType = eCommandType.editNode; m_snappoint = null; base.OnMouseDown(e); return; } DoInvalidate(true); UpdateCursor(); m_selection = new SelectionRectangle(m_mousedownPoint); } if (m_commandType == eCommandType.move) { m_moveHelper.HandleMouseDownForMove(mousepoint, m_snappoint); } if (m_commandType == eCommandType.draw) { if (e.Button == System.Windows.Forms.MouseButtons.Middle && m_newObject != null) { if (m_newObject is ModuleItems.Module) (m_newObject as ModuleItems.Module).horizontal = !(m_newObject as ModuleItems.Module).horizontal; return; } HandleMouseDownWhenDrawing(mousepoint, null); DoInvalidate(true); } if (m_commandType == eCommandType.edit) { if (m_editTool == null) m_editTool = m_model.GetEditTool(m_editToolId); if (m_editTool != null) { if (m_editTool.SupportSelection) m_selection = new SelectionRectangle(m_mousedownPoint); eDrawObjectMouseDown mouseresult = m_editTool.OnMouseDown(m_canvaswrapper, mousepoint, m_snappoint); /* if (mouseresult == eDrawObjectMouseDown.Continue) { if (m_editTool.SupportSelection) m_selection = new SelectionRectangle(m_mousedownPoint); } * */ if (mouseresult == eDrawObjectMouseDown.Done) { m_editTool.Finished(); m_editTool = m_model.GetEditTool(m_editToolId); // continue with new tool //m_editTool = null; if (m_editTool.SupportSelection) m_selection = new SelectionRectangle(m_mousedownPoint); } } DoInvalidate(true); UpdateCursor(); } base.OnMouseDown(e); }
public void CommandEscape() { bool dirty = (m_newObject != null) || (m_snappoint != null); m_newObject = null; m_snappoint = null; if (m_editTool != null) m_editTool.Finished(); m_editTool = null; m_commandType = eCommandType.select; m_moveHelper.HandleCancelMove(); m_nodeMoveHelper.HandleCancelMove(); if (this.Parent is DocumentForm){ DocumentForm temp = this.Parent as DocumentForm; temp.SetHint(""); } DoInvalidate(dirty); UpdateCursor(); }
public void CommandEdit(string editid) { CommandEscape(); m_model.ClearSelectedObjects(); m_commandType = eCommandType.edit; m_editToolId = editid; m_editTool = m_model.GetEditTool(m_editToolId); UpdateCursor(); }
public void AddEditTool(string key, IEditTool tool) { m_editTools.Add(key, tool); }
/// <summary> /// 鼠标按下事件 /// </summary> /// <param name="e"></param> protected override void OnMouseDown(MouseEventArgs e) { m_mousedownPoint = new PointF(e.X, e.Y); // used when panning m_dragOffset = new PointF(0, 0); UnitPoint mousepoint = ToUnit(m_mousedownPoint); //获取当前光标世界坐标 if (m_snappoint != null) { mousepoint = m_snappoint.SnapPoint; } if (m_commandType == eCommandType.editNode) //如果为编辑节点 { bool handled = false; if (m_nodeMoveHelper.HandleMouseDown(mousepoint, ref handled)) { FinishNodeEdit(); base.OnMouseDown(e); return; } } if (m_commandType == eCommandType.select) //如果为选中 { bool handled = false; if (m_nodeMoveHelper.HandleMouseDown(mousepoint, ref handled)) { m_commandType = eCommandType.editNode; m_snappoint = null; base.OnMouseDown(e); return; } m_selection = new SelectionRectangle(m_mousedownPoint); } if (m_commandType == eCommandType.move) //如果为移动 { m_moveHelper.HandleMouseDownForMove(mousepoint, m_snappoint); } if (m_commandType == eCommandType.draw) //如果为绘制 { HandleMouseDownWhenDrawing(mousepoint, null); DoInvalidate(true); } if (m_commandType == eCommandType.edit) //如果为编辑 { if (m_editTool == null) //如果编辑工具为空 { m_editTool = m_model.GetEditTool(m_editToolId); } if (m_editTool != null) //如果编辑工具不为空 { if (m_editTool.SupportSelection) { m_selection = new SelectionRectangle(m_mousedownPoint); } eDrawObjectMouseDown mouseresult = m_editTool.OnMouseDown(m_canvaswrapper, mousepoint, m_snappoint); /* * if (mouseresult == eDrawObjectMouseDown.Continue) * { * if (m_editTool.SupportSelection) * m_selection = new SelectionRectangle(m_mousedownPoint); * } * */ if (mouseresult == eDrawObjectMouseDown.Done) //如果绘制已经完成 { m_editTool.Finished(); m_editTool = m_model.GetEditTool(m_editToolId); // continue with new tool //m_editTool = null; if (m_editTool.SupportSelection) { m_selection = new SelectionRectangle(m_mousedownPoint); } } } DoInvalidate(true); UpdateCursor(); //更新光标 } base.OnMouseDown(e); }
public void CommandEscape() { bool dirty = (m_newObject != null) || (m_snappoint != null); m_newObject = null; m_snappoint = null; if (m_editTool != null) m_editTool.Finished(); m_editTool = null; m_commandType = eCommandType.select; m_moveHelper.HandleCancelMove(); m_nodeMoveHelper.HandleCancelMove(); DoInvalidate(dirty); UpdateCursor(); }
public EditCommandEditTool(IEditTool tool) { m_tool = tool; }
public void ActiveToolChanged(IEditTool newTool) { }
/// <summary> /// ±à¼¹¤¾ß:±à¼ÃüÁî /// </summary> /// <param name="tool"></param> public EditCommandEditTool(IEditTool tool) { //MessageBox.Show(""); m_tool = tool; }
protected override void OnMouseDown(MouseEventArgs e) { if (m_rectBaseTextBox != null && m_rectBaseTextBox.Tag != null) { ((DrawTools.RectBase)m_rectBaseTextBox.Tag).Text = m_rectBaseTextBox.Text; ((DrawTools.RectBase)m_rectBaseTextBox.Tag).Selected = false; Controls.Remove(m_rectBaseTextBox); m_model.ClearSelectedObjects(); m_rectBaseTextBox = null; DoInvalidate(true); return; } if (e.Button == MouseButtons.Middle) { CommandEscape(); CommandPan(); } if (e.Button == MouseButtons.Right) { CommandEscape(); } m_mousedownPoint = new PointF(e.X, e.Y); // used when panning m_dragOffset = new PointF(0, 0); UnitPoint mousepoint = ToUnit(m_mousedownPoint); if (m_snappoint != null) { mousepoint = m_snappoint.SnapPoint; //snap point: rect point } if (m_commandType == eCommandType.editNode) { //modify a obj's node, e.g: move node bool handled = false; if (m_nodeMoveHelper.HandleMouseDown(mousepoint, ref handled, m_snappoint)) { FinishNodeEdit(); base.OnMouseDown(e); return; } } if (m_commandType == eCommandType.select) { //select an exsiting obj bool handled = false; if (m_nodeMoveHelper.HandleMouseDown(mousepoint, ref handled, m_snappoint)) { m_commandType = eCommandType.editNode; m_snappoint = null; base.OnMouseDown(e); return; } m_selection = new SelectionRectangle(m_mousedownPoint); } if (m_commandType == eCommandType.move) { m_moveHelper.HandleMouseDownForMove(mousepoint, m_snappoint); } if (m_commandType == eCommandType.draw) { //make a new obj and add it to model HandleMouseDownWhenDrawing(mousepoint, m_snappoint); DoInvalidate(true); } if (m_commandType == eCommandType.edit) { if (m_editTool == null) { m_editTool = m_model.GetEditTool(m_editToolId); } if (m_editTool != null) { if (m_editTool.SupportSelection) { m_selection = new SelectionRectangle(m_mousedownPoint); } eDrawObjectMouseDown mouseresult = m_editTool.OnMouseDown(m_canvaswrapper, mousepoint, m_snappoint); /* * if (mouseresult == eDrawObjectMouseDown.Continue) * { * if (m_editTool.SupportSelection) * m_selection = new SelectionRectangle(m_mousedownPoint); * } * */ if (mouseresult == eDrawObjectMouseDown.Done) { m_editTool.Finished(); m_editTool = m_model.GetEditTool(m_editToolId); // continue with new tool //m_editTool = null; if (m_editTool.SupportSelection) { m_selection = new SelectionRectangle(m_mousedownPoint); } } } DoInvalidate(true); UpdateCursor(); } base.OnMouseDown(e); }
public void AfterEditObjects(IEditTool edittool) { edittool.Finished(); if (m_undoBuffer.CanCapture) m_undoBuffer.AddCommand(new EditCommandEditTool(edittool)); }