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-4973-Popups-NotAttached #13002

Merged
merged 8 commits into from
Jun 16, 2022
Merged
32 changes: 31 additions & 1 deletion src/DynamoCoreWpf/UI/GuidedTour/GuidesManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,19 @@ namespace Dynamo.Wpf.UI.GuidedTour
/// </summary>
public sealed class GuidesManager
{
/// <summary>
/// enum that represent the state of the current guide.
/// PLAYING - The Guide has started
/// EXIT_MODE - exitGuideWindow Popup is being shown
/// STOPPED - The user has exited completely the guide (so no Popup is being shown)
/// </summary>
internal enum GUIDE_STATE { PLAYING, EXIT_MODE, STOPPED }
#region private properties
/// <summary>
/// currentGuide will contain the Guide being played
/// </summary>
private Guide currentGuide;
internal Guide currentGuide;
internal GUIDE_STATE currentGuideState;

private GuideBackground guideBackgroundElement;
private readonly UIElement mainRootElement;
Expand Down Expand Up @@ -173,6 +181,7 @@ internal void LaunchTour(string tourName)
{
Initialize();
GuideFlowEvents.OnGuidedTourStart(tourName);
currentGuideState = GUIDE_STATE.PLAYING;
QilongTang marked this conversation as resolved.
Show resolved Hide resolved
Logging.Analytics.TrackScreenView("InteractiveGuidedTours");
Logging.Analytics.TrackEvent(Logging.Actions.Start, Logging.Categories.GuidedTourOperations, Resources.ResourceManager.GetString(currentGuide.GuideNameResource).Replace("_", ""), currentGuide.SequenceOrder);
}
Expand Down Expand Up @@ -214,10 +223,12 @@ private void TourFinished(GuidedTourStateEventArgs args)
guideBackgroundElement.ClearHighlightSection();
guideBackgroundElement.ClearCutOffSection();
CreateExitModal(currentGuide.CurrentStep.ExitGuide);
currentGuideState = GUIDE_STATE.EXIT_MODE;
}
else
{
ExitTour();
currentGuideState = GUIDE_STATE.STOPPED;
}
}

Expand Down Expand Up @@ -278,6 +289,23 @@ internal void CreateExitModal(ExitGuide exitGuide)
exitGuideWindow.IsOpen = true;
}

/// <summary>
/// Shows/Hides the Popup based in if the DynamoView is Active or not
/// </summary>
/// <param name="isActive"></param>
internal void ManagePopupActivation(bool isActive)
{
switch(currentGuideState)
QilongTang marked this conversation as resolved.
Show resolved Hide resolved
{
case GUIDE_STATE.PLAYING:
currentGuide.CurrentStep.stepUIPopup.IsOpen = isActive;
break;
case GUIDE_STATE.EXIT_MODE:
exitGuideWindow.IsOpen = isActive;
break;
}
}

private void ContinueTourButton_Click(object sender, RoutedEventArgs e)
{
exitGuideWindow.IsOpen = false;
Expand All @@ -286,12 +314,14 @@ private void ContinueTourButton_Click(object sender, RoutedEventArgs e)
GuideFlowEvents.IsAnyGuideActive = true;
currentGuide.ContinueStep(currentGuide.CurrentStep.Sequence);
}
currentGuideState = GUIDE_STATE.PLAYING;
}

