diff --git a/.gitignore b/.gitignore index 849dd5651d5..20ea2ee26c1 100644 --- a/.gitignore +++ b/.gitignore @@ -67,6 +67,7 @@ launchSettings.json # IDE # ############### .idea +.vscode/ #documentation files doc/html/ diff --git a/src/DynamoCoreWpf/Commands/InfoBubbleCommand.cs b/src/DynamoCoreWpf/Commands/InfoBubbleCommand.cs index 4f30d255b3a..336599c58c9 100644 --- a/src/DynamoCoreWpf/Commands/InfoBubbleCommand.cs +++ b/src/DynamoCoreWpf/Commands/InfoBubbleCommand.cs @@ -1,4 +1,4 @@ -using Dynamo.UI.Commands; +using Dynamo.UI.Commands; namespace Dynamo.ViewModels { @@ -13,6 +13,17 @@ public partial class InfoBubbleViewModel : ViewModelBase private DelegateCommand openDocumentationLinkCommand; private DelegateCommand dismissMessageCommand; private DelegateCommand undismissMessageCommand; + private DelegateCommand copyTextToClipboardCommand; + + public DelegateCommand CopyTextToClipboardCommand + { + get + { + if (copyTextToClipboardCommand == null) + copyTextToClipboardCommand = new DelegateCommand(CopyTextToClipboard, CanCopyTextToClipboard); + return copyTextToClipboardCommand; + } + } public DelegateCommand UpdateContentCommand { @@ -127,4 +138,4 @@ public DelegateCommand UndismissMessageCommand } } } -} \ No newline at end of file +} diff --git a/src/DynamoCoreWpf/DynamoCoreWpf.csproj b/src/DynamoCoreWpf/DynamoCoreWpf.csproj index 497325a43eb..0688cf9da32 100644 --- a/src/DynamoCoreWpf/DynamoCoreWpf.csproj +++ b/src/DynamoCoreWpf/DynamoCoreWpf.csproj @@ -171,6 +171,8 @@ + + @@ -1323,6 +1325,8 @@ + + diff --git a/src/DynamoCoreWpf/Properties/Resources.Designer.cs b/src/DynamoCoreWpf/Properties/Resources.Designer.cs index 1f7a0df772e..14e85faee87 100644 --- a/src/DynamoCoreWpf/Properties/Resources.Designer.cs +++ b/src/DynamoCoreWpf/Properties/Resources.Designer.cs @@ -987,6 +987,24 @@ public static string ConverterMessageZoom { } } + /// + /// Looks up a localized string similar to Copy to clipboard failed. + /// + public static string CopyToClipboardFailedMessage { + get { + return ResourceManager.GetString("CopyToClipboardFailedMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Copy to clipboard. + /// + public static string CopyToClipboardTooltip { + get { + return ResourceManager.GetString("CopyToClipboardTooltip", resourceCulture); + } + } + /// /// Looks up a localized string similar to Copy. /// @@ -1495,24 +1513,15 @@ public static string DynamoViewDebugMenuDumpNodeHelpData { } } - /// - /// Looks up a localized string similar to _Dump Node Icons. + /// + /// Looks up a localized string similar to _Dump Node Icon Data. /// public static string DynamoViewDebugMenuDumpNodeIcons { get { return ResourceManager.GetString("DynamoViewDebugMenuDumpNodeIcons", resourceCulture); } } - - /// - /// Looks up a localized string similar to NodeIconDataIsDumped. - /// - public static string NodeIconDataIsDumped { - get { - return ResourceManager.GetString("NodeIconDataIsDumped", resourceCulture); - } - } - + /// /// Looks up a localized string similar to _Force Re-execute. /// @@ -5254,6 +5263,15 @@ public static string NodeHelpWindowNodeType { } } + /// + /// Looks up a localized string similar to Node Icon Data is dumped to \"{0}\".. + /// + public static string NodeIconDataIsDumped { + get { + return ResourceManager.GetString("NodeIconDataIsDumped", resourceCulture); + } + } + /// /// Looks up a localized string similar to Failed to create node: . /// diff --git a/src/DynamoCoreWpf/Properties/Resources.en-US.resx b/src/DynamoCoreWpf/Properties/Resources.en-US.resx index 37b280d6f7c..37c27f08686 100644 --- a/src/DynamoCoreWpf/Properties/Resources.en-US.resx +++ b/src/DynamoCoreWpf/Properties/Resources.en-US.resx @@ -447,6 +447,12 @@ Don't worry, you'll have the option to save your work. Download Warning + + Copy to clipboard + + + Copy to clipboard failed + A Dynamo update is available. Click to install. @@ -4170,4 +4176,4 @@ To make this file into a new template, save it to a different folder, then move Node Icon Data is dumped to \"{0}\". Debug menu | Dump all node icons - \ No newline at end of file + diff --git a/src/DynamoCoreWpf/Properties/Resources.resx b/src/DynamoCoreWpf/Properties/Resources.resx index 7e29a7fbe80..806cda56dea 100644 --- a/src/DynamoCoreWpf/Properties/Resources.resx +++ b/src/DynamoCoreWpf/Properties/Resources.resx @@ -1126,7 +1126,13 @@ Don't worry, you'll have the option to save your work. Download Warning - + + Copy to clipboard + + + Copy to clipboard failed + + A Dynamo update is available. Click to install. diff --git a/src/DynamoCoreWpf/PublicAPI.Unshipped.txt b/src/DynamoCoreWpf/PublicAPI.Unshipped.txt index 0445e797f91..de70726a818 100644 --- a/src/DynamoCoreWpf/PublicAPI.Unshipped.txt +++ b/src/DynamoCoreWpf/PublicAPI.Unshipped.txt @@ -2362,6 +2362,7 @@ Dynamo.ViewModels.InfoBubbleViewModel.ConnectingDirection.get -> Dynamo.ViewMode Dynamo.ViewModels.InfoBubbleViewModel.ConnectingDirection.set -> void Dynamo.ViewModels.InfoBubbleViewModel.Content.get -> string Dynamo.ViewModels.InfoBubbleViewModel.Content.set -> void +Dynamo.ViewModels.InfoBubbleViewModel.CopyTextToClipboardCommand.get -> Dynamo.UI.Commands.DelegateCommand Dynamo.ViewModels.InfoBubbleViewModel.Direction Dynamo.ViewModels.InfoBubbleViewModel.Direction.Bottom = 4 -> Dynamo.ViewModels.InfoBubbleViewModel.Direction Dynamo.ViewModels.InfoBubbleViewModel.Direction.BottomLeft = 7 -> Dynamo.ViewModels.InfoBubbleViewModel.Direction @@ -4618,6 +4619,8 @@ static Dynamo.Wpf.Properties.Resources.ContinueInstall.get -> string static Dynamo.Wpf.Properties.Resources.ConverterMessageCurrentOffset.get -> string static Dynamo.Wpf.Properties.Resources.ConverterMessageTransformOrigin.get -> string static Dynamo.Wpf.Properties.Resources.ConverterMessageZoom.get -> string +static Dynamo.Wpf.Properties.Resources.CopyToClipboardTooltip.get -> string +static Dynamo.Wpf.Properties.Resources.CopyToClipboardFailedMessage.get -> string static Dynamo.Wpf.Properties.Resources.CrashPromptDialogCopyButton.get -> string static Dynamo.Wpf.Properties.Resources.CrashPromptDialogCrashMessage.get -> string static Dynamo.Wpf.Properties.Resources.CrashPromptDialogDetailButton.get -> string diff --git a/src/DynamoCoreWpf/UI/Images/copy_16px_default.png b/src/DynamoCoreWpf/UI/Images/copy_16px_default.png new file mode 100644 index 00000000000..4459b159f0c Binary files /dev/null and b/src/DynamoCoreWpf/UI/Images/copy_16px_default.png differ diff --git a/src/DynamoCoreWpf/UI/Images/copy_16px_hover.png b/src/DynamoCoreWpf/UI/Images/copy_16px_hover.png new file mode 100644 index 00000000000..a4e21ac6fa5 Binary files /dev/null and b/src/DynamoCoreWpf/UI/Images/copy_16px_hover.png differ diff --git a/src/DynamoCoreWpf/ViewModels/Preview/InfoBubbleViewModel.cs b/src/DynamoCoreWpf/ViewModels/Preview/InfoBubbleViewModel.cs index 7961145c27c..fab7e2459d5 100644 --- a/src/DynamoCoreWpf/ViewModels/Preview/InfoBubbleViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/Preview/InfoBubbleViewModel.cs @@ -4,7 +4,9 @@ using System.Linq; using System.Text.RegularExpressions; using System.Windows; +using System.Windows.Input; using Dynamo.Logging; +using Dynamo.UI.Commands; using Dynamo.Wpf.ViewModels.Core; namespace Dynamo.ViewModels @@ -65,7 +67,7 @@ public enum State // In order to stay above these, we need a high ZIndex value. private double zIndex; private Style infoBubbleStyle; - + [Obsolete] public Direction connectingDirection; @@ -506,6 +508,39 @@ private void InitializeInfoBubble(DynamoViewModel dynamoViewModel) RefreshNodeInformationalStateDisplay(); } + + /// + /// Copies the text of an info bubble message to the clipboard + /// + /// The InfoBubbleDataPacket to copy + private void CopyTextToClipboard(object parameter) + { + if (parameter is InfoBubbleDataPacket infoBubbleDataPacket) + { + try + { + System.Windows.Clipboard.SetText(infoBubbleDataPacket.Text); + Analytics.TrackEvent(Actions.Copy, Categories.NodeOperations, + infoBubbleDataPacket.Style.ToString(), 1); + } + catch (Exception ex) + { + DynamoViewModel.Model.Logger.Log(Wpf.Properties.Resources.CopyToClipboardFailedMessage); + DynamoViewModel.Model.Logger.Log(ex.Message); + } + } + } + + /// + /// Determines if a message can be copied to clipboard + /// + /// The InfoBubbleDataPacket to check + /// True if the message can be copied + private bool CanCopyTextToClipboard(object parameter) + { + return parameter is InfoBubbleDataPacket infoBubbleDataPacket && + !string.IsNullOrEmpty(infoBubbleDataPacket.Text); + } #endregion diff --git a/src/DynamoCoreWpf/Views/Preview/InfoBubbleView.xaml b/src/DynamoCoreWpf/Views/Preview/InfoBubbleView.xaml index 0ef9d17938b..44561939ff8 100644 --- a/src/DynamoCoreWpf/Views/Preview/InfoBubbleView.xaml +++ b/src/DynamoCoreWpf/Views/Preview/InfoBubbleView.xaml @@ -1,4 +1,4 @@ - + - @@ -127,6 +158,15 @@ Foreground="Black" Text="{x:Static p:Resources.InfoBubbleError}" Visibility="{Binding NodeErrorsSectionExpanded, FallbackValue=Collapsed, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource BooleanToVisibilityCollapsedConverter}}" /> + +