private void SelectConversionTo_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            nodeViewModel.WorkspaceViewModel.HasUnsavedChanges = true;
            var undoRecorder = nodeViewModel.WorkspaceViewModel.Model.UndoRecorder;

            WorkspaceModel.RecordModelForModification(nodeModel, undoRecorder);
        }
예제 #2
0
        private void PinToNode(object parameters)
        {
            var nodeToPin = DynamoSelection.Instance.Selection
                            .OfType <NodeModel>()
                            .FirstOrDefault();

            if (nodeToPin == null)
            {
                return;
            }

            WorkspaceModel.RecordModelForModification(Model, WorkspaceViewModel.Model.UndoRecorder);

            var nodeGroup = WorkspaceViewModel.Annotations
                            .FirstOrDefault(x => x.AnnotationModel.ContainsModel(nodeToPin));

            if (nodeGroup != null)
            {
                nodeGroup.AnnotationModel.AddToSelectedModels(this.Model);
            }

            Model.PinnedNode   = nodeToPin;
            Model.UndoRequest += UnpinFromNode;

            MoveNoteAbovePinnedNode();
            SubscribeToPinnedNode();

            WorkspaceViewModel.HasUnsavedChanges = true;
        }
예제 #3
0
        private void RecordModels(UndoRedoRecorder recorder)
        {
            if (model.InPorts.Count == 0)
            {
                return;
            }

            var connectors = model.InPorts.Last().Connectors;

            if (connectors.Count != 0)
            {
                if (connectors.Count != 1)
                {
                    throw new InvalidOperationException(
                              "There should be only one connection to an input port");
                }
                var models = new Dictionary <ModelBase, UndoRedoRecorder.UserAction>
                {
                    { connectors[0], UndoRedoRecorder.UserAction.Deletion },
                    { model, UndoRedoRecorder.UserAction.Modification }
                };
                WorkspaceModel.RecordModelsForUndo(models, recorder);
            }
            else
            {
                WorkspaceModel.RecordModelForModification(model, recorder);
            }
        }
        private void SelectExportedUnit_PreviewMouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            nodeViewModel.WorkspaceViewModel.HasUnsavedChanges = true;
            var undoRecorder = nodeViewModel.WorkspaceViewModel.Model.UndoRecorder;

            WorkspaceModel.RecordModelForModification(nodeModel, undoRecorder);
        }
예제 #5
0
        /// <summary>
        /// Called when Toggle button is clicked.
        /// Switches the combo box values
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        private void OnToggleButtonClick(object obj)
        {
            var undoRecorder = nodeViewModel.WorkspaceViewModel.Model.UndoRecorder;

            WorkspaceModel.RecordModelForModification(nodeModel, undoRecorder);
            dynamoConvertModel.ToggleDropdownValues();
            nodeViewModel.WorkspaceViewModel.HasUnsavedChanges = true;
        }
예제 #6
0
 protected override void OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e)
 {
     base.OnPreviewMouseLeftButtonDown(e);
     if (e.OriginalSource is Rectangle)
     {
         WorkspaceModel.RecordModelForModification(nodeModel, recorder);
     }
 }
예제 #7
0
        private void ToggleIsUpstreamVisible(object parameter)
        {
            // Record the state of this node before changes.
            DynamoModel dynamo = DynamoViewModel.Model;

            WorkspaceModel.RecordModelForModification(nodeLogic, dynamo.CurrentWorkspace.UndoRecorder);

            nodeLogic.IsUpstreamVisible = !nodeLogic.IsUpstreamVisible;

            RaisePropertyChanged("IsUpstreamVisible");
            DynamoViewModel.UndoCommand.RaiseCanExecuteChanged();
            DynamoViewModel.RedoCommand.RaiseCanExecuteChanged();
        }
예제 #8
0
        private void ColorPickerControl_Closed(object sender, System.Windows.RoutedEventArgs e)
        {
            //if the model color is the same as the selected color when the color control is closed
            //we should not record the model for undo again, it's already there.
            var convertedModelColor = ((Color)(converter.Convert(colorPaletteNode.DsColor, null, null, null)));
            var isSameColor         = convertedModelColor
                                      .Equals(ColorPaletteUINode.xceedColorPickerControl.SelectedColor);

            if (!isSameColor)
            {
                //we need to record the colorPicker node before the model is updated.
                var undoRecorder = viewNode.ViewModel.WorkspaceViewModel.Model.UndoRecorder;
                WorkspaceModel.RecordModelForModification(colorPaletteNode, undoRecorder);
                //now that we have recorded the old state, set the color on the model.
                colorPaletteNode.DsColor = converter.ConvertBack(ColorPaletteUINode.xceedColorPickerControl.SelectedColor, null, null, null) as DSColor;
            }
        }
예제 #9
0
        /// <summary>
        ///     Customize View.
        /// </summary>
        /// <param name="model"></param>
        /// <param name="nodeView"></param>
        public void CustomizeView(ColorPalette model, NodeView nodeView)
        {
            viewNode           = nodeView;
            colorPaletteNode   = model;
            converter          = new Converters.MediatoDSColorConverter();
            ColorPaletteUINode = new ColorPaletteUI();
            ColorPaletteUINode.xceedColorPickerControl.Closed += ColorPickerControl_Closed;
            colorPaletteNode.PropertyChanged += ColorPaletteNode_PropertyChanged;
            nodeView.ContentGrid.Children.Add(ColorPaletteUINode);


            var undoRecorder = viewNode.ViewModel.WorkspaceViewModel.Model.UndoRecorder;

            WorkspaceModel.RecordModelForModification(colorPaletteNode, undoRecorder);
            //kick off ui to match initial model state.
            this.ColorPaletteNode_PropertyChanged(ColorPaletteUINode, new PropertyChangedEventArgs("DsColor"));
        }
예제 #10
0
        private void Slider_OnDragStarted(object sender, DragStartedEventArgs e)
        {
            var undoRecorder = ui.ViewModel.WorkspaceViewModel.Model.UndoRecorder;

            WorkspaceModel.RecordModelForModification(nodeModel, undoRecorder);
        }
예제 #11
0
 protected override void OnThumbDragStarted(DragStartedEventArgs e)
 {
     base.OnThumbDragStarted(e);
     WorkspaceModel.RecordModelForModification(nodeModel, recorder);
     (nodeModel as IBlockingModel).OnBlockingStarted(EventArgs.Empty);
 }