Example #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 SerializationCustomNode CreateNode(double offsetx, double offsety, string shape, string content, Brush fillcolor, Brush strokecolor)
        {
            SerializationCustomNode node = new SerializationCustomNode()
            {
                UnitHeight  = 70,
                UnitWidth   = 145,
                OffsetX     = offsetx,
                OffsetY     = offsety,
                Shape       = resourceDictionary[shape],
                Fillcolor   = fillcolor,
                Strokecolor = strokecolor,
            };

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

            (Nodes as NodeCollection).Add(node);

            return(node);
        }
Example #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 SerializationCustomNode)
                {
                    SerializationCustomNode node = args.Item as SerializationCustomNode;
                    this.Fillcolor   = node.Fillcolor;
                    this.Strokecolor = node.Strokecolor;
                }
                else if (args.Item is CustomConnector)
                {
                    CustomConnector con = args.Item as CustomConnector;
                }
            }
            else if (args.ItemSource == ItemSource.Stencil)
            {
                if (args.Item is SerializationCustomNode)
                {
                    SerializationCustomNode node = args.Item as SerializationCustomNode;
                    node.Fillcolor   = new SolidColorBrush(Colors.CornflowerBlue);
                    node.Strokecolor = new SolidColorBrush(Colors.CornflowerBlue);
                }
            }
        }
Example #3
0
        public SerializationViewModel()
        {
            SelectedItems = new SelectorViewModel();

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

            SerializationCustomNode Node1 = CreateNode(450, 60, "Ellipse", "Start", (SolidColorBrush)(new BrushConverter().ConvertFrom("#D0F0F1")), (SolidColorBrush)(new BrushConverter().ConvertFrom("#797979")));
            SerializationCustomNode Node2 = CreateNode(450, 210, "Rectangle", "Alarm Rings", (SolidColorBrush)(new BrushConverter().ConvertFrom("#FBFDC5")), (SolidColorBrush)(new BrushConverter().ConvertFrom("#797979")));
            SerializationCustomNode Node3 = CreateNode(450, 360, "Diamond", "Ready to Get Up?", (SolidColorBrush)(new BrushConverter().ConvertFrom("#C5EFAF")), (SolidColorBrush)(new BrushConverter().ConvertFrom("#797979")));
            SerializationCustomNode Node4 = CreateNode(700, 360, "Rectangle", "Hit Snooze Button", (SolidColorBrush)(new BrushConverter().ConvertFrom("#FBFDC5")), (SolidColorBrush)(new BrushConverter().ConvertFrom("#797979")));
            SerializationCustomNode Node5 = CreateNode(700, 210, "Delay", "Delay", (SolidColorBrush)(new BrushConverter().ConvertFrom("#F8EEE5")), (SolidColorBrush)(new BrushConverter().ConvertFrom("#797979")));
            SerializationCustomNode Node6 = CreateNode(450, 510, "Rectangle", "Climb Out of Bed", (SolidColorBrush)(new BrushConverter().ConvertFrom("#FBFDC5")), (SolidColorBrush)(new BrushConverter().ConvertFrom("#797979")));
            SerializationCustomNode 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 DelegateCommand(OnNew);
            LoadCommand           = new DelegateCommand(OnLoad);
            SaveCommand           = new DelegateCommand(OnSave);
            ItemAddedCommand      = new DelegateCommand(ItemAddedExecution);
            ItemSelectedCommand   = new DelegateCommand(OnItemSelectedCommand);
            ItemUnSelectedCommand = new DelegateCommand(OnItemUnSelected);
        }