Beispiel #1
0
        public DiagramVM()
        {
            CommandManager = new Syncfusion.UI.Xaml.Diagram.CommandManager();

            (CommandManager as Syncfusion.UI.Xaml.Diagram.CommandManager).Commands = new CommandCollection();

            // Initialize the Custom command property.
            Save = new Command(OnSaveCommand);

            //To define the mouse and keyboard gesture for the commands

            GestureCommand saveGesture = new GestureCommand()
            {
                // Define the command with custom command
                Command = Save,
                // Define gesture for custom Command
                Gesture = new Gesture
                {
                    KeyModifiers = ModifierKeys.Control,
                    KeyState     = KeyStates.Down,
                    Key          = System.Windows.Input.Key.S
                },
                // Parameter for command - file name for save command
                Parameter = "diagram"
            };

            // Add the custom command to the existsing command collection.
            CommandManager.Commands.Add(saveGesture);
        }
Beispiel #2
0
 public BrainstormingVM(string file, bool isValidXml) : base(file, isValidXml)
 {
     LevelStyles = new Dictionary <int, System.Tuple <string, StyleId> >();
     LevelStyles.Add(0, new System.Tuple <string, StyleId>("Oval", StyleId.Variant1));
     LevelStyles.Add(1, new System.Tuple <string, StyleId>("Rectangle", StyleId.Variant1));
     LevelStyles.Add(2, new System.Tuple <string, StyleId>("Rectangle", StyleId.Variant1));
     LevelStyles.Add(3, new System.Tuple <string, StyleId>("Rectangle", StyleId.Variant1));
     DiagramType               = DiagramType.Brainstorming;
     this.Nodes                = new NodeVMCollection();
     this.Connectors           = new ConnectorVMCollection();
     Theme                     = new OfficeTheme();
     Constraints              |= GraphConstraints.Events;
     Constraints              &= ~GraphConstraints.Undoable;
     this.DefaultConnectorType = ConnectorType.Orthogonal;
     #region Diagram Commands
     this.ItemSelectedCommand      = new DelegateCommand <object>(ItemSelectedCommandExecute);
     this.AnnotationChangedCommand = new DelegateCommand <object>(AnnotationChangedCommandExecute);
     this.ItemDeletingCommand      = new DelegateCommand <object>(ItemDeletingCommandExecute);
     this.ItemDeletedCommand       = new DelegateCommand <object>(ItemDeletedCommandExecute);
     this.NodeChangedCommand       = new DelegateCommand <object>(NodeChangedCommandExecute);
     this.HorizontalRuler          = new Ruler()
     {
         Orientation     = Orientation.Horizontal,
         BorderBrush     = (SolidColorBrush)(new BrushConverter().ConvertFrom("#D4D4D4")),
         BorderThickness = new Thickness(0, 0, 0, 1)
     };
     this.VerticalRuler = new Ruler()
     {
         Orientation     = Orientation.Vertical,
         BorderBrush     = (SolidColorBrush)(new BrushConverter().ConvertFrom("#D4D4D4")),
         BorderThickness = new Thickness(0, 0, 1, 0)
     };
     if (this.SelectedItems is ISelectorVM)
     {
         (this.SelectedItems as ISelectorVM).SelectorConstraints |= SelectorConstraints.HideDisabledResizer;
     }
     //this.ExpandCollapse = new DelegateCommand<object>(ExpandCollapseCommandExecute);
     #endregion
     if (file == null)
     {
         AddRootNode();
     }
     this.LayoutManager = new Syncfusion.UI.Xaml.Diagram.Layout.LayoutManager()
     {
         Layout = new BrainStormingLayout()
         {
             LayoutRoot        = Rootnode,
             HorizontalSpacing = 25,
             VerticalSpacing   = 65
         }
     };
     CommandManager          = new Syncfusion.UI.Xaml.Diagram.CommandManager();
     CommandManager.Commands = new CommandCollection();
     AddKeyCommands();
     PageSettings = new PageVM();
     (PageSettings as PageVM).InitDiagram(this);
 }
