Esempio n. 1
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            var uiSettings = UISettings.Load();

            if (uiSettings != null)
            {
                Width  = uiSettings.Width ?? Width;
                Height = uiSettings.Height ?? Height;
                Left   = uiSettings.Left ?? Left;
                Top    = uiSettings.Top ?? Top;

                // set theme based on pref
                if (uiSettings.UITheme != null)
                {
                    ((Certify.UI.App)App.Current).ToggleTheme(uiSettings.UITheme);
                }

                if (uiSettings.Scaling > 0.5 && uiSettings.Scaling < 2)
                {
                    _appViewModel.UIScaleFactor = uiSettings.Scaling ?? 1;
                }

                _appViewModel.UISettings = uiSettings;
            }

            await PerformAppStartupChecks();
        }
Esempio n. 2
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            var uiSettings = UISettings.Load();

            if (uiSettings != null)
            {
                Width  = uiSettings.Width ?? Width;
                Height = uiSettings.Height ?? Height;

                Top = uiSettings.Top ?? Top;

                // only apply saved left pos if it's not off-screen
                double virtScreenWidth = System.Windows.SystemParameters.VirtualScreenWidth;
                if (uiSettings.Left < virtScreenWidth)
                {
                    Left = uiSettings.Left ?? Left;
                }

                // set theme based on pref
                if (uiSettings.UITheme != null)
                {
                    ((Certify.UI.App)App.Current).ToggleTheme(uiSettings.UITheme);
                }

                if (uiSettings.Scaling > 0.5 && uiSettings.Scaling < 2)
                {
                    _appViewModel.UIScaleFactor = uiSettings.Scaling ?? 1;
                }

                _appViewModel.UISettings = uiSettings;
            }

            await PerformAppStartupChecks();
        }
Esempio n. 3
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            var uiSettings = UISettings.Load();

            if (uiSettings != null)
            {
                Width  = uiSettings.Width;
                Height = uiSettings.Height;
                Left   = uiSettings.Left;
                Top    = uiSettings.Top;
            }

            await PerformAppStartupChecks();
        }
Esempio n. 4
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            var uiSettings = UISettings.Load();

            if (uiSettings != null)
            {
                Width  = uiSettings.Width;
                Height = uiSettings.Height;
                Left   = uiSettings.Left;
                Top    = uiSettings.Top;


                // set theme based on pref
                if (uiSettings.UITheme != null)
                {
                    ((Certify.UI.App)App.Current).ToggleTheme(uiSettings.UITheme);
                }
            }

            await PerformAppStartupChecks();
        }
Esempio n. 5
0
        private async void MetroWindow_Closing(object sender, CancelEventArgs e)
        {
            // allow cancelling exit to save changes
            if (!await _itemViewModel.ConfirmDiscardUnsavedChanges())
            {
                e.Cancel = true;
            }

            var uiSettings = UISettings.Load();

            if (uiSettings == null)
            {
                uiSettings = new UISettings();
            }

            uiSettings.Width  = Width;
            uiSettings.Height = Height;
            uiSettings.Left   = Left;
            uiSettings.Top    = Top;

            UISettings.Save(uiSettings);
        }
Esempio n. 6
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            var uiSettings = UISettings.Load();

            if (uiSettings != null)
            {
                try
                {
                    // only apply saved left pos if it's not off-screen
                    double virtScreenWidth  = System.Windows.SystemParameters.VirtualScreenWidth;
                    double virtScreenHeight = System.Windows.SystemParameters.VirtualScreenHeight;

                    if (uiSettings.Width < virtScreenWidth)
                    {
                        Width = uiSettings.Width ?? Width;
                    }

                    if (uiSettings.Height < virtScreenHeight)
                    {
                        Height = uiSettings.Height ?? Height;
                    }

                    if (uiSettings.Top >= 0 && uiSettings.Top < (virtScreenHeight - Height))
                    {
                        Top = (double)uiSettings.Top;
                    }

                    if (uiSettings.Left >= 0 && uiSettings.Left < (virtScreenWidth - Width))
                    {
                        Left = (double)uiSettings.Left;
                    }

                    // set theme based on pref
                    if (uiSettings.UITheme != null)
                    {
                        ((ICertifyApp)_appViewModel.GetApplication()).ToggleTheme(uiSettings.UITheme);
                    }
                    else
                    {
                        // default theme
                        ((ICertifyApp)_appViewModel.GetApplication()).ToggleTheme(_appViewModel.DefaultUITheme);
                    }

                    if (uiSettings.Scaling > 0.5 && uiSettings.Scaling < 2)
                    {
                        _appViewModel.UIScaleFactor = uiSettings.Scaling ?? 1;
                    }

                    _appViewModel.UISettings = uiSettings;
                }
                catch
                {
                    // failed to get window position etc
                }
            }
            else
            {
                // default theme
                ((ICertifyApp)_appViewModel.GetApplication()).ToggleTheme(_appViewModel.DefaultUITheme);
            }

            await PerformAppStartupChecks();
        }