Exemplo n.º 1
0
        /// <summary>
        /// This method is used to execute Item Added command
        /// </summary>
        /// <param name="obj"></param>
        private void ItemAddedExecution(object obj)
        {
            var args = obj as ItemAddedEventArgs;

            if (args.ItemSource == ItemSource.Load)
            {
                if (args.Item is CustomNode)
                {
                    CustomNode node = args.Item as CustomNode;
                    this.Fillcolor   = node.Fillcolor;
                    this.Strokecolor = node.Strokecolor;
                }
                else if (args.Item is CustomConnector)
                {
                    CustomConnector con = args.Item as CustomConnector;
                    con.TargetDecoratorStyle   = App.Current.MainWindow.Resources[con.TargetStyleKey] as Style;
                    con.ConnectorGeometryStyle = App.Current.MainWindow.Resources[con.ConnectorStyleKey] as Style;
                }
            }
            else if (args.ItemSource == ItemSource.Stencil)
            {
                if (args.Item is CustomNode)
                {
                    CustomNode node = args.Item as CustomNode;
                    node.Fillcolor   = new SolidColorBrush(Colors.Transparent);
                    node.Strokecolor = new SolidColorBrush(Colors.Black);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// This method is used to create Connectors
        /// </summary>
        /// <param name="node1"></param>
        /// <param name="node2"></param>
        /// <param name="v"></param>
        /// <returns></returns>
        private CustomConnector CreateConnector(NodeViewModel sourcenode, NodeViewModel targetnode, string content)
        {
            CustomConnector con = new CustomConnector()
            {
                SourceNode             = sourcenode,
                TargetNode             = targetnode,
                Annotations            = null,
                TargetDecoratorStyle   = App.Current.MainWindow.Resources["TargetDecoratorStyle"] as Style,
                ConnectorGeometryStyle = App.Current.MainWindow.Resources["ConnectorGeometryStyle"] as Style,
                ConnectorStyleKey      = "ConnectorGeometryStyle",
                TargetStyleKey         = "TargetDecoratorStyle",
            };

            if (content != "")
            {
                if (content == "No" || content == "After 5 mins")
                {
                    con.Annotations = new AnnotationCollection()
                    {
                        new AnnotationEditorViewModel()
                        {
                            Content = content,
                            Pivot   = new Point(0.5, 0),
                        },
                    };
                }
                else
                {
                    con.Annotations = new AnnotationCollection()
                    {
                        new AnnotationEditorViewModel()
                        {
                            Content     = content,
                            RotateAngle = -90,
                            Pivot       = new Point(0, 0.6),
                        },
                    };
                }
            }

            (Connectors as ConnectorCollection).Add(con);

            return(con);
        }