Esempio n. 1
0
        /// <summary>
        /// Adds Height/Width/Top/Left/Windows state to the list of properties to track. Uses
        /// the "ResizeEnd" to trigger persist. Handles validation for edge cases (2nd display
        /// disconnected, saving size info while minimized/maximized).
        /// </summary>
        /// <param name="configuration"></param>
        public override void InitializeConfiguration(TrackingConfiguration configuration)
        {
            var form = configuration.TargetReference.Target as Form;

            configuration
            .AddProperties <Form>(f => f.Height, f => f.Width, f => f.Top, f => f.Left, f => f.WindowState)
            .RegisterPersistTrigger(nameof(form.ResizeEnd))
            .RegisterPersistTrigger(nameof(form.LocationChanged))
            .IdentifyAs(form.Name);

            configuration.PersistingProperty += (sender, args) =>
            {
                //do not save height/width/top/left when the form is maximized or minimized
                args.Cancel = form.WindowState != FormWindowState.Normal && args.Property != nameof(form.WindowState);
            };

            configuration.ApplyingProperty += (sender, args) =>
            {
                //We don't want to restore the form off screeen.
                //This can happen in case of a multi-display setup i.e. the form was closed on 2nd display, but restored after the 2nd display was disconnected
                if (args.Property == "Left")
                {
                    args.Value = (int)Math.Min(Math.Max(SystemParameters.VirtualScreenLeft, (int)args.Value), SystemParameters.VirtualScreenWidth - form.Width);
                }
            };

            base.InitializeConfiguration(configuration);
        }
Esempio n. 2
0
        /// <summary>
        /// Adds Height/Width/Top/Left/Windows state to the list of properties to track. Uses
        /// the "ResizeEnd" to trigger persist. Handles validation for edge cases (2nd display
        /// disconnected, saving size info while minimized/maximized).
        /// </summary>
        /// <param name="configuration"></param>
        public override void InitializeConfiguration(TrackingConfiguration configuration)
        {
            var form = configuration.TargetReference.Target as Form;

            configuration
                .AddProperties<Form>(f => f.Height, f => f.Width, f => f.Top, f => f.Left, f => f.WindowState)
                .RegisterPersistTrigger(nameof(form.ResizeEnd))
                .RegisterPersistTrigger(nameof(form.LocationChanged))
                .IdentifyAs(form.Name);

            configuration.PersistingProperty += (sender, args) =>
            {
                //do not save height/width/top/left when the form is maximized or minimized
                args.Cancel = form.WindowState != FormWindowState.Normal && args.Property != nameof(form.WindowState);
            };

            configuration.ApplyingProperty += (sender, args) =>
            {
                //We don't want to restore the form off screeen.
                //This can happen in case of a multi-display setup i.e. the form was closed on 2nd display, but restored after the 2nd display was disconnected
                if (args.Property == "Left")
                    args.Value = (int)Math.Min(Math.Max(SystemParameters.VirtualScreenLeft, (int)args.Value), SystemParameters.VirtualScreenWidth - form.Width);
            };

            base.InitializeConfiguration(configuration);
        }
Esempio n. 3
0
 protected override void CustomizeConfiguration(TrackingConfiguration configuration)
 {
     Window window = configuration.TargetReference.Target as Window;
     if (window != null)
     {
         configuration
             .AddProperties<Window>(w => w.Left, w => w.Top, w => w.Height, w => w.Width, w => w.WindowState)
             .RegisterPersistTrigger("Closed");
     }
     base.CustomizeConfiguration(configuration);
 }
Esempio n. 4
0
 protected override void CustomizeConfiguration(TrackingConfiguration configuration)
 {
     Form window = configuration.TargetReference.Target as Form;
     if (window != null)
     {
         configuration
             .AddProperties<Form>(f => f.Left, f => f.Top, f => f.Height, f => f.Width, f => f.WindowState)
             .RegisterPersistTrigger("Closed");
     }
     base.CustomizeConfiguration(configuration);
 }
