/// <summary> /// Method that creates a node of the specified type. The method will specify the ports /// that the node should have based on its type. /// </summary> private void CreateNode(IGraph graph, PointD location, FlowChartType type) { var size = FlowChartNodeStyle.GetNodeTypeSize(type); RectD newBounds = new RectD(location, size); graph.CreateNode(newBounds, new FlowChartNodeStyle { FlowChartType = type }); }
/// <summary> /// Returns the size a node with this tag would need. /// </summary> public static SizeD GetNodeTypeSize(FlowChartType type) { switch (type) { case FlowChartType.Start: return(new SizeD(30, 30)); case FlowChartType.Operation: return(new SizeD(60, 30)); case FlowChartType.End: return(new SizeD(30, 30)); case FlowChartType.Branch: return(new SizeD(60, 30)); default: // can't happen return(new SizeD(30, 30)); } }
/// <summary> /// Creates an enumerable of all edges belonging to the type of the node as specified by its /// <see cref="FlowChartType"/> set as its tag or an empty list if there is no /// <see cref="FlowChartType"/>. /// </summary> /// <param name="flowChartType"></param> /// <returns></returns> public static IEnumerable <PortDescriptor> CreatePortDescriptors(FlowChartType flowChartType) { switch (flowChartType) { default: case FlowChartType.Start: return(new List <PortDescriptor> { new PortDescriptor { X = 15, Y = 15, Side = PortDirections.Any } }); case FlowChartType.Operation: return(new List <PortDescriptor> { new PortDescriptor { Side = PortDirections.North }, new PortDescriptor { Side = PortDirections.South } }); case FlowChartType.Branch: return(new List <PortDescriptor> { new PortDescriptor { X = 30, Y = 0, Side = PortDirections.North, Capacity = 1, Cost = 0 }, new PortDescriptor { X = 30, Y = 30, Side = PortDirections.South, Capacity = 1, Cost = 0 }, new PortDescriptor { X = 60, Y = 15, Side = PortDirections.East, Capacity = 1, Cost = 0 }, new PortDescriptor { X = 0, Y = 15, Side = PortDirections.West, Capacity = 1, Cost = 0 }, new PortDescriptor { X = 30, Y = 0, Side = PortDirections.North, Cost = 1 }, new PortDescriptor { X = 30, Y = 30, Side = PortDirections.South, Cost = 1 } }); case FlowChartType.End: return(new List <PortDescriptor> { new PortDescriptor { X = 15, Y = 0, Side = PortDirections.North, Capacity = 1, Cost = 0 }, new PortDescriptor { X = 30, Y = 15, Side = PortDirections.East, Capacity = 1, Cost = 1 }, new PortDescriptor { X = 0, Y = 15, Side = PortDirections.West, Capacity = 1, Cost = 1 }, new PortDescriptor { X = 30, Y = 15, Side = PortDirections.East, Cost = 2 }, new PortDescriptor { X = 0, Y = 15, Side = PortDirections.West, Cost = 2 } }); } }