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

Not working for Windows Forms #22

Closed
ElektroStudios opened this issue Jan 29, 2019 · 2 comments
Closed

Not working for Windows Forms #22

ElektroStudios opened this issue Jan 29, 2019 · 2 comments

Comments

@ElektroStudios
Copy link
Contributor

ElektroStudios commented Jan 29, 2019

Hey, I'm new using this lib. I just took the example from the readme.md and adapted it to use for a Form isntead of a WPF Window. The next code pretends to save and restore the location of a Form, but it does not restore the location...

    Public Sub New()
        MyClass.InitializeComponent()

        Tracker.Configure(Me).IdentifyAs(NameOf(Form1)).
                AddProperties(Of Form)(Function(x As Form) x.Location).
                RegisterPersistTrigger(NameOf(Form.LocationChanged)).
                Apply()

    End Sub

I'm missing something to do?.

@ElektroStudios
Copy link
Contributor Author

Nevermind. I just didn't knew that the values are restored when calling the "Apply" method, so I must call it outside the constructor (in the Form.Load event for example) and then it works perfectly.

@anakic
Copy link
Owner

anakic commented Jan 30, 2019

Hey! Yes, winforms ignore location settings that are applied in the constructor.

I wanted to note a few other things:

  • you can also add properties by name, e.g. AddProperties(NameOf(Form1.Location))
  • if it's a form you're tracking, it's enough to call Tracker.Configure(Me).Apply() since a configuration for tracking forms is included by default in Jot. This configuration handles some edge cases like persisting a minimized form, or restoring a form that was on a display that is no longer connected.

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

No branches or pull requests

2 participants