protected VisualNode(IGraphController graphController, NodeType nodeType) { this.graphController = graphController as GraphController; IdGenerator idGenerator = this.graphController.GetIdGenerator(); this.nodeType = nodeType; this.version = VisualNode.Version.Current; this.nodeId = idGenerator.GetNextId(ComponentType.Node); this.nodeState = States.Visible; this.Dirty = true; this.graphController.AddVisualNode(this); }
protected VisualNode(IGraphController graphController, NodeType nodeType) { this.graphController = graphController as GraphController; IdGenerator idGenerator = this.graphController.GetIdGenerator(); this.nodeType = nodeType; this.version = VisualNode.Version.Current; this.nodeId = idGenerator.GetNextId(ComponentType.Node); this.nodeState = States.Visible; this.Dirty = true; this.graphController.AddVisualNode(this); }
public virtual bool Deserialize(IStorage storage) { if (storage == null) { throw new ArgumentNullException("storage"); } if (storage.ReadUnsignedInteger(FieldCode.NodeSignature) != Configurations.NodeSignature) { throw new InvalidOperationException("Invalid input data"); } try { this.nodeType = (NodeType)storage.ReadInteger(FieldCode.NodeType); this.version = (VisualNode.Version)storage.ReadInteger(FieldCode.NodeVersion); this.nodeId = storage.ReadUnsignedInteger(FieldCode.NodeId); this.nodeState = (States)storage.ReadInteger(FieldCode.NodeState); this.Text = storage.ReadString(FieldCode.Text); this.Caption = storage.ReadString(FieldCode.Caption); this.nodePosition.X = storage.ReadDouble(FieldCode.NodePositionX); this.nodePosition.Y = storage.ReadDouble(FieldCode.NodePositionY); int inputSlotsCount = storage.ReadInteger(FieldCode.InputSlotsCount); this.inputSlots.Clear(); for (int i = 0; i < inputSlotsCount; i++) { this.inputSlots.Add(storage.ReadUnsignedInteger(FieldCode.InputSlots)); } int outputSlotsCount = storage.ReadInteger(FieldCode.OutputSlotsCount); this.outputSlots.Clear(); for (int j = 0; j < outputSlotsCount; j++) { this.outputSlots.Add(storage.ReadUnsignedInteger(FieldCode.OutputSlots)); } this.Dirty = true; // Mark as dirty for painting. return(true); } catch (Exception e) { //@TODO(Zx): Move this to error handler Console.WriteLine(e.Message + "\n Visual node deserialization failed."); return(false); } }
public virtual bool Deserialize(IStorage storage) { if (storage == null) throw new ArgumentNullException("storage"); if (storage.ReadUnsignedInteger(FieldCode.NodeSignature) != Configurations.NodeSignature) throw new InvalidOperationException("Invalid input data"); try { this.nodeType = (NodeType)storage.ReadInteger(FieldCode.NodeType); this.version = (VisualNode.Version)storage.ReadInteger(FieldCode.NodeVersion); this.nodeId = storage.ReadUnsignedInteger(FieldCode.NodeId); this.nodeState = (States)storage.ReadInteger(FieldCode.NodeState); this.Text = storage.ReadString(FieldCode.Text); this.Caption = storage.ReadString(FieldCode.Caption); this.nodePosition.X = storage.ReadDouble(FieldCode.NodePositionX); this.nodePosition.Y = storage.ReadDouble(FieldCode.NodePositionY); int inputSlotsCount = storage.ReadInteger(FieldCode.InputSlotsCount); this.inputSlots.Clear(); for (int i = 0; i < inputSlotsCount; i++) this.inputSlots.Add(storage.ReadUnsignedInteger(FieldCode.InputSlots)); int outputSlotsCount = storage.ReadInteger(FieldCode.OutputSlotsCount); this.outputSlots.Clear(); for (int j = 0; j < outputSlotsCount; j++) this.outputSlots.Add(storage.ReadUnsignedInteger(FieldCode.OutputSlots)); this.Dirty = true; // Mark as dirty for painting. return true; } catch (Exception e) { //@TODO(Zx): Move this to error handler Console.WriteLine(e.Message + "\n Visual node deserialization failed."); return false; } }