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

Add an option to remember last opened Extensions in Dynamo #13812

Merged
merged 65 commits into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from 63 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
8f3236e
merge
zeusongit Nov 2, 2022
f93a50e
Merge branch 'master' of https://github.com/DynamoDS/Dynamo
zeusongit Nov 2, 2022
2272682
Merge branch 'master' of https://github.com/zeusongit/Dynamo
zeusongit Nov 3, 2022
a4e2896
Merge branch 'master' of https://github.com/DynamoDS/Dynamo
zeusongit Nov 8, 2022
75bf8ff
Integrate ML Node-Autocompletion,
reddyashish Nov 9, 2022
58cdba4
Update NodeModel.cs
reddyashish Nov 9, 2022
64db862
Update NodeModel.cs
reddyashish Nov 9, 2022
033df58
some changes
reddyashish Nov 10, 2022
c432616
Merge branch 'master' of https://github.com/DynamoDS/Dynamo
zeusongit Nov 10, 2022
27af5fc
Merge remote-tracking branch 'upstream'
reddyashish Nov 10, 2022
ed04d80
Merge branch 'master' of https://github.com/DynamoDS/Dynamo
zeusongit Nov 10, 2022
50534c4
more changes
reddyashish Nov 11, 2022
ae77dc0
Update NodeAutoCompleteSearchControl.xaml
reddyashish Nov 11, 2022
72d1800
Fix edge cases and UI improvements.
reddyashish Nov 13, 2022
1df7fbc
update
reddyashish Nov 13, 2022
0d5e27b
Update NodeAutoCompleteSearchControl.xaml
reddyashish Nov 13, 2022
fda9caa
fix highlighting items.
reddyashish Nov 13, 2022
8a844d7
fix
reddyashish Nov 13, 2022
bcdce10
Port name for variable input nodes.
reddyashish Nov 14, 2022
5aea09b
Add base test.
reddyashish Nov 14, 2022
b0ed19e
addressing comments.
reddyashish Nov 14, 2022
61af5fe
Fix the edge cases for search results.
reddyashish Nov 15, 2022
57cc70d
Clean up code
reddyashish Nov 15, 2022
384baaf
Update NodeAutoCompleteSearchViewModel.cs
reddyashish Nov 15, 2022
6eb31e8
refactoring.
reddyashish Nov 15, 2022
b9a6851
updates
reddyashish Nov 16, 2022
6bd4e80
Use IDSDK token for authentication
reddyashish Nov 16, 2022
665dba9
updates
reddyashish Nov 16, 2022
26cf8ff
Merge branch 'master' of https://github.com/reddyashish/Dynamo
zeusongit Nov 17, 2022
304f141
Merge branch 'master' of https://github.com/DynamoDS/Dynamo
zeusongit Nov 17, 2022
6e09556
Merge branch 'master' of https://github.com/DynamoDS/Dynamo
zeusongit Nov 22, 2022
2ce5094
Merge branch 'master' of https://github.com/DynamoDS/Dynamo
zeusongit Nov 23, 2022
dbc3f38
Merge branch 'master' of https://github.com/DynamoDS/Dynamo
zeusongit Nov 23, 2022
cd968ff
Merge branch 'master' of https://github.com/DynamoDS/Dynamo
zeusongit Nov 24, 2022
a026143
Merge branch 'master' of https://github.com/DynamoDS/Dynamo
zeusongit Jan 9, 2023
4037eaf
Merge branch 'master' of https://github.com/DynamoDS/Dynamo
zeusongit Jan 18, 2023
9a64536
remove
zeusongit Jan 19, 2023
494b4ea
Merge branch 'master' of https://github.com/DynamoDS/Dynamo
zeusongit Jan 26, 2023
c9272a8
Merge branch 'master' of https://github.com/DynamoDS/Dynamo
zeusongit Feb 3, 2023
47d52cd
Merge branch 'master' of https://github.com/DynamoDS/Dynamo
zeusongit Feb 6, 2023
32770c9
Merge branch 'master' of https://github.com/DynamoDS/Dynamo
zeusongit Feb 6, 2023
b13896c
Merge branch 'master' of https://github.com/DynamoDS/Dynamo
zeusongit Feb 6, 2023
b63e07a
Merge branch 'master' of https://github.com/DynamoDS/Dynamo
zeusongit Feb 6, 2023
06cd92a
Merge branch 'master' of https://github.com/DynamoDS/Dynamo
zeusongit Feb 10, 2023
757bcb5
Merge branch 'master' of https://github.com/zeusongit/Dynamo
zeusongit Feb 10, 2023
268d146
Merge branch 'master' of https://github.com/DynamoDS/Dynamo
zeusongit Feb 15, 2023
f74e319
Merge branch 'master' of https://github.com/DynamoDS/Dynamo
zeusongit Feb 23, 2023
d9a04e0
Merge branch 'master' of https://github.com/DynamoDS/Dynamo
zeusongit Feb 28, 2023
ac498f3
Merge branch 'master' of https://github.com/DynamoDS/Dynamo
zeusongit Feb 28, 2023
90a670a
Merge branch 'master' of https://github.com/zeusongit/Dynamo
zeusongit Feb 28, 2023
1407cde
Merge branch 'master' of https://github.com/zeusongit/Dynamo
zeusongit Mar 2, 2023
b22407b
Merge branch 'master' of https://github.com/DynamoDS/Dynamo
zeusongit Mar 2, 2023
9437da7
testing workflow
zeusongit Mar 8, 2023
5b2513b
Merge branch 'master' of https://github.com/DynamoDS/Dynamo into dyn-t
zeusongit Mar 8, 2023
645bc6b
Add reopen hook
zeusongit Mar 10, 2023
db232ba
Merge branch 'master' of https://github.com/DynamoDS/Dynamo into dyn-t
zeusongit Mar 10, 2023
007af9c
remove unused usings
zeusongit Mar 10, 2023
2aa6c0e
Update PackageDetailsViewExtension.cs
zeusongit Mar 10, 2023
d1b2f6b
Ensure correct state
zeusongit Mar 10, 2023
41ddffa
Update DynamoView.xaml.cs
zeusongit Mar 10, 2023
5099c9e
Add tests and review comments
zeusongit Mar 10, 2023
87b053c
comments
zeusongit Mar 10, 2023
4e1a480
test fix
zeusongit Mar 13, 2023
50fffb4
comment
zeusongit Mar 14, 2023
17dee62
Update PreferenceSettings.cs
zeusongit Mar 14, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,22 @@
using System.IO;
using System.Linq;
using System.Security.Permissions;
using System.Web.UI.WebControls;
using System.Threading;
using System.Windows;
using System.Windows.Threading;
using DesignScript.Builtin;
using Dynamo.Configuration;
using Dynamo.Core;
using Dynamo.DocumentationBrowser.Properties;
using Dynamo.Graph;
using Dynamo.Graph.Annotations;
using Dynamo.Graph.Workspaces;
using Dynamo.Logging;
using Dynamo.Selection;
using Dynamo.Models;
using DynamoProperties = Dynamo.Properties;
using Dynamo.PackageManager;
using Dynamo.Selection;
using Dynamo.ViewModels;
using Dynamo.Wpf.Extensions;
using Dynamo.Wpf.Interfaces;
using DynamoProperties = Dynamo.Properties;
zeusongit marked this conversation as resolved.
Show resolved Hide resolved
using MenuItem = System.Windows.Controls.MenuItem;

