Skip to content
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

Savablz 🎉 #210

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

jeremyVignelles
Copy link

Background

This is the first implementation of what I call "Savablz", layout windows that can be saved.
I think this is a required feature for many of us : #201, someone on gitter asked, this, I needed this, and you also had to do that too in doobry.

I'm pretty new to the project so I admit I've no idea if I cover all the cases.

Implementation

I've read what you did in https://github.com/ButchersBoy/doobry/blob/master/Doobry/MainWindowViewModel.cs , but this implementation:

  • Doesn't need tab ID, the tree is written as-is in the object hierarchy, which doesn't require id manipulations, and serializes well, at least in JSON
  • Works with multiple windows
  • Saves the position and the state (maximized, restored...) of the windows
  • Is flexible (User have control of how this is serialized and what kind of model/viewmodel has a tab)

Note: this PR is based on top of #207, feel free to cherry pick if you don't want that.

I also implemented a new Sample project that demonstrates how that works.

How it works

  • You need to have a ViewModel that represents your tab.
  • Create a Model type that is a POCO object, used to serialize the state of your tab. Include all details that helps you to recreate the state of the ViewModel
  • Call WindowsStateSaver.GetWindowsState<TModel, TViewModel>(viewModelToModelConversionFunction) to get the state of all windows in this app.
  • The state is serialization agnostic, so that you can save that the way you want (JSON, XML...)
  • Restore the state at startup by calling WindowsStateSaver.RestoreWindowsState(window.InitialTabablz, state, modelToViewModelConversionFunction). The window must be shown beforehand for this to work.
  • Enjoy!

About the new sample project

This sample is aimed at providing a simple getting started for the common scenario. It is not meant to provide a full documentation. It is however a good way to get started.

Tabs are just showing a GUID in the header and in the content. The view model is very simple, and so is the Model, but it is here to demonstrate how things work together. When the "main" window is closed, the state is saved and is restored at next startup, thanks to the .net's Settings mechanism.

When the last tab of the main window is closed, the settings are reset and a fresh configuration is generated on the next startup.

Questions

  • Does it work well in all cases?
  • I'm only tackling the simple case of one Partition. What happen when we have multiple partitions? What should be done?
  • We should probably implement a method that can get the state of a window which don't have a Layout (we currently enumerate the layouts to get the windows). The model is ready for that scenario.

Jeremy Vignelles added 2 commits June 5, 2018 10:44
It made my visual studio put squiggles everywhere, making the code
unreadable. Or maybe is it Resharper?
@jeremyVignelles jeremyVignelles changed the title Savablz 🎉 Savablz 🎉 Jun 8, 2018
@jeremyVignelles
Copy link
Author

It looks like I'm using new features of C# that are not available on appveyor? Would you like me to fix that, or do you want to update your appveyor to vs2017 ?

@jeremyVignelles
Copy link
Author

Hi,
I removed the code that used the newest C# syntax features (last 2 commits) to make appveyor happy and to make it generate the NuGet packages correctly.
@ButchersBoy Is it possible to review it ? I really need this feature and I'm sure I'm not the only one.

@Viktor9212
Copy link

How do i DownLoad your commits?

@jeremyVignelles
Copy link
Author

You can use the .nupkg from here https://ci.appveyor.com/project/ButchersBoy/dragablz/build/0.0.3.210/artifacts

@zenchanhk
Copy link

Hi,
Where can I found the sample project? Thanks.

@zenchanhk
Copy link

I found on your github, thanks.

@zenchanhk
Copy link

zenchanhk commented Dec 30, 2018

@jeremyVignelles
I found a bug when running your demo. There is a ghost shadow coming with the window, when it got maximized and reopened after closing the maximized window.
ScreenShot

@jeremyVignelles
Copy link
Author

@zenchanhk : sorry for the delay. I don't know where that ghost comes from, but I don't see how it could be caused by this PR. Do you have a repo when I can try to reproduce your issue?

@speedyalibaba
Copy link

@jeremyVignelles Hi, I downloaded your sample and I have a question. Woh would you implement your solution if you had different views/viewModels in each tab?

@jeremyVignelles
Copy link
Author

I'd have one TabContentModel that might be defined with a Kind property and a Model property?
The corresponding TabContentView would choose the view to display based on the Kind property or something.

I didn't test it tough, just an idea.

@jeremyVignelles
Copy link
Author

Another way I can think of is to make all your model implement the same ITabModel interface, and play with the Newtonsoft.Json's serialization options

@speedyalibaba
Copy link

I'd have one TabContentModel that might be defined with a Kind property and a Model property?
The corresponding TabContentView would choose the view to display based on the Kind property or something.

I didn't test it tough, just an idea.

Thanks a lot :)
Hopefully this PR will be reviewed soon.

@jeremyVignelles
Copy link
Author

jeremyVignelles commented Mar 9, 2019

Hopefully this PR will be reviewed soon.
I wouldn't count on it. It's been around for a while and there have been no commit in a year.

I guess the author, like many other open source devs have no more time to maintain it or has lost interest in maintaining it.
I could try to fork it myself, but my time is also very limited due to maintaining Vlc.DotNet...

EDIT: His status reads "Taking a break from open source."...

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.

4 participants