Comments (6)
@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.
@anakic Thanks for the response! WhenPersistingProperty
is exactly what I was looking for.
from jot.
+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.
Oh man, that's an ancient history for me. I don't even remember on what project i used it with :)
from jot.
@jakoss yeah, my reply wasn't very quick:) if it pops up again, do reply back.
from jot.
Can't reproduce it so closing for now. Will reopen if the issue pops up again.
from jot.
Related Issues (20)
- Confused with the new syntax HOT 3
- [REQUEST] Include XML documentation file for NuGet package. HOT 2
- ITrackingAware AsGeneric not serialising any data on Persist HOT 4
- How change config file name. HOT 3
- Type Initializer throwing an error HOT 3
- Adding an Additional Tracker Breaks Jot for VB
- XML documentation file is missing in distribution HOT 1
- Tracker property is null in TrackingConfiguration<T> class HOT 2
- Support for System.Text.Json HOT 4
- Save user settings HOT 1
- Setup for Caliburn.Micro and WPF without a code behind. HOT 1
- Items duplicated in MyList {set;get;} which is a property inside the ObjectToBeTracked
- idFunc is null when calling GetStoreId HOT 4
- Cast Error HOT 3
- Does DefaultValue Attribute implementation work? HOT 3
- Nested object HOT 3
- Jot throwing an exception HOT 4
- Persisting a list HOT 2
- Persist and load Net 6 TimeOnly type HOT 2
- Jot Abstractions upgrade 7.1, it will report an error HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jot.