Пример #1
0
        private static Result LoadPosition(this Window window, ApplicationSettingsBase settings, string name = "")
        {
            try
            {
                var prefix      = name.IsEmpty() ? window.Name : name;
                var settingName = prefix + "_Position";
                var position    = settings.LoadSetting <Point>(settingName);
                if (Math.Abs(position.X) < .001 && Math.Abs(position.Y) < .001)
                {
                    position.X = 100;
                    position.Y = 100;
                }
                window.Top  = position.Y;
                window.Left = position.X;

                return(Result.Success());
            }
            catch (Exception ex)
            {
                return(Result.Failure(ex));
            }
        }
Пример #2
0
        private static Result LoadSize(this Window window, ApplicationSettingsBase settings, string name = "")
        {
            try
            {
                var prefix      = name.IsEmpty() ? window.Name : name;
                var settingName = prefix + "_Size";
                var size        = settings.LoadSetting <Size>(settingName);
                if (Math.Abs(size.Width) < .001 && Math.Abs(size.Height) < .001)
                {
                    size.Width  = 450;
                    size.Height = 450;
                }
                window.Width  = size.Width;
                window.Height = size.Height;

                return(Result.Success());
            }
            catch (Exception ex)
            {
                return(Result.Failure(ex));
            }
        }