QuickImage – Rev 1

Subversion Repositories:
Rev:
using System.Windows.Forms;
using Jot;
using Jot.Storage;

namespace QuickImage
{
    public static class JotFormTracker
    {
        // expose the tracker instance
        public static Tracker Tracker = new Tracker(new JsonFileStore(Constants.UserApplicationDirectory));

        static JotFormTracker()
        {
            Tracker.Configure<Form>()
                .Id(f => f.Name, SystemInformation.VirtualScreen.Size)
                .Properties(f => new { f.Height, f.Width, f.Left, f.Top, f.WindowState })
                .PersistOn(nameof(Form.Closing))
                .StopTrackingOn(nameof(Form.Closed))
                .WhenPersistingProperty((f, p) =>
                    p.Cancel = (f.WindowState != FormWindowState.Normal && p.Property != nameof(Form.WindowState)));
        }
    }
}