dotMorten / WinUIEx

WinUI Extensions
https://dotmorten.github.io/WinUIEx
MIT License
615 stars 40 forks source link

Expose a way for unpackaged apps to persist window location #63

Closed dotMorten closed 1 year ago

dotMorten commented 2 years ago

61

@mikebattista would this work for you?

mikebattista commented 2 years ago

I'll need to try it and see what the experience is for the app.

dotMorten commented 2 years ago

I'm open for other ways to expose it - this was just the simplest way I could think of.

mikebattista commented 2 years ago

I understand the loading piece. If the app had previously saved the dictionary to LocalAppData, on startup it can read it and set it for PersistenceStorage, then you will load the window size and position as you do today without requiring the app to do its own P/Invokes. That's good.

For save, I'm assuming you'll be writing to the provided Dictionary in memory whenever the window size and position changes? If so, what is the expectation on the developer to save this? Do they need to subscribe to an event to know when save? You probably don't want to write to disk for every pixel change right?

dotMorten commented 2 years ago

For save, I'm assuming you'll be writing to the provided Dictionary in memory whenever the window size and position changes?

This happens when the window closes. You could create a custom IDictonary<string,object> class that'll just read from/write to disk (or just pass it your settings dictionary as-is) (read is happening on the first window activated event).

dotMorten commented 2 years ago

@mikebattista Any more thoughts on this approach?

mikebattista commented 2 years ago

I'll need to try it out but am focused on shipping the 5.2 Template Studio update at the moment. Will take a look for the next update.

dotMorten commented 1 year ago

Closing this in favor of https://github.com/dotMorten/WinUIEx/commit/5e179c280788be8f32fa3c95401d741ebcd3c822