Skip to content

DYN-3606-Preferences Panel Expanders Functionality#11689

Merged
QilongTang merged 13 commits intoDynamoDS:masterfrom
RobertGlobant20:DYN-3606-Preferences-Expanders
May 24, 2021
Merged

DYN-3606-Preferences Panel Expanders Functionality#11689
QilongTang merged 13 commits intoDynamoDS:masterfrom
RobertGlobant20:DYN-3606-Preferences-Expanders

Conversation

@RobertGlobant20
Copy link
Contributor

Purpose

I added the functionality in the Features tab of having just one Expander expander at one time (this functionality already exits in the Visual Settings expander).

Also I added the functionality of recording the current state of the Expander in a way that every time that the Preference window is closed and re-opened then the Expanders will remember the previous state. Due that this functionality was implemented by session then when the Dynamo app is closed the previous Expander settings will be lost.

Declarations

Check these if you believe they are true

  • The codebase is in a better state after this PR
  • Is documented according to the standards
  • The level of testing this PR includes is appropriate
  • User facing strings, if any, are extracted into *.resx files
  • All tests pass using the self-service CI.
  • Snapshot of UI changes, if any.
  • Changes to the API follow Semantic Versioning and are documented in the API Changes document.
  • This PR modifies some build requirements and the readme is updated

Reviewers

@QilongTang

FYIs

@Astul-Betizagasti

I added the functionality in the Features tab of having just one Expander expander at one time (this functionality already exits in the Visual Settings expander).

Also I added the functionality of recording the current state of the Expander in a way that every time that the Preference window is closed and re-opened then the Expanders will remember the previous state. Due that this functionality was implemented by session then when the Dynamo app is closed  the previous Expander settings will be lost.
Based in the comments done in the code review I removed the json entry created in the resources for loading the initial ExpanderSettings and now the list was initialized in the constructor.
Based in the code review comments instead of creating the PreferencesViewModel in PreferencesView.xaml.cs now will be created in DynamoViewModel.cs so the settings for expanders can be loaded/stored by session.
Also the Expanders List was moved inside the PreferencesViewModel.
new ExpanderSettings{ Name = "Styles", IsExpanded = false, Tab = "Visual Settings" },
new ExpanderSettings{ Name = "Scale", IsExpanded = false, Tab = "Visual Settings" },
new ExpanderSettings{ Name = "Precision", IsExpanded = false, Tab = "Visual Settings" },
new ExpanderSettings{ Name = "Display", IsExpanded = false, Tab = "Visual Settings" },
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think we can auto populate this list somehow?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@QilongTang I cannot think of any way of auto populate this list but in order to avoid doing this I re-implemented the functionality of recording/loading the current expansion state of each expander in a List, now instead of recording each one only records the one expanded (only one Expander can be expanded per each tab), so the info for just one is loaded when the Preferences window is opened and just one info is saved when the Expander expansion state is updated (this approach was suggested by @Astul-Betizagasti ).
For implementing this functionality I added a Converter that will be binded in each Expander.IsExpanded as @mjkkirschner suggested.
This re-implementation allows to do the same functionality for Expanders with less code. Thanks

See commit:
RobertGlobant20@3924722

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you @RobertGlobant20 @Astul-Betizagasti I am fine with the new approach as it reduces some complexity

RobertGlobant20 and others added 5 commits May 21, 2021 12:58
Based on the code review comments:
I changed the PreferencesViewModel property from public to Internal.
I reorganized usings in the PreferencesViewModel.cs file.
In the PreferencesView.xaml.cs due that I found a way to find all the Expanders in the PreferencesView, I refactored some code in a way and now there is no need to describe each expander name for binding the IsExpanded property.
I re-implemented the functionality of recording/loading the current expansion state of each expander in a List<ExpanderSettings>, now instead of recording each one only records the one expanded (only one Expander can be expanded per each tab), so the info for one is loaded when the Preferences window is opened and just one info is saved when the Expander expansion state is updated (thiis approach was suggested by Astul).
For implementing this functionality I added a Converter that will be binded in each Expander as Michael suggested.
After fetching the latest changes in the master branch and merging the changes in my feature branch I got several conflicts, this fixes several errors.
<Expander x:Name="PythonExpander"
Grid.Row="0"
Style="{StaticResource MenuExpanderStyle}"
IsExpanded="{Binding PreferencesTabs[0].ExpanderActive, Converter={StaticResource ExpandersBindingConverter}, ConverterParameter=PythonExpander}"
Copy link
Contributor

@QilongTang QilongTang May 23, 2021

Choose a reason for hiding this comment

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

This design is a bit strange that if we will need to cover expander state for General tab in the future (which we know we will do soon :), we will need to shift the index here..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@QilongTang I changed the data structure to use a Dictionary, so in the XAML we can use something more describing like "PreferencesTabs[Features]" also I added the General tab entry as an item in the Dictionary. Thanks
see commit: 4540d66

Copy link
Contributor

Choose a reason for hiding this comment

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

@RobertGlobant20 Thanks, this looks way cleaner

Copy link
Contributor

@QilongTang QilongTang left a comment

Choose a reason for hiding this comment

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

LGTM with comments

Instead of using a list for binding the TabSettings Items in the PreferencesView.xaml , used a Dictionary so in the xaml file I can use something like PreferencesTabs[Features] for the bindings, also added the General tab as an item of the new dictionary.
@QilongTang QilongTang merged commit 38b0b33 into DynamoDS:master May 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants