Esempio n. 1
0
        /// <summary>
        /// This method is used to create Node
        /// </summary>
        /// <param name="height"></param>
        /// <param name="width"></param>
        /// <param name="offsetx"></param>
        /// <param name="offsety"></param>
        /// <param name="fillcolor"></param>
        /// <param name="content"></param>
        /// <param name="rotateangle"></param>
        /// <returns></returns>
        private void CreateNode(double height, double width, double offsetx, double offsety, Brush fillcolor, string content)
        {
            CustomNodeViewModel node = new CustomNodeViewModel()
            {
                UnitHeight = height,
                UnitWidth  = width,
                OffsetX    = offsetx,
                OffsetY    = offsety,
                FillColor  = fillcolor,
                Shape      = App.Current.Resources["Rectangle"],
                ShapeStyle = App.Current.Resources["DefaultStyle"] as Style
            };

            if (content != null && content != "")
            {
                node.Annotations = new AnnotationCollection()
                {
                    new AnnotationEditorViewModel()
                    {
                        Content  = content,
                        ReadOnly = true,
                        WrapText = TextWrapping.Wrap,
                        TextHorizontalAlignment = TextAlignment.Center,
                    },
                };

                node.Constraints = NodeConstraints.Default & ~NodeConstraints.Inherit & ~NodeConstraints.Selectable;
            }
            else
            {
                node.Annotations = null;
            }

            (Nodes as NodeCollection).Add(node);
        }
Esempio n. 2
0
 /// <summary>
 /// This method is used to execute ItemSelected Command
 /// </summary>
 /// <param name="obj"></param>
 private void OnItemSelectedCommand(object obj)
 {
     if (((SelectedItems as SelectorViewModel).Nodes as IEnumerable <object>).Count() > 0)
     {
         if (((SelectedItems as SelectorViewModel).Nodes as IEnumerable <object>).Count() == 1)
         {
             Enabled = true;
             CustomNodeViewModel FlipNode = ((SelectedItems as SelectorViewModel).Nodes as IEnumerable <object>).First() as CustomNodeViewModel;
             if (FlipNode != null && FlipNode.Key != null && FlipNode.Key.ToString() == "Flip")
             {
                 FlipEnabled = true;
             }
         }
     }
 }
Esempio n. 3
0
        public CommandsViewModel()
        {
            SnapSettings = new SnapSettings()
            {
                SnapConstraints = SnapConstraints.All,
                SnapToObject    = SnapToObject.All,
            };

            Constraints = GraphConstraints.Default | GraphConstraints.Undoable;

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

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

            SelectedItems = new SelectorViewModel()
            {
                SelectorConstraints = SelectorConstraints.Default & ~SelectorConstraints.QuickCommands,
            };

            ItemSelectedCommand   = new Command(OnItemSelectedCommand);
            ItemUnSelectedCommand = new Command(OnItemUnSelectedCommand);

            ItemAddedCommand = new Command(OnItemAddedCommand);

            AllCommand = new Command(OnAllCommandExecution);

            CreateNode(40, 60, 150, 100, (SolidColorBrush)(new BrushConverter().ConvertFrom("#DAEBFF")), "");
            CreateNode(40, 80, 150, 170, (SolidColorBrush)(new BrushConverter().ConvertFrom("#F5E0F7")), "");
            CreateNode(40, 100, 150, 240, (SolidColorBrush)(new BrushConverter().ConvertFrom("#E0E5BB")), "");

            CreateNode(60, 40, 80, 470, (SolidColorBrush)(new BrushConverter().ConvertFrom("#DAEBFF")), "");
            CreateNode(80, 40, 160, 470, (SolidColorBrush)(new BrushConverter().ConvertFrom("#F5E0F7")), "");
            CreateNode(100, 40, 240, 470, (SolidColorBrush)(new BrushConverter().ConvertFrom("#E0E5BB")), "");

            CreateNode(40, 80, 600, 100, (SolidColorBrush)(new BrushConverter().ConvertFrom("#DAEBFF")), "");
            CreateNode(40, 80, 750, 100, (SolidColorBrush)(new BrushConverter().ConvertFrom("#F5E0F7")), "");
            CreateNode(40, 80, 720, 180, (SolidColorBrush)(new BrushConverter().ConvertFrom("#E0E5BB")), "");

            CreateNode(40, 80, 600, 400, (SolidColorBrush)(new BrushConverter().ConvertFrom("#DAEBFF")), "");
            CreateNode(40, 80, 600, 500, (SolidColorBrush)(new BrushConverter().ConvertFrom("#F5E0F7")), "");
            CreateNode(40, 80, 750, 430, (SolidColorBrush)(new BrushConverter().ConvertFrom("#E0E5BB")), "");

            CustomNodeViewModel node = new CustomNodeViewModel
            {
                UnitHeight  = 100,
                UnitWidth   = 100,
                OffsetX     = 1100,
                OffsetY     = 120,
                FillColor   = (SolidColorBrush)(new BrushConverter().ConvertFrom("#E0E5BB")),
                Shape       = App.Current.Resources["RightTriangle"],
                Annotations = null,
                Key         = "Flip",
            };

            CreateNode(20, 60, 1100, 350, (SolidColorBrush)(new BrushConverter().ConvertFrom("#DAEBFF")), "");
            CreateNode(40, 80, 1100, 420, (SolidColorBrush)(new BrushConverter().ConvertFrom("#F5E0F7")), "");
            CreateNode(50, 100, 1100, 500, (SolidColorBrush)(new BrushConverter().ConvertFrom("#E0E5BB")), "");

            (Nodes as NodeCollection).Add(node);
        }
Esempio n. 4
0
        public CommandsViewModel()
        {
            SnapSettings = new SnapSettings()
            {
                SnapConstraints = SnapConstraints.All,
                SnapToObject    = SnapToObject.All,
            };

            Constraints = GraphConstraints.Default | GraphConstraints.Undoable;

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

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

            SelectedItems = new SelectorViewModel()
            {
                SelectorConstraints = SelectorConstraints.Default & ~SelectorConstraints.QuickCommands,
            };

            ItemSelectedCommand   = new Command(OnItemSelectedCommand);
            ItemUnSelectedCommand = new Command(OnItemUnSelectedCommand);

            AllCommand = new Command(OnAllCommandExecution);

            CreateNode(40, 60, 150, 100, (SolidColorBrush)(new BrushConverter().ConvertFrom("#DAEBFF")), "");
            CreateNode(40, 80, 150, 170, (SolidColorBrush)(new BrushConverter().ConvertFrom("#F5E0F7")), "");
            CreateNode(40, 100, 150, 240, (SolidColorBrush)(new BrushConverter().ConvertFrom("#E0E5BB")), "");

            CreateNode(60, 40, 80, 470, (SolidColorBrush)(new BrushConverter().ConvertFrom("#DAEBFF")), "");
            CreateNode(80, 40, 160, 470, (SolidColorBrush)(new BrushConverter().ConvertFrom("#F5E0F7")), "");
            CreateNode(100, 40, 240, 470, (SolidColorBrush)(new BrushConverter().ConvertFrom("#E0E5BB")), "");

            CreateNode(40, 80, 600, 100, (SolidColorBrush)(new BrushConverter().ConvertFrom("#DAEBFF")), "");
            CreateNode(40, 80, 750, 100, (SolidColorBrush)(new BrushConverter().ConvertFrom("#F5E0F7")), "");
            CreateNode(40, 80, 720, 180, (SolidColorBrush)(new BrushConverter().ConvertFrom("#E0E5BB")), "");

            CreateNode(40, 80, 600, 400, (SolidColorBrush)(new BrushConverter().ConvertFrom("#DAEBFF")), "");
            CreateNode(40, 80, 600, 500, (SolidColorBrush)(new BrushConverter().ConvertFrom("#F5E0F7")), "");
            CreateNode(40, 80, 750, 430, (SolidColorBrush)(new BrushConverter().ConvertFrom("#E0E5BB")), "");

            CustomNodeViewModel node = new CustomNodeViewModel
            {
                UnitHeight  = 100,
                UnitWidth   = 100,
                OffsetX     = 1100,
                OffsetY     = 120,
                FillColor   = (SolidColorBrush)(new BrushConverter().ConvertFrom("#E0E5BB")),
                Shape       = App.Current.Resources["RightTriangle"],
                Annotations = null,
                Key         = "Flip",
            };

            CreateNode(20, 60, 1100, 350, (SolidColorBrush)(new BrushConverter().ConvertFrom("#DAEBFF")), "");
            CreateNode(40, 80, 1100, 420, (SolidColorBrush)(new BrushConverter().ConvertFrom("#F5E0F7")), "");
            CreateNode(50, 100, 1100, 500, (SolidColorBrush)(new BrushConverter().ConvertFrom("#E0E5BB")), "");

            (Nodes as NodeCollection).Add(node);

            CreateNode(20, 200, 150, 40, new SolidColorBrush(Colors.Transparent), "Select the below nodes");
            CreateNode(50, 250, 150, 300, new SolidColorBrush(Colors.Transparent), "Try Alignment Commands(AlignLeft, AlignRight and AlignCenter)");
            CreateNode(20, 200, 150, 370, new SolidColorBrush(Colors.Transparent), "Select the below nodes");
            CreateNode(50, 250, 170, 580, new SolidColorBrush(Colors.Transparent), "Try Alignment Commands(AlignTop, AlignBottom and AlignMiddle)");
            CreateNode(20, 200, 700, 40, new SolidColorBrush(Colors.Transparent), "Select the below nodes");
            CreateNode(20, 250, 700, 240, new SolidColorBrush(Colors.Transparent), "Try SpaceAcross Command");
            CreateNode(20, 200, 700, 320, new SolidColorBrush(Colors.Transparent), "Select the below nodes");
            CreateNode(20, 250, 700, 570, new SolidColorBrush(Colors.Transparent), "Try SpaceDown Command");
            CreateNode(20, 200, 1100, 40, new SolidColorBrush(Colors.Transparent), "Select the below node");
            CreateNode(20, 250, 1100, 240, new SolidColorBrush(Colors.Transparent), "Try Flip Commands");
            CreateNode(20, 200, 1100, 300, new SolidColorBrush(Colors.Transparent), "Select the below nodes");
            CreateNode(20, 250, 1100, 570, new SolidColorBrush(Colors.Transparent), "Try Sizing Commands");
        }