From 0404772f7102d38e9339adef35b52c9e9069822e Mon Sep 17 00:00:00 2001 From: "Aaron (Qilong)" <173288704@qq.com> Date: Tue, 2 Jul 2024 00:33:13 -0400 Subject: [PATCH] DYN-7203 [Cherry-pick] #15355 and #15361 (#15368) Co-authored-by: pinzart90 <46732933+pinzart90@users.noreply.github.com> Co-authored-by: Roberto T <61755417+RobertGlobant20@users.noreply.github.com> --- .../Graph/Workspaces/HomeWorkspaceModel.cs | 9 +- src/DynamoCoreWpf/PublicAPI.Unshipped.txt | 4 + .../ViewModels/Core/DynamoViewModel.cs | 5 + .../Core/DynamoViewModelDelegateCommands.cs | 4 + src/DynamoCoreWpf/Views/Core/DynamoView.xaml | 4 +- .../Views/HomePage/HomePage.xaml.cs | 4 +- test/DynamoCoreWpfTests/PreviewBubbleTests.cs | 19 +++ test/UI/GeometryScalingInfoBubble.dyn | 160 ++++++++++++++++++ 8 files changed, 203 insertions(+), 6 deletions(-) create mode 100644 test/UI/GeometryScalingInfoBubble.dyn diff --git a/src/DynamoCore/Graph/Workspaces/HomeWorkspaceModel.cs b/src/DynamoCore/Graph/Workspaces/HomeWorkspaceModel.cs index ed38fdf765a..753a27c3da2 100644 --- a/src/DynamoCore/Graph/Workspaces/HomeWorkspaceModel.cs +++ b/src/DynamoCore/Graph/Workspaces/HomeWorkspaceModel.cs @@ -708,6 +708,9 @@ private void OnUpdateGraphCompleted(AsyncTask task) } } + // All nodes that have runtime warnings or infos + HashSet nodesWithInfos = [.. warnings.Keys]; + // Update node info message. foreach (var info in updateTask.RuntimeInfos) { @@ -716,6 +719,8 @@ private void OnUpdateGraphCompleted(AsyncTask task) if (node == null) continue; + nodesWithInfos.Add(guid); + // Block Infos updates during the many errors/warnings/notifications added here // InfoBubbles will be updated on NodeViewModel's EvaluationCompleted handler. using (node.PropertyChangeManager.SetPropsToSuppress(nameof(NodeModel.Infos), nameof(NodeModel.State))) @@ -735,8 +740,8 @@ private void OnUpdateGraphCompleted(AsyncTask task) // Dispatch the failure message display for execution on UI thread. // EvaluationCompletedEventArgs e = task.Exception == null || IsTestMode - ? new EvaluationCompletedEventArgs(true,warnings.Keys,null) - : new EvaluationCompletedEventArgs(true, warnings.Keys, task.Exception); + ? new EvaluationCompletedEventArgs(true, nodesWithInfos, null) + : new EvaluationCompletedEventArgs(true, nodesWithInfos, task.Exception); EvaluationCount ++; diff --git a/src/DynamoCoreWpf/PublicAPI.Unshipped.txt b/src/DynamoCoreWpf/PublicAPI.Unshipped.txt index bf17d2be88d..906d58ddc31 100644 --- a/src/DynamoCoreWpf/PublicAPI.Unshipped.txt +++ b/src/DynamoCoreWpf/PublicAPI.Unshipped.txt @@ -2067,6 +2067,10 @@ Dynamo.ViewModels.DynamoViewModel.ShowOpenDialogAndOpenResultCommand.get -> Dyna Dynamo.ViewModels.DynamoViewModel.ShowOpenDialogAndOpenResultCommand.set -> void Dynamo.ViewModels.DynamoViewModel.ShowOpenTemplateDialogCommand.get -> Dynamo.UI.Commands.DelegateCommand Dynamo.ViewModels.DynamoViewModel.ShowOpenTemplateDialogCommand.set -> void +Dynamo.ViewModels.DynamoViewModel.ShowOpenDialogAndOpenResultAsyncCommand.get -> Dynamo.UI.Commands.DelegateCommand +Dynamo.ViewModels.DynamoViewModel.ShowOpenDialogAndOpenResultAsyncCommand.set -> void +Dynamo.ViewModels.DynamoViewModel.ShowOpenTemplateDialogAsyncCommand.get -> Dynamo.UI.Commands.DelegateCommand +Dynamo.ViewModels.DynamoViewModel.ShowOpenTemplateDialogAsyncCommand.set -> void Dynamo.ViewModels.DynamoViewModel.ShowPackageManagerCommand.get -> Dynamo.UI.Commands.DelegateCommand Dynamo.ViewModels.DynamoViewModel.ShowPackageManagerCommand.set -> void Dynamo.ViewModels.DynamoViewModel.ShowPackageManagerSearchCommand.get -> Dynamo.UI.Commands.DelegateCommand diff --git a/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs b/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs index 38366670234..2cd04ba7d7b 100644 --- a/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs @@ -2185,6 +2185,11 @@ private void ShowOpenDialogAndOpenResult(object parameter) } } + private async void ShowOpenDialogAndOpenResultAsync(object parameter) + { + UIDispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, () => ShowOpenDialogAndOpenResult(parameter)); + } + private void SetDefaultInitialDirectory(DynamoOpenFileDialog _fileDialog) { try diff --git a/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModelDelegateCommands.cs b/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModelDelegateCommands.cs index 9405cf7910f..f3d671658b3 100644 --- a/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModelDelegateCommands.cs +++ b/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModelDelegateCommands.cs @@ -18,6 +18,8 @@ private void InitializeDelegateCommands() SaveCommand = new DelegateCommand(Save, CanSave); SaveAsCommand = new DelegateCommand(SaveAs, CanSaveAs); ShowOpenDialogAndOpenResultCommand = new DelegateCommand(ShowOpenDialogAndOpenResult, CanShowOpenDialogAndOpenResultCommand); + ShowOpenDialogAndOpenResultAsyncCommand = new DelegateCommand(ShowOpenDialogAndOpenResultAsync, CanShowOpenDialogAndOpenResultCommand); + ShowOpenTemplateDialogAsyncCommand = new DelegateCommand(ShowOpenDialogAndOpenResultAsync, CanShowOpenDialogAndOpenResultCommand); ShowOpenTemplateDialogCommand = new DelegateCommand(ShowOpenDialogAndOpenResult, CanShowOpenDialogAndOpenResultCommand); ShowInsertDialogAndInsertResultCommand = new DelegateCommand(ShowInsertDialogAndInsertResult, CanShowInsertDialogAndInsertResultCommand); ShowSaveDialogAndSaveResultCommand = new DelegateCommand(ShowSaveDialogAndSaveResult, CanShowSaveDialogAndSaveResult); @@ -99,8 +101,10 @@ private void InitializeDelegateCommands() public DelegateCommand OpenFromJsonCommand { get; set; } public DelegateCommand OpenIfSavedCommand { get; set; } public DelegateCommand OpenCommand { get; set; } + public DelegateCommand ShowOpenDialogAndOpenResultAsyncCommand { get; set; } public DelegateCommand ShowOpenDialogAndOpenResultCommand { get; set; } public DelegateCommand ShowOpenTemplateDialogCommand { get; set; } + public DelegateCommand ShowOpenTemplateDialogAsyncCommand { get; set; } public DelegateCommand ShowInsertDialogAndInsertResultCommand { get; set; } public DelegateCommand WriteToLogCmd { get; set; } public DelegateCommand PostUiActivationCommand { get; set; } diff --git a/src/DynamoCoreWpf/Views/Core/DynamoView.xaml b/src/DynamoCoreWpf/Views/Core/DynamoView.xaml index 5e8bb76558e..eb63099df2b 100644 --- a/src/DynamoCoreWpf/Views/Core/DynamoView.xaml +++ b/src/DynamoCoreWpf/Views/Core/DynamoView.xaml @@ -114,10 +114,10 @@ Command="{Binding Path=DataContext.ShowSaveDialogAndSaveResultCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type controls:DynamoView}}}" /> + Command="{Binding Path=DataContext.ShowOpenDialogAndOpenResultAsyncCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type controls:DynamoView}}}" /> errorNodes = ViewModel.Model.CurrentWorkspace.Nodes.ToList().FindAll(n => n.State == ElementState.Error); + List warningNodes = ViewModel.Model.CurrentWorkspace.Nodes.ToList().FindAll(n => n.State == ElementState.Warning || n.State == ElementState.PersistentWarning); + List infoNodes = ViewModel.Model.CurrentWorkspace.Nodes.ToList().FindAll(n => n.State == ElementState.Info); + + Assert.AreEqual(0, errorNodes.Count); + Assert.AreEqual(0, warningNodes.Count); + Assert.AreEqual(1, infoNodes.Count); + } + private bool ElementIsInContainer(FrameworkElement element, FrameworkElement container, int offset) { var relativePosition = element.TranslatePoint(new Point(), container); diff --git a/test/UI/GeometryScalingInfoBubble.dyn b/test/UI/GeometryScalingInfoBubble.dyn new file mode 100644 index 00000000000..4bf49a47ebe --- /dev/null +++ b/test/UI/GeometryScalingInfoBubble.dyn @@ -0,0 +1,160 @@ +{ + "Uuid": "dbf58b8e-9c0f-4739-b651-86909a9ff802", + "IsCustomNode": false, + "Description": "", + "Name": "GeometryScalingInfoBubble", + "ElementResolver": { + "ResolutionMap": {} + }, + "Inputs": [], + "Outputs": [], + "Nodes": [ + { + "ConcreteType": "Dynamo.Graph.Nodes.ZeroTouch.DSFunction, DynamoCore", + "Id": "f16400ac984e4818800d15aa324a0956", + "NodeType": "FunctionNode", + "Inputs": [ + { + "Id": "aff3dd620552421a8628da8a3712cc98", + "Name": "x", + "Description": "X coordinate\n\ndouble\nDefault value : 0", + "UsingDefaultValue": true, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + }, + { + "Id": "2ac43c47bd4149d988fa8f62896bfd05", + "Name": "y", + "Description": "Y coordinate\n\ndouble\nDefault value : 0", + "UsingDefaultValue": true, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + }, + { + "Id": "d56001c28a0247409c740f4f48c79126", + "Name": "z", + "Description": "Z coordinate\n\ndouble\nDefault value : 0", + "UsingDefaultValue": true, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [ + { + "Id": "7069ed19976246f382c3765f78657b08", + "Name": "Point", + "Description": "Point created by coordinates", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "FunctionSignature": "Autodesk.DesignScript.Geometry.Point.ByCoordinates@double,double,double", + "Replication": "Auto", + "Description": "Form a Point given 3 cartesian coordinates\n\nPoint.ByCoordinates (x: double = 0, y: double = 0, z: double = 0): Point" + }, + { + "ConcreteType": "CoreNodeModels.Input.DoubleInput, CoreNodeModels", + "NumberType": "Double", + "Id": "7556b378a2484190bb10ee4c5c8f89cc", + "NodeType": "NumberInputNode", + "Inputs": [], + "Outputs": [ + { + "Id": "05869dc333194864b3dff3efda633d9e", + "Name": "", + "Description": "Double", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Disabled", + "Description": "Creates a number", + "InputValue": 2000000000.0 + } + ], + "Connectors": [ + { + "Start": "05869dc333194864b3dff3efda633d9e", + "End": "d56001c28a0247409c740f4f48c79126", + "Id": "761c9400d67e4425b0c559faec43f5b2", + "IsHidden": "False" + } + ], + "Dependencies": [], + "NodeLibraryDependencies": [], + "EnableLegacyPolyCurveBehavior": null, + "Thumbnail": "", + "GraphDocumentationURL": null, + "ExtensionWorkspaceData": [ + { + "ExtensionGuid": "28992e1d-abb9-417f-8b1b-05e053bee670", + "Name": "Properties", + "Version": "3.2", + "Data": {} + } + ], + "Author": "", + "Linting": { + "activeLinter": "None", + "activeLinterId": "7b75fb44-43fd-4631-a878-29f4d5d8399a", + "warningCount": 0, + "errorCount": 0 + }, + "Bindings": [], + "View": { + "Dynamo": { + "ScaleFactor": 1.0, + "HasRunWithoutCrash": true, + "IsVisibleInDynamoLibrary": true, + "Version": "3.2.1.5440", + "RunType": "Manual", + "RunPeriod": "1000" + }, + "Camera": { + "Name": "_Background Preview", + "EyeX": -17.0, + "EyeY": 24.0, + "EyeZ": 50.0, + "LookX": 12.0, + "LookY": -13.0, + "LookZ": -58.0, + "UpX": 0.0, + "UpY": 1.0, + "UpZ": 0.0 + }, + "ConnectorPins": [], + "NodeViews": [ + { + "Id": "f16400ac984e4818800d15aa324a0956", + "Name": "Point.ByCoordinates", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "ShowGeometry": true, + "X": 404.79999999999995, + "Y": 194.00000000000006 + }, + { + "Id": "7556b378a2484190bb10ee4c5c8f89cc", + "Name": "Number", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "ShowGeometry": true, + "X": 2.0000000000001137, + "Y": 326.4000000000001 + } + ], + "Annotations": [], + "X": 28.600000000000023, + "Y": -12.400000000000091, + "Zoom": 1.0 + } +} \ No newline at end of file