private void pictureBox1_MouseUp(object sender, MouseEventArgs e) { if (IsWriting) { return; } ViewPort.InvTransformPoint(e.Location.X, e.Location.Y); ScreenLastPoint = new Point(e.Location.X, e.Location.Y); if (e.Button == MouseButtons.Left) { if (Command != null) { //图元绘制 if (Command.cMDType == CMDType.PriCommand) { if (StartWriting) { IsWriting = true; TextFunction(e.Location.X, e.Location.Y); } } //图元编辑 else if (Command.cMDType == CMDType.PriEditCommand) { } //图形操作 else if (Command.cMDType == CMDType.PicCommand) { } Command.MouseUp(e); } else { if (Primitive.CurrentSelectionPrimitive != null) { var pri = Primitive.CurrentSelectionPrimitive; bool isContains = Primitive.CurrentSelectedPrimitives.Contains(pri); if (isContains) { Primitive.CurrentSelectedPrimitives.Remove(pri); } else { Primitive.CurrentSelectedPrimitives.Add(pri); } Primitive.CurrentSelectionPrimitive = null; } } } pictureBox1.Invalidate(); }
private void pictureBox1_MouseMove(object sender, MouseEventArgs e) { //重点 事件: //第一步 判断是否有命令 //第二步 判断是否编辑 //第三步 执行命令 //设置图元选择距离 Primitive.SelectDistance = ViewPort.SurveyLengthOfOneScreenMillimeter() * 2; if (IsWriting) { return; } if (Command != null) { if (Command.cMDType == CMDType.PriCommand) { Primitive.SelectEnable = false; Primitive.SnapEnable = true; if (StartWriting) { TextFunction(e.Location.X, e.Location.Y); } } else if (Command.cMDType == CMDType.PriEditCommand) { Primitive.SelectEnable = true; Primitive.SnapEnable = false; } else if (Command.cMDType == CMDType.PicCommand) { ; } ViewPort.InvTransformPoint(e.Location.X, e.Location.Y); Command.MouseMove(e); } else { ViewPort.InvTransformPoint(e.Location.X, e.Location.Y); } //鼠标位置 this.StatusLabelXY.Text = ViewPort.MouseSurveyX.ToString("F3") + "," + ViewPort.MouseSurveyY.ToString("F3"); pictureBox1.Invalidate(); }