Giter Club home page Giter Club logo

Comments (6)

anakic avatar anakic commented on August 25, 2024 1

@jakoss I've just tried it and had no issues on both .net 4.7.2 and .net core 5. Can you make a sample project with the problem? Winforms do have this problem where the size/location is bogus while the window is minimized, but I haven't seen that behavior in WPF. For winForms you can handle it by hooking up a callback function by calling WhenPersistingProperty. See the example for winforms in the readme.

@micahmo Yep, that's already supported. There are methods you can use (WhenPersistingProperty and WhenApplyingProperty) to hook into the process of applying/persisting, and you can transform the value or cancel applying/persisting the property. Take a look at the winforms example in the readme, it cancels persisting if the windowstate is minimized.

from jot.

micahmo avatar micahmo commented on August 25, 2024 1

@anakic Thanks for the response! WhenPersistingProperty is exactly what I was looking for.

from jot.

micahmo avatar micahmo commented on August 25, 2024

+1 to this. I don't think anyone wants their app to start minimized, even if it was minimized when closed.

That said, I'm not sure how much Jot wants to add custom code to prevent these kinds of scenarios. Maybe a more generic approach (such as the ability to block/replace a particular enum value) would be preferable. I don't know the internals of Jot, but a potential solution could look like this.

The user could configure a function on the TrackingConfiguration<T> that performs a custom transformation on any value of the given type. In the case of this bug, I might register a transformation that handles any value of type WindowState, and returns the value Normal if the value is Minimized, otherwise leave the value as is.

// Set up the transformation when configuring the tracker so that we never save Minimized
configuration.Transform<WindowState>(ws => ws == WindowState.Minimized ? WindowState.Normal : ws);

// As defined by...
public TrackingConfiguration<T> Transform<TProp>(Func<TProp, TProp> transformPredicate) { ... }

For the second part of the bug, maybe we could define mins and maxes for certain values. We could use a similar transformation method, but instead of doing it for all values of a given type, we could pass a property name for the configuration engine to filter on (so it will only invoke our delegate if the value matches TProp and name). Since I don't want my window to start off screen, I can say that Left and Top should never be less than 0.

// Set up the transformation when configuring the tracker so that we never get a Top or Left value less than 0
configuration.Transform<double>(nameof(Window.Top), value => Math.Max(value, 0));
configuration.Transform<double>(nameof(Window.Left), value => Math.Max(value, 0));

// As defined by
public TrackingConfiguration<T> Transform<TProp>(string name, Func<TProp, TProp> transformPredicate) { ... }

Again, all of this is easy to say without actually diving into the code to see if it's possible. But hopefully it can spark some ideas! :-)

from jot.

jakoss avatar jakoss commented on August 25, 2024

Oh man, that's an ancient history for me. I don't even remember on what project i used it with :)

from jot.

anakic avatar anakic commented on August 25, 2024

@jakoss yeah, my reply wasn't very quick:) if it pops up again, do reply back.

from jot.

anakic avatar anakic commented on August 25, 2024

Can't reproduce it so closing for now. Will reopen if the issue pops up again.

from jot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.