예제 #1
0
        public LaneViewModel CreateLaneViewModel(bool ishorizontal, string content, double angle)
        {
            AnnotationEditorViewModel annotation = new AnnotationEditorViewModel()
            {
                RotateAngle = angle, Content = content, Offset = new Point(0.5, 0.5)
            };

            annotation.Constraints |= AnnotationConstraints.Rotatable & ~AnnotationConstraints.InheritRotatable;
            LaneViewModel l1 = new LaneViewModel()
            {
                Header = new SwimlaneHeaderViewModel()
                {
                    Annotation = annotation,
                },
            };

            if (ishorizontal)
            {
                (l1.Header as SwimlaneHeaderViewModel).UnitWidth = 50;
            }
            else
            {
                (l1.Header as SwimlaneHeaderViewModel).UnitHeight = 50;
            }
            return(l1);
        }
예제 #2
0
 //Event to notify the Changes
 private void info_ItemAdded(object sender, ItemAddedEventArgs args)
 {
     //Items added due to clipboard operation
     if (args.ItemSource == ItemSource.ClipBoard)
     {
         if (args.Item is INode)
         {
             NodeVm node = args.Item as NodeVm;
             if (!node.IsCustomStyle)
             {
                 node.ShapeStyle = GetStyle("#65c7d0");
             }
             else
             {
                 node.ShapeStyle = GetStyle("#858585");
             }
             AnnotationEditorViewModel vm = (node.Annotations as ICollection <IAnnotation>).ToList()[0] as AnnotationEditorViewModel;
             if (!node.IsMultiline)
             {
                 vm.ViewTemplate = this.Resources["viewtemplate1"] as DataTemplate;
             }
             else
             {
                 vm.ViewTemplate = this.Resources["viewtemplate"] as DataTemplate;
             }
         }
     }
 }
예제 #3
0
        public TextNode()
        {
            this.Annotations = new ObservableCollection <IAnnotation>();

            //Add Annotation to TitleNode
            AnnotationEditorViewModel title = new AnnotationEditorViewModel()
            {
                Content      = Label1,
                ViewTemplate = Application.Current.MainWindow.Resources["viewtemplate"] as DataTemplate,
                EditTemplate = Application.Current.MainWindow.Resources["edittemplate"] as DataTemplate
            };

            (this.Annotations as ICollection <IAnnotation>).Add(title);
        }
        /// <summary>
        /// Method to create Node
        /// </summary>
        /// <param name="offsetx"></param>
        /// <param name="shape"></param>
        /// <param name="annotation"></param>
        /// <param name="constraints"></param>
        private void CreateNode(double offsetx, string shape, string annotation, string constraints)
        {
            AnnotationEditorViewModel anno = new AnnotationEditorViewModel()
            {
                Content = annotation,
            };

            NodeViewModel node = new NodeViewModel()
            {
                OffsetX     = offsetx,
                OffsetY     = 250,
                UnitHeight  = 100,
                UnitWidth   = 100,
                Shape       = App.Current.Resources[shape],
                Annotations = new AnnotationCollection()
                {
                    anno,
                },
                ShapeStyle = App.Current.Resources["DefaultStyle"] as Style,
            };

            if (constraints.Equals("Selection"))
            {
                node.Constraints = node.Constraints.Remove(NodeConstraints.Selectable);
            }
            else if (constraints.Equals("Drag"))
            {
                node.Constraints = node.Constraints.Remove(NodeConstraints.InheritDraggable);
            }
            else if (constraints.Equals("Resize"))
            {
                node.Constraints = node.Constraints.Remove(NodeConstraints.InheritResizable);
            }
            else if (constraints.Equals("Rotate"))
            {
                node.ID          = "Rotate";
                node.RotateAngle = 45;
                node.Constraints = node.Constraints.Remove(NodeConstraints.InheritRotatable);
            }
            else if (constraints.Equals("Edit"))
            {
                anno.Constraints = anno.Constraints.Remove(AnnotationConstraints.InheritEditable | AnnotationConstraints.Editable);
            }
            else if (constraints.Equals("Delete"))
            {
                node.Constraints = node.Constraints.Remove(NodeConstraints.Delete);
            }

            (Nodes as NodeCollection).Add(node);
        }
