-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Addition of MaxOpenBlades property on BladeView control #1049
Conversation
Things I'd like to see in the PR:
|
Talked with @ScottIsAFool on possibility to add VisualStates in favour of the BladeItemMode, but due to the fact that we are working with a Templated control, I can't change a property of the Parent from within the Child. So we need to stick with the coded version. Property name is changed to AutoCollapseCountThreshold and default value is now Int.MaxValue. |
@Depechie Why are you saying it cannot be done? If the threshold is reached, call Collapse() on the items, in the Collapse method it fires an event that it has collapsed and sets a visual state. The BladeItem would also have an Expand method and an Expanded event. Or it could work like the Expander control and have an IsExpanded property. It could even inherit from Expander |
@skendrot I tried that... if I introduced a visual state in the style for the BladeItem, I was not able to adjust it's own width. If you look at the expander, it's changing a property of a child element. That is indeed possible... Could be I'm missing something, so be my guest and maybe you can retry it, just fork my repo? Do note looked at it with @ScottIsAFool so guessing we both miss something you are seeing :D |
ping, do you guys think we can have this for 1.5? |
@nmetulev for me there aren't any open issues with it anymore... not sure what the standpoint is from the core team? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor code style adjustments, as long as they get done, consider this approved.
|
||
_enlargeButton.Click -= EnlargeButton_Click; | ||
_enlargeButton.Click += EnlargeButton_Click; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove empty line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
private void OnSizeChanged(object sender, SizeChangedEventArgs sizeChangedEventArgs) | ||
{ | ||
if(BladeItemMode == BladeItemMode.Normal) | ||
_normalModeWidth = Width; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should have curly braces around if statement content.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
var openBlades = ActiveBlades.Where(item => item.TitleBarVisibility == Visibility.Visible).ToList(); | ||
if (openBlades?.Count > AutoCollapseCountThreshold) | ||
{ | ||
for (int i = 0; i < openBlades.Count - 1; i++) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should have curly braces around for statement content
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -116,6 +127,9 @@ private void CycleBlades() | |||
|
|||
if (visibility == Visibility.Visible) | |||
{ | |||
if (Items == null) | |||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curly braces please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
var lastBlade = ActiveBlades.LastOrDefault(); | ||
if (lastBlade != null && lastBlade.TitleBarVisibility == Visibility.Visible) | ||
lastBlade.BladeItemMode = BladeItemMode.Normal; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curly braces please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -47,11 +54,29 @@ protected override void OnApplyTemplate() | |||
|
|||
_closeButton.Click -= CloseButton_Click; | |||
_closeButton.Click += CloseButton_Click; | |||
|
|||
if (_enlargeButton == null) | |||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curly braces please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
ContentPresenter content = bladeItem.GetTemplateChild("ContentPresenter") as ContentPresenter; | ||
if (content == null) | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curly braces please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@Depechie We don't need to set the width when a blade item is collapsed. Create a Visual State for expanded and collapsed. When collapsed set the visibility of the ContentPresenter and the title bar to Collapsed. This will make the entire control the width you are expecting. |
What are other thoughts about making the BladeItem an Expander control? |
@skendrot Changing it to an expander control is maybe not such a bad idea indeed About the Visual States, if you can show this can be done through my PR, I'm happy to learn :) |
Add a visual state for expanded/collaped to the blade item
Control the blade item visual state when the mode changes
@nmetulev was this q directed to me? So does your question mean you guys now only want the control change in there when it is a real expander instead of the current rework? |
@Depechie If changing to an expander is too difficult I can handle the changes |
// For now we skip this feature when blade mode is set to fullscreen | ||
if (AutoCollapseCountThreshold > 0 && BladeMode != BladeMode.Fullscreen && ActiveBlades.Any()) | ||
{ | ||
var openBlades = ActiveBlades.Where(item => item.TitleBarVisibility == Visibility.Visible).ToList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should check the expand mode instead of the visibility of the title bar. This could be set by the user
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding was that the TitleBarVisibility property was used to pin blades to the screen.
I want to filter the pinned once out, they are not touched by the auto resize mechanism.
@skendrot Is there another property that tells me this? I don't seem to find it...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right! Thanks for pointing that out
if (AutoCollapseCountThreshold > 0 && BladeMode != BladeMode.Fullscreen && ActiveBlades.Any()) | ||
{ | ||
var openBlades = ActiveBlades.Where(item => item.TitleBarVisibility == Visibility.Visible).ToList(); | ||
if (openBlades?.Count > AutoCollapseCountThreshold) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to check for null, guaranteed to be a list
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
{ | ||
for (int i = 0; i < openBlades.Count - 1; i++) | ||
{ | ||
openBlades[i].BladeItemMode = BladeItemMode.Small; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this close ALL open blades? Or just the amount under the threshold count?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All open blades except the last one, IF the amount of blades drawn is over the threshold.
@@ -133,6 +151,12 @@ private void CycleBlades() | |||
|
|||
BladeClosed?.Invoke(this, blade); | |||
ActiveBlades.Remove(blade); | |||
|
|||
var lastBlade = ActiveBlades.LastOrDefault(); | |||
if (lastBlade != null && lastBlade.TitleBarVisibility == Visibility.Visible) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't check the titlebar visibility. This can be set to collapsed by the user but still want the last blade to be expanded
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same remark as above, I don't want to auto size pinned blades.
Apologies for randomizing you :(. My vote is to keep the changes you've done as it seems that your changes are very useful and needed. We should then open a new issue to discuss further updates/changes to the control before we start a new PR. Looks like @skendrot has some minor requests that should be looked at before merging the control. Do you think you can take a look at those this week? |
Tested this out. If I set the AutoCollapse to 3 and open three blades they are all open. When I open the forth it collapses the first three and then leaves the last one open. If I add a fifth it collapses the fourth and leaves the fifth open. I was expecting it to always leave the last three open. This is probably a misunderstanding on my part but I'm wondering if others will think the same. Should it only leave the last one open? Or should it leave the amount open that you specify? |
Yeah... every person could have a different view on this I guess! We could add an extra property to also accomplish the other need, to start collapsing blades After the threshold count AND keep in mind the new property called KeepOpenBlades for example to not close the x last ones where x equals that keep open property. |
Yea, completely understand the usecase and I agree the open blades can be a distraction. Definitely no need to update this PR to handle a different use case. I'm good with things as is. @nmetulev, what are your thoughts on the workflow or property name? Do they communicate the intended functionality properly? |
Reading your description again, it makes sense why you are doing it this way. But just from the property name, I had the same assumption as @skendrot, that it would only keep up to max open blades. How do you feel about changing the name to something else, maybe along the lines of "CollapseAllButLastThreshold" |
The original property was named |
Oh, that's much better, apologies. I'm good with that name :) |
We should make sure we add it to the documentation though before we merge it :) |
@Depechie, could you add the new property to the documentation before we merge? |
@nmetulev ok will try to fit that in this week! |
Thanks @Depechie, let me know if you can make it by Wednesday, or if you need help. Code freeze for 1.5 is Wednesday EOD PST. |
Added new AutoCollapseCountThreshold to documents
@nmetulev could some people double check for English spelling error, and is the wording ok? Updated the BladeView.md. |
docs/controls/BladeView.md
Outdated
@@ -66,6 +66,12 @@ Here is an example of a BladeView where the `BladeMode` property is binded to a | |||
|
|||
``` | |||
|
|||
## AutoCollapseCountThreshold | |||
|
|||
If you want to use the BladeView for handling a flow of actions, you can use the `AutoCollapseCountThreshold` property to tell it to start auto collapsing BladeItems after a certain threshold count has been reached. This will also help keeping a clean, uncluttered screen real estate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change
This will also help keeping a clean, uncluttered screen real estate.
To
This will also help keep a clean, uncluttered screen real estate.
(change keeping to keep)
English is hard
docs/controls/BladeView.md
Outdated
|
||
If you want to use the BladeView for handling a flow of actions, you can use the `AutoCollapseCountThreshold` property to tell it to start auto collapsing BladeItems after a certain threshold count has been reached. This will also help keeping a clean, uncluttered screen real estate. | ||
|
||
Let's explain this with an example; if you put the `AutoCollapseCountThreshold` property to 3, the BladeView will start counting all BladeItems that are open in the BladeView and have their `TitleBarVisibility` property set to Visible. When the n+1 BladeItem, in our case the 4th one, is being added, the BladeView will auto collaps all n BladeItems except for the last one. All additional BladeItems that are added afterwards will trigger the same effect; collapse all BladeItems except for the last open one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change
Let's explain this with an example
To
For example
docs/controls/BladeView.md
Outdated
|
||
If you want to use the BladeView for handling a flow of actions, you can use the `AutoCollapseCountThreshold` property to tell it to start auto collapsing BladeItems after a certain threshold count has been reached. This will also help keeping a clean, uncluttered screen real estate. | ||
|
||
Let's explain this with an example; if you put the `AutoCollapseCountThreshold` property to 3, the BladeView will start counting all BladeItems that are open in the BladeView and have their `TitleBarVisibility` property set to Visible. When the n+1 BladeItem, in our case the 4th one, is being added, the BladeView will auto collaps all n BladeItems except for the last one. All additional BladeItems that are added afterwards will trigger the same effect; collapse all BladeItems except for the last open one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change
if you put the
AutoCollapseCountThreshold
property to 3
To
if you set
AutoCollapseCountThreshold
to 3
docs/controls/BladeView.md
Outdated
|
||
If you want to use the BladeView for handling a flow of actions, you can use the `AutoCollapseCountThreshold` property to tell it to start auto collapsing BladeItems after a certain threshold count has been reached. This will also help keeping a clean, uncluttered screen real estate. | ||
|
||
Let's explain this with an example; if you put the `AutoCollapseCountThreshold` property to 3, the BladeView will start counting all BladeItems that are open in the BladeView and have their `TitleBarVisibility` property set to Visible. When the n+1 BladeItem, in our case the 4th one, is being added, the BladeView will auto collaps all n BladeItems except for the last one. All additional BladeItems that are added afterwards will trigger the same effect; collapse all BladeItems except for the last open one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix spelling of collaps
the BladeView will auto collaps all
More spell checking
Cfr #627 for the discussion and a demo movie posted to YouTube.
This is my vision of how we can keep screen real estate to a minimal when using blades.
The first original Azure portal had a similar feature ( although no longer present ).
In short, once we reached MaxOpenBlades count threshold of open blades with a title bar, we collapse all blades but the last one each time we add a new blade.
The sample page has been updated.