Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assign F1 as the hotkey to display node help docs #12894

Merged
merged 3 commits into from
May 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/DynamoCoreWpf/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/DynamoCoreWpf/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -2482,7 +2482,7 @@ Do you wish to uninstall {1}? Restart {2} to complete the uninstall and try down
<comment>Dynamo Guided Tours</comment>
</data>
<data name="GetStartedGuideLibraryText" xml:space="preserve">
<value>The library contains all default functions #(nodes)=https://www.dynamoprimer.com/03_Anatomy-of-a-Dynamo-Definition/3-1_dynamo_nodes.html of Dynamo, as well as custom nodes you may have loaded. \n\nTo find a node, search the library or browse its categories.</value>
<value>The library contains all default functions #(nodes)=https://primer2.dynamobim.org/4_nodes_and_wires of Dynamo, as well as custom nodes you may have loaded. \n\nTo find a node, search the library or browse its categories.</value>
</data>
<data name="GetStartedGuideLibraryTitle" xml:space="preserve">
<value>Library</value>
Expand Down
2 changes: 1 addition & 1 deletion src/DynamoCoreWpf/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -2724,7 +2724,7 @@ Do you wish to uninstall {1}? Restart {2} to complete the uninstall and try down
<comment>Dynamo Guided Tours</comment>
</data>
<data name="GetStartedGuideLibraryText" xml:space="preserve">
<value>The library contains all default functions #(nodes)=https://www.dynamoprimer.com/03_Anatomy-of-a-Dynamo-Definition/3-1_dynamo_nodes.html of Dynamo, as well as custom nodes you may have loaded. \n\nTo find a node, search the library or browse its categories.</value>
<value>The library contains all default functions #(nodes)=https://primer2.dynamobim.org/4_nodes_and_wires of Dynamo, as well as custom nodes you may have loaded. \n\nTo find a node, search the library or browse its categories.</value>
</data>
<data name="GetStartedGuideLibraryTitle" xml:space="preserve">
<value>Library</value>
Expand Down
8 changes: 6 additions & 2 deletions src/DynamoCoreWpf/Utilities/NodeContextMenuBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ internal static void Build(ContextMenu contextMenu, NodeViewModel nodeViewModel,
/// <param name="visibility"></param>
/// <param name="isEnabled"></param>
/// <param name="itemsSource"></param>
/// <param name="hotkey"></param>
/// <returns></returns>
internal static MenuItem CreateMenuItem
(
Expand All @@ -96,7 +97,8 @@ internal static MenuItem CreateMenuItem
Binding isChecked = null,
Binding visibility = null,
Binding isEnabled = null,
Binding itemsSource = null
Binding itemsSource = null,
string hotkey = null
)
{
MenuItem menuItem = new MenuItem { Header = header, IsCheckable = isCheckable };
Expand All @@ -108,6 +110,7 @@ internal static MenuItem CreateMenuItem
if (visibility != null) menuItem.SetBinding(UIElement.VisibilityProperty, visibility);
if (isEnabled != null) menuItem.SetBinding(UIElement.IsEnabledProperty, isEnabled);
if (itemsSource != null) menuItem.SetBinding(ItemsControl.ItemsSourceProperty, itemsSource);
if (!string.IsNullOrWhiteSpace(hotkey)) menuItem.InputGestureText = hotkey;

return menuItem;
}
Expand Down Expand Up @@ -433,7 +436,8 @@ internal static MenuItem BuildHelpMenuItem()
{
Source = NodeViewModel,
Path = new PropertyPath(nameof(NodeViewModel.ShowHelpCommand))
}
},
hotkey: "F1"
);
}

Expand Down
18 changes: 18 additions & 0 deletions src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2676,6 +2676,24 @@ internal void OpenDocumentationLink(object parameter)
OnRequestOpenDocumentationLink((OpenDocumentationLinkEventArgs)parameter);
}

internal void ShowNodeDocumentation(object parameter)
{
var node = DynamoSelection.Instance.Selection.OfType<NodeModel>().LastOrDefault();

var nodeAnnotationEventArgs = new OpenNodeAnnotationEventArgs(node, this);
OpenDocumentationLink(nodeAnnotationEventArgs);
}
internal bool CanShowNodeDocumentation(object parameter)
{
var node = DynamoSelection.Instance.Selection.OfType<NodeModel>().LastOrDefault();

if (node == null || !(node is NodeModel))
{
return false;
}
return true;
}

private bool CanZoomIn(object parameter)
{
return CurrentSpaceViewModel.CanZoomIn;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ private void InitializeDelegateCommands()
ShowNewPresetsDialogCommand = new DelegateCommand(ShowNewPresetStateDialogAndMakePreset, CanShowNewPresetStateDialog);
NodeFromSelectionCommand = new DelegateCommand(CreateNodeFromSelection, CanCreateNodeFromSelection);
OpenDocumentationLinkCommand = new DelegateCommand(OpenDocumentationLink);
ShowNodeDocumentationCommand = new DelegateCommand(ShowNodeDocumentation, CanShowNodeDocumentation);
}
public DelegateCommand OpenFromJsonIfSavedCommand { get; set; }
public DelegateCommand OpenFromJsonCommand { get; set; }
Expand Down Expand Up @@ -167,5 +168,7 @@ private void InitializeDelegateCommands()
public DelegateCommand ShowNewPresetsDialogCommand { get; set; }
public DelegateCommand NodeFromSelectionCommand { get; set; }
public DelegateCommand OpenDocumentationLinkCommand { get; set; }
public DelegateCommand ShowNodeDocumentationCommand { get; set; }

}
}
2 changes: 2 additions & 0 deletions src/DynamoCoreWpf/Views/Core/DynamoView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@
<KeyBinding Key="T"
Modifiers="Control"
Command="{Binding Path=DataContext.ShowNewPresetsDialogCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type controls:DynamoView}}}" />
<KeyBinding Key="F1"
Command="{Binding Path=DataContext.ShowNodeDocumentationCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type controls:DynamoView}}}" />
</Window.InputBindings>

<Grid Name="mainGrid"
Expand Down
8 changes: 8 additions & 0 deletions src/DynamoCoreWpf/Views/Core/NodeView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@
</Style>
</Label.Style>
</Label>
<TextBlock x:Name="InputGestureText"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah so this is the trick?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, the missing piece

Margin="0,2,2,2"
DockPanel.Dock="Right"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Text="{TemplateBinding InputGestureText}"
TextBlock.FontFamily="{StaticResource ArtifaktElementRegular}"
TextBlock.FontSize="13px" />
<Popup x:Name="PART_Popup"
AllowsTransparency="true"
Focusable="false"
Expand Down