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

DYN-5643 ml confidence #13867

Merged
merged 5 commits into from
Apr 4, 2023
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
61 changes: 48 additions & 13 deletions src/DynamoCoreWpf/Controls/Docs/NodeAutocompleteDocumentation.html

Large diffs are not rendered by default.

27 changes: 26 additions & 1 deletion src/DynamoCoreWpf/Controls/NodeAutoCompleteSearchControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
Handler="OnMouseEnter" />
<EventSetter Event="MouseLeave"
Handler="OnMouseLeave" />
<EventSetter Event="MouseMove"
Handler="OnMouseMove" />
</Style>

<Style TargetType="{x:Type ScrollViewer}"
Expand Down Expand Up @@ -142,7 +144,6 @@
</ListBox.ItemTemplate>
</ListBox>
</Border>

<StackPanel Visibility="{Binding Path=DisplayAutocompleteMLStaticPage, Converter={StaticResource BooleanToVisibilityConverter}}">
<Image Name="NoRecommendations"
Width="205"
Expand Down Expand Up @@ -216,6 +217,30 @@
<uicontrols:ToolTipWindow />
</Popup>
</Border>
<Popup Name="confidenceToolTip" Height="auto" Width="250" StaysOpen="True" AllowsTransparency="True" Margin="50,-10,0,0" PopupAnimation="Fade">
<Grid x:Name="ShadowBackground" Background="Transparent">
<Path Margin="5 0 0 0" Width="20" Height="6" HorizontalAlignment="Left" VerticalAlignment="Top" Data="M0,6 L6,0 12,6Z" Stroke="{StaticResource CustomToolTipBorderColor}" Fill="{StaticResource objectLabelBackground}" Stretch="None" />
<Path Margin="5 0 0 0" Width="30" Height="6" HorizontalAlignment="Left" VerticalAlignment="Top" Data="M12 6 L26 6 L26 0 L4 0" Fill="{StaticResource LibraryCommonBackground}" Stretch="None" />
<Border BorderThickness="1 0 1 1" CornerRadius="2" Margin="0 5 7 7" BorderBrush="{StaticResource CustomToolTipBorderColor}" Background="{StaticResource objectLabelBackground}" Padding="10,8" MouseLeftButtonUp="onCloseConfidenceToolTip">
<StackPanel Margin="3">
<TextBlock Margin="0,0,0,10" Name="confidenceScoreTitle" Style="{StaticResource TextBlockToolTipTitle}"/>
<TextBlock Margin="0,0,0,10" LineHeight="14px" TextWrapping="Wrap">
<TextBlock.Inlines>
<Run Text="{x:Static p:Resources.ConfidenceToolTipDescription}" Style="{StaticResource TextBlockToolTipDescription}"/>
</TextBlock.Inlines>
</TextBlock>
<TextBlock Name="confidenceLearnMore"
Text="{x:Static p:Resources.ConfidenceToolTipoLearnMore}"
Style="{StaticResource TextBlockLinkDark}"
HorizontalAlignment="Right"
VerticalAlignment="Center"
MouseLeftButtonDown="onConfidenceToolTipLearnMoreClicked"/>
</StackPanel>
</Border>
<Border BorderThickness="0 1 0 0" CornerRadius="0 0 2 0" Margin="16 5 9 0" HorizontalAlignment="Stretch" VerticalAlignment="Top" Height="7" BorderBrush="#999999" />
<Border BorderThickness="0 1 0 0" CornerRadius="2 0 0 0" Margin="0 5 0 0" HorizontalAlignment="Left" VerticalAlignment="Top" Height="7" Width="6" BorderBrush="#999999" />
</Grid>
</Popup>

<Grid Name="SearchText"
Background="{StaticResource LibraryCommonBackground}"
Expand Down
46 changes: 46 additions & 0 deletions src/DynamoCoreWpf/Controls/NodeAutoCompleteSearchControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using Dynamo.Utilities;
using Dynamo.ViewModels;
using Dynamo.Wpf.ViewModels;
using Res = Dynamo.Wpf.Properties.Resources;

