コード例 #1
0
 /// <summary>
 /// Method to restict the undo redo command from history manager.
 /// </summary>
 /// <param name="parameter"></param>
 private void OnRestrictUndoRedoCommandExecute(object parameter)
 {
     if (this != null)
     {
         if ((bool)parameter)
         {
             NodeVm selectedNode = ((IEnumerable <object>)(this.SelectedItems as SelectorViewModel).Nodes).FirstOrDefault() as NodeVm;
             if (selectedNode != null)
             {
                 selectedNode.CanLogmultipleselect = false;
             }
         }
         else
         {
             NodeVm selectedNode = ((IEnumerable <object>)(this.SelectedItems as SelectorViewModel).Nodes).FirstOrDefault() as NodeVm;
             if (selectedNode != null)
             {
                 selectedNode.CanLogmultipleselect = true;
             }
         }
     }
 }
コード例 #2
0
        public HistoryViewModel()
        {
            //Initialize the nodes and connectors.
            this.Nodes      = new ObservableCollection <NodeVm>();
            this.Connectors = new ConnectorCollection();

            //Initialize the rulers.
            this.HorizontalRuler = new Syncfusion.UI.Xaml.Diagram.Controls.Ruler();
            this.VerticalRuler   = new Syncfusion.UI.Xaml.Diagram.Controls.Ruler()
            {
                Orientation = Orientation.Vertical,
            };

            //Initialize the history manager.
            this.HistoryManager = new HistoryManagerViewModel();

            //Creating the NodeViewModel
            NodeVm redNode = new NodeVm()
            {
                UnitWidth  = 100,
                UnitHeight = 100,
                OffsetX    = 100,
                OffsetY    = 160,
                //Specify shape to the Node from built-in Shape Dictionary
                Shape = App.Current.Resources["Ellipse"],
                Fill  = new SolidColorBrush(Colors.LightPink),
            };

            NodeVm blackNode = new NodeVm()
            {
                UnitWidth  = 100,
                UnitHeight = 100,
                OffsetX    = 250,
                OffsetY    = 160,
                //Specify shape to the Node from built-in Shape Dictionary
                Shape = App.Current.Resources["Ellipse"],
                Fill  = new SolidColorBrush(Colors.LightBlue),
            };

            NodeVm greenNode = new NodeVm()
            {
                UnitWidth  = 100,
                UnitHeight = 100,
                OffsetX    = 400,
                OffsetY    = 160,
                //Specify shape to the Node from built-in Shape Dictionary
                Shape = App.Current.Resources["Ellipse"],
                Fill  = new SolidColorBrush(Colors.LightGray),
            };

            //Add Node to Nodes property of the Diagram
            (this.Nodes as ObservableCollection <NodeVm>).Add(redNode);
            (this.Nodes as ObservableCollection <NodeVm>).Add(blackNode);
            (this.Nodes as ObservableCollection <NodeVm>).Add(greenNode);

            //Enable the undo constraint
            this.Constraints = GraphConstraints.Default | GraphConstraints.Undoable;

            //Initialize the command to execute the undo redo values
            ChangeNodeColorCommand  = new Command(OnChangeNodeColorCommandExecute);
            UndoCommand             = new Command(OnUndoCommandExecute);
            RedoCommand             = new Command(OnRedoCommandExecute);
            RestrictUndoRedoCommand = new Command(OnRestrictUndoRedoCommandExecute);

            //Initialize the selected items.
            this.SelectedItems = new SelectorViewModel()
            {
            };

            //Restrict the quick command and rotator command.
            (this.SelectedItems as SelectorViewModel).SelectorConstraints &= ~(SelectorConstraints.QuickCommands | SelectorConstraints.Rotator);
        }