public DiagramPoint Copy() { DiagramPoint diagramPoint = new DiagramPoint(this.X, this.Y); diagramPoint.ConnectorDirection = this.ConnectorDirection; return(diagramPoint); }
protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); if (tracking) { selectedEntity.Move(new Point(e.X - _stratPoint.GetPoint().X, e.Y - _stratPoint.GetPoint().Y)); if (typeof(Connector).IsInstanceOfType(selectedEntity)) { for (int k = 0; k < shapes.Count; k++) { shapes[k].HitConnector(e.Location); } } } else if (_leftMouse) { _viewOriginPoint = new DiagramPoint(_viewOriginPoint.GetPoint().X + e.X - _stratPoint.GetPoint().X, _viewOriginPoint.GetPoint().Y + e.Y - _stratPoint.GetPoint().Y); } int entityTYpe = -1;//0:ShapeBase;1:ShapeBase.connectors;2:connections;3:connections.From;4:connections.To. Entity hoveredentity = shapes.Cast <Entity>().FirstOrDefault(f => f.Hit(e.Location)); if (hoveredentity == null) { hoveredentity = connections.Cast <Connection>().FirstOrDefault(f => { if (f.Hit(e.Location)) { entityTYpe = 2; return(true); } if (f.From.Hit(e.Location)) { entityTYpe = 3; return(true); } if (f.To.Hit(e.Location)) { entityTYpe = 4; return(true); } return(false); }); } if (entityTYpe == 3) { hoveredentity = ((Connection)hoveredentity).From; } if (entityTYpe == 4) { hoveredentity = ((Connection)hoveredentity).To; } UpdateHovered(hoveredentity); _stratPoint = e.Location; Invalidate(true); }
public Connection AddConnection(DiagramPoint from, DiagramPoint to) { Connection con = new Connection(from, to); con.Site = this; this.AddConnection(con); return(con); }
public void CopyControlParams(SaveDataInfo dataInfo) { this.ViewOriginPoint = dataInfo.ViewOriginPoint; this.LineHoveredColor = dataInfo.LineHoveredColor; this.LineSelectedColor = dataInfo.LineSelectedColor; this.LineColor = dataInfo.LineColor; this.BackColor = dataInfo.BackColor; this.ShowGrid = dataInfo.ShowGrid; }
/// <summary> /// Constructs a connection between the two given points /// </summary> /// <param name="from">the starting point of the connection</param> /// <param name="to">the end-point of the connection</param> public Connection(DiagramPoint from, DiagramPoint to) { Connector connector1, connector2; Connectors = new ConnectorCollection(); this.from = new Connector(from.Copy()); this.from.Name = "From"; this.from.LocationChanged += Connector_LocationChanged; connector1 = this.from; Connectors.Add(connector1); this.to = new Connector(to.Copy()); this.To.Name = "To"; connector2 = this.to; this.to.LocationChanged += Connector_LocationChanged; this.To.AttachedToChanged += To_AttachedToChanged; Connectors.Add(connector2); }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); _leftMouse = e.Button == MouseButtons.Left; _stratPoint = e.Location; int entityTYpe = -1;//0:ShapeBase;1:ShapeBase.connectors;2:connections;3:connections.From;4:connections.To. Entity hoveredentity = shapes.Cast <ShapeBase>().FirstOrDefault(f => { if (f.Hit(e.Location)) { return(true); } return(false); }); if (hoveredentity == null && selectedEntity != null && selectedEntity is ShapeBase) { Connector connector = (selectedEntity as ShapeBase).HitConnector(e.Location); if (connector != null) { Point point = e.Location; point.Offset(-this.ViewOriginPoint.GetPoint().X, -this.ViewOriginPoint.GetPoint().Y); Connection connection = this.AddConnection(connector.Point, point); connection.From.ContainEntity = connector.ContainEntity; connection.From.ConnectorsIndexOfContainEntity = connector.ConnectorsIndexOfContainEntity; UpdateSelected(connection.To); connector.AttachConnector(connection.From); tracking = true; Invalidate(true); return; } } if (hoveredentity != null) { tracking = true; OnSelectChanged(hoveredentity, new SelectElementChangedEventArgs() { CurrentEntity = hoveredentity, PreviousEntity = selectedEntity }); } else { hoveredentity = connections.Cast <Connection>().FirstOrDefault(f => { if (f.Hit(e.Location)) { entityTYpe = 2; return(true); } if (f.From.Hit(e.Location)) { entityTYpe = 3; return(true); } if (f.To.Hit(e.Location)) { entityTYpe = 4; return(true); } return(false); }); if (entityTYpe == 3) { hoveredentity = ((Connection)hoveredentity).From; tracking = true; } else if (entityTYpe == 4) { hoveredentity = ((Connection)hoveredentity).To; tracking = true; } else if (entityTYpe == 2) { OnSelectChanged(hoveredentity, new SelectElementChangedEventArgs() { CurrentEntity = hoveredentity, PreviousEntity = selectedEntity }); } } if (hoveredentity == null) { OnSelectChanged(this.proxy, new SelectElementChangedEventArgs() { CurrentEntity = hoveredentity, PreviousEntity = selectedEntity }); } UpdateSelected(hoveredentity); Invalidate(true); }
/// <summary> /// Constructs a connector, passing its location /// </summary> /// <param name="p"></param> public Connector(DiagramPoint p) { attachedConnectors = new ConnectorCollection(); Point = p; }