Windows-Apps-Hub / UnitedSets

Bringing back Sets and Browser
https://www.microsoft.com/store/apps/9N7CWZ3L5RWL
MIT License
232 stars 10 forks source link

Large encapsulation changes for MainWindow logic and HwndHost wrapped in our class #40

Closed mitchcapper closed 1 year ago

mitchcapper commented 1 year ago

This is a fairly large refectoring to try and improve encapsulation between classes. Rather than having duplicate logic in multiple places, have other classes modifying mainwindow items, have each class handle itself (mostly).

I am not sure how I feel about the static event on Cell. It was an easy hack, at the same time I am not sure there is really a reason to not have static TabBase events but this mostly seems appropriate.

It introduces a new OurHwndHost class that wraps the old HwndHost completely. Insulating it so we have one chokepoint that all commands must flow through. This does something else in it allows the properties like crop, borderless, activecrop are all cached in that class so even if HwndHost is disposed we can still access them. In addition when we detach we reset all these things, but this class retains the original values.

Encapsulation also makes sure that every time we detach a tab, or add a tab all the correct operations are performed.

mitchcapper commented 1 year ago

Also, the constructor for HwndHostTab is wonky. We don't really want to pass UI items it doesn't need but we need a reference to the tab itself for OurHwndHost. We could change OurHwndHost so the constructor doesn't take the parent, there is an Init() function that passes the parent to it as another option.

mitchcapper commented 1 year ago

Also, there was some DeepClone code there I wasn't sure if should be implemented or removed completely so I just commented it out. It doesn't seem to be used anywhere.