public eDrawObjectMouseDown OnMouseDown(ICanvas canvas, UnitPoint point, ISnapPoint snappoint) { if (snappoint is SnapPointBase && snappoint.Owner is RectBase) { NodePointMultiConnectionLine.ePoint pointType = HitUtil.Distance(point, m_p1) < HitUtil.Distance(point, m_p2) ? NodePointMultiConnectionLine.ePoint.P1 : NodePointMultiConnectionLine.ePoint.P2; RectBase rect = snappoint.Owner as RectBase; rect.AttachConnectionCrvNode(new NodePointMultiConnectionLine(this, pointType)); if (pointType == NodePointMultiConnectionLine.ePoint.P1) { m_p1 = point; } else { m_p2 = point; } return(eDrawObjectMouseDown.Done); } OnMouseMove(canvas, point); Selected = false; if (m_allPts == null || m_allPts.Count < 2) { return(eDrawObjectMouseDown.Cancel); } return(eDrawObjectMouseDown.Done); }
public virtual void Finish() { m_endPoint = GetPoint(m_pointId); m_owner.P1 = m_clone.P1; m_owner.P3 = m_clone.P3; m_clone = null; }
public void TrySnapConnectCrvToRectShape(ICanvas canvas, IConnectionCurve crv) { if (crv == null) { return; } List <IDrawObject> allSelectObjs = GetHitObjects(canvas, ((IDrawObject)crv).GetBoundingRect(canvas), true); foreach (var curObj in allSelectObjs) { DrawTools.RectBase rectBase = curObj as DrawTools.RectBase; if (rectBase == null) { continue; } DrawTools.RectBase.eVertexId vid = rectBase.GetVertexIdFromPoint(crv.StartPoint.GetPosition()); if (vid != DrawTools.RectBase.eVertexId.None) { rectBase.AttachConnectionCrvNode(crv.StartPoint); } vid = rectBase.GetVertexIdFromPoint(crv.EndPoint.GetPosition()); if (vid != DrawTools.RectBase.eVertexId.None) { rectBase.AttachConnectionCrvNode(crv.EndPoint); } } }
public NodePointRectBase(RectBase owner, ePoint id) { m_owner = owner; m_clone = m_owner.Clone() as RectBase; m_clone.CurrentPoint = m_owner.CurrentPoint; m_originalPoint = GetPoint(id); m_pointId = id; }
public void Copy(RectBase acopy) { base.Copy(acopy); P1 = acopy.P1; P3 = acopy.P3; Selected = acopy.Selected; CurrentPoint = acopy.CurrentPoint; m_guid = acopy.m_guid; UpdateCenter(); }
protected void SetPoint(ePoint pointid, UnitPoint point, RectBase oval) { if (pointid == ePoint.P1) { oval.P1 = point; } else if (pointid == ePoint.P3) { oval.P3 = point; } else if (pointid == ePoint.Center) { oval.Center = point; } }
public static void ActivateSymbolAtPoint(ICanvas canvas, List <IDrawObject> selectedObjs, UnitPoint hitPoint) { foreach (var obj in selectedObjs) { DrawTools.RectBase rectBase = obj as DrawTools.RectBase; if (rectBase == null) { continue; } List <DrawTools.Symbol> allSymbols = rectBase.GetAllSymbol(); foreach (var symbol in allSymbols) { if (symbol.PointInObject(canvas, hitPoint)) { symbol.OnClick(); } } } }
public eDrawObjectMouseDown OnMouseDown(ICanvas canvas, UnitPoint point, ISnapPoint snappoint) { Selected = false; OnMouseMove(canvas, point); if (snappoint is PerpendicularSnapPoint && snappoint.Owner is Line) { Line src = snappoint.Owner as Line; m_p2 = HitUtil.NearestPointOnLine(src.P1, src.P2, m_p1, true); return(eDrawObjectMouseDown.DoneRepeat); } if (snappoint is PerpendicularSnapPoint && snappoint.Owner is Arc) { Arc src = snappoint.Owner as Arc; m_p2 = HitUtil.NearestPointOnCircle(src.Center, src.Radius, m_p1, 0); return(eDrawObjectMouseDown.DoneRepeat); } if (snappoint is SnapPointBase && snappoint.Owner is RectBase) { NodePointCubicBezier.ePoint pointType = HitUtil.Distance(point, m_p1) < HitUtil.Distance(point, m_p2) ? NodePointCubicBezier.ePoint.P1 : NodePointCubicBezier.ePoint.P2; RectBase rect = snappoint.Owner as RectBase; rect.AttachConnectionCrvNode(new NodePointCubicBezier(this, pointType)); if (pointType == NodePointCubicBezier.ePoint.P1) { m_p1 = point; } else { m_p2 = point; } UpdateCtrlPts(); return(eDrawObjectMouseDown.Done); } if (Control.ModifierKeys == Keys.Control) { point = HitUtil.OrthoPointD(m_p1, point, 45); } m_p2 = point; UpdateCtrlPts(); return(eDrawObjectMouseDown.Done); }
protected override void OnMouseDoubleClick(MouseEventArgs e) { if (m_commandType != eCommandType.select || m_model.SelectedCount < 1) { return; } UnitPoint mousePt = ToUnit(new PointF(e.X, e.Y)); DrawTools.RectBase rectBase = null; foreach (var curObj in m_model.SelectedObjects) { rectBase = curObj as DrawTools.RectBase; if (rectBase != null && rectBase.PointInObject(m_canvaswrapper, mousePt)) { break; } } if (rectBase == null) { return; } //lay down a textbox on the rect shape RectangleF rect = ScreenUtils.ToScreenNormalized(m_canvaswrapper, rectBase.GetExactBoundingRect(m_canvaswrapper)); rect.Inflate(1, 1); m_rectBaseTextBox = new TextBox(); m_rectBaseTextBox.Tag = rectBase; m_rectBaseTextBox.Multiline = true; m_rectBaseTextBox.Font = new Font("Times New Roman", 15.0f); m_rectBaseTextBox.Location = new Point((int)rect.Left, (int)rect.Top); m_rectBaseTextBox.Size = new Size((int)rect.Width, (int)rect.Height); m_rectBaseTextBox.Text = rectBase.Text; Controls.Add(m_rectBaseTextBox); m_rectBaseTextBox.Focus(); m_rectBaseTextBox.SelectAll(); base.OnMouseDoubleClick(e); }
public void UpdateClone() { m_clone = m_owner.Clone() as RectBase; }