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

Fix guided tour crash #13097

Merged
merged 6 commits into from
Jul 11, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2362,7 +2362,7 @@ private void CloseHomeWorkspace(object parameter)

private bool CanCloseHomeWorkspace(object parameter)
{
return HomeSpace.RunSettings.RunEnabled;
return HomeSpace.RunSettings.RunEnabled || parameter is true;
reddyashish marked this conversation as resolved.
Show resolved Hide resolved
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/DynamoCoreWpf/ViewModels/Core/WorkspaceViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1283,7 +1283,7 @@ private void Hide(object parameters)

if (this.IsHomeSpace)
{
if (DynamoViewModel.CloseHomeWorkspaceCommand.CanExecute(null))
if (DynamoViewModel.CloseHomeWorkspaceCommand.CanExecute(true))
reddyashish marked this conversation as resolved.
Show resolved Hide resolved
DynamoViewModel.CloseHomeWorkspaceCommand.Execute(null);
reddyashish marked this conversation as resolved.
Show resolved Hide resolved
}
else
Expand Down
27 changes: 20 additions & 7 deletions src/DynamoCoreWpf/Views/FileTrust/FileTrustWarning.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Windows.Controls.Primitives;
using System.Windows.Threading;
using Dynamo.Controls;
using Dynamo.Graph.Workspaces;
using Dynamo.Models;
using Dynamo.ViewModels;
using Dynamo.Wpf.Utilities;
Expand Down Expand Up @@ -40,16 +41,18 @@ public FileTrustWarning(DynamoView dynamoViewWindow)
DataContext = fileTrustWarningViewModel;

if (dynamoViewWindow == null) return;

//Creating the background of the Popup
BackgroundRectangle.Rect = new Rect(fileTrustWarningViewModel.PopupBordersOffSet, fileTrustWarningViewModel.PopupBordersOffSet, fileTrustWarningViewModel.PopupRectangleWidth, fileTrustWarningViewModel.PopupRectangleHeight);
SetUpPopup();

HomeWorkspaceModel.WorkspaceClosed += CloseWarningPopup;
}

private void ViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
//When the ShowWarningPopup property is changed we need to enable or disable the Dynamo Run section
if (e.PropertyName == nameof(FileTrustWarningViewModel.ShowWarningPopup) )
if (e.PropertyName == nameof(FileTrustWarningViewModel.ShowWarningPopup))
{
var fileTrustWarningViewModel = sender as FileTrustWarningViewModel;
if (fileTrustWarningViewModel == null) return;
Expand All @@ -59,12 +62,11 @@ private void ViewModel_PropertyChanged(object sender, System.ComponentModel.Prop
//Force to run all the drawing events in the Dispatcher so later we can disable the button/combobox in the Run section
mainWindow.Dispatcher.Invoke(DispatcherPriority.Background, new Action(delegate { }));
DisableRunInteractivity();
}
}
else
{
EnableRunInteractivity();
}

}
}

Expand Down Expand Up @@ -126,11 +128,11 @@ private void YesButton_Click(object sender, RoutedEventArgs e)
{
fileTrustWarningViewModel.AllowOneTimeTrust = true;
fileTrustWarningViewModel.ShowWarningPopup = false;

RunSettings.ForceBlockRun = false;
if (FileTrustWarningCheckBox.IsChecked.Value == true)
{
if(dynViewModel.PreferenceSettings.AddTrustedLocation(fileTrustWarningViewModel.DynFileDirectoryName))
if (dynViewModel.PreferenceSettings.AddTrustedLocation(fileTrustWarningViewModel.DynFileDirectoryName))
dynViewModel.MainGuideManager.CreateRealTimeInfoWindow(string.Format(Properties.Resources.TrustLocationAddedNotification, fileTrustWarningViewModel.DynFileDirectoryName));
}
if (dynViewModel.CurrentSpaceViewModel.RunSettingsViewModel.Model.RunType != RunType.Manual)
Expand Down Expand Up @@ -162,10 +164,12 @@ internal void UpdatePopupLocation()
internal void CleanPopup()
{
if (fileTrustWarningViewModel != null)
{
{
fileTrustWarningViewModel.PropertyChanged -= ViewModel_PropertyChanged;
fileTrustWarningViewModel.DynFileDirectoryName = string.Empty;
}

HomeWorkspaceModel.WorkspaceClosed -= CloseWarningPopup;
reddyashish marked this conversation as resolved.
Show resolved Hide resolved
}

/// <summary>
Expand All @@ -186,5 +190,14 @@ private void SetUpPopup()
fileTrustWarningViewModel.PropertyChanged += ViewModel_PropertyChanged;
}
}

/// <summary>
/// Close the warning popup
/// </summary>
internal void CloseWarningPopup()
{
fileTrustWarningViewModel.ShowWarningPopup = false;
fileTrustWarningViewModel.DynFileDirectoryName = string.Empty;
}
}
}