/// <summary> /// Change the currently visible workspace to a custom node's workspace /// </summary> /// <param name="symbol">The function definition for the custom node workspace to be viewed</param> internal void ViewCustomNodeWorkspace(FunctionDefinition symbol) { if (symbol == null) { throw new Exception("There is a null function definition for this node."); } if (_model.CurrentSpace.Name.Equals(symbol.Workspace.Name)) { return; } dynWorkspaceModel newWs = symbol.Workspace; if (!this._model.Workspaces.Contains(newWs)) { this._model.Workspaces.Add(newWs); } CurrentSpaceViewModel.OnStopDragging(this, EventArgs.Empty); _model.CurrentSpace = newWs; _model.CurrentSpace.OnDisplayed(); //set the zoom and offsets events var vm = dynSettings.Controller.DynamoViewModel.Workspaces.First(x => x.Model == newWs); vm.OnCurrentOffsetChanged(this, new PointEventArgs(new Point(newWs.X, newWs.Y))); vm.OnZoomChanged(this, new ZoomEventArgs(newWs.Zoom)); }
private void UndoRedoImpl(DynamoModel.UndoRedoCommand command) { if (command.CmdOperation == DynamoModel.UndoRedoCommand.Operation.Undo) { CurrentSpaceViewModel.CancelActiveState(); } }
public void Pan(object parameter) { Debug.WriteLine(string.Format("Offset: {0},{1}, Zoom: {2}", _model.CurrentSpace.X, _model.CurrentSpace.Y, _model.CurrentSpace.Zoom)); var panType = parameter.ToString(); double pan = 10; var pt = new Point(_model.CurrentSpace.X, _model.CurrentSpace.Y); switch (panType) { case "Left": pt.X += pan; break; case "Right": pt.X -= pan; break; case "Up": pt.Y += pan; break; case "Down": pt.Y -= pan; break; } _model.CurrentSpace.X = pt.X; _model.CurrentSpace.Y = pt.Y; CurrentSpaceViewModel.OnCurrentOffsetChanged(this, new PointEventArgs(pt)); }
private void MakeConnectionImpl(DynamoModel.MakeConnectionCommand command) { Guid nodeId = command.ModelGuid; switch (command.ConnectionMode) { case DynamoModel.MakeConnectionCommand.Mode.Begin: CurrentSpaceViewModel.BeginConnection( nodeId, command.PortIndex, command.Type); break; case DynamoModel.MakeConnectionCommand.Mode.End: CurrentSpaceViewModel.EndConnection( nodeId, command.PortIndex, command.Type); break; case DynamoModel.MakeConnectionCommand.Mode.BeginShiftReconnections: CurrentSpaceViewModel.BeginShiftReconnections( nodeId, command.PortIndex, command.Type); break; case DynamoModel.MakeConnectionCommand.Mode.EndShiftReconnections: CurrentSpaceViewModel.EndConnection( nodeId, command.PortIndex, command.Type); break; case DynamoModel.MakeConnectionCommand.Mode.Cancel: CurrentSpaceViewModel.CancelConnection(); break; } }
private void ToggleOrbit(object parameter) { CurrentSpaceViewModel.RequestToggleOrbitMode(); // Since panning and orbiting modes are exclusive from one another, // turning one on may turn the other off. This is the reason we must // raise property change for both at the same time to update visual. RaisePropertyChanged("IsPanning"); RaisePropertyChanged("IsOrbiting"); RaisePropertyChanged("LeftClickCommand"); }
private void DragSelectionImpl(DragSelectionCommand command) { if (DragSelectionCommand.Operation.BeginDrag == command.DragOperation) { CurrentSpaceViewModel.BeginDragSelection(command.MouseCursor); } else { CurrentSpaceViewModel.EndDragSelection(command.MouseCursor); } }
private void MakeConnectionImpl(DynamoModel.MakeConnectionCommand command) { Guid nodeId = command.ModelGuid; switch (command.ConnectionMode) { case DynamoModel.MakeConnectionCommand.Mode.Begin: CurrentSpaceViewModel.BeginConnection( nodeId, command.PortIndex, command.Type); break; case DynamoModel.MakeConnectionCommand.Mode.End: CurrentSpaceViewModel.EndConnection( nodeId, command.PortIndex, command.Type); break; case DynamoModel.MakeConnectionCommand.Mode.BeginShiftReconnections: CurrentSpaceViewModel.BeginShiftReconnections( nodeId, command.PortIndex, command.Type); break; case DynamoModel.MakeConnectionCommand.Mode.EndShiftReconnections: CurrentSpaceViewModel.EndConnection( nodeId, command.PortIndex, command.Type); break; // TODO - can be removed in Dynamo 3.0 - DYN-1729 case DynamoModel.MakeConnectionCommand.Mode.EndAndStartCtrlConnection: CurrentSpaceViewModel.BeginCreateConnections( nodeId, command.PortIndex, command.Type); break; case DynamoModel.MakeConnectionCommand.Mode.BeginDuplicateConnection: CurrentSpaceViewModel.BeginConnection( nodeId, command.PortIndex, command.Type); break; case DynamoModel.MakeConnectionCommand.Mode.BeginCreateConnections: CurrentSpaceViewModel.BeginCreateConnections( nodeId, command.PortIndex, command.Type); break; case DynamoModel.MakeConnectionCommand.Mode.Cancel: CurrentSpaceViewModel.CancelConnection(); break; } }
private void MakeConnectionImpl(MakeConnectionCommand command) { System.Guid nodeId = command.NodeId; switch (command.ConnectionMode) { case MakeConnectionCommand.Mode.Begin: CurrentSpaceViewModel.BeginConnection( nodeId, command.PortIndex, command.Type); break; case MakeConnectionCommand.Mode.End: CurrentSpaceViewModel.EndConnection( nodeId, command.PortIndex, command.Type); break; case MakeConnectionCommand.Mode.Cancel: CurrentSpaceViewModel.CancelConnection(); break; } }
private void ToggleOrbit(object parameter) { CurrentSpaceViewModel.RequestToggleOrbitMode(); RefreshState(); }
internal void TogglePan(object parameter) { CurrentSpaceViewModel.RequestTogglePanMode(); RefreshState(); }
private void SelectInRegionImpl(SelectInRegionCommand command) { CurrentSpaceViewModel.SelectInRegion(command.Region, command.IsCrossSelection); }
void OnModelCommandCompleted(DynamoModel.RecordableCommand command) { var name = command.GetType().Name; switch (name) { case "OpenFileCommand": this.AddToRecentFiles((command as DynamoModel.OpenFileCommand).XmlFilePath); this.VisualizationManager.UnPause(); break; case "MutateTestCommand": var mutatorDriver = new Dynamo.TestInfrastructure.MutatorDriver(this); mutatorDriver.RunMutationTests(); break; case "SelectInRegionCommand": var selectC = command as DynamoModel.SelectInRegionCommand; CurrentSpaceViewModel.SelectInRegion(selectC.Region, selectC.IsCrossSelection); break; case "DragSelectionCommand": var dragC = command as DynamoModel.DragSelectionCommand; if (DynamoModel.DragSelectionCommand.Operation.BeginDrag == dragC.DragOperation) { CurrentSpaceViewModel.BeginDragSelection(dragC.MouseCursor); } else { CurrentSpaceViewModel.EndDragSelection(dragC.MouseCursor); } break; case "DeleteModelCommand": case "CreateNodeCommand": case "CreateNoteCommand": case "UndoRedoCommand": case "ModelEventCommand": case "UpdateModelValueCommand": case "ConvertNodesToCodeCommand": UndoCommand.RaiseCanExecuteChanged(); RedoCommand.RaiseCanExecuteChanged(); break; case "SwitchTabCommand": if (command.IsInPlaybackMode) { RaisePropertyChanged("CurrentWorkspaceIndex"); } break; case "RunCancelCommand": case "ForceRunCancelCommand": case "SelectModelCommand": case "MakeConnectionCommand": case "CreateCustomNodeCommand": // for this commands there is no need // to do anything after execution break; default: throw new InvalidOperationException("Unhandled command name"); } }
void OnModelCommandCompleted(DynamoModel.RecordableCommand command) { var name = command.GetType().Name; switch (name) { case "OpenFileCommand": this.AddToRecentFiles((command as DynamoModel.OpenFileCommand).FilePath); break; case "SelectInRegionCommand": var selectC = command as DynamoModel.SelectInRegionCommand; CurrentSpaceViewModel.SelectInRegion(selectC.Region, selectC.IsCrossSelection); break; case "DragSelectionCommand": var dragC = command as DynamoModel.DragSelectionCommand; if (DynamoModel.DragSelectionCommand.Operation.BeginDrag == dragC.DragOperation) { CurrentSpaceViewModel.BeginDragSelection(dragC.MouseCursor); } else { CurrentSpaceViewModel.EndDragSelection(dragC.MouseCursor); } break; case "DeleteModelCommand": CurrentSpaceViewModel.CancelActiveState(); RaiseCanExecuteUndoRedo(); break; case "CreateNodeCommand": case "CreateProxyNodeCommand": case "CreateNoteCommand": case "CreateAnnotationCommand": case "UndoRedoCommand": case "ModelEventCommand": case "UpdateModelValueCommand": case "ConvertNodesToCodeCommand": case "UngroupModelCommand": case "AddModelToGroupCommand": case "CreateAndConnectNodeCommand": RaiseCanExecuteUndoRedo(); break; case "SwitchTabCommand": if (command.IsInPlaybackMode) { RaisePropertyChanged("CurrentWorkspaceIndex"); } break; case "RunCancelCommand": case "ForceRunCancelCommand": case "SelectModelCommand": case "MakeConnectionCommand": case "CreateCustomNodeCommand": case "AddPresetCommand": case "ApplyPresetCommand": // for this commands there is no need // to do anything after execution break; default: throw new InvalidOperationException("Unhandled command name"); } }