Skip to content

Commit

Permalink
Fixes #525 F1 and Context Menu to open dax.guide for functions
Browse files Browse the repository at this point in the history
  • Loading branch information
dgosbell committed Jan 28, 2021
1 parent f96f450 commit 331a2c2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
21 changes: 21 additions & 0 deletions src/DaxStudio.UI/ViewModels/FunctionPaneViewModel.cs
@@ -1,14 +1,18 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Diagnostics;
using System.Windows.Input;
using System.Windows.Media;
using ADOTabular;
using Caliburn.Micro;
using DaxStudio.Interfaces;
using DaxStudio.UI.Enums;
using DaxStudio.UI.Events;
using DaxStudio.UI.Interfaces;
using DaxStudio.UI.Model;
using Serilog;
using FocusManager = DaxStudio.UI.Utils.FocusManager;

namespace DaxStudio.UI.ViewModels
{
Expand Down Expand Up @@ -97,5 +101,22 @@ public void Handle(ConnectionChangedEvent message)
NotifyOfPropertyChange(() => FunctionGroups);
//EventAggregator.PublishOnUIThread(new FunctionsLoadedEvent(Document, _functionProvider.FunctionGroups));
}

public void MetadataKeyUp(IFilterableTreeViewItem selectedItem, KeyEventArgs args)
{
switch (args.Key)
{
case Key.F1:

LaunchDaxGuide(selectedItem);
break;
}
}

public void LaunchDaxGuide(IFilterableTreeViewItem selectedItem)
{
if (!(selectedItem is ADOTabularFunctionsExtensions.TreeViewFunction func)) return;
Process.Start(new ProcessStartInfo($"https://dax.guide/{func.Name}"));
}
}
}
11 changes: 9 additions & 2 deletions src/DaxStudio.UI/Views/FunctionPaneView.xaml
Expand Up @@ -64,7 +64,7 @@
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="False"
dd:DragDrop.DragHandler="{Binding}"
cal:Message.Attach="[Event MouseDoubleClick] = [Action MouseDoubleClick($this.SelectedItem,$eventArgs)]"
cal:Message.Attach="[Event MouseDoubleClick] = [Action MouseDoubleClick($this.SelectedItem,$eventArgs)]; [Event KeyUp] = [Action MetadataKeyUp($this.SelectedItem, $eventArgs)]"
>
<!--" dd:DragDrop.DragAdornerTemplate="{StaticResource DragAdorner}">>-->
<TreeView.ItemTemplate>
Expand All @@ -77,7 +77,7 @@
<!-- Function Template -->
<HierarchicalDataTemplate.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" >
<StackPanel Orientation="Horizontal" Tag="{Binding DataContext, ElementName=FunctionGroups}">
<Image Source="{StaticResource Function}" Margin="2,1,5,1" />
<TextBlock Text="{Binding Caption}" >
<TextBlock.ToolTip>
Expand All @@ -92,6 +92,13 @@
</StackPanel>
</TextBlock.ToolTip>
</TextBlock>
<StackPanel.ContextMenu>
<ContextMenu cal:Action.TargetWithoutContext="{Binding Path=PlacementTarget.Tag, RelativeSource={RelativeSource Self}}">
<MenuItem Header="Open in Dax.Guide"
cal:Message.Attach="[Event Click] = [Action LaunchDaxGuide($dataContext)]">
</MenuItem>
</ContextMenu>
</StackPanel.ContextMenu>
</StackPanel>
</DataTemplate>
</HierarchicalDataTemplate.ItemTemplate>
Expand Down

0 comments on commit 331a2c2

Please sign in to comment.