private void graphVisualization_OnEntityAdded(object sender, EntityEventArgs e) { IConnection connection = e.Entity as IConnection; if (connection != null && !this.connectionInfoConnectionMapping.ContainsSecond(connection)) { IConnector connectorFrom = connection.From.AttachedTo; IConnector connectorTo = connection.To.AttachedTo; this.RemoveConnection(connection); //is added again by the model events if (connectorFrom != null && connectorTo != null) { IShape shapeFrom = (IShape)connectorFrom.Parent; IShape shapeTo = (IShape)connectorTo.Parent; IShapeInfo shapeInfoFrom = this.shapeInfoShapeMapping.GetBySecond(shapeFrom); IShapeInfo shapeInfoTo = this.shapeInfoShapeMapping.GetBySecond(shapeTo); string connectorFromName = connectorFrom.Name; string connectorToName = connectorTo.Name; if (shapeInfoFrom != shapeInfoTo) //avoid self references { this.Content.AddConnectionInfo(new ConnectionInfo(shapeInfoFrom, connectorFromName, shapeInfoTo, connectorToName)); } } } }
public static IShape CreateShape(this IShapeInfo shapeInfo) { if (shapeInfo is IOperatorShapeInfo) { return(CreateShape((IOperatorShapeInfo)shapeInfo)); } throw new ArgumentException("Could not determine which shape object should be created."); }
public static void UpdateShapeInfo(this IShapeInfo shapeInfo, IShape shape) { shapeInfo.Location = shape.Location; if (shapeInfo is IOperatorShapeInfo && shape is OperatorShape) { UpdateShapeInfo((IOperatorShapeInfo)shapeInfo, (OperatorShape)shape); } }
public override void RemoveShapeInfo(IShapeInfo shapeInfo) { IOperatorShapeInfo opShapeInfo = (IOperatorShapeInfo)shapeInfo; if (this.operatorShapeInfoMapping.ContainsSecond(opShapeInfo)) { IOperator op = this.operatorShapeInfoMapping.GetBySecond(opShapeInfo); this.operatorGraph.Operators.Remove(op); } }
private void shapeInfo_Changed(object sender, EventArgs e) { IShapeInfo shapeInfo = (IShapeInfo)sender; IShape shape = this.shapeInfoShapeMapping.GetByFirst(shapeInfo); this.DeregisterShapeEvents(shape); shapeInfo.UpdateShape(shape); shape.Invalidate(); this.RegisterShapeEvents(shape); }
private void shape_OnEntityChange(object sender, EntityEventArgs e) { IShape shape = e.Entity as IShape; IShapeInfo shapeInfo = this.shapeInfoShapeMapping.GetBySecond(shape); this.DeregisterShapeInfoEvents(shapeInfo); shapeInfo.UpdateShapeInfo(shape); this.RegisterShapeInfoEvents(shapeInfo); this.graphVisualization.Invalidate(); }
private void AddShapeInfo(IShapeInfo shapeInfo) { this.RegisterShapeInfoEvents(shapeInfo); IShape shape = shapeInfo.CreateShape(); this.RegisterShapeEvents(shape); this.shapeInfoShapeMapping.Add(shapeInfo, shape); this.graphVisualization.Controller.Model.AddShape(shape); this.graphVisualization.Invalidate(); }
private void Controller_OnShowContextMenu(object sender, EntityMenuEventArgs e) { IShape shape = this.graphVisualizationInfoView.Controller.Model.GetShapeAt(e.MouseEventArgs.Location); if (shape != null) { IShapeInfo shapeInfo = shape.Tag as IShapeInfo; this.shapeContextMenu.Tag = shapeInfo; PointF worldPoint = this.graphVisualizationInfoView.Controller.View.WorldToView(e.MouseEventArgs.Location); this.shapeContextMenu.Show(this, Point.Round(worldPoint)); } }
public ConnectionInfo(IShapeInfo from, string connectorFrom, IShapeInfo to, string connectorTo) : base() { if (from == to) throw new ArgumentException("Could not create connections between the same shape info."); if (!from.Connectors.Contains(connectorFrom) || !to.Connectors.Contains(connectorTo)) throw new ArgumentException("Could not create connection between not existent connectors."); this.from = from; this.connectorFrom = connectorFrom; this.to = to; this.connectorTo = connectorTo; }
private void UpdateLayoutRoot() { IShapeInfo shapeInfo = this.Content.InitialShape; if (shapeInfo != null) { this.graphVisualization.Controller.Model.LayoutRoot = this.shapeInfoShapeMapping.GetByFirst(shapeInfo); } else { this.graphVisualization.Controller.Model.LayoutRoot = null; } }
private void RemoveShapeInfo(IShapeInfo shapeInfo) { this.DeregisterShapeInfoEvents(shapeInfo); IShape shape = this.shapeInfoShapeMapping.GetByFirst(shapeInfo); this.DeregisterShapeEvents(shape); this.shapeInfoShapeMapping.RemoveByFirst(shapeInfo); if (this.graphVisualization.Controller.Model.Shapes.Contains(shape)) { this.graphVisualization.Controller.Model.RemoveShape(shape); this.graphVisualization.Controller.Model.Selection.Clear(); this.graphVisualization.Invalidate(); } }
public ConnectionInfo(IShapeInfo from, string connectorFrom, IShapeInfo to, string connectorTo) : base() { if (from == to) { throw new ArgumentException("Could not create connections between the same shape info."); } if (!from.Connectors.Contains(connectorFrom) || !to.Connectors.Contains(connectorTo)) { throw new ArgumentException("Could not create connection between not existent connectors."); } this.from = from; this.connectorFrom = connectorFrom; this.to = to; this.connectorTo = connectorTo; }
private void graphVisualization_OnEntityRemoved(object sender, EntityEventArgs e) { IShape shape = e.Entity as IShape; if (shape != null && this.shapeInfoShapeMapping.ContainsSecond(shape)) { IShapeInfo shapeInfo = this.shapeInfoShapeMapping.GetBySecond(shape); this.Content.RemoveShapeInfo(shapeInfo); } IConnection connection = e.Entity as IConnection; if (connection != null && this.connectionInfoConnectionMapping.ContainsSecond(connection)) { IConnectionInfo connectionInfo = connectionInfoConnectionMapping.GetBySecond(connection); this.Content.RemoveConnectionInfo(connectionInfo); } }
public virtual void AddShapeInfo(IShapeInfo shapeInfo) { this.shapeInfos.Add(shapeInfo); }
public virtual void RemoveShapeInfo(IShapeInfo shapeInfo) { this.shapeInfos.Remove(shapeInfo); this.connectionInfos.RemoveWhere(c => c.From == shapeInfo); this.connectionInfos.RemoveWhere(c => c.To == shapeInfo); }
public IEnumerable<IConnectionInfo> GetConnectionInfos(IShapeInfo shapeInfo) { return this.ConnectionInfos.Where(c => c.From == shapeInfo || c.To == shapeInfo); }
public IEnumerable<IConnectionInfo> GetConnectionInfos(IShapeInfo shapeInfo, string connector) { return this.ConnectionInfos.Where(c => (c.From == shapeInfo && c.ConnectorFrom == connector) || (c.To == shapeInfo && c.ConnectorTo == connector)); }
private void DeregisterShapeInfoEvents(IShapeInfo shapeInfo) { shapeInfo.Changed -= new EventHandler(shapeInfo_Changed); }
public IEnumerable <IConnectionInfo> GetConnectionInfos(IShapeInfo shapeInfo, string connector) { return(this.ConnectionInfos.Where(c => (c.From == shapeInfo && c.ConnectorFrom == connector) || (c.To == shapeInfo && c.ConnectorTo == connector))); }
public IEnumerable <IConnectionInfo> GetConnectionInfos(IShapeInfo shapeInfo) { return(this.ConnectionInfos.Where(c => c.From == shapeInfo || c.To == shapeInfo)); }