/// <summary> /// 创建控件终止 /// </summary> public void End() { if (_nodeObject != null) { INodeEdit node = (INodeEdit)_nodeObject; //最后一个点为动态移动点,需要删除 int count = node.NodeDatas.Count; if (count > 0) { node.DeleteNode(count - 1); } //创建成功 if (node.CreateSuccess) { node.IsNodeCreating = false; _studio.ControlPoint.ChangeSelectObj(new List <IDrawObj> { _nodeObject }); _nodeObject.Invalidate(); } else { _studio.Objs.Remove(_nodeObject); } _nodeObject = null; _studio.Container.Framework.Manager.ResetToolboxPointerFunction(); } _studio.Container.Cursor = Cursors.Default; _state = CreateState.NotCreate; _orthoState = OrthoMode.Invalid; }
public void FlipY() { if (IsSingle) { Vector.IsFlipY = !Vector.IsFlipY; } else { Invalidate(); foreach (IDrawObj obj in _list) { IDrawVector v = (IDrawVector)obj; v.IsFlipY = !v.IsFlipY; float offset = Rect.Top + Rect.Bottom - v.Bound.Top * 2 - v.Bound.Height; RectangleF rf = v.Rect; rf.Y += offset; v.Rect = rf; } Invalidate(true); } }
public void FlipX() { if (IsSingle) { Vector.IsFlipX = !Vector.IsFlipX; } else { Invalidate(); foreach (IDrawObj obj in _list) { IDrawVector v = (IDrawVector)obj; v.IsFlipX = !v.IsFlipX; float offset = Rect.Left + Rect.Right - v.Bound.Left * 2 - v.Bound.Width; RectangleF rf = v.Rect; rf.X += offset; v.Rect = rf; } Invalidate(true); } }
public bool MouseDown(MouseButtons button, PointF location, PointF revertPoint) { if (_studio.IsGrid) { revertPoint = Tool.GetGridPointF(revertPoint); } if (_state == CreateState.BeginCreate) { _state = CreateState.HasCreate; if (_nodeObject != null) { End(); return(true); } if (_isNodeCreate) { _nodeObject = (IDrawVector)_studio.CreateDrawObj(_type); _nodeObject.Parant = _studio.Container; ((ObjName)_studio.NameManager).CreateName(_nodeObject); _studio.Objs.Add(_nodeObject); INodeEdit node = (INodeEdit)_nodeObject; node.IsNodeCreating = true; node.AddNode(revertPoint); node.AddNode(revertPoint); _nodeObject.LoadInitializationEvent(); } return(true); } if (_state == CreateState.HasCreate) { if (_isNodeCreate && _nodeObject != null) { INodeEdit node = (INodeEdit)_nodeObject; int count = node.NodeDatas.Count; PointF lastPoint = node.NodeDatas[count - 2]; revertPoint = GetOrthoHoriorVert(lastPoint, revertPoint); //预防在同一位置重复添加点 if (Point.Ceiling(lastPoint) == Point.Ceiling(revertPoint)) { return(true); } node.MoveNode(revertPoint, count - 1); node.AddNode(revertPoint); //添加点后创建成功,则直接结束 if (node.CreateFinish) { End(); return(true); } } return(true); } return(false); }