namespace Dynamo.DocumentationBrowser
Expand Down Expand Up @@ -179,8 +176,7 @@ public override void Loaded(ViewLoadedParams viewLoadedParams)
this.ViewModel.DynamoView = viewLoadedParams.DynamoWindow;
}


public void Shutdown()
public override void Shutdown()
zeusongit marked this conversation as resolved.
Show resolved Hide resolved
{
Dispose();
}
Expand Down
17 changes: 17 additions & 0 deletions src/DynamoCore/Configuration/PreferenceSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public class PreferenceSettings : NotificationObject, IPreferences, IRenderPreci
private double defaultScaleFactor;
private bool disableTrustWarnings = false;
private bool isNotificationCenterEnabled;
private bool isEnablePersistExtensionsEnabled;
private bool isStaticSplashScreenEnabled;
private bool isCreatedFromValidFile = true;
private bool isADPChecked = false;
Expand Down Expand Up @@ -575,6 +576,22 @@ public bool EnableNotificationCenter
}
}

/// <summary>
/// This defines if user wants to the Extensions settings to persist across sessions.
zeusongit marked this conversation as resolved.
Show resolved Hide resolved
/// </summary>
public bool EnablePersistExtensions
{
get
{
return isEnablePersistExtensionsEnabled;
}
set
{
isEnablePersistExtensionsEnabled = value;
RaisePropertyChanged(nameof(EnablePersistExtensions));
}
}


