Profile Picture

NDockingToolbar persistence

Posted By Craig Swearingen 11 Years Ago
Author
Message
Craig Swearingen
Posted 11 Years Ago
View Quick Profile
Supreme Being

Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)

Group: Forum Members
Last Active: 7 Years Ago
Posts: 99, Visits: 654

I've been using NDockingToolbars just fine but I've disabled letting the user move them around til now.  I've turned on the properties to allow the toolbars to be moved around and that operation works as expected.  I've been trying to persist the toolbar location for several hours now and can't make it work reasonably.

I build my toolbars (1 MenuBar and 2 icon bars) mostly dynamically by adding an NCommand to my NDockingToolbar Commands collection.  Works great. 

I briefly tried using the NCommandBarsState class to save my toolbars state.  When I loaded a saved state my click events on my commands were unknown.  I gave up at that point.  I would imagine the way I build my toolbars is not compatible with this persisting approach. 

Thus I'm trying to persist the toolbar Dock, Location, and RowIndex properties.  I don't allow the user to edit the toolbars themselves so I was hoping that would be sufficient to remember and it nearly is.

1) When calling toolbar.Dock = DockStyle.None my toolbar properly floats out from the docked position.  If I then call toolbar.Dock = DockStyle.Top the toolbar docks back at the top but its height is wrong and it continues to show parts of the floated toolbar visual.  I've tried setting the above properties in different orders and using the NCommandBarsManager Suspend/ResumeDockLayout methods as well as setting the FloatingSize/Location to 0 but nothing helps.  Works great when the user docks using the mouse.  What else can I do programatically to get the visual to look the same?  (I attached a scribbled out picture of this docked toolbar visual issue.)

2) I read on this forum that the ability to move a toolbar above the menu bar (which is a toolbar too) is by design.  Someone has already asked if there was a way to stop this.  I can't think of a single application that has allowed me to move my toolbars above a menu bar.  This should be optional.  I briefly tried persisting my menubar as a toolbar too so as to accomodate the user doing this and began getting some form of exception (not in my code).  I did not persue this further.

3) I tried setting CanFloat to false.  When doing this the user can't move the toolbar to any other dock state.  I was hoping they could move it around the borders but it seems its stuck.  Anyway to not support float but move around all borders?

I'm running on Win7 using build 11.12.14.12.  I would appreciate any suggestions on the proper persisting of toolbars and recommendations on these issues I've seen.



Attachments
dockedtoolbarvisual.GIF (340 views, 8.00 KB)
Nevron Support
Posted 11 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 3,039, Visits: 3,746
Hello Craig,

I will try to give you an answers to your questions:

"When I loaded a saved state my click events on my commands were unknown" - Docking toolbar framework does not persist the events. After the state was restored you should attach to the desired events again.

" If I then call toolbar.Dock = DockStyle.Top the toolbar docks back at the top but its height is wrong and it continues to show parts of the floated toolbar visual." - This is a bug which will be fixed in the next release.

"I can't think of a single application that has allowed me to move my toolbars above a menu bar." - Visual Studio 2008 .

" I briefly tried persisting my menubar as a toolbar too so as to accomodate the user doing this and began getting some form of exception (not in my code). " - Could you post the exception message so we can investigate what cause it.

"I tried setting CanFloat to false. When doing this the user can't move the toolbar to any other dock state." - To change the docking location of a toolbar it first becomes floating, and then becomes docked on the new location. That's why you cannot change the docking position when CanFloat is false.

Best Regards,
Nevron Support Team



Craig Swearingen
Posted 11 Years Ago
View Quick Profile
Supreme Being

Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)

Group: Forum Members
Last Active: 7 Years Ago
Posts: 99, Visits: 654

Thanks so much for replying. 

Regarding losing the click events, that makes sense.  I guess I thought it would just change an already built toolbar instead of recreate the objects for it.

Glad to know a fix makes sense for the programatic docking of the toolbar.  Was hoping for something I could do in my build, however.

Ha, I never used VS08 but I tried VS10 just now and it doesn't let me move the toolbar above the menu.  They must have fixed that bug! 

Not sure I'll get back to that exception with trying to persist the menu bar.  Will post something if I do.

I understand the limitation caused by CanFloat=false.  However, you could have easily not allowed the float state and let the user move to any docking border.  That was your choice just as allowing the user to move the toolbar above a menubar is.  As you can imagine people see things differently and we love options allowing this.

 

 



Craig Swearingen
Posted 11 Years Ago
View Quick Profile
Supreme Being

Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)

Group: Forum Members
Last Active: 7 Years Ago
Posts: 99, Visits: 654

Given the indication that you may provide a fix for the programatic docking of the toolbar painting issue in a future release I went further and tried to persist the floating toolbar state.  Thus I'm trying to persist the FloatingLocation and FloatingSize parameters of an NDockingToolbar.

1) When a toolbar is already floating and I subsequently want to have it floating with a different size and location its not clear how to make this work.  Setting the FloatingLocation and FloatingSize sometimes doesn't change the values.  Its as though they are in a state where they can not be updated.

2) There seems to be an issue with persisting the FloatingSize initially.  Perhaps too soon after the toolbar is created.  The first time I try to set the size the toolbar comes out a little smaller than it should and thus flows differently.

I'd like to be able to provide multiple layouts a user could switch to for my NDockingToolbars much like I can for my NDocuments.  Can I do this?



Nevron Support
Posted 11 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 3,039, Visits: 3,746
Hello Craig,

FloatingLocation property applies only when the toolbar becomes floating for first time. If you dock it and then make it floating again it loads the last floating position.
To provide multiple layouts you can save a state for each one and then load the one when the user request a layout.

Best Regards,
Nevron Support Team



Craig Swearingen
Posted 11 Years Ago
View Quick Profile
Supreme Being

Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)

Group: Forum Members
Last Active: 7 Years Ago
Posts: 99, Visits: 654

Thanks for the explanation.  I'm trying to provide multiple layouts as you suggest but since I can't move a floated toolbar...  I'll try to find a way to work with this design.  Wish I could turn off the float feature and still move to any side as I'd be done.

I did hit an unexpected exception again and it had to do with code like this:

foreach (NDockingToolbar tb in nCommandBarManager.Toolbars)

If I then changed the dock, rowindex, and location on the tb an exception could be thrown.

It appears the exception is due to the nCommandBarManager.Toolbars changing its contents.  Thus iterating through it like this isn't possible.  To get around I had to iterate through an nCommandBarManager.Toolbars.ToArray() instead.





Similar Topics


Reading This Topic