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

Save/Load view extension size and location #11278

Merged
merged 8 commits into from
Nov 30, 2020
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
6 changes: 6 additions & 0 deletions src/DynamoCore/Configuration/PreferenceSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,11 @@ public string DefaultPythonEngine
[XmlIgnore]
public bool NamespacesToExcludeFromLibrarySpecified { get; set; }

/// <summary>
/// Settings that apply to view extensions.
/// </summary>
public List<ViewExtensionSettings> ViewExtensionSettings { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

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

The setting here is good design. I also wonder when we about do make internal window like Python editor dockable, do we apply same setting for them or use a list of different but similar setting? Or we make this setting more generic? Let me know what you think. I think it might be something we want to consider

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think this can be reused just like that. ViewExtensionSettings by itself contains view extension specific properties like UniqueId and Name that don't apply to script editors. Still, a lot of things in this contribution can be reused.

Copy link
Contributor

Choose a reason for hiding this comment

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

@mmisol Yes, and thinking more on this. We may not need to support remembering the positions of python editor at all. Will take a look at the rest of code


#endregion

/// <summary>
Expand Down Expand Up @@ -415,6 +420,7 @@ public PreferenceSettings()
ShowTabsAndSpacesInScriptEditor = false;
EnableNodeAutoComplete = false;
DefaultPythonEngine = string.Empty;
ViewExtensionSettings = new List<ViewExtensionSettings>();
}

/// <summary>
Expand Down
86 changes: 86 additions & 0 deletions src/DynamoCore/Configuration/ViewExtensionSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
namespace Dynamo.Configuration
{
/// <summary>
/// Settings that apply to a view extension specifically.
/// </summary>
public class ViewExtensionSettings
{
/// <summary>
/// Name of the view extension.
/// </summary>
public string Name { get; set; }
/// <summary>
/// UniqueId of the view extension.
/// </summary>
public string UniqueId { get; set; }
/// <summary>
/// Specifies how an extension UI control should be displayed.
/// </summary>
public ViewExtensionDisplayMode DisplayMode { get; set; }
/// <summary>
/// Window settings for the extension control when displayed in FloatingWindow mode.
/// </summary>
public WindowSettings WindowSettings { get; set; }
}

/// <summary>
/// Possible display modes for an extension UI control.
/// </summary>
public enum ViewExtensionDisplayMode
{
/// <summary>
/// Not really a display mode but rather the absence of one.
/// </summary>
Unspecified,
/// <summary>
/// Extension control should be displayed docked to the right side.
/// </summary>
DockRight,
/// <summary>
/// Extension control should be displayed in a floating window.
/// </summary>
FloatingWindow
}

/// <summary>
/// Settings that define how to display an extension control in floating window mode.
/// </summary>
public class WindowSettings
{
/// <summary>
/// Status of the window, i.e. whether it is maximized.
/// </summary>
public WindowStatus Status { get; set; }
/// <summary>
/// Coordinates of the leftmost side of the window.
/// </summary>
public int Left { get; set; }
/// <summary>
/// Coordinates of the topmost side of the window.
/// </summary>
public int Top { get; set; }
/// <summary>
/// Width of the window.
/// </summary>
public int Width { get; set; }
/// <summary>
/// Height of the window.
/// </summary>
public int Height { get; set; }
}

/// <summary>
/// Possible status of a floating window.
/// </summary>
public enum WindowStatus
{
/// <summary>
/// The window can be moved and resized.
/// </summary>
Normal,
/// <summary>
/// The window is maximized.
/// </summary>
Maximized
}
}
1 change: 1 addition & 0 deletions src/DynamoCore/DynamoCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ limitations under the License.
<Link>Properties\AssemblySharedInfo.cs</Link>
</Compile>
<Compile Include="Configuration\ExecutionSession.cs" />
<Compile Include="Configuration\ViewExtensionSettings.cs" />
<Compile Include="Core\CrashPromptArgs.cs" />
<Compile Include="Configuration\DebugSettings.cs" />
<Compile Include="Configuration\Context.cs" />
Expand Down
4 changes: 2 additions & 2 deletions src/DynamoCoreWpf/Extensions/ViewLoadedParams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ public void AddMenuItem(MenuBarType type, MenuItem menuItem, int index = -1)
/// <returns></returns>
public void AddToExtensionsSideBar(IViewExtension viewExtension, ContentControl contentControl)
{
TabItem tabItem = dynamoView.AddExtensionTabItem(viewExtension, contentControl);
bool added = dynamoView.AddOrFocusExtensionControl(viewExtension, contentControl);

if (tabItem != null)
if (added)
{
dynamoViewModel.Model.Logger.Log(Wpf.Properties.Resources.ExtensionAdded);
}
Expand Down
Loading