Skip to content

Commit 1a241cf

Browse files
committed
Show rating prompt
1 parent c2ee215 commit 1a241cf

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

src/EFCore.Visualizer/EFCore.Visualizer.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net472</TargetFramework>
3+
<TargetFramework>net48</TargetFramework>
44
<ImplicitUsings>enable</ImplicitUsings>
55
<Nullable>enable</Nullable>
66
<LangVersion>latest</LangVersion>
@@ -21,6 +21,7 @@
2121
</ItemGroup>
2222

2323
<ItemGroup>
24+
<PackageReference Include="Community.VisualStudio.Toolkit.17" Version="17.0.533" />
2425
<PackageReference Include="Microsoft.VisualStudio.DebuggerVisualizers" Version="17.6.1032901" />
2526
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="17.9.2092" />
2627
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Build" Version="17.9.2092" />

src/EFCore.Visualizer/General.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using Community.VisualStudio.Toolkit;
2+
3+
namespace EFCore.Visualizer;
4+
5+
class General : BaseOptionModel<General>, IRatingConfig
6+
{
7+
public int RatingRequests { get; set; }
8+
}

src/EFCore.Visualizer/QueryPlanUserControl.xaml.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using IQueryableObjectSource;
1+
using Community.VisualStudio.Toolkit;
2+
using IQueryableObjectSource;
23
using Microsoft.VisualStudio.Extensibility.DebuggerVisualizers;
34
using Microsoft.VisualStudio.PlatformUI;
45
using Microsoft.Web.WebView2.Core;
@@ -9,16 +10,18 @@
910
using System.Text;
1011
using System.Windows;
1112
using System.Windows.Controls;
13+
using MessageBox = System.Windows.MessageBox;
1214

1315
namespace EFCore.Visualizer;
1416

1517
public partial class QueryPlanUserControl : UserControl
1618
{
19+
private string? filePath;
1720
private readonly VisualizerTarget visualizerTarget;
1821
private static readonly string AssemblyLocation = Path.GetDirectoryName(typeof(QueryPlanUserControl).Assembly.Location);
19-
private string? filePath;
2022

2123
private Color backgroundColor = VSColorTheme.GetThemedColor(ThemedDialogColors.WindowPanelBrushKey);
24+
private readonly RatingPrompt ratingPrompt = new RatingPrompt("GiorgiDalakishvili.EFCoreVisualizer", "EFCore Visualizer", General.Instance, requestsBeforePrompt: 3);
2225

2326
public QueryPlanUserControl(VisualizerTarget visualizerTarget)
2427
{
@@ -33,6 +36,7 @@ private void QueryPlanUserControlUnloaded(object sender, RoutedEventArgs e)
3336
SafeDeleteFile(filePath);
3437

3538
Unloaded -= QueryPlanUserControlUnloaded;
39+
_ = ratingPrompt.PromptAsync();
3640
}
3741

3842
#pragma warning disable VSTHRD100 // Avoid async void methods
@@ -74,6 +78,8 @@ protected override async void OnInitialized(EventArgs e)
7478
if (!string.IsNullOrEmpty(filePath))
7579
{
7680
webView.CoreWebView2.Navigate(filePath);
81+
82+
ratingPrompt.RegisterSuccessfulUsage();
7783
}
7884
}
7985
}

0 commit comments

Comments
 (0)