internal VisualEdge(EdgeController edgeController, uint startSlotId, uint endSlotId, bool isImplicit) { this.edgeController = edgeController; if (isImplicit) this.EdgeType = EdgeType.ImplicitConnection; else this.EdgeType = EdgeType.ExplicitConnection; this.version = VisualEdge.Version.Current; this.StartSlotId = startSlotId; this.EndSlotId = endSlotId; // Generate new ID for this visual edge. GraphController graphController = edgeController.GetGraphController(); IdGenerator idGenerator = graphController.GetIdGenerator(); this.EdgeId = idGenerator.GetNextId(ComponentType.Edge); controlPoints.Add(new Point()); controlPoints.Add(new Point()); controlPoints.Add(new Point()); controlPoints.Add(new Point()); GraphController controller = edgeController.GetGraphController(); Slot startSlot = controller.GetSlot(this.StartSlotId) as Slot; Slot endSlot = controller.GetSlot(this.EndSlotId) as Slot; if (startSlot != null && endSlot != null) { Point startPoint = startSlot.GetPosition(); Point endPoint = endSlot.GetPosition(); UpdateControlPoint(startPoint, endPoint, startSlot.SlotType != SlotType.Output); } else throw new ArgumentNullException("startSlot or endSlot"); }
internal VisualEdge(EdgeController edgeController, uint startSlotId, uint endSlotId, bool isImplicit) { this.edgeController = edgeController; if (isImplicit) { this.EdgeType = EdgeType.ImplicitConnection; } else { this.EdgeType = EdgeType.ExplicitConnection; } this.version = VisualEdge.Version.Current; this.StartSlotId = startSlotId; this.EndSlotId = endSlotId; // Generate new ID for this visual edge. GraphController graphController = edgeController.GetGraphController(); IdGenerator idGenerator = graphController.GetIdGenerator(); this.EdgeId = idGenerator.GetNextId(ComponentType.Edge); controlPoints.Add(new Point()); controlPoints.Add(new Point()); controlPoints.Add(new Point()); controlPoints.Add(new Point()); GraphController controller = edgeController.GetGraphController(); Slot startSlot = controller.GetSlot(this.StartSlotId) as Slot; Slot endSlot = controller.GetSlot(this.EndSlotId) as Slot; if (startSlot != null && endSlot != null) { Point startPoint = startSlot.GetPosition(); Point endPoint = endSlot.GetPosition(); UpdateControlPoint(startPoint, endPoint, startSlot.SlotType != SlotType.Output); } else { throw new ArgumentNullException("startSlot or endSlot"); } }
public bool Deserialize(IStorage storage) { if (storage == null) { throw new ArgumentNullException("storage"); } if (storage.ReadUnsignedInteger(FieldCode.EdgeSignature) != Configurations.EdgeSignature) { throw new InvalidOperationException("Invalid input data"); } try { this.EdgeType = (EdgeType)storage.ReadInteger(FieldCode.EdgeType); this.version = (VisualEdge.Version)storage.ReadInteger(FieldCode.EdgeVersion); this.EdgeId = storage.ReadUnsignedInteger(FieldCode.EdgeId); this.edgeState = (States)storage.ReadInteger(FieldCode.EdgeState); this.StartSlotId = storage.ReadUnsignedInteger(FieldCode.StartSlotId); this.EndSlotId = storage.ReadUnsignedInteger(FieldCode.EndSlotId); int controlPointsCount = storage.ReadInteger(FieldCode.ControlPointsCount); this.controlPoints.Clear(); for (int i = 0; i < controlPointsCount; i++) { double ptX = storage.ReadDouble(FieldCode.ControlPointsX); double ptY = storage.ReadDouble(FieldCode.ControlPointsY); Point pt = new Point(ptX, ptY); this.controlPoints.Add(pt); } this.Dirty = true; return(true); } catch (Exception e) { Console.WriteLine(e.Message + "\n Edge deserialization failed."); return(false); } }
public bool Deserialize(IStorage storage) { if (storage == null) throw new ArgumentNullException("storage"); if (storage.ReadUnsignedInteger(FieldCode.EdgeSignature) != Configurations.EdgeSignature) throw new InvalidOperationException("Invalid input data"); try { this.EdgeType = (EdgeType)storage.ReadInteger(FieldCode.EdgeType); this.version = (VisualEdge.Version)storage.ReadInteger(FieldCode.EdgeVersion); this.EdgeId = storage.ReadUnsignedInteger(FieldCode.EdgeId); this.edgeState = (States)storage.ReadInteger(FieldCode.EdgeState); this.StartSlotId = storage.ReadUnsignedInteger(FieldCode.StartSlotId); this.EndSlotId = storage.ReadUnsignedInteger(FieldCode.EndSlotId); int controlPointsCount = storage.ReadInteger(FieldCode.ControlPointsCount); this.controlPoints.Clear(); for (int i = 0; i < controlPointsCount; i++) { double ptX = storage.ReadDouble(FieldCode.ControlPointsX); double ptY = storage.ReadDouble(FieldCode.ControlPointsY); Point pt = new Point(ptX, ptY); this.controlPoints.Add(pt); } this.Dirty = true; return true; } catch (Exception e) { Console.WriteLine(e.Message + "\n Edge deserialization failed."); return false; } }