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

TuneUp menu item should be under Extensions menu. #39

Merged
merged 3 commits into from
Aug 3, 2021
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
10 changes: 5 additions & 5 deletions TuneUp/TuneUp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TuneUp</RootNamespace>
<AssemblyName>TuneUp</AssemblyName>
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<StartAction>Program</StartAction>
<StartProgram>C:\Program Files\Dynamo\Dynamo Core\2\DynamoSandbox.exe</StartProgram>
<FileAlignment>512</FileAlignment>
Expand Down Expand Up @@ -65,17 +65,17 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="DynamoVisualProgramming.Core">
<Version>2.5.0.7432</Version>
<Version>2.12.0.5650</Version>
<ExcludeAssets>runtime</ExcludeAssets>
<IncludeAssets>compile; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="DynamoVisualProgramming.DynamoServices">
<Version>2.5.0.7432</Version>
<Version>2.12.0.5650</Version>
<ExcludeAssets>runtime</ExcludeAssets>
<IncludeAssets>compile; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="DynamoVisualProgramming.WpfUILibrary">
<Version>2.5.0.7432</Version>
<Version>2.12.0.5650</Version>
<ExcludeAssets>runtime</ExcludeAssets>
<IncludeAssets>compile; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand All @@ -93,7 +93,7 @@
</Target>
-->
<PropertyGroup>
<DynamoVersion>2.5</DynamoVersion>
<DynamoVersion>2.12</DynamoVersion>
<PackageName>TuneUp</PackageName>
<PackageFolder>$(ProjectDir)dist\$(PackageName)\</PackageFolder>
<BinFolder>$(PackageFolder)bin\</BinFolder>
Expand Down
40 changes: 31 additions & 9 deletions TuneUp/TuneUpViewExtension.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System.Linq;
using System.Windows.Controls;
using Dynamo.Wpf.Extensions;

Expand All @@ -9,24 +9,27 @@ namespace TuneUp
/// which allows Dynamo users to analyze the performance of graphs
/// and diagnose bottlenecks and problem areas.
/// </summary>
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)
{
// Use dynamic object type of ViewLoadedParams to dynamically call its methods.
dynamic dp = (dynamic) p;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add comments to this?

ViewModel = new TuneUpWindowViewModel(p);

TuneUpView = new TuneUpWindow(p, UniqueId)
{
// Set the data context for the main grid in the window.
Expand All @@ -47,9 +50,20 @@ public void Loaded(ViewLoadedParams p)
{
p.CloseExtensioninInSideBar(this);
}

};
p.AddMenuItem(MenuBarType.View, TuneUpMenuItem);

// Add this view extension's menu item to the Extensions tab or View tab accordingly.
var dynamoMenuItems = p.dynamoMenu.Items.OfType<MenuItem>();
var extensionsMenuItem = dynamoMenuItems.Where(item => item.Header.ToString() == "_Extensions");

if (extensionsMenuItem.Count() > 0)
{
dp.AddExtensionMenuItem(TuneUpMenuItem);
}
else
{
dp.AddMenuItem(MenuBarType.View, TuneUpMenuItem);
}
}

/// <summary>
Expand All @@ -63,7 +77,7 @@ public void Shutdown()
/// <summary>
/// ID for the TuneUp extension
/// </summary>
public string UniqueId
public override string UniqueId
{
get
{
Expand All @@ -74,12 +88,20 @@ public string UniqueId
/// <summary>
/// Name of this extension
/// </summary>
public string Name
public override string Name
{
get
{
return "TuneUp";
}
}

public override void Closed()
{
if (this.TuneUpMenuItem != null)
{
this.TuneUpMenuItem.IsChecked = false;
}
}
}
}
10 changes: 5 additions & 5 deletions TuneUpTests/TuneUpTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TuneUpTests</RootNamespace>
<AssemblyName>TuneUpTests</AssemblyName>
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>
Expand Down Expand Up @@ -65,16 +65,16 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="DynamoVisualProgramming.Core">
<Version>2.5.0.7432</Version>
<Version>2.12.0.5650</Version>
</PackageReference>
<PackageReference Include="DynamoVisualProgramming.DynamoServices">
<Version>2.5.0.7432</Version>
<Version>2.12.0.5650</Version>
</PackageReference>
<PackageReference Include="DynamoVisualProgramming.Tests">
<Version>2.5.0.7432</Version>
<Version>2.12.0.5650</Version>
</PackageReference>
<PackageReference Include="DynamoVisualProgramming.ZeroTouchLibrary">
<Version>2.5.0.7432</Version>
<Version>2.12.0.5650</Version>
</PackageReference>
<PackageReference Include="MSTest.TestAdapter">
<Version>1.3.2</Version>
Expand Down