private void RequestUserSaveWorkflow(object sender, WorkspaceSaveEventArgs e) { // Some test cases may create nodes or modify nodes, so when Dynamo // is shutting down, Dynamo will fire RequestUserSaveWorkflow event // to save the change, if there is no a corresponding event handler, // or the event handler fails to save the change, shut down process // will be aborted and a lot of resource will not be released // (details refer to DynamoViewModel.PerformShutdownSequence()). // // As this test fixture is UIless, DynamoView, which implements // event handler for DynamoViewModel.RequestUserSaveWorkflow event, // won't be created. To ensure resource be released properly, we // implement event handler here and simply mark the save event's // susccess status to true to notify Dynamo to continue the shut // down process. e.Success = true; }
void _vm_RequestUserSaveWorkflow(object sender, WorkspaceSaveEventArgs e) { var dialogText = ""; if (e.Workspace is CustomNodeWorkspaceModel) { dialogText = "You have unsaved changes to custom node workspace: \"" + e.Workspace.Name + "\"\n\n Would you like to save your changes?"; } else // homeworkspace { if (string.IsNullOrEmpty(e.Workspace.FileName)) { dialogText = "You have unsaved changes to the Home workspace." + "\n\n Would you like to save your changes?"; } else { dialogText = "You have unsaved changes to " + Path.GetFileName(e.Workspace.FileName) + "\n\n Would you like to save your changes?"; } } var buttons = e.AllowCancel ? MessageBoxButton.YesNoCancel : MessageBoxButton.YesNo; var result = System.Windows.MessageBox.Show(dialogText, "Confirmation", buttons, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { _vm.ShowSaveDialogIfNeededAndSave(e.Workspace); e.Success = true; } else if (result == MessageBoxResult.Cancel) { //return false; e.Success = false; } else { e.Success = true; } }
void DynamoViewModelRequestUserSaveWorkflow(object sender, WorkspaceSaveEventArgs e) { var dialogText = ""; if (e.Workspace is CustomNodeWorkspaceModel) { dialogText = String.Format(Dynamo.Wpf.Properties.Resources.MessageConfirmToSaveCustomNode, e.Workspace.Name); } else // homeworkspace { if (string.IsNullOrEmpty(e.Workspace.FileName)) { dialogText = Dynamo.Wpf.Properties.Resources.MessageConfirmToSaveHomeWorkSpace; } else { dialogText = String.Format(Dynamo.Wpf.Properties.Resources.MessageConfirmToSaveNamedHomeWorkSpace, Path.GetFileName(e.Workspace.FileName)); } } var buttons = e.AllowCancel ? MessageBoxButton.YesNoCancel : MessageBoxButton.YesNo; var result = System.Windows.MessageBox.Show(dialogText, Dynamo.Wpf.Properties.Resources.SaveConfirmationMessageBoxTitle, buttons, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { e.Success = dynamoViewModel.ShowSaveDialogIfNeededAndSave(e.Workspace); } else if (result == MessageBoxResult.Cancel) { //return false; e.Success = false; } else { e.Success = true; } }