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

homePage loading from code behind #14991

Merged
merged 4 commits into from
Mar 6, 2024
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
17 changes: 4 additions & 13 deletions src/DynamoCoreWpf/Views/Core/DynamoView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -1791,24 +1791,15 @@
</ItemsControl.Visibility>
</ItemsControl>
</Grid>
<!--Do not delete newHomePageContainer grid as it is hosting the HomePage-->
<Grid x:Name="newHomePageContainer"
Visibility="{Binding IsNewAppHomeEnabled,
Converter={StaticResource BooleanToVisibilityConverter},
RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"
Converter={StaticResource BooleanToVisibilityConverter},
RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"
Grid.Row="2"
Grid.RowSpan="4"
Grid.Column="0"
Grid.ColumnSpan="5">
<uiviews:HomePage x:Name="homePage">
<uiviews:HomePage.Visibility>
<Binding Path="DataContext.ShowStartPage"
Mode="OneWay"
RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type controls:DynamoView}}"
Converter="{StaticResource BooleanToVisibilityConverter}"
UpdateSourceTrigger="Explicit" />
</uiviews:HomePage.Visibility>
</uiviews:HomePage>
</Grid>
Grid.ColumnSpan="5"/>

<Grid Name="FocusableGrid" Width="0" Height="0" Focusable="True"/>
</Grid>
Expand Down
42 changes: 40 additions & 2 deletions src/DynamoCoreWpf/Views/Core/DynamoView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ internal PreferencesView PreferencesWindow {
get { return preferencesWindow; }
}

internal Dynamo.UI.Views.HomePage homePage;

/// <summary>
/// Keeps the default value of the Window's MinWidth to calculate it again later
/// </summary>
Expand Down Expand Up @@ -1208,7 +1210,6 @@ private void InitializeStartPage(bool isFirstRun)

startPage = new StartPageViewModel(dynamoViewModel, isFirstRun);
startPageItemsControl.Items.Add(startPage);
homePage.DataContext = startPage;
}
}

Expand Down Expand Up @@ -1383,9 +1384,36 @@ private void DynamoView_Loaded(object sender, EventArgs e)
{
this.Deactivated += (s, args) => { HidePopupWhenWindowDeactivated(null); };
}

// Load the new HomePage
if (IsNewAppHomeEnabled) LoadHomePage();

loaded = true;
}

// Add the HomePage to the DynamoView once its loaded
private void LoadHomePage()
{
if (homePage == null && startPage != null)
{
homePage = new UI.Views.HomePage();
homePage.DataContext = startPage;

var visibilityBinding = new System.Windows.Data.Binding
{
RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(DynamoView), 1),
Path = new PropertyPath("DataContext.ShowStartPage"),
Mode = BindingMode.OneWay,
Converter = new BooleanToVisibilityConverter(),
UpdateSourceTrigger = UpdateSourceTrigger.Explicit
};

BindingOperations.SetBinding(homePage, UIElement.VisibilityProperty, visibilityBinding);

this.newHomePageContainer.Children.Add(homePage);
}
}

/// <summary>
/// Assign the value to the toolBarRightMenuWidth when the ShortcutToolbar is loaded
/// </summary>
Expand Down Expand Up @@ -2021,14 +2049,24 @@ private void WindowClosed(object sender, EventArgs e)
this.dynamoViewModel.RequestExportWorkSpaceAsImage -= OnRequestExportWorkSpaceAsImage;
this.dynamoViewModel.RequestShorcutToolbarLoaded -= onRequestShorcutToolbarLoaded;

this.homePage.Dispose();
if (homePage != null)
{
RemoveHomePage();
}

this.Dispose();
sharedViewExtensionLoadedParams?.Dispose();
this._pkgSearchVM?.Dispose();
this._pkgVM?.Dispose();
}

// Remove the HomePage from the visual tree and dispose of its resources
private void RemoveHomePage()
{
this.newHomePageContainer.Children.Remove(homePage);
this.homePage.Dispose();
}

// the key press event is being intercepted before it can get to
// the active workspace. This code simply grabs the key presses and
// passes it to thecurrent workspace
Expand Down
14 changes: 14 additions & 0 deletions test/DynamoCoreWpfTests/HomePageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ internal static string CONTAINER_ITEM_CLICK_SCRIPT(string elementId)
}})();";
}


[Test]
[Ignore("IsNewAppHomeEnabled flag is set to false")]
public void CanClickRecentGraph()
{
// Arrange
Expand Down Expand Up @@ -155,6 +157,7 @@ public void CanClickRecentGraph()
}