/// <summary>
/// This defines if the user wants to see the static splash screen again
Expand Down
8 changes: 6 additions & 2 deletions src/DynamoCore/Configuration/ViewExtensionSettings.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Dynamo.Configuration
namespace Dynamo.Configuration
{
/// <summary>
/// Settings that apply to a view extension specifically.
Expand All @@ -21,6 +21,10 @@ public class ViewExtensionSettings
/// Window settings for the extension control when displayed in FloatingWindow mode.
/// </summary>
public WindowSettings WindowSettings { get; set; }
/// <summary>
/// Specifies if the extension was Open in the last session before closing Dynamo, if the property to remember view extension status was enabled.<br/> <c>Default: False</c>
/// </summary>
public bool IsOpen { get; set; }
}

/// <summary>
Expand Down Expand Up @@ -83,4 +87,4 @@ public enum WindowStatus
/// </summary>
Maximized
}
}
}
17 changes: 10 additions & 7 deletions src/DynamoCoreWpf/Extensions/ViewExtensionBase.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Dynamo.Wpf.Extensions
{
/// <summary>
Expand Down Expand Up @@ -70,6 +64,15 @@ public virtual void Startup(ViewStartupParams viewStartupParams)

}

/// <summary>
/// Action to be invoked when Dynamo starts up, to re-open the view extension which was open in the last session, if the preference setting
/// to remember the last opened extensions was enabled.
/// </summary>
public virtual void ReOpen()
{

}

/// <summary>
/// Action to be invoked when the view extension is closed.
/// </summary>
Expand All @@ -78,4 +81,4 @@ public virtual void Closed()

}
}
}
}
18 changes: 18 additions & 0 deletions src/DynamoCoreWpf/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions src/DynamoCoreWpf/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -3494,6 +3494,13 @@ In certain complex graphs or host program scenarios, Automatic mode may cause in
<data name="DynamoViewSettingLibraryZoomScale" xml:space="preserve">
<value>Library</value>
</data>
<data name="PreferencesViewEnablePersistExtensions" xml:space="preserve">
<value>On launch, remember open extensions panels from last session</value>
</data>
<data name="PreferencesViewExtensions" xml:space="preserve">
<value>Extensions</value>
<comment>Preferences | Features | Extensions</comment>
</data>
<data name="PythonZoomScaleTooltipText" xml:space="preserve">
<value>Drag to adjust Python Editor zoom scale between 10% and 100%. You can also adjust this in Python Editor by pressing Shift and scrolling the mouse wheel.</value>
</data>
Expand Down
7 changes: 7 additions & 0 deletions src/DynamoCoreWpf/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -3481,6 +3481,13 @@ In certain complex graphs or host program scenarios, Automatic mode may cause in
<data name="DynamoViewSettingLibraryZoomScale" xml:space="preserve">
<value>Library</value>
</data>
<data name="PreferencesViewEnablePersistExtensions" xml:space="preserve">
<value>On launch, remember open extensions panels from last session</value>
</data>
<data name="PreferencesViewExtensions" xml:space="preserve">
<value>Extensions</value>
<comment>Preferences | Features | Extensions</comment>
</data>
<data name="PythonZoomScaleTooltipText" xml:space="preserve">
<value>Drag to adjust Python Editor zoom scale between 10% and 100%. You can also adjust this in Python Editor by pressing Shift and scrolling the mouse wheel.</value>
</data>
Expand Down
23 changes: 20 additions & 3 deletions src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ public string SelectedPythonEngine
}

