From 069cf79411e05042879fb5e6f7b29a6d6e1f12ce Mon Sep 17 00:00:00 2001 From: Ivo Petrov <48355182+ivaylo-matov@users.noreply.github.com> Date: Wed, 10 Apr 2024 14:41:36 +0100 Subject: [PATCH 01/13] works - dirty draft --- .../AssemblySharedInfo.cs | 6 +-- .../Commands/WorkspaceCommands.cs | 24 ++++++++- .../Properties/Resources.Designer.cs | 9 ++++ .../Properties/Resources.en-US.resx | 10 ++++ src/DynamoCoreWpf/Properties/Resources.resx | 11 ++++ src/DynamoCoreWpf/PublicAPI.Unshipped.txt | 5 ++ .../ViewModels/Core/DynamoViewModel.cs | 16 ++++++ .../Core/DynamoViewModelDelegateCommands.cs | 16 ++++++ .../ViewModels/Core/NodeViewModel.cs | 8 +++ .../ViewModels/Core/WorkspaceViewModel.cs | 24 +++++++++ src/DynamoCoreWpf/Views/Core/DynamoView.xaml | 9 ++++ .../Views/Core/DynamoView.xaml.cs | 7 +++ src/DynamoCoreWpf/Views/Core/NodeView.xaml.cs | 21 +++++++- .../Views/Core/WorkspaceView.xaml.cs | 54 +++++++++++++++++-- .../Views/Preview/PreviewControl.xaml.cs | 8 +++ 15 files changed, 219 insertions(+), 9 deletions(-) diff --git a/src/AssemblySharedInfoGenerator/AssemblySharedInfo.cs b/src/AssemblySharedInfoGenerator/AssemblySharedInfo.cs index d27acfce5d3..449558e064a 100644 --- a/src/AssemblySharedInfoGenerator/AssemblySharedInfo.cs +++ b/src/AssemblySharedInfoGenerator/AssemblySharedInfo.cs @@ -8,7 +8,7 @@ // associated with an assembly. [assembly: AssemblyCompany("Autodesk, Inc")] [assembly: AssemblyProduct("Dynamo")] -[assembly: AssemblyCopyright("Copyright � Autodesk, Inc 2024")] +[assembly: AssemblyCopyright("Copyright © Autodesk, Inc 2024")] [assembly: AssemblyTrademark("")] //In order to begin building localizable applications, set @@ -45,7 +45,7 @@ // to distinguish one build from another. AssemblyFileVersion is specified // in AssemblyVersionInfo.cs so that it can be easily incremented by the // automated build process. -[assembly: AssemblyVersion("3.1.0.3411")] +[assembly: AssemblyVersion("3.1.0.4654")] // By default, the "Product version" shown in the file properties window is @@ -64,4 +64,4 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyFileVersion("3.1.0.3411")] +[assembly: AssemblyFileVersion("3.1.0.4654")] diff --git a/src/DynamoCoreWpf/Commands/WorkspaceCommands.cs b/src/DynamoCoreWpf/Commands/WorkspaceCommands.cs index 3780bbc167f..7889c1cea6f 100644 --- a/src/DynamoCoreWpf/Commands/WorkspaceCommands.cs +++ b/src/DynamoCoreWpf/Commands/WorkspaceCommands.cs @@ -1,4 +1,4 @@ -using System.Linq; +using System.Linq; using Dynamo.Graph.Nodes; using Dynamo.Graph.Workspaces; using Dynamo.Selection; @@ -23,6 +23,13 @@ public partial class WorkspaceViewModel private DelegateCommand setArgumentLacingCommand; private DelegateCommand findNodesFromSelectionCommand; private DelegateCommand selectAllCommand; + + private DelegateCommand unpinPBCommand; + + + + + private DelegateCommand graphAutoLayoutCommand; private DelegateCommand showHideAllGeometryPreviewCommand; private DelegateCommand showInCanvasSearchCommand; @@ -58,6 +65,21 @@ public DelegateCommand SelectAllCommand } } + + [JsonIgnore] + public DelegateCommand UnpinPBCommand + { + get + { + if (unpinPBCommand == null) + unpinPBCommand = new DelegateCommand(UnpinPB, CanUnpinPB); + return unpinPBCommand; + } + } + + + + [JsonIgnore] public DelegateCommand GraphAutoLayoutCommand { diff --git a/src/DynamoCoreWpf/Properties/Resources.Designer.cs b/src/DynamoCoreWpf/Properties/Resources.Designer.cs index 6e04b4bb8a8..51a72269495 100644 --- a/src/DynamoCoreWpf/Properties/Resources.Designer.cs +++ b/src/DynamoCoreWpf/Properties/Resources.Designer.cs @@ -1693,6 +1693,15 @@ public static string DynamoViewEditMenuUndo { } } + /// + /// Looks up a localized string similar to _Unpin PB. + /// + public static string DynamoViewEditMenuUnpinPB { + get { + return ResourceManager.GetString("DynamoViewEditMenuUnpinPB", resourceCulture); + } + } + /// /// Looks up a localized string similar to E_xtensions. /// diff --git a/src/DynamoCoreWpf/Properties/Resources.en-US.resx b/src/DynamoCoreWpf/Properties/Resources.en-US.resx index ea3d8cbeb24..99c1fecfa2c 100644 --- a/src/DynamoCoreWpf/Properties/Resources.en-US.resx +++ b/src/DynamoCoreWpf/Properties/Resources.en-US.resx @@ -582,6 +582,16 @@ Don't worry, you'll have the option to save your work. _Select All Edit menu | Select all nodes + + _Unpin PB + Edit menu | Unpin preview bubbles + + + + + + + _Select Neighbors diff --git a/src/DynamoCoreWpf/Properties/Resources.resx b/src/DynamoCoreWpf/Properties/Resources.resx index d6e033680f6..2d420b4b30a 100644 --- a/src/DynamoCoreWpf/Properties/Resources.resx +++ b/src/DynamoCoreWpf/Properties/Resources.resx @@ -330,6 +330,17 @@ _Select All Edit menu | Select all nodes + + _Unpin PB + Edit menu | Unpin preview bubbles + + + + + + + + _Undo Edit menu | Undo diff --git a/src/DynamoCoreWpf/PublicAPI.Unshipped.txt b/src/DynamoCoreWpf/PublicAPI.Unshipped.txt index ea80c64aafd..31fdd289e92 100644 --- a/src/DynamoCoreWpf/PublicAPI.Unshipped.txt +++ b/src/DynamoCoreWpf/PublicAPI.Unshipped.txt @@ -2024,6 +2024,8 @@ Dynamo.ViewModels.DynamoViewModel.ScaleFactorLog.set -> void Dynamo.ViewModels.DynamoViewModel.SelectAll(object parameter) -> void Dynamo.ViewModels.DynamoViewModel.SelectAllCommand.get -> Dynamo.UI.Commands.DelegateCommand Dynamo.ViewModels.DynamoViewModel.SelectAllCommand.set -> void +Dynamo.ViewModels.DynamoViewModel.UnpinPBCommand.get -> Dynamo.UI.Commands.DelegateCommand +Dynamo.ViewModels.DynamoViewModel.UnpinPBCommand.set -> void Dynamo.ViewModels.DynamoViewModel.SelectNeighbors(object parameters) -> void Dynamo.ViewModels.DynamoViewModel.SelectNeighborsCommand.get -> Dynamo.UI.Commands.DelegateCommand Dynamo.ViewModels.DynamoViewModel.SelectNeighborsCommand.set -> void @@ -3027,6 +3029,7 @@ Dynamo.ViewModels.WorkspaceViewModel.ResetFitViewToggleCommand.get -> Dynamo.UI. Dynamo.ViewModels.WorkspaceViewModel.RunSettingsViewModel.get -> Dynamo.Wpf.ViewModels.RunSettingsViewModel Dynamo.ViewModels.WorkspaceViewModel.RunSettingsViewModel.set -> void Dynamo.ViewModels.WorkspaceViewModel.SelectAllCommand.get -> Dynamo.UI.Commands.DelegateCommand +Dynamo.ViewModels.WorkspaceViewModel.UnpinPBCommand.get -> Dynamo.UI.Commands.DelegateCommand Dynamo.ViewModels.WorkspaceViewModel.SelectionArgumentLacing.get -> Dynamo.Graph.Nodes.LacingStrategy Dynamo.ViewModels.WorkspaceViewModel.SetArgumentLacingCommand.get -> Dynamo.UI.Commands.DelegateCommand Dynamo.ViewModels.WorkspaceViewModel.SetCurrentOffsetCommand.get -> Dynamo.UI.Commands.DelegateCommand @@ -3034,6 +3037,7 @@ Dynamo.ViewModels.WorkspaceViewModel.SetZoomCommand.get -> Dynamo.UI.Commands.De Dynamo.ViewModels.WorkspaceViewModel.ShowAllWiresCommand.get -> Dynamo.UI.Commands.DelegateCommand Dynamo.ViewModels.WorkspaceViewModel.ShowHideAllGeometryPreviewCommand.get -> Dynamo.UI.Commands.DelegateCommand Dynamo.ViewModels.WorkspaceViewModel.ShowInCanvasSearchCommand.get -> Dynamo.UI.Commands.DelegateCommand +Dynamo.ViewModels.WorkspaceViewModel.UnpinPBsTriggered -> System.EventHandler Dynamo.ViewModels.WorkspaceViewModel.Watch3DViewModels.get -> System.Collections.ObjectModel.ObservableCollection Dynamo.ViewModels.WorkspaceViewModel.Watch3DViewModels.set -> void Dynamo.ViewModels.WorkspaceViewModel.WorkspaceElements.get -> System.Windows.Data.CompositeCollection @@ -4495,6 +4499,7 @@ static Dynamo.Wpf.Properties.Resources.DynamoViewEditMenuPresetsMenu.get -> stri static Dynamo.Wpf.Properties.Resources.DynamoViewEditMenuRedo.get -> string static Dynamo.Wpf.Properties.Resources.DynamoViewEditMenuRestorePreset.get -> string static Dynamo.Wpf.Properties.Resources.DynamoViewEditMenuSelectAll.get -> string +static Dynamo.Wpf.Properties.Resources.DynamoViewEditMenuUnpinPB.get -> string static Dynamo.Wpf.Properties.Resources.DynamoViewEditMenuSelectNeighbours.get -> string static Dynamo.Wpf.Properties.Resources.DynamoViewEditMenuUndo.get -> string static Dynamo.Wpf.Properties.Resources.DynamoViewExtensionsMenu.get -> string diff --git a/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs b/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs index 0becc9ac897..be4cb56c6ce 100644 --- a/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs @@ -2803,6 +2803,22 @@ internal bool CanSelectAll(object parameter) return this.CurrentSpaceViewModel.CanSelectAll(null); } + public void UnpinPB(object parameter) + { + this.CurrentSpaceViewModel.UnpinPB(null); + } + + internal bool CanUnpinPB(object parameter) + { + return this.CurrentSpaceViewModel.CanUnpinPB(null); + } + + + + + + + public void MakeNewHomeWorkspace(object parameter) { if (ClearHomeWorkspaceInternal()) diff --git a/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModelDelegateCommands.cs b/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModelDelegateCommands.cs index 56faceb04df..a6d5ed9fbfb 100644 --- a/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModelDelegateCommands.cs +++ b/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModelDelegateCommands.cs @@ -40,6 +40,15 @@ private void InitializeDelegateCommands() GraphAutoLayoutCommand = new DelegateCommand(DoGraphAutoLayout, CanDoGraphAutoLayout); GoHomeCommand = new DelegateCommand(GoHomeView, CanGoHomeView); SelectAllCommand = new DelegateCommand(SelectAll, CanSelectAll); + + UnpinPBCommand = new DelegateCommand(UnpinPB, CanUnpinPB); + + + + + + + HomeCommand = new DelegateCommand(GoHome, CanGoHome); NewHomeWorkspaceCommand = new DelegateCommand(MakeNewHomeWorkspace, CanMakeNewHomeWorkspace); CloseHomeWorkspaceCommand = new DelegateCommand(CloseHomeWorkspace, CanCloseHomeWorkspace); @@ -136,6 +145,13 @@ private void InitializeDelegateCommands() public DelegateCommand ToggleBackgroundGridVisibilityCommand { get; set; } public DelegateCommand UpdateGraphicHelpersScaleCommand { get; set; } public DelegateCommand SelectAllCommand { get; set; } + + public DelegateCommand UnpinPBCommand { get; set; } + + + + + public DelegateCommand SaveImageCommand { get; set; } public DelegateCommand Save3DImageCommand { get; set; } public DelegateCommand ValidateWorkSpaceBeforeToExportAsImageCommand { get; set; } diff --git a/src/DynamoCoreWpf/ViewModels/Core/NodeViewModel.cs b/src/DynamoCoreWpf/ViewModels/Core/NodeViewModel.cs index ef89e10d916..39857be819d 100644 --- a/src/DynamoCoreWpf/ViewModels/Core/NodeViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/Core/NodeViewModel.cs @@ -94,12 +94,20 @@ public bool PreviewPinned if (previewPinned == value) return; previewPinned = value; + // ip code: + RaisePropertyChanged(nameof(PreviewPinned)); + DynamoViewModel.ExecuteCommand( new DynamoModel.UpdateModelValueCommand( System.Guid.Empty, NodeModel.GUID, "PreviewPinned", previewPinned.ToString())); } } + //protected virtual void OnPreviewPinnedChanged() + //{ + // PreviewPinnedChanged?.Invoke(this, EventArgs.Empty); + //} + [JsonIgnore] public NodeModel NodeModel { get { return nodeLogic; } private set { nodeLogic = value; } } diff --git a/src/DynamoCoreWpf/ViewModels/Core/WorkspaceViewModel.cs b/src/DynamoCoreWpf/ViewModels/Core/WorkspaceViewModel.cs index 4f1dcc9fa1c..06adb39da0b 100644 --- a/src/DynamoCoreWpf/ViewModels/Core/WorkspaceViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/Core/WorkspaceViewModel.cs @@ -1027,6 +1027,30 @@ internal bool CanSelectAll(object parameter) return true; } + // ip code : + public event EventHandler UnpinPBsTriggered; + /// + /// ip code : + /// + /// + internal void UnpinPB(object parameter) + { + RaisePropertyChanged("UnpinAllPBs"); + + foreach (var nodeVM in Nodes) + { + nodeVM.PreviewPinned = false; + } + UnpinPBsTriggered?.Invoke(this, EventArgs.Empty); + } + + internal bool CanUnpinPB(object parameter) + { + return true; + } + + + /// /// After command framework is implemented, this method should now be only /// called from a menu item (i.e. Ctrl + W). It should not be used as a diff --git a/src/DynamoCoreWpf/Views/Core/DynamoView.xaml b/src/DynamoCoreWpf/Views/Core/DynamoView.xaml index 44be7126d45..88c1a5528aa 100644 --- a/src/DynamoCoreWpf/Views/Core/DynamoView.xaml +++ b/src/DynamoCoreWpf/Views/Core/DynamoView.xaml @@ -450,6 +450,15 @@ Command="{Binding SelectAllCommand}" Name="selectAll" InputGestureText="Ctrl + A" /> + + + + + + + /// Called when the NodeModel's CachedValue property is updated /// @@ -501,7 +510,7 @@ private void EditableNameBox_KeyDown(object sender, KeyEventArgs e) #region Preview Control Related Event Handlers - private void OnNodeViewMouseEnter(object sender, MouseEventArgs e) + private void OnNodeViewMouseEnter(object sender, MouseEventArgs e) { // if the node is located under "Hide preview bubbles" menu item and the item is clicked, // ViewModel.DynamoViewModel.ShowPreviewBubbles will be updated AFTER node mouse enter event occurs @@ -570,6 +579,16 @@ private void OnNodeViewMouseLeave(object sender, MouseEventArgs e) } } + // ip code : + private void OnForceUnpinPB(object sender, RoutedEventArgs e) + { + if (PreviewControl.StaysOpen) + { + //PreviewControl.StaysOpen = false; + + } + } + /// /// This event fires right after preview's state has been changed. /// This event is necessary, it handles some preview's manipulations, diff --git a/src/DynamoCoreWpf/Views/Core/WorkspaceView.xaml.cs b/src/DynamoCoreWpf/Views/Core/WorkspaceView.xaml.cs index 2af85880d8f..07e16cc73f5 100644 --- a/src/DynamoCoreWpf/Views/Core/WorkspaceView.xaml.cs +++ b/src/DynamoCoreWpf/Views/Core/WorkspaceView.xaml.cs @@ -11,6 +11,7 @@ using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; +using DSCore; using Dynamo.Controls; using Dynamo.Graph; using Dynamo.Graph.Annotations; @@ -143,6 +144,9 @@ private void RemoveViewModelsubscriptions(WorkspaceViewModel ViewModel) ViewModel.WorkspacePropertyEditRequested -= VmOnWorkspacePropertyEditRequested; ViewModel.RequestSelectionBoxUpdate -= VmOnRequestSelectionBoxUpdate; + // ip code : + ViewModel.UnpinPBsTriggered -= OnUnpinPBsTriggered; + ViewModel.Model.RequestNodeCentered -= vm_RequestNodeCentered; ViewModel.Model.CurrentOffsetChanged -= vm_CurrentOffsetChanged; DynamoSelection.Instance.Selection.CollectionChanged -= OnSelectionCollectionChanged; @@ -171,12 +175,29 @@ private void AttachViewModelsubscriptions(WorkspaceViewModel ViewModel) ViewModel.WorkspacePropertyEditRequested += VmOnWorkspacePropertyEditRequested; ViewModel.RequestSelectionBoxUpdate += VmOnRequestSelectionBoxUpdate; + // ip code : + ViewModel.UnpinPBsTriggered += OnUnpinPBsTriggered; + ViewModel.Model.RequestNodeCentered += vm_RequestNodeCentered; ViewModel.Model.CurrentOffsetChanged += vm_CurrentOffsetChanged; DynamoSelection.Instance.Selection.CollectionChanged += OnSelectionCollectionChanged; infiniteGridView.AttachToZoomBorder(zoomBorder); } + + + + // ip code : + public void OnUnpinPBsTriggered(object sender, EventArgs e) + { + var allNodes = this.ChildrenOfType().Where(view => view.HasPreviewControl); + + foreach (var node in allNodes) + { + node.PreviewControl.ForceHidePreviewBubble(); // look for HidePreviewBubble() + } + } + private void ShowHideNodeAutoCompleteControl(ShowHideFlags flag) { ShowHidePopup(flag, NodeAutoCompleteSearchBar); @@ -390,8 +411,8 @@ private RenderTargetBitmap GetRender() if (!initialized) return null; // Add padding to the edge and make them multiples of two (pad 10px on each side). - bounds.Width = 20 + ((((int)Math.Ceiling(bounds.Width)) + 1) & ~0x01); - bounds.Height = 20 + ((((int)Math.Ceiling(bounds.Height)) + 1) & ~0x01); + bounds.Width = 20 + ((((int)System.Math.Ceiling(bounds.Width)) + 1) & ~0x01); + bounds.Height = 20 + ((((int)System.Math.Ceiling(bounds.Height)) + 1) & ~0x01); var currentTransformGroup = WorkspaceElements.RenderTransform as TransformGroup; WorkspaceElements.RenderTransform = new TranslateTransform(10.0 - bounds.X - minX, 10.0 - bounds.Y - minY); @@ -783,6 +804,31 @@ private void OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) } } + + // ip code : + private void OnForceHidePreview(object sender, MouseButtonEventArgs e) + { + //if (snappedPort != null) + //{ + // ViewModel.HandlePortClicked(snappedPort); + //} + //else if (Keyboard.Modifiers != ModifierKeys.Control) + //{ + // ViewModel.HandleLeftButtonDown(workBench, e); + //} + + //if (!ViewModel.IsDragging) return; + + var nodesToHidePreview = this.ChildrenOfType().Where(view => + view.HasPreviewControl && !view.PreviewControl.IsHidden && view.PreviewControl.StaysOpen); + + foreach (var node in nodesToHidePreview) + { + node.PreviewControl.ForceHidePreviewBubble(); + } + } + + private void OnCanvasMouseDown(object sender, MouseButtonEventArgs e) { ContextMenuPopup.IsOpen = false; @@ -877,9 +923,9 @@ private void OnMouseMove(object sender, MouseEventArgs e) // Check that current mouse position is far enough from start position. var canDrag = - (Math.Abs(currentMousePosition.X - startMousePosition.X) > + (System.Math.Abs(currentMousePosition.X - startMousePosition.X) > SystemParameters.MinimumHorizontalDragDistance) && - (Math.Abs(currentMousePosition.Y - startMousePosition.Y) > + (System.Math.Abs(currentMousePosition.Y - startMousePosition.Y) > SystemParameters.MinimumVerticalDragDistance) && e.OriginalSource is DragCanvas; diff --git a/src/DynamoCoreWpf/Views/Preview/PreviewControl.xaml.cs b/src/DynamoCoreWpf/Views/Preview/PreviewControl.xaml.cs index 983001f69cb..119b4691dac 100644 --- a/src/DynamoCoreWpf/Views/Preview/PreviewControl.xaml.cs +++ b/src/DynamoCoreWpf/Views/Preview/PreviewControl.xaml.cs @@ -180,6 +180,14 @@ internal void HidePreviewBubble() } } + // ip code : + internal void ForceHidePreviewBubble() + { + StaysOpen = false; + if (IsExpanded) TransitionToState(State.Condensed); + if (IsCondensed) TransitionToState(State.Hidden); + } + /// /// It is possible for a run to complete while the preview display is /// in transition. In these situations, we can store the MirrorData and From e082ccc33c049049438eb14e6f23a641c79bb3cc Mon Sep 17 00:00:00 2001 From: Ivo Petrov <48355182+ivaylo-matov@users.noreply.github.com> Date: Wed, 10 Apr 2024 15:54:21 +0100 Subject: [PATCH 02/13] working - cleaner code without hotkey some code might be redundant --- .../Commands/WorkspaceCommands.cs | 39 +++++----- .../Properties/Resources.Designer.cs | 6 +- .../Properties/Resources.en-US.resx | 10 +-- src/DynamoCoreWpf/Properties/Resources.resx | 11 +-- src/DynamoCoreWpf/PublicAPI.Unshipped.txt | 11 +-- .../ViewModels/Core/DynamoViewModel.cs | 14 ++-- .../Core/DynamoViewModelDelegateCommands.cs | 20 +----- .../ViewModels/Core/WorkspaceViewModel.cs | 46 ++++++------ src/DynamoCoreWpf/Views/Core/DynamoView.xaml | 12 +--- .../Views/Core/DynamoView.xaml.cs | 7 -- src/DynamoCoreWpf/Views/Core/NodeView.xaml.cs | 31 +++----- .../Views/Core/WorkspaceView.xaml.cs | 71 +++++++++---------- .../Views/Preview/PreviewControl.xaml.cs | 6 +- 13 files changed, 111 insertions(+), 173 deletions(-) diff --git a/src/DynamoCoreWpf/Commands/WorkspaceCommands.cs b/src/DynamoCoreWpf/Commands/WorkspaceCommands.cs index 7889c1cea6f..03515941ed4 100644 --- a/src/DynamoCoreWpf/Commands/WorkspaceCommands.cs +++ b/src/DynamoCoreWpf/Commands/WorkspaceCommands.cs @@ -23,13 +23,6 @@ public partial class WorkspaceViewModel private DelegateCommand setArgumentLacingCommand; private DelegateCommand findNodesFromSelectionCommand; private DelegateCommand selectAllCommand; - - private DelegateCommand unpinPBCommand; - - - - - private DelegateCommand graphAutoLayoutCommand; private DelegateCommand showHideAllGeometryPreviewCommand; private DelegateCommand showInCanvasSearchCommand; @@ -37,6 +30,7 @@ public partial class WorkspaceViewModel private DelegateCommand hideAllPopupCommand; private DelegateCommand showAllWiresCommand; private DelegateCommand hideAllWiresCommand; + private DelegateCommand unpinAllPreviewBubblesCommand; #endregion @@ -64,22 +58,7 @@ public DelegateCommand SelectAllCommand return selectAllCommand; } } - - - [JsonIgnore] - public DelegateCommand UnpinPBCommand - { - get - { - if (unpinPBCommand == null) - unpinPBCommand = new DelegateCommand(UnpinPB, CanUnpinPB); - return unpinPBCommand; - } - } - - - - + [JsonIgnore] public DelegateCommand GraphAutoLayoutCommand { @@ -297,6 +276,20 @@ public DelegateCommand HideAllWiresCommand return hideAllWiresCommand; } } + + /// + /// View Command to hide all pinned preview bubbles, if any are pinned + /// + [JsonIgnore] + public DelegateCommand UnpinAllPreviewBubblesCommand + { + get + { + if (unpinAllPreviewBubblesCommand == null) + unpinAllPreviewBubblesCommand = new DelegateCommand(UnpinAllPreviewBubbles, CanUnpinAllPreviewBubbles); + return unpinAllPreviewBubblesCommand; + } + } #endregion #region Properties for Command Data Binding diff --git a/src/DynamoCoreWpf/Properties/Resources.Designer.cs b/src/DynamoCoreWpf/Properties/Resources.Designer.cs index 51a72269495..aad81334e2b 100644 --- a/src/DynamoCoreWpf/Properties/Resources.Designer.cs +++ b/src/DynamoCoreWpf/Properties/Resources.Designer.cs @@ -1694,11 +1694,11 @@ public static string DynamoViewEditMenuUndo { } /// - /// Looks up a localized string similar to _Unpin PB. + /// Looks up a localized string similar to _Unpin All Preview Bubbles. /// - public static string DynamoViewEditMenuUnpinPB { + public static string DynamoViewEditMenuUnpinAllPreviewBubbles { get { - return ResourceManager.GetString("DynamoViewEditMenuUnpinPB", resourceCulture); + return ResourceManager.GetString("DynamoViewEditMenuUnpinAllPreviewBubbles", resourceCulture); } } diff --git a/src/DynamoCoreWpf/Properties/Resources.en-US.resx b/src/DynamoCoreWpf/Properties/Resources.en-US.resx index 99c1fecfa2c..6b06f307e02 100644 --- a/src/DynamoCoreWpf/Properties/Resources.en-US.resx +++ b/src/DynamoCoreWpf/Properties/Resources.en-US.resx @@ -582,16 +582,10 @@ Don't worry, you'll have the option to save your work. _Select All Edit menu | Select all nodes - - _Unpin PB + + _Unpin All Preview Bubbles Edit menu | Unpin preview bubbles - - - - - - _Select Neighbors diff --git a/src/DynamoCoreWpf/Properties/Resources.resx b/src/DynamoCoreWpf/Properties/Resources.resx index 2d420b4b30a..f0f403d8cd3 100644 --- a/src/DynamoCoreWpf/Properties/Resources.resx +++ b/src/DynamoCoreWpf/Properties/Resources.resx @@ -330,17 +330,10 @@ _Select All Edit menu | Select all nodes - - _Unpin PB + + _Unpin All Preview Bubbles Edit menu | Unpin preview bubbles - - - - - - - _Undo Edit menu | Undo diff --git a/src/DynamoCoreWpf/PublicAPI.Unshipped.txt b/src/DynamoCoreWpf/PublicAPI.Unshipped.txt index 31fdd289e92..68fd2d84222 100644 --- a/src/DynamoCoreWpf/PublicAPI.Unshipped.txt +++ b/src/DynamoCoreWpf/PublicAPI.Unshipped.txt @@ -2024,8 +2024,8 @@ Dynamo.ViewModels.DynamoViewModel.ScaleFactorLog.set -> void Dynamo.ViewModels.DynamoViewModel.SelectAll(object parameter) -> void Dynamo.ViewModels.DynamoViewModel.SelectAllCommand.get -> Dynamo.UI.Commands.DelegateCommand Dynamo.ViewModels.DynamoViewModel.SelectAllCommand.set -> void -Dynamo.ViewModels.DynamoViewModel.UnpinPBCommand.get -> Dynamo.UI.Commands.DelegateCommand -Dynamo.ViewModels.DynamoViewModel.UnpinPBCommand.set -> void +Dynamo.ViewModels.DynamoViewModel.UnpinAllPreviewBubblesCommand.get -> Dynamo.UI.Commands.DelegateCommand +Dynamo.ViewModels.DynamoViewModel.UnpinAllPreviewBubblesCommand.set -> void Dynamo.ViewModels.DynamoViewModel.SelectNeighbors(object parameters) -> void Dynamo.ViewModels.DynamoViewModel.SelectNeighborsCommand.get -> Dynamo.UI.Commands.DelegateCommand Dynamo.ViewModels.DynamoViewModel.SelectNeighborsCommand.set -> void @@ -3029,7 +3029,6 @@ Dynamo.ViewModels.WorkspaceViewModel.ResetFitViewToggleCommand.get -> Dynamo.UI. Dynamo.ViewModels.WorkspaceViewModel.RunSettingsViewModel.get -> Dynamo.Wpf.ViewModels.RunSettingsViewModel Dynamo.ViewModels.WorkspaceViewModel.RunSettingsViewModel.set -> void Dynamo.ViewModels.WorkspaceViewModel.SelectAllCommand.get -> Dynamo.UI.Commands.DelegateCommand -Dynamo.ViewModels.WorkspaceViewModel.UnpinPBCommand.get -> Dynamo.UI.Commands.DelegateCommand Dynamo.ViewModels.WorkspaceViewModel.SelectionArgumentLacing.get -> Dynamo.Graph.Nodes.LacingStrategy Dynamo.ViewModels.WorkspaceViewModel.SetArgumentLacingCommand.get -> Dynamo.UI.Commands.DelegateCommand Dynamo.ViewModels.WorkspaceViewModel.SetCurrentOffsetCommand.get -> Dynamo.UI.Commands.DelegateCommand @@ -3037,7 +3036,7 @@ Dynamo.ViewModels.WorkspaceViewModel.SetZoomCommand.get -> Dynamo.UI.Commands.De Dynamo.ViewModels.WorkspaceViewModel.ShowAllWiresCommand.get -> Dynamo.UI.Commands.DelegateCommand Dynamo.ViewModels.WorkspaceViewModel.ShowHideAllGeometryPreviewCommand.get -> Dynamo.UI.Commands.DelegateCommand Dynamo.ViewModels.WorkspaceViewModel.ShowInCanvasSearchCommand.get -> Dynamo.UI.Commands.DelegateCommand -Dynamo.ViewModels.WorkspaceViewModel.UnpinPBsTriggered -> System.EventHandler +Dynamo.ViewModels.WorkspaceViewModel.UnpinAllPreviewBubblesTriggered -> System.EventHandler Dynamo.ViewModels.WorkspaceViewModel.Watch3DViewModels.get -> System.Collections.ObjectModel.ObservableCollection Dynamo.ViewModels.WorkspaceViewModel.Watch3DViewModels.set -> void Dynamo.ViewModels.WorkspaceViewModel.WorkspaceElements.get -> System.Windows.Data.CompositeCollection @@ -3051,6 +3050,7 @@ Dynamo.ViewModels.WorkspaceViewModel.Zoom.get -> double Dynamo.ViewModels.WorkspaceViewModel.Zoom.set -> void Dynamo.ViewModels.WorkspaceViewModel.ZoomChanged -> Dynamo.ViewModels.WorkspaceViewModel.ZoomEventHandler Dynamo.ViewModels.WorkspaceViewModel.ZoomEventHandler +Dynamo.ViewModels.WorkspaceViewModel.UnpinAllPreviewBubblesCommand.get -> Dynamo.UI.Commands.DelegateCommand Dynamo.Views.GeometryScalingPopup Dynamo.Views.GeometryScalingPopup.GeometryScalingPopup(Dynamo.ViewModels.DynamoViewModel dynViewModel) -> void Dynamo.Views.GeometryScalingPopup.InitializeComponent() -> void @@ -3075,6 +3075,7 @@ Dynamo.Views.WorkspaceView.Dispose() -> void Dynamo.Views.WorkspaceView.HideAllPopUp(object sender) -> void Dynamo.Views.WorkspaceView.InitializeComponent() -> void Dynamo.Views.WorkspaceView.ViewModel.get -> Dynamo.ViewModels.WorkspaceViewModel +Dynamo.Views.WorkspaceView.vm_UnpinAllPreviewBubblesTriggered(object sender, System.EventArgs e) -> void Dynamo.Views.WorkspaceView.WorkspacePropertyEditClick(object sender, System.Windows.RoutedEventArgs routedEventArgs) -> void Dynamo.Views.WorkspaceView.WorkspaceView() -> void Dynamo.Wpf.AssemblyNodeViewCustomizations @@ -4499,7 +4500,6 @@ static Dynamo.Wpf.Properties.Resources.DynamoViewEditMenuPresetsMenu.get -> stri static Dynamo.Wpf.Properties.Resources.DynamoViewEditMenuRedo.get -> string static Dynamo.Wpf.Properties.Resources.DynamoViewEditMenuRestorePreset.get -> string static Dynamo.Wpf.Properties.Resources.DynamoViewEditMenuSelectAll.get -> string -static Dynamo.Wpf.Properties.Resources.DynamoViewEditMenuUnpinPB.get -> string static Dynamo.Wpf.Properties.Resources.DynamoViewEditMenuSelectNeighbours.get -> string static Dynamo.Wpf.Properties.Resources.DynamoViewEditMenuUndo.get -> string static Dynamo.Wpf.Properties.Resources.DynamoViewExtensionsMenu.get -> string @@ -4519,6 +4519,7 @@ static Dynamo.Wpf.Properties.Resources.DynamoViewFileMenuOpenTemplate.get -> str static Dynamo.Wpf.Properties.Resources.DynamoViewFileMenuRecentFiles.get -> string static Dynamo.Wpf.Properties.Resources.DynamoViewFileMenuSave.get -> string static Dynamo.Wpf.Properties.Resources.DynamoViewFileMenuSaveAs.get -> string +static Dynamo.Wpf.Properties.Resources.DynamoViewEditMenuUnpinAllPreviewBubbles.get -> string static Dynamo.Wpf.Properties.Resources.DynamoViewHelpDictionary.get -> string static Dynamo.Wpf.Properties.Resources.DynamoViewHelpMenu.get -> string static Dynamo.Wpf.Properties.Resources.DynamoViewHelpMenuDisplayStartPage.get -> string diff --git a/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs b/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs index be4cb56c6ce..8f17786e9ea 100644 --- a/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs @@ -2803,22 +2803,16 @@ internal bool CanSelectAll(object parameter) return this.CurrentSpaceViewModel.CanSelectAll(null); } - public void UnpinPB(object parameter) + public void UnpinAllPreviewBubbles(object parameter) { - this.CurrentSpaceViewModel.UnpinPB(null); + this.CurrentSpaceViewModel.UnpinAllPreviewBubbles(null); } - internal bool CanUnpinPB(object parameter) + internal bool CanUnpinAllPreviewBubbles(object parameter) { - return this.CurrentSpaceViewModel.CanUnpinPB(null); + return this.CurrentSpaceViewModel.CanUnpinAllPreviewBubbles(null); } - - - - - - public void MakeNewHomeWorkspace(object parameter) { if (ClearHomeWorkspaceInternal()) diff --git a/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModelDelegateCommands.cs b/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModelDelegateCommands.cs index a6d5ed9fbfb..a4674a05d64 100644 --- a/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModelDelegateCommands.cs +++ b/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModelDelegateCommands.cs @@ -40,15 +40,6 @@ private void InitializeDelegateCommands() GraphAutoLayoutCommand = new DelegateCommand(DoGraphAutoLayout, CanDoGraphAutoLayout); GoHomeCommand = new DelegateCommand(GoHomeView, CanGoHomeView); SelectAllCommand = new DelegateCommand(SelectAll, CanSelectAll); - - UnpinPBCommand = new DelegateCommand(UnpinPB, CanUnpinPB); - - - - - - - HomeCommand = new DelegateCommand(GoHome, CanGoHome); NewHomeWorkspaceCommand = new DelegateCommand(MakeNewHomeWorkspace, CanMakeNewHomeWorkspace); CloseHomeWorkspaceCommand = new DelegateCommand(CloseHomeWorkspace, CanCloseHomeWorkspace); @@ -102,6 +93,7 @@ private void InitializeDelegateCommands() NodeFromSelectionCommand = new DelegateCommand(CreateNodeFromSelection, CanCreateNodeFromSelection); OpenDocumentationLinkCommand = new DelegateCommand(OpenDocumentationLink); ShowNodeDocumentationCommand = new DelegateCommand(ShowNodeDocumentation, CanShowNodeDocumentation); + UnpinAllPreviewBubblesCommand = new DelegateCommand(UnpinAllPreviewBubbles, CanUnpinAllPreviewBubbles); } public DelegateCommand OpenFromJsonIfSavedCommand { get; set; } public DelegateCommand OpenFromJsonCommand { get; set; } @@ -145,13 +137,6 @@ private void InitializeDelegateCommands() public DelegateCommand ToggleBackgroundGridVisibilityCommand { get; set; } public DelegateCommand UpdateGraphicHelpersScaleCommand { get; set; } public DelegateCommand SelectAllCommand { get; set; } - - public DelegateCommand UnpinPBCommand { get; set; } - - - - - public DelegateCommand SaveImageCommand { get; set; } public DelegateCommand Save3DImageCommand { get; set; } public DelegateCommand ValidateWorkSpaceBeforeToExportAsImageCommand { get; set; } @@ -191,6 +176,7 @@ private void InitializeDelegateCommands() public DelegateCommand NodeFromSelectionCommand { get; set; } public DelegateCommand OpenDocumentationLinkCommand { get; set; } public DelegateCommand ShowNodeDocumentationCommand { get; set; } - + public DelegateCommand UnpinAllPreviewBubblesCommand { get; set; } + } } diff --git a/src/DynamoCoreWpf/ViewModels/Core/WorkspaceViewModel.cs b/src/DynamoCoreWpf/ViewModels/Core/WorkspaceViewModel.cs index 06adb39da0b..b8bedbc27e8 100644 --- a/src/DynamoCoreWpf/ViewModels/Core/WorkspaceViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/Core/WorkspaceViewModel.cs @@ -1027,30 +1027,6 @@ internal bool CanSelectAll(object parameter) return true; } - // ip code : - public event EventHandler UnpinPBsTriggered; - /// - /// ip code : - /// - /// - internal void UnpinPB(object parameter) - { - RaisePropertyChanged("UnpinAllPBs"); - - foreach (var nodeVM in Nodes) - { - nodeVM.PreviewPinned = false; - } - UnpinPBsTriggered?.Invoke(this, EventArgs.Empty); - } - - internal bool CanUnpinPB(object parameter) - { - return true; - } - - - /// /// After command framework is implemented, this method should now be only /// called from a menu item (i.e. Ctrl + W). It should not be used as a @@ -1761,6 +1737,28 @@ private void ShowHideAllWires(List nodeModels, bool isHidden) } } + // ip code : + public event EventHandler UnpinAllPreviewBubblesTriggered; + /// + /// ip code : + /// + /// + internal void UnpinAllPreviewBubbles(object parameter) + { + RaisePropertyChanged("UnpinAllPBs"); + + foreach (var nodeVM in Nodes) + { + nodeVM.PreviewPinned = false; + } + UnpinAllPreviewBubblesTriggered?.Invoke(this, EventArgs.Empty); + } + + internal bool CanUnpinAllPreviewBubbles(object parameter) + { + return true; + } + /// /// Collapse a set of nodes and notes currently selected in workspace /// diff --git a/src/DynamoCoreWpf/Views/Core/DynamoView.xaml b/src/DynamoCoreWpf/Views/Core/DynamoView.xaml index 88c1a5528aa..bcd66aaded3 100644 --- a/src/DynamoCoreWpf/Views/Core/DynamoView.xaml +++ b/src/DynamoCoreWpf/Views/Core/DynamoView.xaml @@ -450,15 +450,9 @@ Command="{Binding SelectAllCommand}" Name="selectAll" InputGestureText="Ctrl + A" /> - - - - - - - + /// Called when the NodeModel's CachedValue property is updated /// @@ -579,21 +570,21 @@ private void OnNodeViewMouseLeave(object sender, MouseEventArgs e) } } - // ip code : - private void OnForceUnpinPB(object sender, RoutedEventArgs e) - { - if (PreviewControl.StaysOpen) - { - //PreviewControl.StaysOpen = false; + ////// ip code : + ////private void OnForceUnpinPB(object sender, RoutedEventArgs e) + ////{ + //// if (PreviewControl.StaysOpen) + //// { + //// //PreviewControl.StaysOpen = false; - } - } + //// } + ////} /// /// This event fires right after preview's state has been changed. /// This event is necessary, it handles some preview's manipulations, /// that we can't handle in mouse enter/leave events. - /// E.g. When mouse leaves preview control, it should be first condesed, after that hidden. + /// E.g. When mouse leaves preview control, it should be first condensed, after that hidden. /// /// PreviewControl /// Event arguments diff --git a/src/DynamoCoreWpf/Views/Core/WorkspaceView.xaml.cs b/src/DynamoCoreWpf/Views/Core/WorkspaceView.xaml.cs index 07e16cc73f5..7d620764aff 100644 --- a/src/DynamoCoreWpf/Views/Core/WorkspaceView.xaml.cs +++ b/src/DynamoCoreWpf/Views/Core/WorkspaceView.xaml.cs @@ -143,9 +143,7 @@ private void RemoveViewModelsubscriptions(WorkspaceViewModel ViewModel) ViewModel.RequestAddViewToOuterCanvas -= vm_RequestAddViewToOuterCanvas; ViewModel.WorkspacePropertyEditRequested -= VmOnWorkspacePropertyEditRequested; ViewModel.RequestSelectionBoxUpdate -= VmOnRequestSelectionBoxUpdate; - - // ip code : - ViewModel.UnpinPBsTriggered -= OnUnpinPBsTriggered; + ViewModel.UnpinAllPreviewBubblesTriggered -= vm_UnpinAllPreviewBubblesTriggered; ViewModel.Model.RequestNodeCentered -= vm_RequestNodeCentered; ViewModel.Model.CurrentOffsetChanged -= vm_CurrentOffsetChanged; @@ -174,9 +172,7 @@ private void AttachViewModelsubscriptions(WorkspaceViewModel ViewModel) ViewModel.RequestAddViewToOuterCanvas += vm_RequestAddViewToOuterCanvas; ViewModel.WorkspacePropertyEditRequested += VmOnWorkspacePropertyEditRequested; ViewModel.RequestSelectionBoxUpdate += VmOnRequestSelectionBoxUpdate; - - // ip code : - ViewModel.UnpinPBsTriggered += OnUnpinPBsTriggered; + ViewModel.UnpinAllPreviewBubblesTriggered += vm_UnpinAllPreviewBubblesTriggered; ViewModel.Model.RequestNodeCentered += vm_RequestNodeCentered; ViewModel.Model.CurrentOffsetChanged += vm_CurrentOffsetChanged; @@ -184,20 +180,6 @@ private void AttachViewModelsubscriptions(WorkspaceViewModel ViewModel) infiniteGridView.AttachToZoomBorder(zoomBorder); } - - - - // ip code : - public void OnUnpinPBsTriggered(object sender, EventArgs e) - { - var allNodes = this.ChildrenOfType().Where(view => view.HasPreviewControl); - - foreach (var node in allNodes) - { - node.PreviewControl.ForceHidePreviewBubble(); // look for HidePreviewBubble() - } - } - private void ShowHideNodeAutoCompleteControl(ShowHideFlags flag) { ShowHidePopup(flag, NodeAutoCompleteSearchBar); @@ -805,30 +787,47 @@ private void OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) } - // ip code : - private void OnForceHidePreview(object sender, MouseButtonEventArgs e) - { - //if (snappedPort != null) - //{ - // ViewModel.HandlePortClicked(snappedPort); - //} - //else if (Keyboard.Modifiers != ModifierKeys.Control) - //{ - // ViewModel.HandleLeftButtonDown(workBench, e); - //} - //if (!ViewModel.IsDragging) return; - var nodesToHidePreview = this.ChildrenOfType().Where(view => - view.HasPreviewControl && !view.PreviewControl.IsHidden && view.PreviewControl.StaysOpen); - foreach (var node in nodesToHidePreview) + + // ip code : + public void vm_UnpinAllPreviewBubblesTriggered(object sender, EventArgs e) + { + var allNodes = this.ChildrenOfType().Where(view => view.HasPreviewControl); + + foreach (var node in allNodes) { - node.PreviewControl.ForceHidePreviewBubble(); + node.PreviewControl.UnpinAllPreviewBubbles(); } } + + //// ip code : + //private void OnForceHidePreview(object sender, MouseButtonEventArgs e) + //{ + // //if (snappedPort != null) + // //{ + // // ViewModel.HandlePortClicked(snappedPort); + // //} + // //else if (Keyboard.Modifiers != ModifierKeys.Control) + // //{ + // // ViewModel.HandleLeftButtonDown(workBench, e); + // //} + + // //if (!ViewModel.IsDragging) return; + + // var nodesToHidePreview = this.ChildrenOfType().Where(view => + // view.HasPreviewControl && !view.PreviewControl.IsHidden && view.PreviewControl.StaysOpen); + + // foreach (var node in nodesToHidePreview) + // { + // node.PreviewControl.UnpinAllPreviewBubbles(); + // } + //} + + private void OnCanvasMouseDown(object sender, MouseButtonEventArgs e) { ContextMenuPopup.IsOpen = false; diff --git a/src/DynamoCoreWpf/Views/Preview/PreviewControl.xaml.cs b/src/DynamoCoreWpf/Views/Preview/PreviewControl.xaml.cs index 119b4691dac..1da3f80a1f3 100644 --- a/src/DynamoCoreWpf/Views/Preview/PreviewControl.xaml.cs +++ b/src/DynamoCoreWpf/Views/Preview/PreviewControl.xaml.cs @@ -180,8 +180,10 @@ internal void HidePreviewBubble() } } - // ip code : - internal void ForceHidePreviewBubble() + /// + /// Unpins and hides all preview bubbles + /// + internal void UnpinAllPreviewBubbles() { StaysOpen = false; if (IsExpanded) TransitionToState(State.Condensed); From 7b1e134f43663e23739359a5ca672ee1e1baf80e Mon Sep 17 00:00:00 2001 From: Ivo Petrov <48355182+ivaylo-matov@users.noreply.github.com> Date: Wed, 10 Apr 2024 16:07:24 +0100 Subject: [PATCH 03/13] working with hotkey --- src/DynamoCoreWpf/Views/Core/DynamoView.xaml | 7 +++++-- .../Views/Preview/PreviewControl.xaml.cs | 11 +++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/DynamoCoreWpf/Views/Core/DynamoView.xaml b/src/DynamoCoreWpf/Views/Core/DynamoView.xaml index bcd66aaded3..dba46ca52b1 100644 --- a/src/DynamoCoreWpf/Views/Core/DynamoView.xaml +++ b/src/DynamoCoreWpf/Views/Core/DynamoView.xaml @@ -86,7 +86,9 @@ - + @@ -452,7 +454,8 @@ InputGestureText="Ctrl + A" /> + Name="unpinPB" + InputGestureText="Ctrl + E"/> From 3b203d269101143fd51c79a24f2439136102dee1 Mon Sep 17 00:00:00 2001 From: Ivo Petrov <48355182+ivaylo-matov@users.noreply.github.com> Date: Wed, 10 Apr 2024 17:25:17 +0100 Subject: [PATCH 04/13] new hotkey + cleaner --- src/DynamoCoreWpf/PublicAPI.Unshipped.txt | 2 +- .../Core/DynamoViewModelDelegateCommands.cs | 1 - .../ViewModels/Core/NodeViewModel.cs | 8 ---- .../ViewModels/Core/WorkspaceViewModel.cs | 15 +++---- src/DynamoCoreWpf/Views/Core/DynamoView.xaml | 4 +- .../Views/Core/WorkspaceView.xaml.cs | 45 ++++--------------- .../Views/Preview/PreviewControl.xaml.cs | 14 ++---- 7 files changed, 22 insertions(+), 67 deletions(-) diff --git a/src/DynamoCoreWpf/PublicAPI.Unshipped.txt b/src/DynamoCoreWpf/PublicAPI.Unshipped.txt index 68fd2d84222..c2bbfb47ca2 100644 --- a/src/DynamoCoreWpf/PublicAPI.Unshipped.txt +++ b/src/DynamoCoreWpf/PublicAPI.Unshipped.txt @@ -3036,7 +3036,7 @@ Dynamo.ViewModels.WorkspaceViewModel.SetZoomCommand.get -> Dynamo.UI.Commands.De Dynamo.ViewModels.WorkspaceViewModel.ShowAllWiresCommand.get -> Dynamo.UI.Commands.DelegateCommand Dynamo.ViewModels.WorkspaceViewModel.ShowHideAllGeometryPreviewCommand.get -> Dynamo.UI.Commands.DelegateCommand Dynamo.ViewModels.WorkspaceViewModel.ShowInCanvasSearchCommand.get -> Dynamo.UI.Commands.DelegateCommand -Dynamo.ViewModels.WorkspaceViewModel.UnpinAllPreviewBubblesTriggered -> System.EventHandler +Dynamo.ViewModels.WorkspaceViewModel.UnpinAllPreviewBubblesTriggered -> Dynamo.ViewModels.ViewEventHandler Dynamo.ViewModels.WorkspaceViewModel.Watch3DViewModels.get -> System.Collections.ObjectModel.ObservableCollection Dynamo.ViewModels.WorkspaceViewModel.Watch3DViewModels.set -> void Dynamo.ViewModels.WorkspaceViewModel.WorkspaceElements.get -> System.Windows.Data.CompositeCollection diff --git a/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModelDelegateCommands.cs b/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModelDelegateCommands.cs index a4674a05d64..9405cf7910f 100644 --- a/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModelDelegateCommands.cs +++ b/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModelDelegateCommands.cs @@ -177,6 +177,5 @@ private void InitializeDelegateCommands() public DelegateCommand OpenDocumentationLinkCommand { get; set; } public DelegateCommand ShowNodeDocumentationCommand { get; set; } public DelegateCommand UnpinAllPreviewBubblesCommand { get; set; } - } } diff --git a/src/DynamoCoreWpf/ViewModels/Core/NodeViewModel.cs b/src/DynamoCoreWpf/ViewModels/Core/NodeViewModel.cs index 39857be819d..ef89e10d916 100644 --- a/src/DynamoCoreWpf/ViewModels/Core/NodeViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/Core/NodeViewModel.cs @@ -94,20 +94,12 @@ public bool PreviewPinned if (previewPinned == value) return; previewPinned = value; - // ip code: - RaisePropertyChanged(nameof(PreviewPinned)); - DynamoViewModel.ExecuteCommand( new DynamoModel.UpdateModelValueCommand( System.Guid.Empty, NodeModel.GUID, "PreviewPinned", previewPinned.ToString())); } } - //protected virtual void OnPreviewPinnedChanged() - //{ - // PreviewPinnedChanged?.Invoke(this, EventArgs.Empty); - //} - [JsonIgnore] public NodeModel NodeModel { get { return nodeLogic; } private set { nodeLogic = value; } } diff --git a/src/DynamoCoreWpf/ViewModels/Core/WorkspaceViewModel.cs b/src/DynamoCoreWpf/ViewModels/Core/WorkspaceViewModel.cs index b8bedbc27e8..97f2469552d 100644 --- a/src/DynamoCoreWpf/ViewModels/Core/WorkspaceViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/Core/WorkspaceViewModel.cs @@ -1737,20 +1737,19 @@ private void ShowHideAllWires(List nodeModels, bool isHidden) } } - // ip code : - public event EventHandler UnpinAllPreviewBubblesTriggered; + public event ViewEventHandler UnpinAllPreviewBubblesTriggered; /// - /// ip code : + /// Triggers unpinning of all preview bubbles in the workspace /// /// internal void UnpinAllPreviewBubbles(object parameter) { - RaisePropertyChanged("UnpinAllPBs"); + RaisePropertyChanged("UnpinAllPreviewBubbles"); - foreach (var nodeVM in Nodes) - { - nodeVM.PreviewPinned = false; - } + //foreach (var nodeVM in Nodes) + //{ + // nodeVM.PreviewPinned = false; + //} UnpinAllPreviewBubblesTriggered?.Invoke(this, EventArgs.Empty); } diff --git a/src/DynamoCoreWpf/Views/Core/DynamoView.xaml b/src/DynamoCoreWpf/Views/Core/DynamoView.xaml index dba46ca52b1..b1e0a394b6c 100644 --- a/src/DynamoCoreWpf/Views/Core/DynamoView.xaml +++ b/src/DynamoCoreWpf/Views/Core/DynamoView.xaml @@ -86,7 +86,7 @@ - + InputGestureText="Ctrl + K"/> + /// Handles the event triggered when all preview bubbles in the workspace need to be unpinned + /// + /// + /// public void vm_UnpinAllPreviewBubblesTriggered(object sender, EventArgs e) { - var allNodes = this.ChildrenOfType().Where(view => view.HasPreviewControl); + var nodesWithPinnedPreview = this.ChildrenOfType() + .Where(view => view.HasPreviewControl && view.PreviewControl.StaysOpen); - foreach (var node in allNodes) + foreach (var node in nodesWithPinnedPreview) { - node.PreviewControl.UnpinAllPreviewBubbles(); + node.PreviewControl.UnpinPreviewBubble(); } } - - - //// ip code : - //private void OnForceHidePreview(object sender, MouseButtonEventArgs e) - //{ - // //if (snappedPort != null) - // //{ - // // ViewModel.HandlePortClicked(snappedPort); - // //} - // //else if (Keyboard.Modifiers != ModifierKeys.Control) - // //{ - // // ViewModel.HandleLeftButtonDown(workBench, e); - // //} - - // //if (!ViewModel.IsDragging) return; - - // var nodesToHidePreview = this.ChildrenOfType().Where(view => - // view.HasPreviewControl && !view.PreviewControl.IsHidden && view.PreviewControl.StaysOpen); - - // foreach (var node in nodesToHidePreview) - // { - // node.PreviewControl.UnpinAllPreviewBubbles(); - // } - //} - - private void OnCanvasMouseDown(object sender, MouseButtonEventArgs e) { ContextMenuPopup.IsOpen = false; diff --git a/src/DynamoCoreWpf/Views/Preview/PreviewControl.xaml.cs b/src/DynamoCoreWpf/Views/Preview/PreviewControl.xaml.cs index 4796c69b4d0..f19bb48e582 100644 --- a/src/DynamoCoreWpf/Views/Preview/PreviewControl.xaml.cs +++ b/src/DynamoCoreWpf/Views/Preview/PreviewControl.xaml.cs @@ -181,20 +181,12 @@ internal void HidePreviewBubble() } /// - /// Unpins and hides all preview bubbles + /// Unpins and hides the preview bubbles /// - internal void UnpinAllPreviewBubbles() + internal void UnpinPreviewBubble() { StaysOpen = false; - if (IsExpanded) - { - TransitionToState(State.Condensed); - } - - if (IsCondensed) - { - TransitionToState(State.Hidden); - } + this.HidePreviewBubble(); } /// From 7706a148b71d1bc198138cf10be41f3ac558097a Mon Sep 17 00:00:00 2001 From: Ivo Petrov <48355182+ivaylo-matov@users.noreply.github.com> Date: Wed, 10 Apr 2024 17:46:20 +0100 Subject: [PATCH 05/13] final draft --- src/DynamoCoreWpf/Commands/WorkspaceCommands.cs | 4 ++-- .../ViewModels/Core/WorkspaceViewModel.cs | 10 +++------- src/DynamoCoreWpf/Views/Core/NodeView.xaml.cs | 10 ---------- src/DynamoCoreWpf/Views/Core/WorkspaceView.xaml.cs | 8 ++++---- 4 files changed, 9 insertions(+), 23 deletions(-) diff --git a/src/DynamoCoreWpf/Commands/WorkspaceCommands.cs b/src/DynamoCoreWpf/Commands/WorkspaceCommands.cs index 03515941ed4..cb402539e11 100644 --- a/src/DynamoCoreWpf/Commands/WorkspaceCommands.cs +++ b/src/DynamoCoreWpf/Commands/WorkspaceCommands.cs @@ -58,7 +58,7 @@ public DelegateCommand SelectAllCommand return selectAllCommand; } } - + [JsonIgnore] public DelegateCommand GraphAutoLayoutCommand { @@ -278,7 +278,7 @@ public DelegateCommand HideAllWiresCommand } /// - /// View Command to hide all pinned preview bubbles, if any are pinned + /// View Command to hide all currently pinned preview bubbles within the workspace /// [JsonIgnore] public DelegateCommand UnpinAllPreviewBubblesCommand diff --git a/src/DynamoCoreWpf/ViewModels/Core/WorkspaceViewModel.cs b/src/DynamoCoreWpf/ViewModels/Core/WorkspaceViewModel.cs index 97f2469552d..364b9ffda89 100644 --- a/src/DynamoCoreWpf/ViewModels/Core/WorkspaceViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/Core/WorkspaceViewModel.cs @@ -1741,19 +1741,15 @@ private void ShowHideAllWires(List nodeModels, bool isHidden) /// /// Triggers unpinning of all preview bubbles in the workspace /// - /// - internal void UnpinAllPreviewBubbles(object parameter) + /// + internal void UnpinAllPreviewBubbles(object o) { RaisePropertyChanged("UnpinAllPreviewBubbles"); - //foreach (var nodeVM in Nodes) - //{ - // nodeVM.PreviewPinned = false; - //} UnpinAllPreviewBubblesTriggered?.Invoke(this, EventArgs.Empty); } - internal bool CanUnpinAllPreviewBubbles(object parameter) + internal bool CanUnpinAllPreviewBubbles(object o) { return true; } diff --git a/src/DynamoCoreWpf/Views/Core/NodeView.xaml.cs b/src/DynamoCoreWpf/Views/Core/NodeView.xaml.cs index 6e4cb7a837c..570fd02bdaf 100644 --- a/src/DynamoCoreWpf/Views/Core/NodeView.xaml.cs +++ b/src/DynamoCoreWpf/Views/Core/NodeView.xaml.cs @@ -570,16 +570,6 @@ private void OnNodeViewMouseLeave(object sender, MouseEventArgs e) } } - ////// ip code : - ////private void OnForceUnpinPB(object sender, RoutedEventArgs e) - ////{ - //// if (PreviewControl.StaysOpen) - //// { - //// //PreviewControl.StaysOpen = false; - - //// } - ////} - /// /// This event fires right after preview's state has been changed. /// This event is necessary, it handles some preview's manipulations, diff --git a/src/DynamoCoreWpf/Views/Core/WorkspaceView.xaml.cs b/src/DynamoCoreWpf/Views/Core/WorkspaceView.xaml.cs index 4d80e181691..5bff79c5833 100644 --- a/src/DynamoCoreWpf/Views/Core/WorkspaceView.xaml.cs +++ b/src/DynamoCoreWpf/Views/Core/WorkspaceView.xaml.cs @@ -392,8 +392,8 @@ private RenderTargetBitmap GetRender() if (!initialized) return null; // Add padding to the edge and make them multiples of two (pad 10px on each side). - bounds.Width = 20 + ((((int)System.Math.Ceiling(bounds.Width)) + 1) & ~0x01); - bounds.Height = 20 + ((((int)System.Math.Ceiling(bounds.Height)) + 1) & ~0x01); + bounds.Width = 20 + ((((int)Math.Ceiling(bounds.Width)) + 1) & ~0x01); + bounds.Height = 20 + ((((int)Math.Ceiling(bounds.Height)) + 1) & ~0x01); var currentTransformGroup = WorkspaceElements.RenderTransform as TransformGroup; WorkspaceElements.RenderTransform = new TranslateTransform(10.0 - bounds.X - minX, 10.0 - bounds.Y - minY); @@ -895,9 +895,9 @@ private void OnMouseMove(object sender, MouseEventArgs e) // Check that current mouse position is far enough from start position. var canDrag = - (System.Math.Abs(currentMousePosition.X - startMousePosition.X) > + (Math.Abs(currentMousePosition.X - startMousePosition.X) > SystemParameters.MinimumHorizontalDragDistance) && - (System.Math.Abs(currentMousePosition.Y - startMousePosition.Y) > + (Math.Abs(currentMousePosition.Y - startMousePosition.Y) > SystemParameters.MinimumVerticalDragDistance) && e.OriginalSource is DragCanvas; From 1818f2a94c9bb1acc435cc14e906baa539baca74 Mon Sep 17 00:00:00 2001 From: Ivo Petrov <48355182+ivaylo-matov@users.noreply.github.com> Date: Thu, 11 Apr 2024 12:23:50 +0100 Subject: [PATCH 06/13] test working - needs to cleaned --- src/DynamoCoreWpf/PublicAPI.Unshipped.txt | 1 + test/DynamoCoreWpfTests/PreviewBubbleTests.cs | 47 ++++++++++ test/core/pinnedpreviewbubble.dyn | 94 +++++++++++++++++++ 3 files changed, 142 insertions(+) create mode 100644 test/core/pinnedpreviewbubble.dyn diff --git a/src/DynamoCoreWpf/PublicAPI.Unshipped.txt b/src/DynamoCoreWpf/PublicAPI.Unshipped.txt index c2bbfb47ca2..a1d9e8ef09a 100644 --- a/src/DynamoCoreWpf/PublicAPI.Unshipped.txt +++ b/src/DynamoCoreWpf/PublicAPI.Unshipped.txt @@ -2024,6 +2024,7 @@ Dynamo.ViewModels.DynamoViewModel.ScaleFactorLog.set -> void Dynamo.ViewModels.DynamoViewModel.SelectAll(object parameter) -> void Dynamo.ViewModels.DynamoViewModel.SelectAllCommand.get -> Dynamo.UI.Commands.DelegateCommand Dynamo.ViewModels.DynamoViewModel.SelectAllCommand.set -> void +Dynamo.ViewModels.DynamoViewModel.UnpinAllPreviewBubbles(object parameter) -> void Dynamo.ViewModels.DynamoViewModel.UnpinAllPreviewBubblesCommand.get -> Dynamo.UI.Commands.DelegateCommand Dynamo.ViewModels.DynamoViewModel.UnpinAllPreviewBubblesCommand.set -> void Dynamo.ViewModels.DynamoViewModel.SelectNeighbors(object parameters) -> void diff --git a/test/DynamoCoreWpfTests/PreviewBubbleTests.cs b/test/DynamoCoreWpfTests/PreviewBubbleTests.cs index a38ccb58421..eaa1eed06c6 100644 --- a/test/DynamoCoreWpfTests/PreviewBubbleTests.cs +++ b/test/DynamoCoreWpfTests/PreviewBubbleTests.cs @@ -8,6 +8,7 @@ using Dynamo.Controls; using Dynamo.Graph.Nodes; using Dynamo.Models; +using Dynamo.Nodes; using Dynamo.Utilities; using DynamoCoreWpfTests.Utility; using NUnit.Framework; @@ -533,6 +534,42 @@ public void PreviewBubble_ToggleShowPreviewBubbles() Assert.IsTrue(nodeView.PreviewControl.IsHidden, "Preview bubble is not hidden"); } + [Test] + public void PreviewBubble_UnpinAllPreviewBubble() + { + Open(@"core\DetailedPreviewMargin_Test.dyn"); + var nodeView = NodeViewWithGuid("7828a9dd-88e6-49f4-9ed3-72e355f89bcc"); + + var previewBubble = nodeView.PreviewControl; + previewBubble.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent)); + previewBubble.bubbleTools.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent)); + + // open preview bubble + RaiseMouseEnterOnNode(nodeView); + Assert.IsTrue(previewBubble.IsCondensed, "Compact preview bubble should be shown"); + Assert.AreEqual(Visibility.Collapsed, previewBubble.bubbleTools.Visibility, "Pin icon should not be shown"); + + // hover preview bubble to see pin icon + RaiseMouseEnterOnNode(previewBubble); + Assert.AreEqual(Visibility.Visible, previewBubble.bubbleTools.Visibility, "Pin icon should be shown"); + + // expand preview bubble + RaiseMouseEnterOnNode(previewBubble.bubbleTools); + Assert.IsTrue(previewBubble.IsExpanded, "Expanded preview bubble should be shown"); + + // click on the pin map + RaiseLeftMouseClick(previewBubble.pinIconBorder); + Assert.IsTrue(previewBubble.StaysOpen, "Expanded preview bubble should be pinned"); + Assert.IsTrue(previewBubble.IsExpanded, "Expanded preview bubble should be pinned"); + + ViewModel.UnpinAllPreviewBubblesCommand.Execute(null); + + Assert.IsTrue(!previewBubble.StaysOpen, "Expanded preview bubble should be unpinned"); + + } + + + [Test] public void PreviewBubble_ShowExpandedPreviewOnPinIconHover() { @@ -923,6 +960,16 @@ private void RaiseMouseLeaveNode(IInputElement nv) DispatcherUtil.DoEvents(); } + private void RaiseLeftMouseClick(IInputElement nv) + { + View.Dispatcher.Invoke(() => + { + nv.RaiseEvent(new MouseButtonEventArgs(Mouse.PrimaryDevice, 0, MouseButton.Left) { RoutedEvent = Mouse.MouseDownEvent }); + }); + + DispatcherUtil.DoEvents(); + } + protected NodeModel GetNodeModel(string guid) { return Model.CurrentWorkspace.Nodes.First(n => n.GUID == Guid.Parse(guid)); diff --git a/test/core/pinnedpreviewbubble.dyn b/test/core/pinnedpreviewbubble.dyn new file mode 100644 index 00000000000..09e28d08470 --- /dev/null +++ b/test/core/pinnedpreviewbubble.dyn @@ -0,0 +1,94 @@ +{ + "Uuid": "fd4f3520-9d4e-4ee2-bea1-218933238139", + "IsCustomNode": false, + "Description": "", + "Name": "pinnedpreviewbubble", + "ElementResolver": { + "ResolutionMap": {} + }, + "Inputs": [], + "Outputs": [], + "Nodes": [ + { + "ConcreteType": "Dynamo.Graph.Nodes.CodeBlockNodeModel, DynamoCore", + "Id": "2234c0c8bfc0498096c395b1781282b4", + "NodeType": "CodeBlockNode", + "Inputs": [], + "Outputs": [ + { + "Id": "202065fcfc5d405197842cdbbde16dc0", + "Name": "", + "Description": "Value of expression at line 1", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Disabled", + "Description": "Allows for DesignScript code to be authored directly", + "Code": "5;" + } + ], + "Connectors": [], + "Dependencies": [], + "NodeLibraryDependencies": [], + "EnableLegacyPolyCurveBehavior": true, + "Thumbnail": "", + "GraphDocumentationURL": null, + "ExtensionWorkspaceData": [ + { + "ExtensionGuid": "28992e1d-abb9-417f-8b1b-05e053bee670", + "Name": "Properties", + "Version": "3.1", + "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.1.0.4654", + "RunType": "Automatic", + "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": "2234c0c8bfc0498096c395b1781282b4", + "Name": "Code Block", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "ShowGeometry": true, + "X": 265.0, + "Y": 128.0 + } + ], + "Annotations": [], + "X": 45.90939489678124, + "Y": -21.117745236632118, + "Zoom": 0.937432296686001 + } +} \ No newline at end of file From 4cda00e7915d29467222a48ebe916b3aaa6f02a0 Mon Sep 17 00:00:00 2001 From: Ivo Petrov <48355182+ivaylo-matov@users.noreply.github.com> Date: Thu, 11 Apr 2024 13:00:07 +0100 Subject: [PATCH 07/13] unpin all preview bubbles + test all working --- test/DynamoCoreWpfTests/PreviewBubbleTests.cs | 58 ++++++++++--------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/test/DynamoCoreWpfTests/PreviewBubbleTests.cs b/test/DynamoCoreWpfTests/PreviewBubbleTests.cs index eaa1eed06c6..d9439064e87 100644 --- a/test/DynamoCoreWpfTests/PreviewBubbleTests.cs +++ b/test/DynamoCoreWpfTests/PreviewBubbleTests.cs @@ -538,38 +538,44 @@ public void PreviewBubble_ToggleShowPreviewBubbles() public void PreviewBubble_UnpinAllPreviewBubble() { Open(@"core\DetailedPreviewMargin_Test.dyn"); - var nodeView = NodeViewWithGuid("7828a9dd-88e6-49f4-9ed3-72e355f89bcc"); - - var previewBubble = nodeView.PreviewControl; - previewBubble.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent)); - previewBubble.bubbleTools.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent)); - - // open preview bubble - RaiseMouseEnterOnNode(nodeView); - Assert.IsTrue(previewBubble.IsCondensed, "Compact preview bubble should be shown"); - Assert.AreEqual(Visibility.Collapsed, previewBubble.bubbleTools.Visibility, "Pin icon should not be shown"); - - // hover preview bubble to see pin icon - RaiseMouseEnterOnNode(previewBubble); - Assert.AreEqual(Visibility.Visible, previewBubble.bubbleTools.Visibility, "Pin icon should be shown"); - // expand preview bubble - RaiseMouseEnterOnNode(previewBubble.bubbleTools); - Assert.IsTrue(previewBubble.IsExpanded, "Expanded preview bubble should be shown"); - - // click on the pin map - RaiseLeftMouseClick(previewBubble.pinIconBorder); - Assert.IsTrue(previewBubble.StaysOpen, "Expanded preview bubble should be pinned"); - Assert.IsTrue(previewBubble.IsExpanded, "Expanded preview bubble should be pinned"); + // List of GUIDs and corresponding NodeView instances + var guids = new List + { + "1382aaf9-9432-4cf0-86ae-c586d311767e", + "81c94fd0-35a0-4680-8535-00aff41192d3", + "7828a9dd-88e6-49f4-9ed3-72e355f89bcc" + }; + var nodeViews = guids.Select(guid => NodeViewWithGuid(guid)).ToList(); + + // Pin each preview bubble + foreach (var nodeView in nodeViews) + { + var previewBubble = nodeView.PreviewControl; + previewBubble.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent)); + previewBubble.bubbleTools.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent)); + + // Simulate mouse enter events to trigger bubble visibility and pinning + RaiseMouseEnterOnNode(nodeView); + RaiseMouseEnterOnNode(previewBubble); + RaiseMouseEnterOnNode(previewBubble.bubbleTools); + RaiseLeftMouseClick(previewBubble.pinIconBorder); + + // Assert the bubble is expanded and pinned + Assert.IsTrue(previewBubble.IsExpanded, "Expanded preview bubble should be shown"); + Assert.IsTrue(previewBubble.StaysOpen, "Expanded preview bubble should be pinned"); + } + // Execute command to unpin all preview bubbles ViewModel.UnpinAllPreviewBubblesCommand.Execute(null); - Assert.IsTrue(!previewBubble.StaysOpen, "Expanded preview bubble should be unpinned"); - + // Assert all preview bubbles are unpinned + foreach (var nodeView in nodeViews) + { + Assert.IsTrue(!nodeView.PreviewControl.StaysOpen, "Expanded preview bubble should be unpinned"); + } } - - [Test] public void PreviewBubble_ShowExpandedPreviewOnPinIconHover() { From f64568cc8fd095dce76f7e91d43786775f8e8795 Mon Sep 17 00:00:00 2001 From: Ivo Petrov <48355182+ivaylo-matov@users.noreply.github.com> Date: Thu, 11 Apr 2024 14:51:25 +0100 Subject: [PATCH 08/13] dyn removed --- test/DynamoCoreWpfTests/PreviewBubbleTests.cs | 1 - test/core/pinnedpreviewbubble.dyn | 94 ------------------- 2 files changed, 95 deletions(-) delete mode 100644 test/core/pinnedpreviewbubble.dyn diff --git a/test/DynamoCoreWpfTests/PreviewBubbleTests.cs b/test/DynamoCoreWpfTests/PreviewBubbleTests.cs index d9439064e87..21417643f51 100644 --- a/test/DynamoCoreWpfTests/PreviewBubbleTests.cs +++ b/test/DynamoCoreWpfTests/PreviewBubbleTests.cs @@ -8,7 +8,6 @@ using Dynamo.Controls; using Dynamo.Graph.Nodes; using Dynamo.Models; -using Dynamo.Nodes; using Dynamo.Utilities; using DynamoCoreWpfTests.Utility; using NUnit.Framework; diff --git a/test/core/pinnedpreviewbubble.dyn b/test/core/pinnedpreviewbubble.dyn deleted file mode 100644 index 09e28d08470..00000000000 --- a/test/core/pinnedpreviewbubble.dyn +++ /dev/null @@ -1,94 +0,0 @@ -{ - "Uuid": "fd4f3520-9d4e-4ee2-bea1-218933238139", - "IsCustomNode": false, - "Description": "", - "Name": "pinnedpreviewbubble", - "ElementResolver": { - "ResolutionMap": {} - }, - "Inputs": [], - "Outputs": [], - "Nodes": [ - { - "ConcreteType": "Dynamo.Graph.Nodes.CodeBlockNodeModel, DynamoCore", - "Id": "2234c0c8bfc0498096c395b1781282b4", - "NodeType": "CodeBlockNode", - "Inputs": [], - "Outputs": [ - { - "Id": "202065fcfc5d405197842cdbbde16dc0", - "Name": "", - "Description": "Value of expression at line 1", - "UsingDefaultValue": false, - "Level": 2, - "UseLevels": false, - "KeepListStructure": false - } - ], - "Replication": "Disabled", - "Description": "Allows for DesignScript code to be authored directly", - "Code": "5;" - } - ], - "Connectors": [], - "Dependencies": [], - "NodeLibraryDependencies": [], - "EnableLegacyPolyCurveBehavior": true, - "Thumbnail": "", - "GraphDocumentationURL": null, - "ExtensionWorkspaceData": [ - { - "ExtensionGuid": "28992e1d-abb9-417f-8b1b-05e053bee670", - "Name": "Properties", - "Version": "3.1", - "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.1.0.4654", - "RunType": "Automatic", - "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": "2234c0c8bfc0498096c395b1781282b4", - "Name": "Code Block", - "IsSetAsInput": false, - "IsSetAsOutput": false, - "Excluded": false, - "ShowGeometry": true, - "X": 265.0, - "Y": 128.0 - } - ], - "Annotations": [], - "X": 45.90939489678124, - "Y": -21.117745236632118, - "Zoom": 0.937432296686001 - } -} \ No newline at end of file From d6b73616979ce437d9d6a322011fe0b36a4bf6ab Mon Sep 17 00:00:00 2001 From: "Aaron (Qilong)" Date: Tue, 30 Apr 2024 13:25:50 -0400 Subject: [PATCH 09/13] Update AssemblySharedInfo.cs From eef4586ed428ea7751f5aea2de36df6df8a45f1a Mon Sep 17 00:00:00 2001 From: "Aaron (Qilong)" <173288704@qq.com> Date: Tue, 30 Apr 2024 13:58:46 -0400 Subject: [PATCH 10/13] Update --- src/AssemblySharedInfoGenerator/AssemblySharedInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AssemblySharedInfoGenerator/AssemblySharedInfo.cs b/src/AssemblySharedInfoGenerator/AssemblySharedInfo.cs index 86f8e9192a4..d08fb4be399 100644 --- a/src/AssemblySharedInfoGenerator/AssemblySharedInfo.cs +++ b/src/AssemblySharedInfoGenerator/AssemblySharedInfo.cs @@ -8,7 +8,7 @@ // associated with an assembly. [assembly: AssemblyCompany("Autodesk, Inc")] [assembly: AssemblyProduct("Dynamo")] -[assembly: AssemblyCopyright("Copyright © Autodesk, Inc 2024")] +[assembly: AssemblyCopyright("Copyright � Autodesk, Inc 2024")] [assembly: AssemblyTrademark("")] //In order to begin building localizable applications, set From 96f72721a7cd620be0148249826fc1cedc444e70 Mon Sep 17 00:00:00 2001 From: "Aaron (Qilong)" <173288704@qq.com> Date: Tue, 30 Apr 2024 13:59:47 -0400 Subject: [PATCH 11/13] update --- src/AssemblySharedInfoGenerator/AssemblySharedInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AssemblySharedInfoGenerator/AssemblySharedInfo.cs b/src/AssemblySharedInfoGenerator/AssemblySharedInfo.cs index d08fb4be399..86f8e9192a4 100644 --- a/src/AssemblySharedInfoGenerator/AssemblySharedInfo.cs +++ b/src/AssemblySharedInfoGenerator/AssemblySharedInfo.cs @@ -8,7 +8,7 @@ // associated with an assembly. [assembly: AssemblyCompany("Autodesk, Inc")] [assembly: AssemblyProduct("Dynamo")] -[assembly: AssemblyCopyright("Copyright � Autodesk, Inc 2024")] +[assembly: AssemblyCopyright("Copyright © Autodesk, Inc 2024")] [assembly: AssemblyTrademark("")] //In order to begin building localizable applications, set From 08c75fc1051c16afcf65eccbe7512386e547f1bd Mon Sep 17 00:00:00 2001 From: Ivo Petrov <48355182+ivaylo-matov@users.noreply.github.com> Date: Fri, 3 May 2024 13:15:10 +0100 Subject: [PATCH 12/13] failing test fix UnpinPreviewBubble() was not updating the nodeViewModel --- src/DynamoCoreWpf/Views/Preview/PreviewControl.xaml.cs | 1 + test/DynamoCoreWpfTests/PreviewBubbleTests.cs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/DynamoCoreWpf/Views/Preview/PreviewControl.xaml.cs b/src/DynamoCoreWpf/Views/Preview/PreviewControl.xaml.cs index f19bb48e582..f6fa2b2214d 100644 --- a/src/DynamoCoreWpf/Views/Preview/PreviewControl.xaml.cs +++ b/src/DynamoCoreWpf/Views/Preview/PreviewControl.xaml.cs @@ -186,6 +186,7 @@ internal void HidePreviewBubble() internal void UnpinPreviewBubble() { StaysOpen = false; + nodeViewModel.PreviewPinned = false; this.HidePreviewBubble(); } diff --git a/test/DynamoCoreWpfTests/PreviewBubbleTests.cs b/test/DynamoCoreWpfTests/PreviewBubbleTests.cs index 4648bd2923c..3150e97956f 100644 --- a/test/DynamoCoreWpfTests/PreviewBubbleTests.cs +++ b/test/DynamoCoreWpfTests/PreviewBubbleTests.cs @@ -81,7 +81,7 @@ public void PreviewBubbleVisible_MouseMoveOutOfNode() } [Test] - public void PreviewBubbleHiiden_OnFrozenNode() + public void PreviewBubbleHidden_OnFrozenNode() { Open(@"core\DetailedPreviewMargin_Test.dyn"); var nodeView = NodeViewWithGuid("7828a9dd-88e6-49f4-9ed3-72e355f89bcc"); From b2fc9117a3cc65f407001fe374f63312c6426791 Mon Sep 17 00:00:00 2001 From: Ivo Petrov <48355182+ivaylo-matov@users.noreply.github.com> Date: Fri, 3 May 2024 16:35:29 +0100 Subject: [PATCH 13/13] Update AssemblySharedInfo.cs