namespace Dynamo.UI.Controls
{
Expand All @@ -28,6 +29,10 @@ public partial class NodeAutoCompleteSearchControl

internal event Action<ShowHideFlags> RequestShowNodeAutoCompleteSearch;

double currentX;

ListBoxItem currentListBoxItem;

/// <summary>
/// Node AutoComplete Search ViewModel DataContext
/// </summary>
Expand Down Expand Up @@ -117,6 +122,30 @@ private void ExecuteSearchElement(ListBoxItem listBoxItem)
searchElementInfo);
}
}
}

private void OnMouseMove(object sender, MouseEventArgs e)
{
if (!(sender is FrameworkElement fromSender)) return;
currentX = e.GetPosition(MembersListBox).X;

DisplayOrHideConfidenceTooltip(sender);
}

private void DisplayOrHideConfidenceTooltip(object sender)
{
currentListBoxItem = sender as ListBoxItem;
if (currentX <= 35)
{
confidenceToolTip.PlacementTarget = currentListBoxItem;
confidenceToolTip.Placement = PlacementMode.Bottom;
confidenceToolTip.IsOpen = true;
}
else
{
confidenceToolTip.IsOpen = false;
confidenceToolTip.PlacementTarget = null;
}
}

private void OnMouseEnter(object sender, MouseEventArgs e)
Expand All @@ -126,6 +155,17 @@ private void OnMouseEnter(object sender, MouseEventArgs e)
HighlightedItem.IsSelected = false;
toolTipPopup.DataContext = fromSender.DataContext;
toolTipPopup.IsOpen = true;
confidenceToolTip.IsOpen = false;

DisplayOrHideConfidenceTooltip(sender);

dynamic currentNodeSearchElement = currentListBoxItem.DataContext;
confidenceScoreTitle.Text = $"{Res.ConfidenceToolTipTitle}: {currentNodeSearchElement.AutoCompletionNodeMachineLearningInfo.ConfidenceScore}%";
}

private void onCloseConfidenceToolTip(object sender, RoutedEventArgs e)
{
confidenceToolTip.IsOpen = false;
}

private void OnMouseLeave(object sender, MouseEventArgs e)
Expand All @@ -137,6 +177,12 @@ private void OnMouseLeave(object sender, MouseEventArgs e)
toolTipPopup.IsOpen = false;
}

private void onConfidenceToolTipLearnMoreClicked(object sender, MouseButtonEventArgs e)
{
confidenceToolTip.IsOpen = false;
ViewModel.dynamoViewModel.OpenDocumentationLinkCommand.Execute(new OpenDocumentationLinkEventArgs(new Uri(Res.NodeAutocompleteDocumentationUriString, UriKind.Relative)));
}

