예제 #1
0
        /// <summary>
        /// This method is used to create Node
        /// </summary>
        /// <param name="offsetx"></param>
        /// <param name="offsety"></param>
        /// <param name="shape"></param>
        /// <param name="content"></param>
        /// <returns></returns>
        private CustomNode CreateNode(double offsetx, double offsety, string shape, string content, Brush fillcolor, Brush strokecolor)
        {
            CustomNode node = new CustomNode()
            {
                UnitHeight  = 70,
                UnitWidth   = 145,
                OffsetX     = offsetx,
                OffsetY     = offsety,
                Shape       = App.Current.Resources[shape],
                Fillcolor   = fillcolor,
                Strokecolor = strokecolor,
            };

            if (content != "")
            {
                node.Annotations = new AnnotationCollection()
                {
                    new AnnotationEditorViewModel()
                    {
                        Content  = content,
                        WrapText = TextWrapping.NoWrap,
                    },
                };
            }

            (Nodes as NodeCollection).Add(node);

            return(node);
        }
예제 #2
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);
                }
            }
        }
예제 #3
0
        public SerializationViewModel()
        {
            SnapSettings = new SnapSettings()
            {
                SnapConstraints = SnapConstraints.ShowLines,
            };

            SelectedItems = new SelectorViewModel();

            HorizontalRuler = new Ruler()
            {
                Orientation = Orientation.Horizontal
            };
            VerticalRuler = new Ruler()
            {
                Orientation = Orientation.Vertical
            };

            CustomNode Node1 = CreateNode(450, 60, "Ellipse", "Start", (SolidColorBrush)(new BrushConverter().ConvertFrom("#D0F0F1")), (SolidColorBrush)(new BrushConverter().ConvertFrom("#797979")));
            CustomNode Node2 = CreateNode(450, 210, "Rectangle", "Alarm Rings", (SolidColorBrush)(new BrushConverter().ConvertFrom("#FBFDC5")), (SolidColorBrush)(new BrushConverter().ConvertFrom("#797979")));
            CustomNode Node3 = CreateNode(450, 360, "Diamond", "Ready to Get Up?", (SolidColorBrush)(new BrushConverter().ConvertFrom("#C5EFAF")), (SolidColorBrush)(new BrushConverter().ConvertFrom("#797979")));
            CustomNode Node4 = CreateNode(700, 360, "Rectangle", "Hit Snooze Button", (SolidColorBrush)(new BrushConverter().ConvertFrom("#FBFDC5")), (SolidColorBrush)(new BrushConverter().ConvertFrom("#797979")));
            CustomNode Node5 = CreateNode(700, 210, "Delay", "Delay", (SolidColorBrush)(new BrushConverter().ConvertFrom("#F8EEE5")), (SolidColorBrush)(new BrushConverter().ConvertFrom("#797979")));
            CustomNode Node6 = CreateNode(450, 510, "Rectangle", "Climb Out of Bed", (SolidColorBrush)(new BrushConverter().ConvertFrom("#FBFDC5")), (SolidColorBrush)(new BrushConverter().ConvertFrom("#797979")));
            CustomNode Node7 = CreateNode(450, 660, "Ellipse", "End", (SolidColorBrush)(new BrushConverter().ConvertFrom("#D0F0F1")), (SolidColorBrush)(new BrushConverter().ConvertFrom("#797979")));

            ConnectorViewModel Con1 = CreateConnector(Node1, Node2, "");
            ConnectorViewModel Con2 = CreateConnector(Node2, Node3, "");
            ConnectorViewModel Con3 = CreateConnector(Node3, Node4, "No");
            ConnectorViewModel Con4 = CreateConnector(Node3, Node6, "Yes");
            ConnectorViewModel Con5 = CreateConnector(Node5, Node2, "After 5 mins");
            ConnectorViewModel Con6 = CreateConnector(Node4, Node5, "");
            ConnectorViewModel Con7 = CreateConnector(Node6, Node7, "");

            NewCommand            = new Command(OnNew);
            LoadCommand           = new Command(OnLoad);
            SaveCommand           = new Command(OnSave);
            ItemAddedCommand      = new Command(ItemAddedExecution);
            ItemSelectedCommand   = new Command(OnItemSelectedCommand);
            ItemUnSelectedCommand = new Command(OnItemUnSelected);
        }