예제 #5
0
        public TitleNode()
        {
            //To Represent Annotation Property
            this.Annotations = new ObservableCollection <IAnnotation>();
            //Add Annotation to TitleNode
            AnnotationEditorViewModel title = new AnnotationEditorViewModel()
            {
                WrapText = TextWrapping.NoWrap,
                TextVerticalAlignment = System.Windows.VerticalAlignment.Bottom,
                ReadOnly = true,
                //Set Annotation Template to Node
                ViewTemplate = Application.Current.MainWindow.Resources["viewtemplate1"] as DataTemplate,
                EditTemplate = Application.Current.MainWindow.Resources["edittemplate"] as DataTemplate
            };

            (this.Annotations as ICollection <IAnnotation>).Add(title);
        }
        /// <summary>
        /// Method to create Connectors
        /// </summary>
        /// <param name="point1"></param>
        /// <param name="point2"></param>
        /// <param name="annotation"></param>
        /// <param name="constraints"></param>
        private void CreateConnector(Point point1, Point point2, string annotation, string constraints)
        {
            AnnotationEditorViewModel anno = new AnnotationEditorViewModel()
            {
                Content = annotation,
                Margin  = new Thickness(0, 10, 30, 0),
            };

            ConnectorViewModel con = new ConnectorViewModel()
            {
                SourcePoint = point1,
                TargetPoint = point2,
                Annotations = new AnnotationCollection()
                {
                    anno,
                },
            };

            if (constraints.Equals("Selection"))
            {
                con.Constraints = con.Constraints.Remove(ConnectorConstraints.Selectable);
            }
            else if (constraints.Equals("Drag"))
            {
                con.Constraints = con.Constraints.Add(ConnectorConstraints.Draggable);
            }
            else if (constraints.Equals("Delete"))
            {
                con.Constraints = con.Constraints.Remove(ConnectorConstraints.Delete);
            }
            else if (constraints.Equals("EndThumb"))
            {
                con.Constraints = con.Constraints.Remove(ConnectorConstraints.EndThumbs);
            }
            else if (constraints.Equals("EndDraggable"))
            {
                con.Constraints = con.Constraints.Remove(ConnectorConstraints.EndDraggable);
            }
            else if (constraints.Equals("SegmentThumb"))
            {
                con.Constraints = con.Constraints.Remove(ConnectorConstraints.SegmentThumbs);
            }

            (Connectors as ConnectorCollection).Add(con);
        }
예제 #7
0
 //Event to notify the Changes
 void info_ItemAdded(object sender, ItemAddedEventArgs args)
 {
     //Items added due to clipboard operation
     if (args.ItemSource == ItemSource.ClipBoard)
     {
         if (args.Item is INode)
         {
             NodeVm node = args.Item as NodeVm;
             if (!node.IsCustomStyle)
             {
                 node.ShapeStyle = App.Current.Resources["nodeshapestyle"] as Style;
             }
             else
             {
                 node.ShapeStyle = App.Current.Resources["nodeshapestyle1"] as Style;
             }
             AnnotationEditorViewModel vm = (node.Annotations as ICollection <IAnnotation>).ToList()[0] as AnnotationEditorViewModel;
             if (node.IsMultiline)
             {
                 vm.ViewTemplate = App.Current.Resources["viewtemplate"] as DataTemplate;
             }
             else
             {
                 vm.ViewTemplate = App.Current.Resources["viewtemplate1"] as DataTemplate;
             }
         }
     }
     if (args.Item is ConnectorViewModel)
     {
         ConnectorViewModel cvm = args.Item as ConnectorViewModel;
         if (cvm.Annotations == null)
         {
             cvm.Annotations = new ObservableCollection <IAnnotation>()
             {
                 new AnnotationEditorViewModel()
                 {
                     Content = "",
                 }
             };
         }
     }
 }
예제 #8
0
        public DiagramVM()
        {
            Nodes      = new NodeCollection();
            Connectors = new ConnectorCollection();

            anno = new AnnotationEditorViewModel()
            {
                Content = "Annoatation",
            };

            NodeViewModel node = new NodeViewModel()
            {
                OffsetX     = 500,
                OffsetY     = 250,
                UnitHeight  = 100,
                UnitWidth   = 100,
                Annotations = new AnnotationCollection()
                {
                    anno,
                },
            };

            (Nodes as NodeCollection).Add(node);
        }
        public MainWindow()
        {
            InitializeComponent();
            ObservableCollection <NodeViewModel> nodes = new ObservableCollection <NodeViewModel>();
            AnnotationEditorViewModel            a2    = new AnnotationEditorViewModel()
            {
                Content     = "hi",
                UnitHeight  = 60,
                UnitWidth   = 60,
                Constraints = AnnotationConstraints.Default,
            };
            ObservableCollection <ConnectorViewModel> connectors = new ObservableCollection <ConnectorViewModel>();
            NodeViewModel n2 = new NodeViewModel()
            {
                UnitWidth  = 100,
                UnitHeight = 100,
                OffsetX    = 100,
                OffsetY    = 100,
                Shape      = new RectangleGeometry()
                {
                    Rect = new Rect(0, 0, 10, 10)
                },
                Annotations = new ObservableCollection <IAnnotation>()
                {
                    a2,
                },
            };
            AnnotationEditorViewModel a3 = new AnnotationEditorViewModel()
            {
                Content     = "hello",
                UnitHeight  = 60,
                UnitWidth   = 60,
                Constraints = AnnotationConstraints.Default,
            };
            NodeViewModel n3 = new NodeViewModel()
            {
                UnitWidth  = 100,
                UnitHeight = 100,
                OffsetX    = 300,
                OffsetY    = 300,
                Shape      = new RectangleGeometry()
                {
                    Rect = new Rect(0, 0, 10, 10)
                },
                Annotations = new ObservableCollection <IAnnotation>()
                {
                    a3,
                },
            };
            ConnectorViewModel c1 = new ConnectorViewModel()
            {
                SourceNode = n2,
                TargetNode = n3,
            };

            nodes.Add(n2);
            nodes.Add(n3);
            diag.Nodes = nodes;
            connectors.Add(c1);
            diag.Connectors = connectors;
            (diag.Info as IGraphInfo).ItemSelectedEvent += MainWindow_ItemSelectedEvent;
            (diag.Info as IGraphInfo).AnnotationChanged += MainWindow_AnnotationChanged;
        }