private void OnNodeAutoCompleteSearchControlVisibilityChanged(object sender, DependencyPropertyChangedEventArgs e)
{
// If visibility is false, then stop processing it.
Expand Down
33 changes: 30 additions & 3 deletions src/DynamoCoreWpf/Properties/Resources.Designer.cs

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

12 changes: 12 additions & 0 deletions src/DynamoCoreWpf/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -2318,6 +2318,18 @@ Uninstall the following packages: {0}?</value>
<value>Default Ranking Method</value>
<comment>Label used in the features tab</comment>
</data>
<data name="ConfidenceToolTipTitle" xml:space="preserve">
<value>Confidence rating</value>
<comment>Confidence tooltip title</comment>
</data>
<data name="ConfidenceToolTipDescription" xml:space="preserve">
<value>Represents estimated probability that the given node is the right choice. Recommended nodes are listed in order from highest to lowest confidence level. Confidence level percentages for all recommended nodes add up to about 100%.</value>
<comment>Confidence tooltip description</comment>
</data>
<data name="ConfidenceToolTipoLearnMore" xml:space="preserve">
<value>Learn more</value>
<comment>Confidence tooltip Learn more</comment>
</data>
<data name="ObjectType" xml:space="preserve">
<value>Node Type Match</value>
<comment>Label used in the features tab</comment>
Expand Down
12 changes: 12 additions & 0 deletions src/DynamoCoreWpf/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -2537,6 +2537,18 @@ Uninstall the following packages: {0}?</value>
<value>Default Ranking Method</value>
<comment>Label used in the features tab</comment>
</data>
<data name="ConfidenceToolTipTitle" xml:space="preserve">
<value>Confidence rating</value>
<comment>Confidence tooltip title</comment>
</data>
<data name="ConfidenceToolTipDescription" xml:space="preserve">
<value>Represents estimated probability that the given node is the right choice. Recommended nodes are listed in order from highest to lowest confidence level. Confidence level percentages for all recommended nodes add up to about 100%.</value>
<comment>Confidence tooltip description</comment>
</data>
<data name="ConfidenceToolTipoLearnMore" xml:space="preserve">
<value>Learn more</value>
<comment>Confidence tooltip Learn more</comment>
</data>
<data name="ObjectType" xml:space="preserve">
<value>Node Type Match</value>
<comment>Label used in the features tab</comment>
Expand Down
12 changes: 11 additions & 1 deletion src/DynamoCoreWpf/UI/Themes/Modern/DynamoColorsAndBrushes.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<Color x:Key="Blue300">#6AC0E7</Color>
<Color x:Key="Blue350">#6DD2FF</Color>
<Color x:Key="Blue400">#38ABDF</Color>
<Color x:Key="Blue450">#006EAF</Color>
<Color x:Key="DarkBlue200">#BCD3EE</Color>
<Color x:Key="DefaultFontColor">#DCDCDC</Color>
<Color x:Key="HoverFontColor">#1AFFFFFF</Color>
Expand Down Expand Up @@ -54,6 +55,7 @@
<SolidColorBrush x:Key="Blue200Brush" Color="{StaticResource Blue200}" />
<SolidColorBrush x:Key="Blue300Brush" Color="{StaticResource Blue300}" />
<SolidColorBrush x:Key="Blue400Brush" Color="{StaticResource Blue400}" />
<SolidColorBrush x:Key="Blue450Brush" Color="{StaticResource Blue450}" />
<SolidColorBrush x:Key="DarkBlue200Brush" Color="{StaticResource DarkBlue200}" />
<SolidColorBrush x:Key="DefaultFontColorBrush" Color="{StaticResource DefaultFontColor}" />
<SolidColorBrush x:Key="HoverFontColorBrush" Color="{StaticResource HoverFontColor}" />
Expand Down Expand Up @@ -189,5 +191,13 @@

<!-- TextBlock Link -->
<SolidColorBrush x:Key="TextBlockLinkForegroundColor" Color="{StaticResource Blue350}" />


<!-- TextBlock Link Dark -->
<SolidColorBrush x:Key="TextBlockLinkForegroundColorDark" Color="{StaticResource Blue450}" />

<!-- TextBlock ToolTip color -->
<SolidColorBrush x:Key="TextBlockToolTipDescriptionColor" Color="{StaticResource DarkerGrey}" />

<!-- Custom ToolTip border color -->
<SolidColorBrush x:Key="CustomToolTipBorderColor" Color="#808080" />
</ResourceDictionary>
20 changes: 20 additions & 0 deletions src/DynamoCoreWpf/UI/Themes/Modern/DynamoModern.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5561,6 +5561,26 @@
<Setter Property="Cursor" Value="Hand" />
</Style>

<!-- TextBlock Dark as a Link -->
<Style x:Key="TextBlockLinkDark" TargetType="TextBlock">
<Setter Property="Foreground" Value="{StaticResource TextBlockLinkForegroundColorDark}" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="FontSize" Value="11" />
</Style>

<!-- TextBlock ToolTip Title -->
<Style x:Key="TextBlockToolTipTitle" TargetType="TextBlock">
<Setter Property="FontFamily" Value="{StaticResource ArtifaktElementBold}" />
<Setter Property="FontSize" Value="12" />
</Style>


<!-- TextBlock ToolTip Description -->
<Style x:Key="TextBlockToolTipDescription" TargetType="Run">
<Setter Property="Foreground" Value="{StaticResource TextBlockToolTipDescriptionColor}" />
<Setter Property="FontSize" Value="11" />
</Style>

<!-- Common Information Icon -->
<Style x:Key="InformationIcon" TargetType="{x:Type Image}">
<Style.Triggers>
Expand Down