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

Enabling ShortcutBar items #13761

Merged
merged 5 commits into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 10 additions & 0 deletions src/DynamoCoreWpf/Controls/ShortcutToolbar.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public ShortcutToolbar(DynamoViewModel dynamoViewModel)
else {
logoutOption.Visibility = Visibility.Collapsed;
}
EnableItems = false;
}

private void SignOutHandler(LoginState status)
Expand Down Expand Up @@ -107,6 +108,15 @@ private void LoginButton_OnClick(object sender, RoutedEventArgs e)
}
}
}

public bool EnableItems
QilongTang marked this conversation as resolved.
Show resolved Hide resolved
{
set
{
this.exportMenu.IsEnabled = value;
this.NotificationCenter.IsEnabled = value;
}
}
}

/// <summary>
Expand Down
1 change: 1 addition & 0 deletions src/DynamoCoreWpf/UI/GuidedTour/GuidesManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,7 @@ internal Guide GetNextGuide()

private void Popup_StepClosed(string name, Step.StepTypes stepType)
{
dynamoViewModel.OnEnableShortcutBarItems(true);
GuideFlowEvents.OnGuidedTourFinish(currentGuide.Name);

//The exit tour popup will be shown only when a popup (doesn't apply for survey) is closed or when the tour is closed.
Expand Down
1 change: 1 addition & 0 deletions src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2540,6 +2540,7 @@ private void CloseHomeWorkspace(object parameter)
// workspaces opened at the time, then we should show the start page.
this.ShowStartPage = (Model.Workspaces.Count() <= 1);
RunSettings.ForceBlockRun = false;
OnEnableShortcutBarItems(false);
}
}

Expand Down
7 changes: 7 additions & 0 deletions src/DynamoCoreWpf/ViewModels/Core/DynamoViewModelEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,13 @@ internal void OnRequestReturnFocusToView()
RequestReturnFocusToView();
}

public event Action<bool> RequestEnableShortcutBarItems;
public virtual void OnEnableShortcutBarItems(bool enable)
{
if (RequestEnableShortcutBarItems != null)
RequestEnableShortcutBarItems(enable);
}

/// <summary>
/// Event used to verify that the correct dialog is being showed when saving a graph with unresolved linter issues.
/// This is only meant to be used for unit testing purposes.
Expand Down
10 changes: 10 additions & 0 deletions src/DynamoCoreWpf/Views/Core/DynamoView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ public DynamoView(DynamoViewModel dynamoViewModel)
this.dynamoViewModel.RequestReturnFocusToView += OnRequestReturnFocusToView;
this.dynamoViewModel.Model.WorkspaceSaving += OnWorkspaceSaving;
this.dynamoViewModel.Model.WorkspaceOpened += OnWorkspaceOpened;
this.dynamoViewModel.RequestEnableShortcutBarItems += DynamoViewModel_RequestEnableShortcutBarItems;
FocusableGrid.InputBindings.Clear();

if (fileTrustWarningPopup == null)
Expand All @@ -239,6 +240,11 @@ public DynamoView(DynamoViewModel dynamoViewModel)
}
}

private void DynamoViewModel_RequestEnableShortcutBarItems(bool enable)
{
shortcutBar.EnableItems = enable;
}

private void OnWorkspaceOpened(WorkspaceModel workspace)
{
if (!(workspace is HomeWorkspaceModel hws))
Expand All @@ -248,6 +254,7 @@ private void OnWorkspaceOpened(WorkspaceModel workspace)
{
DynamoModel.RaiseIExtensionStorageAccessWorkspaceOpened(hws, extension, dynamoViewModel.Model.Logger);
}
shortcutBar.EnableItems = true;
}

private void OnWorkspaceSaving(WorkspaceModel workspace, Graph.SaveContext saveContext)
Expand Down Expand Up @@ -1650,6 +1657,8 @@ private void WindowClosed(object sender, EventArgs e)
this.dynamoViewModel.Model.WorkspaceOpened -= OnWorkspaceOpened;
DynamoUtilities.DynamoFeatureFlagsManager.FlagsRetrieved -= CheckTestFlags;

this.dynamoViewModel.RequestEnableShortcutBarItems -= DynamoViewModel_RequestEnableShortcutBarItems;

this.Dispose();
sharedViewExtensionLoadedParams?.Dispose();
}
Expand Down Expand Up @@ -2464,6 +2473,7 @@ private void ShowGetStartedGuidedTour()
//We pass the root UIElement to the GuidesManager so we can found other child UIElements
try
{
shortcutBar.EnableItems = false;
dynamoViewModel.MainGuideManager.LaunchTour(GuidesManager.GetStartedGuideName);
}
catch (Exception)
Expand Down