[Test]
[Ignore("IsNewAppHomeEnabled flag is set to false")]
public void CanClickSampleGraph()
{
// Arrange
Expand Down Expand Up @@ -200,6 +203,7 @@ public void CanClickSampleGraph()
}

[Test]
[Ignore("IsNewAppHomeEnabled flag is set to false")]
public void CanClickTourGuide()
{
// Arrange
Expand Down Expand Up @@ -234,6 +238,7 @@ public void CanClickTourGuide()
}

[Test]
[Ignore("IsNewAppHomeEnabled flag is set to false")]
public void ReceiveCorrectNumberOfRecentGrphs()
{
// Arrange
Expand Down Expand Up @@ -263,6 +268,7 @@ public void ReceiveCorrectNumberOfRecentGrphs()
}

[Test]
[Ignore("IsNewAppHomeEnabled flag is set to false")]
public void ReceiveCorrectNumberOfSamples()
{
// Arrange
Expand Down Expand Up @@ -299,6 +305,7 @@ public void ReceiveCorrectNumberOfSamples()
}

[Test]
[Ignore("IsNewAppHomeEnabled flag is set to false")]
public void ReceiveCorrectNumberOfTourGuides()
{
// Arrange
Expand All @@ -319,6 +326,7 @@ public void ReceiveCorrectNumberOfTourGuides()
}

[Test]
[Ignore("IsNewAppHomeEnabled flag is set to false")]
public void ReceiveCorrectNumberOfCarouselVideos()
{
// Arrange
Expand All @@ -339,6 +347,7 @@ public void ReceiveCorrectNumberOfCarouselVideos()
}

[Test]
[Ignore("IsNewAppHomeEnabled flag is set to false")]
public void CanRunNewHomeWorkspaceCommandFromHomePage()
{
// Arrange
Expand Down Expand Up @@ -376,6 +385,7 @@ void Model_WorkspaceCleared(WorkspaceModel model)
}

[Test]
[Ignore("IsNewAppHomeEnabled flag is set to false")]
public void CanRunNewCustomNodeCommandFromHomePage()
{
// Arrange
Expand Down Expand Up @@ -408,6 +418,7 @@ public void CanRunNewCustomNodeCommandFromHomePage()
}

[Test]
[Ignore("IsNewAppHomeEnabled flag is set to false")]
public void CanOpenWorkspaceCommandFromHomePage()
{
// Arrange
Expand Down Expand Up @@ -440,6 +451,7 @@ public void CanOpenWorkspaceCommandFromHomePage()
}

[Test]
[Ignore("IsNewAppHomeEnabled flag is set to false")]
public void ShowTemplateCommandFromHomePage()
{
// Arrange
Expand Down Expand Up @@ -473,6 +485,7 @@ public void ShowTemplateCommandFromHomePage()
}

[Test]
[Ignore("IsNewAppHomeEnabled flag is set to false")]
public void ShowBackupFolderCommandFromHomePage()
{
// Arrange
Expand Down Expand Up @@ -505,6 +518,7 @@ public void ShowBackupFolderCommandFromHomePage()
}

[Test]
[Ignore("IsNewAppHomeEnabled flag is set to false")]
public void ShowSampleFilesFolderCommandFromHomePage()
{
// Arrange
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
using Dynamo.Utilities;
using Dynamo.Notifications.View;
using NUnit.Framework;
using System;
using System.IO;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using Dynamo.Notifications;
using Dynamo.DocumentationBrowser;
using Dynamo.Notifications.View;
using Dynamo.Utilities;
using DynamoCoreWpfTests.Utility;
using NUnit.Framework;

namespace DynamoCoreWpfTests.ViewExtensions
{
Expand All @@ -28,6 +27,7 @@ public void PressNotificationButtonAndShowPopup()
{
return notificationExtension.notificationCenterController.initState == DynamoUtilities.AsyncMethodState.Done;
});

Assert.AreEqual(DynamoUtilities.AsyncMethodState.Done, notificationExtension.notificationCenterController.initState);

NotificationUI notificationUI = PresentationSource.CurrentSources.OfType<System.Windows.Interop.HwndSource>()
Expand All @@ -37,9 +37,9 @@ public void PressNotificationButtonAndShowPopup()
.OfType<NotificationUI>()
.FirstOrDefault(p => p.IsOpen);

Assert.NotNull(notificationUI);
var webView = notificationUI.FindName("dynWebView");
Assert.NotNull(webView);
Assert.NotNull(notificationUI, "Notification popup not part of the dynamo visual tree");
var webView = notificationUI.FindName("webView");
Assert.NotNull(webView, "WebView framework element not found.");
}

[Test]
Expand Down
Loading