Beispiel #3
0
        public DiagramVM()
        {
            #region Properties

            Constraints = Constraints.Add(GraphConstraints.Undoable);

            DefaultConnectorType = ConnectorType.Line;

            SelectedItems = new SelectorViewModel()
            {
                SelectorConstraints = SelectorConstraints.Default & ~SelectorConstraints.QuickCommands,
            };
            Theme            = new LinearTheme();
            Theme.NodeStyles = (Theme as LinearTheme).VariantStyles[1];


            #endregion

            #region Nodes and Connectors Creation

            CustomNode Node1  = CreateNode(550, 100, "A", "SkyBlue", "1", "");
            CustomNode Node2  = CreateNode(450, 200, "B", "Red", "2", "1");
            CustomNode Node3  = CreateNode(550, 200, "C", "Red", "3", "1");
            CustomNode Node4  = CreateNode(650, 200, "D", "Red", "4", "1");
            CustomNode Node5  = CreateNode(400, 300, "E", "Yellow", "5", "2");
            CustomNode Node6  = CreateNode(500, 300, "F", "Yellow", "6", "2");
            CustomNode Node7  = CreateNode(600, 300, "G", "Yellow", "7", "4");
            CustomNode Node8  = CreateNode(700, 300, "H", "Yellow", "8", "4");
            CustomNode Node9  = CreateNode(450, 400, "I", "Violet", "9", "6");
            CustomNode Node10 = CreateNode(550, 400, "J", "Violet", "10", "6");
            CustomNode Node11 = CreateNode(650, 400, "K", "Violet", "11", "8");
            CustomNode Node12 = CreateNode(750, 400, "L", "Violet", "12", "8");
            CustomNode Node13 = CreateNode(400, 500, "M", "Green", "13", "9");
            CustomNode Node14 = CreateNode(500, 500, "N", "Green", "14", "9");
            CustomNode Node15 = CreateNode(600, 500, "O", "Green", "15", "11");
            CustomNode Node16 = CreateNode(700, 500, "P", "Green", "16", "11");
            CustomNode Node17 = CreateNode(450, 600, "Q", "SkyBlue", "17", "14");
            CustomNode Node18 = CreateNode(550, 600, "R", "SkyBlue", "18", "14");
            CustomNode Node19 = CreateNode(650, 600, "S", "SkyBlue", "19", "16");
            CustomNode Node20 = CreateNode(750, 600, "T", "SkyBlue", "20", "16");

            (Nodes as NodeCollection).Add(Node1);
            (Nodes as NodeCollection).Add(Node2);
            (Nodes as NodeCollection).Add(Node3);
            (Nodes as NodeCollection).Add(Node4);
            (Nodes as NodeCollection).Add(Node5);
            (Nodes as NodeCollection).Add(Node6);
            (Nodes as NodeCollection).Add(Node7);
            (Nodes as NodeCollection).Add(Node8);
            (Nodes as NodeCollection).Add(Node9);
            (Nodes as NodeCollection).Add(Node10);
            (Nodes as NodeCollection).Add(Node11);
            (Nodes as NodeCollection).Add(Node12);
            (Nodes as NodeCollection).Add(Node13);
            (Nodes as NodeCollection).Add(Node14);
            (Nodes as NodeCollection).Add(Node15);
            (Nodes as NodeCollection).Add(Node16);
            (Nodes as NodeCollection).Add(Node17);
            (Nodes as NodeCollection).Add(Node18);
            (Nodes as NodeCollection).Add(Node19);
            (Nodes as NodeCollection).Add(Node20);

            CreateConnector(Node1, Node2);
            CreateConnector(Node1, Node3);
            CreateConnector(Node1, Node4);
            CreateConnector(Node2, Node5);
            CreateConnector(Node2, Node6);
            CreateConnector(Node4, Node7);
            CreateConnector(Node4, Node8);
            CreateConnector(Node6, Node9);
            CreateConnector(Node6, Node10);
            CreateConnector(Node8, Node11);
            CreateConnector(Node8, Node12);
            CreateConnector(Node9, Node13);
            CreateConnector(Node9, Node14);
            CreateConnector(Node11, Node15);
            CreateConnector(Node11, Node16);
            CreateConnector(Node14, Node17);
            CreateConnector(Node14, Node18);
            CreateConnector(Node16, Node19);
            CreateConnector(Node16, Node20);

            #endregion

            #region Commands and CommandManager

            // Custom command and Modified Commands

            CustomGroup   = new Command(OnCustomGroupCommand);
            CustomUngroup = new Command(OnCustomUngroupCommand);
            ChildNode     = new Command(OnChildNodeCommand);
            ParentNode    = new Command(OnParentNodeCommand);
            NextChild     = new Command(OnNextChildCommand);
            PreviousChild = new Command(OnPreviousChildCommand);

            ItemAddedCommand = new Command(OnItemAdded);

            CommandManager = new Syncfusion.UI.Xaml.Diagram.CommandManager();

            (CommandManager as Syncfusion.UI.Xaml.Diagram.CommandManager).Commands = new CommandCollection();

            (CommandManager.Commands as CommandCollection).Add
            (
                new GestureCommand()
            {
                Name    = "CustomGroup",
                Command = CustomGroup,
                Gesture = new Gesture
                {
                    KeyModifiers = ModifierKeys.Control,
                    KeyState     = KeyStates.Down,
                    Key          = System.Windows.Input.Key.G,
                },
            }
            );

            (CommandManager.Commands as CommandCollection).Add
            (
                new GestureCommand()
            {
                Name    = "CustomUngroup",
                Command = CustomUngroup,
                Gesture = new Gesture
                {
                    KeyModifiers = ModifierKeys.Control,
                    KeyState     = KeyStates.Down,
                    Key          = System.Windows.Input.Key.U,
                },
            }
            );


            (CommandManager.Commands as CommandCollection).Add
            (
                new GestureCommand()
            {
                Name    = "ChildNode",
                Command = ChildNode,
                Gesture = new Gesture
                {
                    KeyState = KeyStates.Down,
                    Key      = System.Windows.Input.Key.Down,
                },
            }
            );


            (CommandManager.Commands as CommandCollection).Add
            (
                new GestureCommand()
            {
                Name    = "ParentNode",
                Command = ParentNode,
                Gesture = new Gesture
                {
                    KeyState = KeyStates.Down,
                    Key      = System.Windows.Input.Key.Up,
                },
            }
            );

            (CommandManager.Commands as CommandCollection).Add
            (
                new GestureCommand()
            {
                Name    = "NextChild",
                Command = NextChild,
                Gesture = new Gesture
                {
                    KeyState = KeyStates.Down,
                    Key      = System.Windows.Input.Key.Right,
                },
            }
            );

            (CommandManager.Commands as CommandCollection).Add
            (
                new GestureCommand()
            {
                Name    = "PreviousChild",
                Command = PreviousChild,
                Gesture = new Gesture
                {
                    KeyState = KeyStates.Down,
                    Key      = System.Windows.Input.Key.Left,
                },
            }
            );

            #endregion
        }