/// <summary>
/// Controls the IsChecked property in the "Hide IronPython alerts" toogle button
/// Controls the IsChecked property in the "Hide IronPython alerts" toggle button
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice

/// </summary>
public bool HideIronPythonAlertsIsChecked
{
Expand All @@ -787,7 +787,7 @@ public bool HideIronPythonAlertsIsChecked
}

/// <summary>
/// Controls the IsChecked property in the "Show Whitespace in Python editor" toogle button
/// Controls the IsChecked property in the "Show Whitespace in Python editor" toggle button
/// </summary>
public bool ShowWhitespaceIsChecked
{
Expand All @@ -804,7 +804,7 @@ public bool ShowWhitespaceIsChecked
}

/// <summary>
/// Controls the IsChecked property in the "Notification Center" toogle button
/// Controls the IsChecked property in the "Notification Center" toggle button
/// </summary>
public bool NotificationCenterIsChecked
{
Expand All @@ -819,6 +819,23 @@ public bool NotificationCenterIsChecked
}
}

/// <summary>
/// Controls the IsChecked property in the "Extensions" toggle button, to enable persisted extensions, that will remember
/// extensions setting as per the last session.
/// </summary>
public bool PersistExtensionsIsChecked
{
get
{
return preferenceSettings.EnablePersistExtensions;
}
set
{
preferenceSettings.EnablePersistExtensions = value;
RaisePropertyChanged(nameof(PersistExtensionsIsChecked));
}
}

#region [ Node Autocomplete ]

