예제 #1
0
    /// <summary>
    ///     Adapts the titlebar buttons to the current theme.
    /// </summary>
    public static void UpdateTheme(UISettings uISettings, object theObject)
    {
        ISettingsService settingsService = Ioc.Default.GetService <ISettingsService>();
        SettingAppTheme  theme           = (SettingAppTheme)settingsService?.GetSetting(AppSetting.SettingAppTheme);

        if (theme == SettingAppTheme.System)
        {
            if ((new UISettings()).GetColorValue(UIColorType.Background).ToString() == "#FF000000")
            {
                // dark mode is active
                applicationViewTitlebar.ButtonForegroundColor        = Windows.UI.Colors.White;
                applicationViewTitlebar.ButtonHoverForegroundColor   = Windows.UI.Colors.White;
                applicationViewTitlebar.ButtonHoverBackgroundColor   = Windows.UI.Color.FromArgb(32, 169, 169, 211);
                applicationViewTitlebar.ButtonPressedForegroundColor = Windows.UI.Colors.White;
                applicationViewTitlebar.ButtonPressedBackgroundColor = Windows.UI.Color.FromArgb(96, 169, 169, 211);
            }
            else
            {
                // light mode is active
                applicationViewTitlebar.ButtonForegroundColor        = Windows.UI.Colors.Black;
                applicationViewTitlebar.ButtonHoverForegroundColor   = Windows.UI.Colors.Black;
                applicationViewTitlebar.ButtonHoverBackgroundColor   = Windows.UI.Color.FromArgb(64, 169, 169, 169);
                applicationViewTitlebar.ButtonPressedForegroundColor = Windows.UI.Colors.Black;
                applicationViewTitlebar.ButtonPressedBackgroundColor = Windows.UI.Color.FromArgb(156, 169, 169, 169);
            }
        }
        else
        {
            if (theme == SettingAppTheme.Light)
            {
                // light mode is forced
                applicationViewTitlebar.ButtonForegroundColor        = Windows.UI.Colors.Black;
                applicationViewTitlebar.ButtonHoverForegroundColor   = Windows.UI.Colors.Black;
                applicationViewTitlebar.ButtonHoverBackgroundColor   = Windows.UI.Color.FromArgb(64, 169, 169, 169);
                applicationViewTitlebar.ButtonPressedForegroundColor = Windows.UI.Colors.Black;
                applicationViewTitlebar.ButtonPressedBackgroundColor = Windows.UI.Color.FromArgb(156, 169, 169, 169);
            }
            else
            {
                // dark mode is forced
                applicationViewTitlebar.ButtonForegroundColor        = Windows.UI.Colors.White;
                applicationViewTitlebar.ButtonHoverForegroundColor   = Windows.UI.Colors.White;
                applicationViewTitlebar.ButtonHoverBackgroundColor   = Windows.UI.Color.FromArgb(32, 169, 169, 211);
                applicationViewTitlebar.ButtonPressedForegroundColor = Windows.UI.Colors.White;
                applicationViewTitlebar.ButtonPressedBackgroundColor = Windows.UI.Color.FromArgb(96, 169, 169, 211);
            }
        }
    }
예제 #2
0
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            this.InitializeComponent();
            this.Suspending += OnSuspending;

            // configure service landscape
            Ioc.Default.ConfigureServices(new ServiceCollection()
                                          .AddSingleton <IMessenger>(WeakReferenceMessenger.Default)
                                          .AddSingleton <ISettingsService, SettingsService>()
                                          .AddSingleton <IScannerDiscoveryService, ScannerDiscoveryService>()
                                          .AddSingleton <IScanService, ScanService>()
                                          .AddSingleton <ILogService, LogService>()
                                          .AddSingleton <IAppCenterService, AppCenterService>()
                                          .AddSingleton <IScanOptionsDatabaseService, ScanOptionsDatabaseService>()
                                          .AddSingleton <IPersistentScanOptionsDatabaseService, PersistentScanOptionsDatabaseService>()
                                          .AddSingleton <IAppDataService, AppDataService>()
                                          .AddSingleton <IAccessibilityService, AccessibilityService>()
                                          .AddSingleton <IScanResultService, ScanResultService>()
                                          .AddSingleton <IHelperService, HelperService>()
                                          .AddSingleton <IAutoRotatorService, AutoRotatorService>()
                                          .AddSingleton <IPdfService, PdfService>()
                                          .BuildServiceProvider());

            // apply theme
            SettingsService = Ioc.Default.GetRequiredService <ISettingsService>();
            SettingAppTheme theme = (SettingAppTheme)SettingsService.GetSetting(AppSetting.SettingAppTheme);

            switch (theme)
            {
            case SettingAppTheme.Light:
                this.RequestedTheme = ApplicationTheme.Light;
                break;

            case SettingAppTheme.Dark:
                this.RequestedTheme = ApplicationTheme.Dark;
                break;

            case SettingAppTheme.System:
            default:
                break;
            }
        }