Esempio n. 5
0
        protected override void CustomizeConfiguration(TrackingConfiguration configuration)
        {
            Form window = configuration.TargetReference.Target as Form;

            if (window != null)
            {
                configuration
                .AddProperties <Form>(f => f.Left, f => f.Top, f => f.Height, f => f.Width, f => f.WindowState)
                .RegisterPersistTrigger("Closed");
            }
            base.CustomizeConfiguration(configuration);
        }
Esempio n. 6
0
        protected override void CustomizeConfiguration(TrackingConfiguration configuration)
        {
            Window window = configuration.TargetReference.Target as Window;

            if (window != null)
            {
                configuration
                .AddProperties <Window>(w => w.Left, w => w.Top, w => w.Height, w => w.Width, w => w.WindowState)
                .RegisterPersistTrigger("Closed");
            }
            base.CustomizeConfiguration(configuration);
        }
        /// <summary>
        /// Adds Height/Width/Top/Left/WindowState to list of tracked properties. Uses
        /// the "Sizechanged" event to trigger persistence. Handles validation for edge
        /// cases (2nd display disconnected between application shutdown and restart).
        /// </summary>
        /// <param name="configuration"></param>
        public override void InitializeConfiguration(TrackingConfiguration configuration)
        {
            Window window = configuration.TargetReference.Target as Window;

            configuration
                .AddProperties<Window>(w => w.Height, w => w.Width, w => w.Top, w => w.Left, w => w.WindowState)
                .RegisterPersistTrigger(nameof(window.SizeChanged))
                .RegisterPersistTrigger(nameof(window.LocationChanged))
                .IdentifyAs(window.Name);

            configuration.ApplyingProperty += (sender, args) =>
            {
                //We don't want to restore the form off screeen.
                //This can happen in case of a multi-display setup i.e. the form was closed on 2nd display, but restored after the 2nd display was disconnected
                if (args.Property == "Left")
                    args.Value = Math.Min(Math.Max(SystemParameters.VirtualScreenLeft, (double)args.Value), SystemParameters.VirtualScreenWidth - window.Width);
            };

            base.InitializeConfiguration(configuration);
        }
        /// <summary>
        /// Adds Height/Width/Top/Left/WindowState to list of tracked properties. Uses
        /// the "Sizechanged" event to trigger persistence. Handles validation for edge
        /// cases (2nd display disconnected between application shutdown and restart).
        /// </summary>
        /// <param name="configuration"></param>
        public override void InitializeConfiguration(TrackingConfiguration configuration)
        {
            Window window = configuration.TargetReference.Target as Window;

            configuration
            .AddProperties <Window>(w => w.Height, w => w.Width, w => w.Top, w => w.Left, w => w.WindowState)
            .RegisterPersistTrigger(nameof(window.SizeChanged))
            .RegisterPersistTrigger(nameof(window.LocationChanged))
            .IdentifyAs(window.Name);

            configuration.ApplyingProperty += (sender, args) =>
            {
                //We don't want to restore the form off screeen.
                //This can happen in case of a multi-display setup i.e. the form was closed on 2nd display, but restored after the 2nd display was disconnected
                if (args.Property == "Left")
                {
                    args.Value = Math.Min(Math.Max(SystemParameters.VirtualScreenLeft, (double)args.Value), SystemParameters.VirtualScreenWidth - window.Width);
                }
            };

            base.InitializeConfiguration(configuration);
        }
Esempio n. 9
0
 public void InitConfiguration(TrackingConfiguration configuration)
 {
     configuration.AddProperties("Value1", "Value2");
 }
Esempio n. 10
0
 public void InitializeConfiguration(TrackingConfiguration configuration)
 {
     configuration.AddProperties<Foo>(t => t.A, t => t.B, t => t.Double, t => t.Int, t => t.Timespan);
 }
Esempio n. 11
0
 public void InitConfiguration(TrackingConfiguration configuration)
 {
     configuration.AddProperties("Value1", "Value2");
 }
Esempio n. 12
0
 public void InitializeConfiguration(TrackingConfiguration configuration)
 {
     configuration.AddProperties <Foo>(t => t.A, t => t.B, t => t.Double, t => t.Int, t => t.Timespan);
 }