public static NodeState GetCurrentState(this SfNodeViewModel node) { return(new NodeState() { Fill = node.FillColor, Stroke = node.StrokeColor }); }
private SfNodeViewModel CreateNode(double offsetx, double offsety, string shape, string content, string shapestylecolor) { var node = new SfNodeViewModel() { OffsetX = offsetx, OffsetY = offsety, Shape = resourceDictionary[shape], UnitWidth = 120, }; if (content == "Design") { node.Ports = new PortCollection() { new NodePortViewModel() { NodeOffsetX = 0, NodeOffsetY = 0.5, ConnectionDirection = ConnectionDirection.Left, Constraints = PortConstraints.Default | PortConstraints.ConnectionDirection, }, }; } if (content == "Design Errors?") { node.Ports = new PortCollection() { new NodePortViewModel() { NodeOffsetX = 0.5, NodeOffsetY = 1, ConnectionDirection = ConnectionDirection.Bottom, Constraints = PortConstraints.Default | PortConstraints.ConnectionDirection, }, }; } if (content == "Errors?") { node.Ports = new PortCollection() { new NodePortViewModel() { NodeOffsetX = 0, NodeOffsetY = 0.5, ConnectionDirection = ConnectionDirection.Left, Constraints = PortConstraints.Default | PortConstraints.ConnectionDirection, }, }; } Style shapestyle = new Style(typeof(Path)); shapestyle.Setters.Add(new Setter(Path.StrokeProperty, Brushes.WhiteSmoke)); shapestyle.Setters.Add(new Setter(Path.StrokeThicknessProperty, 1d)); shapestyle.Setters.Add(new Setter(Path.StretchProperty, Stretch.Fill)); if (shapestylecolor == "Pink") { shapestyle.Setters.Add(new Setter(Path.FillProperty, Brushes.LightPink)); } else if (shapestylecolor == "Grey") { shapestyle.Setters.Add(new Setter(Path.FillProperty, Brushes.LightGray)); } else if (shapestylecolor == "Green") { shapestyle.Setters.Add(new Setter(Path.FillProperty, Brushes.LightGreen)); } node.ShapeStyle = shapestyle; if (shape != "Diamond") { node.UnitHeight = 40; } else { node.UnitHeight = 100; } if (content != "") { node.Annotations = new AnnotationCollection() { new TextAnnotationViewModel() { Text = content, WrapText = TextWrapping.NoWrap, }, }; } (Nodes as ObservableCollection <SfNodeViewModel>).Add(node); return(node); }
private SfConnectorViewModel CreateConnector(SfNodeViewModel sourcenode, SfNodeViewModel targetnode, string content) { var con = new SfConnectorViewModel() { SourceNode = sourcenode, TargetNode = targetnode, Annotations = null, TargetDecorator = resourceDictionary["ClosedSharp"], }; if (targetnode.Ports != null && (targetnode.Ports as PortCollection).Count > 0 && content != "") { con.TargetPort = (targetnode.Ports as PortCollection).First() as NodePortViewModel; } if (sourcenode.Ports != null && (sourcenode.Ports as PortCollection).Count > 0 && content != "" && content == "Yes") { con.SourcePort = (sourcenode.Ports as PortCollection).First() as NodePortViewModel; } if (content != "") { if (content == "Yes") { con.Annotations = new AnnotationCollection() { new TextAnnotationViewModel() { Text = content, Pivot = new Point(0.5, 0), }, }; } else if (content == "No" && ((targetnode.Annotations as AnnotationCollection).First() as TextAnnotationViewModel).Text == "End") { con.Annotations = new AnnotationCollection() { new TextAnnotationViewModel() { Text = content, Pivot = new Point(0, 1), Margin = new Thickness(0, 0, 0, 10), RotateAngle = -90, }, }; } else if (content == "No") { con.Annotations = new AnnotationCollection() { new TextAnnotationViewModel() { Text = content, Pivot = new Point(0.5, 0) }, }; } } (Connectors as ObservableCollection <SfConnectorViewModel>).Add(con); return(con); }
public static void UpdateState(this SfNodeViewModel node, NodeState state) { node.FillColor = state.Fill; node.StrokeColor = state.Stroke; }