From 354a691421f7c19022a8292420ab6f857c6a3c1a Mon Sep 17 00:00:00 2001 From: reddyashish <43763136+reddyashish@users.noreply.github.com> Date: Fri, 23 Jul 2021 09:20:58 -0400 Subject: [PATCH 1/3] TuneUp menu item should be under Extensions menu. --- TuneUp/TuneUp.csproj | 10 +++++----- TuneUp/TuneUpViewExtension.cs | 22 +++++++++++++++------- TuneUpTests/TuneUpTests.csproj | 10 +++++----- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/TuneUp/TuneUp.csproj b/TuneUp/TuneUp.csproj index fcd97bc..13550b2 100644 --- a/TuneUp/TuneUp.csproj +++ b/TuneUp/TuneUp.csproj @@ -10,7 +10,7 @@ Properties TuneUp TuneUp - v4.7 + v4.8 Program C:\Program Files\Dynamo\Dynamo Core\2\DynamoSandbox.exe 512 @@ -65,17 +65,17 @@ - 2.5.0.7432 + 2.12.0.5650 runtime compile; build; native; contentfiles; analyzers - 2.5.0.7432 + 2.12.0.5650 runtime compile; build; native; contentfiles; analyzers - 2.5.0.7432 + 2.12.0.5650 runtime compile; build; native; contentfiles; analyzers @@ -93,7 +93,7 @@ --> - 2.5 + 2.12 TuneUp $(ProjectDir)dist\$(PackageName)\ $(PackageFolder)bin\ diff --git a/TuneUp/TuneUpViewExtension.cs b/TuneUp/TuneUpViewExtension.cs index a8b51c9..18a18c8 100644 --- a/TuneUp/TuneUpViewExtension.cs +++ b/TuneUp/TuneUpViewExtension.cs @@ -9,22 +9,22 @@ namespace TuneUp /// which allows Dynamo users to analyze the performance of graphs /// and diagnose bottlenecks and problem areas. /// - public class TuneUpViewExtension : IViewExtension + public class TuneUpViewExtension : ViewExtensionBase, IViewExtension { internal MenuItem TuneUpMenuItem; private TuneUpWindow TuneUpView; internal TuneUpWindowViewModel ViewModel; - public void Dispose() + public override void Dispose() { TuneUpView.Dispose(); } - public void Startup(ViewStartupParams p) + public override void Startup(ViewStartupParams p) { } - public void Loaded(ViewLoadedParams p) + public override void Loaded(ViewLoadedParams p) { ViewModel = new TuneUpWindowViewModel(p); TuneUpView = new TuneUpWindow(p, UniqueId) @@ -49,7 +49,7 @@ public void Loaded(ViewLoadedParams p) } }; - p.AddMenuItem(MenuBarType.View, TuneUpMenuItem); + p.AddExtensionMenuItem(TuneUpMenuItem); } /// @@ -63,7 +63,7 @@ public void Shutdown() /// /// ID for the TuneUp extension /// - public string UniqueId + public override string UniqueId { get { @@ -74,12 +74,20 @@ public string UniqueId /// /// Name of this extension /// - public string Name + public override string Name { get { return "TuneUp"; } } + + public override void Closed() + { + if (this.TuneUpMenuItem != null) + { + this.TuneUpMenuItem.IsChecked = false; + } + } } } \ No newline at end of file diff --git a/TuneUpTests/TuneUpTests.csproj b/TuneUpTests/TuneUpTests.csproj index 8357e1c..883c770 100644 --- a/TuneUpTests/TuneUpTests.csproj +++ b/TuneUpTests/TuneUpTests.csproj @@ -9,7 +9,7 @@ Properties TuneUpTests TuneUpTests - v4.7 + v4.8 512 {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 15.0 @@ -65,16 +65,16 @@ - 2.5.0.7432 + 2.12.0.5650 - 2.5.0.7432 + 2.12.0.5650 - 2.5.0.7432 + 2.12.0.5650 - 2.5.0.7432 + 2.12.0.5650 1.3.2 From 640c1230a4035adae074cc4f434ee8d1b3babf0b Mon Sep 17 00:00:00 2001 From: reddyashish <43763136+reddyashish@users.noreply.github.com> Date: Fri, 30 Jul 2021 13:49:46 -0400 Subject: [PATCH 2/3] Use Dynamic object to call the respective API's on ViewLoadedParams --- TuneUp/TuneUpViewExtension.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/TuneUp/TuneUpViewExtension.cs b/TuneUp/TuneUpViewExtension.cs index 18a18c8..3489c10 100644 --- a/TuneUp/TuneUpViewExtension.cs +++ b/TuneUp/TuneUpViewExtension.cs @@ -1,4 +1,4 @@ -using System; +using System.Linq; using System.Windows.Controls; using Dynamo.Wpf.Extensions; @@ -26,7 +26,9 @@ public override void Startup(ViewStartupParams p) public override void Loaded(ViewLoadedParams p) { + dynamic dp = (dynamic) p; ViewModel = new TuneUpWindowViewModel(p); + TuneUpView = new TuneUpWindow(p, UniqueId) { // Set the data context for the main grid in the window. @@ -47,9 +49,19 @@ public override void Loaded(ViewLoadedParams p) { p.CloseExtensioninInSideBar(this); } - }; - p.AddExtensionMenuItem(TuneUpMenuItem); + + var dynamoMenuItems = p.dynamoMenu.Items.OfType(); + var extensionsMenuItem = dynamoMenuItems.Where(item => item.Header.ToString() == "_Extensions"); + + if (extensionsMenuItem.Count() > 0) + { + dp.AddExtensionMenuItem(TuneUpMenuItem); + } + else + { + dp.AddMenuItem(MenuBarType.View, TuneUpMenuItem); + } } /// From 482674a449d9c91004153fc561a3791e46792544 Mon Sep 17 00:00:00 2001 From: reddyashish <43763136+reddyashish@users.noreply.github.com> Date: Tue, 3 Aug 2021 01:53:24 -0400 Subject: [PATCH 3/3] Add comments. --- TuneUp/TuneUpViewExtension.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/TuneUp/TuneUpViewExtension.cs b/TuneUp/TuneUpViewExtension.cs index 3489c10..d31875a 100644 --- a/TuneUp/TuneUpViewExtension.cs +++ b/TuneUp/TuneUpViewExtension.cs @@ -26,6 +26,7 @@ public override void Startup(ViewStartupParams p) public override void Loaded(ViewLoadedParams p) { + // Use dynamic object type of ViewLoadedParams to dynamically call its methods. dynamic dp = (dynamic) p; ViewModel = new TuneUpWindowViewModel(p); @@ -51,6 +52,7 @@ public override void Loaded(ViewLoadedParams p) } }; + // Add this view extension's menu item to the Extensions tab or View tab accordingly. var dynamoMenuItems = p.dynamoMenu.Items.OfType(); var extensionsMenuItem = dynamoMenuItems.Where(item => item.Header.ToString() == "_Extensions");