private void ExitTourButton_Click(object sender, RoutedEventArgs e)
{
exitGuideWindow.IsOpen = false;
ExitTour();
currentGuideState = GUIDE_STATE.STOPPED;
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/DynamoCoreWpf/UI/GuidedTour/Step.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ internal Popup StepUIPopup
#endregion

#region Protected Properties
protected Popup stepUIPopup;
internal Popup stepUIPopup;
protected Func<bool, bool> validator;
/// <summary>
/// This property describe which will be the pointing direction of the tooltip (if is a Welcome or Survey popup then is not used)
Expand Down
2 changes: 2 additions & 0 deletions src/DynamoCoreWpf/Views/Core/DynamoView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
SnapsToDevicePixels="True"
ResizeMode="CanResizeWithGrip"
UseLayoutRounding="True"
Activated="DynamoView_Activated"
Deactivated="DynamoView_Deactivated"
reddyashish marked this conversation as resolved.
Show resolved Hide resolved
Style="{DynamicResource DynamoWindowStyle}">

<Window.Resources>
Expand Down
22 changes: 22 additions & 0 deletions src/DynamoCoreWpf/Views/Core/DynamoView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
using Dynamo.Wpf.UI.GuidedTour;
using Dynamo.Wpf.Utilities;
using Dynamo.Wpf.ViewModels.Core;
using Dynamo.Wpf.ViewModels.FileTrust;
using Dynamo.Wpf.Views;
using Dynamo.Wpf.Views.Debug;
using Dynamo.Wpf.Views.FileTrust;
Expand Down Expand Up @@ -2475,6 +2476,27 @@ private void FileTrustWarning_Click(object sender, RoutedEventArgs e)
dynViewModel.FileTrustViewModel.ShowWarningPopup = true;
}

private void DynamoView_Activated(object sender, EventArgs e)
{
if (dynamoViewModel.MainGuideManager != null && dynamoViewModel.MainGuideManager.currentGuide != null)
{
dynamoViewModel.MainGuideManager.ManagePopupActivation(true);
}


if (warningPopup != null)
QilongTang marked this conversation as resolved.
Show resolved Hide resolved
warningPopup.ManagePopupActivation(true);
}

private void DynamoView_Deactivated(object sender, EventArgs e)
{
if (dynamoViewModel.MainGuideManager != null && dynamoViewModel.MainGuideManager.currentGuide != null)
dynamoViewModel.MainGuideManager.ManagePopupActivation(false);

if(warningPopup != null)
warningPopup.ManagePopupActivation(false);
}

public void Dispose()
{
viewExtensionManager.Dispose();
Expand Down
2 changes: 1 addition & 1 deletion src/DynamoCoreWpf/Views/Core/WorkspaceView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@
AllowsTransparency="True"
Opened="OnContextMenuOpened"
Placement="MousePoint"
StaysOpen="True"
QilongTang marked this conversation as resolved.
Show resolved Hide resolved
StaysOpen="False"
Style="{StaticResource WorkspaceContextMenuStylePopup}">
<Popup.Resources>
<Style TargetType="{x:Type MenuItem}">
Expand Down
13 changes: 13 additions & 0 deletions src/DynamoCoreWpf/Views/FileTrust/FileTrustWarning.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ private void SettingsButton_Click(object sender, RoutedEventArgs e)
private void CloseFileButton_Click(object sender, RoutedEventArgs e)
{
fileTrustWarningViewModel.ShowWarningPopup = false;
fileTrustWarningViewModel.DynFileDirectoryName = string.Empty;
if (dynViewModel.CloseHomeWorkspaceCommand.CanExecute(null))
{
dynViewModel.CloseHomeWorkspaceCommand.Execute(null);
Expand All @@ -125,6 +126,7 @@ private void YesButton_Click(object sender, RoutedEventArgs e)
{
fileTrustWarningViewModel.AllowOneTimeTrust = true;
fileTrustWarningViewModel.ShowWarningPopup = false;
fileTrustWarningViewModel.DynFileDirectoryName = string.Empty;
RunSettings.ForceBlockRun = false;
if (FileTrustWarningCheckBox.IsChecked.Value == true)
{
Expand Down Expand Up @@ -164,6 +166,17 @@ internal void CleanPopup()
}
}

/// <summary>
/// This method will show/hide the Popup when the main window is Activated or Deactivated
/// </summary>
internal void ManagePopupActivation(bool activate)
{
if (dynViewModel.FileTrustViewModel.ShowWarningPopup == !activate &&
!string.IsNullOrEmpty(dynViewModel.FileTrustViewModel.DynFileDirectoryName) &&
RunSettings.ForceBlockRun == true)
IsOpen = activate;
}

private void SetUpPopup()
{
if (fileTrustWarningViewModel != null)
Expand Down