/// <summary>
Expand Down
81 changes: 76 additions & 5 deletions src/DynamoCoreWpf/Views/Core/DynamoView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ namespace Dynamo.Controls
public partial class DynamoView : Window, IDisposable
{
public const string BackgroundPreviewName = "BackgroundPreview";
private const int SideBarCollapseThreshold = 20;
Copy link
Member

Choose a reason for hiding this comment

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

this is actually a nice thing to add to the preferences!

private const int navigationInterval = 100;
// This is used to determine whether ESC key is being held down
private bool IsEscKeyPressed = false;
Expand Down Expand Up @@ -324,6 +325,11 @@ internal bool AddOrFocusExtensionControl(IViewExtension viewExtension, UIElement
this.dynamoViewModel.PreferenceSettings.ViewExtensionSettings.Add(settings);
}

if (this.dynamoViewModel.PreferenceSettings.EnablePersistExtensions)
{
settings.IsOpen = true;
}

if (settings.DisplayMode == ViewExtensionDisplayMode.FloatingWindow)
{
window = AddExtensionWindow(viewExtension, content, settings.WindowSettings);
Expand Down Expand Up @@ -969,6 +975,7 @@ private void DynamoLoadedViewExtensionHandler(ViewLoadedParams loadedParams, IEn
try
{
ext.Loaded(loadedParams);
ReOpenSavedExtensionOnDynamoStartup(ext);
}
catch (Exception exc)
{
Expand All @@ -977,6 +984,27 @@ private void DynamoLoadedViewExtensionHandler(ViewLoadedParams loadedParams, IEn
}
}

/// <summary>
/// This method will re-open saved extension from last session,
/// if the setting to remember last opened extensions was enabled.
/// </summary>
/// <param name="ext">Extension to be re-opened, if saved from last session.</param>
private void ReOpenSavedExtensionOnDynamoStartup(IViewExtension ext)
{
var viewExtensionSettings = dynamoViewModel.PreferenceSettings.EnablePersistExtensions ? dynamoViewModel.PreferenceSettings.ViewExtensionSettings : null;
if (viewExtensionSettings != null && viewExtensionSettings.Count > 0)
{
var setting = viewExtensionSettings.Find(s => s.UniqueId == ext.UniqueId);
if (setting != null && setting.IsOpen)
{
if (ext is ViewExtensionBase viewExtensionBase)
{
viewExtensionBase.ReOpen();
}
}
}
}

private void DynamoView_Loaded(object sender, EventArgs e)
{
// Do an initial load of the cursor collection
Expand Down Expand Up @@ -1586,7 +1614,7 @@ private bool PerformShutdownSequenceOnViewModel()

private void WindowClosing(object sender, CancelEventArgs e)
{
SaveExtensionWindowsState();
SaveExtensionsState();

if (!PerformShutdownSequenceOnViewModel() && !DynamoModel.IsTestMode)
{
Expand All @@ -1599,14 +1627,57 @@ private void WindowClosing(object sender, CancelEventArgs e)
}

/// <summary>
/// Saves the state of currently displayed extension windows. This is needed because the closing event is
/// Saves the state of currently displayed extension windows and tabs. This is needed because the closing event is
/// not called on child windows: https://docs.microsoft.com/en-us/dotnet/api/system.windows.window.closing
/// </summary>
private void SaveExtensionWindowsState()
private void SaveExtensionsState()
{
//loop over all active extension windows and tabs.
foreach (var window in ExtensionWindows.Values)
{
SaveExtensionWindowSettings(window);
SaveExtensionOpenState(window);
}
//for any new extensions that are opened for the first time
foreach (var tab in ExtensionTabItems)
{
SaveExtensionOpenState(tab);
}
//update open state of all existing view extension in setting, if option to remember extensions is enabled in preferences
var settings = dynamoViewModel.PreferenceSettings.ViewExtensionSettings;
foreach (var setting in settings)
{
if (!ExtensionTabItems.Any(e => e.Uid == setting.UniqueId) && !ExtensionWindows.Values.Any(e => e.Uid == setting.UniqueId))
{
setting.IsOpen = false;
}
}
}
//This method is to ensure that the extensions states are correctly saved for newly added extensions.
private void SaveExtensionOpenState(object o)
{
if (!dynamoViewModel.PreferenceSettings.EnablePersistExtensions || o == null) return;

var extId = "";
switch (o)
{
case TabItem t:
extId = t.Uid;
break;
case ExtensionWindow w:
extId = w.Uid;
break;
default:
Log("Incorrect extension type, could not save extension state.");
break;
}

if (extId == "") return;
zeusongit marked this conversation as resolved.
Show resolved Hide resolved

var setting = dynamoViewModel.Model.PreferenceSettings.ViewExtensionSettings?.Find(ext => ext.UniqueId == extId);
if (setting != null)
{
setting.IsOpen = true;
}
}

Expand Down Expand Up @@ -2166,7 +2237,7 @@ public bool LibraryCollapsed
get
{
// Threshold that determines if button should be displayed
if (LeftExtensionsViewColumn.Width.Value < 20)
if (LeftExtensionsViewColumn.Width.Value < SideBarCollapseThreshold)
{ libraryCollapsed = true; }

else
Expand All @@ -2192,7 +2263,7 @@ public bool ExtensionsCollapsed
}
else
{
extensionsCollapsed = RightExtensionsViewColumn.Width.Value < 20;
extensionsCollapsed = RightExtensionsViewColumn.Width.Value < SideBarCollapseThreshold;
}

return extensionsCollapsed;
Expand Down
Loading