Beispiel #4
0
        public OrganizationChartDiagramVM(string file, bool isValidXml) : base(file, isValidXml)
        {
            Theme = new OfficeTheme();
            this.DefaultConnectorType = ConnectorType.Orthogonal;
            DiagramType               = DiagramType.OrganizationChart;
            this.Constraints         |= GraphConstraints.Undoable;
            this.Connectors           = new ConnectorVMCollection();
            this.Nodes                = new NodeVMCollection();
            this.GetLayoutInfoCommand = new DelegateCommand <object>(OnGetLayoutInfoChanged);
            this.Orgchartcommand      = new DelegateCommand <object>(OrgchartcommandExecute);
            this.IncreaseSpacing      = new DelegateCommand <object>(IncreaseSpacingExecute);
            this.DecreaseSpacing      = new DelegateCommand <object>(DecreaseSpacingExecute);
            this.ExpandCollapse       = new DelegateCommand <object>(ExpandCollapseExecute);
            this.InsertPicture        = new DelegateCommand <object>(InsertPictureExecute);
            this.DeletePicture        = new DelegateCommand <object>(DeletePictureExecute);
            this.ShowhidePicture      = new DelegateCommand <object>(ShowhidePictureExecute);
            this.QuickShape           = new DelegateCommand <object>(OnQuickShapeExecute);

            if (file == null)
            {
                AddRootNode();
            }
            this.LayoutManager = new LayoutManager()
            {
                Layout = new OrganizationChartLayout()
                {
                    Type              = LayoutType.Organization,
                    Orientation       = TreeOrientation.TopToBottom,
                    HorizontalSpacing = 50,
                    VerticalSpacing   = 50,
                }
            };

            this.DataSourceSettings = new DataSourceSettings()
            {
                DataSource = OrgNodeCollection,
                Id         = "ID",
                ParentId   = "ParentID",
            };
            this.ItemSelectedCommand = new DelegateCommand <object>(ItemSelectedCommandExecute);
            this.HorizontalRuler     = new Ruler()
            {
                Orientation     = Orientation.Horizontal,
                BorderBrush     = (SolidColorBrush)(new BrushConverter().ConvertFrom("#D4D4D4")),
                BorderThickness = new Thickness(0, 0, 0, 1)
            };
            this.VerticalRuler = new Ruler()
            {
                Orientation     = Orientation.Vertical,
                BorderBrush     = (SolidColorBrush)(new BrushConverter().ConvertFrom("#D4D4D4")),
                BorderThickness = new Thickness(0, 0, 1, 0)
            };
            if (this.SelectedItems is ISelectorVM)
            {
                (this.SelectedItems as ISelectorVM).SelectorConstraints |= SelectorConstraints.Resizer;
            }

            CommandManager          = new Syncfusion.UI.Xaml.Diagram.CommandManager();
            CommandManager.Commands = new CommandCollection();
            PageSettings            = new PageVM();
            (PageSettings as PageVM).InitDiagram(this);
        }