Beispiel #1
0
 /// <summary>
 /// Handles the SelectedIndexChanged event of the ThemePicker control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
 private void ThemePicker_SelectedIndexChanged(object sender, EventArgs e)
 {
     ThemeManager.ChangeTheme(themePicker.SelectedItem.ToString());
 }
Beispiel #2
0
        public void OverloadSettings()
        {
            Monitor.Enter(_watcherSyncObject);
            var retry      = true;
            var retryCount = 0;

            while (retry)
            {
                try
                {
                    retryCount++;
                    CreateSettingsIfNotExists();

                    var overloadSettings = _settingsUtils.GetSettings <PowerLauncherSettings>(PowerLauncherSettings.ModuleName);

                    var openPowerlauncher = ConvertHotkey(overloadSettings.Properties.OpenPowerLauncher);
                    if (_settings.Hotkey != openPowerlauncher)
                    {
                        _settings.Hotkey = openPowerlauncher;
                    }

                    var shell = PluginManager.AllPlugins.Find(pp => pp.Metadata.Name == "Shell");
                    if (shell != null)
                    {
                        var shellSettings = shell.Plugin as ISettingProvider;
                        shellSettings.UpdateSettings(overloadSettings);
                    }

                    if (_settings.MaxResultsToShow != overloadSettings.Properties.MaximumNumberOfResults)
                    {
                        _settings.MaxResultsToShow = overloadSettings.Properties.MaximumNumberOfResults;
                    }

                    if (_settings.IgnoreHotkeysOnFullscreen != overloadSettings.Properties.IgnoreHotkeysInFullscreen)
                    {
                        _settings.IgnoreHotkeysOnFullscreen = overloadSettings.Properties.IgnoreHotkeysInFullscreen;
                    }

                    // Using OrdinalIgnoreCase since this is internal
                    var indexer = PluginManager.AllPlugins.Find(p => p.Metadata.Name.Equals("Windows Indexer", StringComparison.OrdinalIgnoreCase));
                    if (indexer != null)
                    {
                        var indexerSettings = indexer.Plugin as ISettingProvider;
                        indexerSettings.UpdateSettings(overloadSettings);
                    }

                    if (_settings.ClearInputOnLaunch != overloadSettings.Properties.ClearInputOnLaunch)
                    {
                        _settings.ClearInputOnLaunch = overloadSettings.Properties.ClearInputOnLaunch;
                    }

                    if (_settings.Theme != overloadSettings.Properties.Theme)
                    {
                        _settings.Theme = overloadSettings.Properties.Theme;
                        _themeManager.ChangeTheme(_settings.Theme, _settings.Theme == Theme.System);
                    }

                    retry = false;
                }

                // the settings application can hold a lock on the settings.json file which will result in a IOException.
                // This should be changed to properly synch with the settings app instead of retrying.
                catch (IOException e)
                {
                    if (retryCount > MaxRetries)
                    {
                        retry = false;
                        Log.Exception($"Failed to Deserialize PowerToys settings, Retrying {e.Message}", e, GetType());
                    }
                    else
                    {
                        Thread.Sleep(1000);
                    }
                }
                catch (JsonException e)
                {
                    if (retryCount > MaxRetries)
                    {
                        retry = false;
                        Log.Exception($"Failed to Deserialize PowerToys settings, Creating new settings as file could be corrupted {e.Message}", e, GetType());

                        // Settings.json could possibly be corrupted. To mitigate this we delete the
                        // current file and replace it with a correct json value.
                        _settingsUtils.DeleteSettings(PowerLauncherSettings.ModuleName);
                        CreateSettingsIfNotExists();
                        ErrorReporting.ShowMessageBox(Properties.Resources.deseralization_error_title, Properties.Resources.deseralization_error_message);
                    }
                    else
                    {
                        Thread.Sleep(1000);
                    }
                }
            }

            Monitor.Exit(_watcherSyncObject);
        }
 protected override void OnStartup(StartupEventArgs e)
 {
     base.OnStartup(e);
     ThemeManager.ChangeTheme(this, Instance.GetInstance().GetParameters().GetTheme());
 }
Beispiel #4
0
 private void ChangeColor(string color)
 {
     ThemeManager.ChangeTheme(this, ThemeManager.DefaultAccents.First(accent => accent.Name == color), Theme.Dark);
 }
Beispiel #5
0
 private void MiDarkPurple(object sender, RoutedEventArgs e)
 {
     ThemeManager.ChangeTheme(this, ThemeManager.DefaultAccents.First(a => a.Name == "Purple"), Theme.Dark);
 }
Beispiel #6
0
 private void ThemeDark(object sender, RoutedEventArgs e)
 {
     this.currentTheme = Theme.Dark;
     ThemeManager.ChangeTheme(this, this.currentAccent, Theme.Dark);
 }
Beispiel #7
0
        public void ReadSettings()
        {
            Monitor.Enter(_readSyncObject);
            var retry      = true;
            var retryCount = 0;

            while (retry)
            {
                try
                {
                    retryCount++;
                    CreateSettingsIfNotExists();

                    var overloadSettings = _settingsUtils.GetSettingsOrDefault <PowerLauncherSettings>(PowerLauncherSettings.ModuleName);
                    if (overloadSettings != null)
                    {
                        Log.Info($"Successfully read new settings. retryCount={retryCount}", GetType());
                    }

                    foreach (var setting in overloadSettings.Plugins)
                    {
                        var plugin = PluginManager.AllPlugins.FirstOrDefault(x => x.Metadata.ID == setting.Id);
                        plugin?.Update(setting, App.API);
                    }

                    var openPowerlauncher = ConvertHotkey(overloadSettings.Properties.OpenPowerLauncher);
                    if (_settings.Hotkey != openPowerlauncher)
                    {
                        _settings.Hotkey = openPowerlauncher;
                    }

                    if (_settings.UseCentralizedKeyboardHook != overloadSettings.Properties.UseCentralizedKeyboardHook)
                    {
                        _settings.UseCentralizedKeyboardHook = overloadSettings.Properties.UseCentralizedKeyboardHook;
                    }

                    if (_settings.MaxResultsToShow != overloadSettings.Properties.MaximumNumberOfResults)
                    {
                        _settings.MaxResultsToShow = overloadSettings.Properties.MaximumNumberOfResults;
                    }

                    if (_settings.IgnoreHotkeysOnFullscreen != overloadSettings.Properties.IgnoreHotkeysInFullscreen)
                    {
                        _settings.IgnoreHotkeysOnFullscreen = overloadSettings.Properties.IgnoreHotkeysInFullscreen;
                    }

                    if (_settings.ClearInputOnLaunch != overloadSettings.Properties.ClearInputOnLaunch)
                    {
                        _settings.ClearInputOnLaunch = overloadSettings.Properties.ClearInputOnLaunch;
                    }

                    if (_settings.Theme != overloadSettings.Properties.Theme)
                    {
                        _settings.Theme = overloadSettings.Properties.Theme;
                        _themeManager.ChangeTheme(_settings.Theme, true);
                    }

                    if (_settings.StartupPosition != overloadSettings.Properties.Position)
                    {
                        _settings.StartupPosition = overloadSettings.Properties.Position;
                    }

                    retry = false;
                }

                // the settings application can hold a lock on the settings.json file which will result in a IOException.
                // This should be changed to properly synch with the settings app instead of retrying.
                catch (IOException e)
                {
                    if (retryCount > MaxRetries)
                    {
                        retry = false;
                        Log.Exception($"Failed to Deserialize PowerToys settings, Retrying {e.Message}", e, GetType());
                    }
                    else
                    {
                        Thread.Sleep(1000);
                    }
                }
                catch (JsonException e)
                {
                    if (retryCount > MaxRetries)
                    {
                        retry = false;
                        Log.Exception($"Failed to Deserialize PowerToys settings, Creating new settings as file could be corrupted {e.Message}", e, GetType());

                        // Settings.json could possibly be corrupted. To mitigate this we delete the
                        // current file and replace it with a correct json value.
                        _settingsUtils.DeleteSettings(PowerLauncherSettings.ModuleName);
                        CreateSettingsIfNotExists();
                        ErrorReporting.ShowMessageBox(Properties.Resources.deseralization_error_title, Properties.Resources.deseralization_error_message);
                    }
                    else
                    {
                        Thread.Sleep(1000);
                    }
                }
            }

            Monitor.Exit(_readSyncObject);
        }
 public MainWindow()
 {
     Instance = this;
     InitializeComponent();
     ThemeManager.ChangeTheme(this, ThemeManager.DefaultAccents.First(a => a.Name == "Netw"), Theme.Light);
 }
Beispiel #9
0
        /// <summary>
        /// アプリケーションがエンド ユーザーによって正常に起動されたときに呼び出されます。他のエントリ ポイントは、
        /// アプリケーションが特定のファイルを開くために起動されたときなどに使用されます。
        /// </summary>
        /// <param name="e">起動の要求とプロセスの詳細を表示します。</param>
        protected async override void OnLaunched(LaunchActivatedEventArgs e)
        {
#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif
            await JumpListCreator.CreateDefaultList();

            if (_localSettings.Values.ContainsKey(Constants.ThemeDefault))
            {
                var themeType = (ThemeTypes)_localSettings.Values[Constants.ThemeDefault];
                switch (themeType)
                {
                case ThemeTypes.YOSPOS:
                    ThemeManager.SetThemeManager(ElementTheme.Dark);
                    ThemeManager.ChangeTheme(new Uri("ms-appx:///Themes/Yospos.xaml"));
                    break;
                }
            }
            SystemNavigationManager.GetForCurrentView().BackRequested += BackPressed;
            RootFrame = Window.Current.Content as Frame;
            if (_localSettings.Values.ContainsKey(Constants.NavigateBack) &&
                (bool)_localSettings.Values[Constants.NavigateBack])
            {
                if (RootFrame != null)
                {
                    return;
                }
            }
            var isIoT = ApiInformation.IsTypePresent("Windows.Devices.Gpio.GpioController");

            if (!isIoT)
            {
                TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true);
            }

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (RootFrame == null)
            {
                CreateRootFrame();
            }
            if (!isIoT)
            {
                BackgroundTaskUtils.UnregisterBackgroundTasks(BackgroundTaskUtils.ToastBackgroundTaskName);
                var task2 = await
                            BackgroundTaskUtils.RegisterBackgroundTask(BackgroundTaskUtils.ToastBackgroundTaskEntryPoint,
                                                                       BackgroundTaskUtils.ToastBackgroundTaskName, new ToastNotificationActionTrigger(),
                                                                       null);

                if (_localSettings.Values.ContainsKey(Constants.BackgroundEnable) && (bool)_localSettings.Values[Constants.BackgroundEnable])
                {
                    BackgroundTaskUtils.UnregisterBackgroundTasks(BackgroundTaskUtils.BackgroundTaskName);
                    var task = await
                               BackgroundTaskUtils.RegisterBackgroundTask(BackgroundTaskUtils.BackgroundTaskEntryPoint,
                                                                          BackgroundTaskUtils.BackgroundTaskName,
                                                                          new TimeTrigger(15, false),
                                                                          null);
                }
            }

            var             localStorageManager = new LocalStorageManager();
            CookieContainer cookieContainer     = await localStorageManager.LoadCookie("SACookies2.txt");

            bool cookieTest = true;
            foreach (Cookie cookie in cookieContainer.GetCookies(new Uri(Constants.CookieDomainUrl)))
            {
                if (cookie.Expired)
                {
                    cookieTest = false;
                }
            }

            if (cookieContainer.Count <= 0)
            {
                if (!RootFrame.Navigate(typeof(LoginPage)))
                {
                    throw new Exception("Failed to create initial page");
                }
            }
            else
            {
                if (!cookieTest)
                {
                    if (!RootFrame.Navigate(typeof(LoginPage)))
                    {
                        throw new Exception("Failed to create initial page");
                    }
                }

                if (!RootFrame.Navigate(typeof(MainPage), e.Arguments))
                {
                    throw new Exception("Failed to create initial page");
                }
            }
            // Ensure the current window is active
            Window.Current.Activate();

            try
            {
                // Install the main VCD. Since there's no simple way to test that the VCD has been imported, or that it's your most recent
                // version, it's not unreasonable to do this upon app load.
                StorageFile vcdStorageFile = await Package.Current.InstalledLocation.GetFileAsync(@"SomethingAwfulCommands.xml");

                await Windows.ApplicationModel.VoiceCommands.VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(vcdStorageFile);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Installing Voice Commands Failed: " + ex.ToString());
            }
        }
Beispiel #10
0
 public void ChangeTheme(string themeName)
 {
     ThemeManager.ChangeTheme(Application.Current, themeName);
 }
Beispiel #11
0
 public void ChangeThemeForAppShouldThrowArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => ThemeManager.ChangeTheme((Application)null, ThemeManager.GetTheme("Light.Red")));
     Assert.Throws <ArgumentNullException>(() => ThemeManager.ChangeTheme(Application.Current, ThemeManager.GetTheme("UnknownTheme")));
 }
Beispiel #12
0
        public static void ApplyWindowTheme(UserControl control)
        {
            var windowTheme = GetWindowTheme(control.GetType().FullName);

            ThemeManager.ChangeTheme(control.Resources, windowTheme.theme);
        }
Beispiel #13
0
        public static void ApplyWindowTheme(BaseWindow window)
        {
            var windowTheme = GetWindowTheme(window);

            ThemeManager.ChangeTheme(window.Resources, windowTheme.theme);
        }
Beispiel #14
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            var dm = new DefaultDockingManager
            {
                DocumentPaneControlStyle   = FindResource("AvalonDockThemeCustomDocumentPaneControlStyle") as Style,
                AnchorablePaneControlStyle = FindResource("AvalonDockThemeCustomAnchorablePaneControlStyle") as Style,
            };

            dm.SetResourceReference(Control.BackgroundProperty, "MahApps.Brushes.White");

            var shell = UiStarter.Start <IDockWindow>(
                new Bootstrap(),
                new UiShowStartWindowOptions
            {
                Title          = "Domain0.Desktop",
                DockingManager = dm,
            }
                );

            shell.SetContainerWidth(DefaultDockingManager.Tools, new GridLength(60));

            // log trace to monik
            var monik = shell.Container.Resolve <IMonik>();

            Trace.Listeners.Add(new MonikTraceListener(monik));
            // catch unhandled exceptions
            AppDomain.CurrentDomain.UnhandledException += (sender, args) =>
            {
                if (args.IsTerminating)
                {
                    monik.ApplicationFatal("Unhandled fatal exception: {1}", args.ExceptionObject);
                }
                else
                {
                    monik.ApplicationError("Unhandled exception: {1}", args.ExceptionObject);
                }
            };

            var config = shell.Container.Resolve <IAppConfigStorage>().Load();

            ThemeManager.ChangeTheme(this, config.AppTheme, config.AccentColor);

            shell.ShowTool <ManageToolsView>(new ViewRequest("manage-tools"), new UiShowOptions {
                Title = "Tools"
            });
            shell.ShowUsers();

            var domain0      = shell.Container.Resolve <IDomain0Service>();
            var loginService = shell.Container.Resolve <ILoginService>();

            if (config.HostUrl != null && loginService.IsLoggedIn)
            {
                shell.Container.Resolve <IAuthenticationContext>().HostUrl = config.HostUrl;
                domain0.LoadModel();
            }
            else
            {
                loginService.ShowLogin(() => domain0.LoadModel());
            }
        }
Beispiel #15
0
        private void ChangeAccent(string accentName)
        {
            this.currentAccent = ThemeManager.DefaultAccents.First(x => x.Name == accentName);

            ThemeManager.ChangeTheme(this, this.currentAccent, this.currentTheme);
        }
Beispiel #16
0
        public void OverloadSettings()
        {
            Monitor.Enter(_watcherSyncObject);
            var retry      = true;
            var retryCount = 0;

            while (retry)
            {
                try
                {
                    retryCount++;
                    CreateSettingsIfNotExists();

                    var overloadSettings = _settingsUtils.GetSettingsOrDefault <PowerLauncherSettings>(PowerLauncherSettings.ModuleName);

                    if (overloadSettings.Plugins == null || overloadSettings.Plugins.Count() != PluginManager.AllPlugins.Count)
                    {
                        // Needed to be consistent with old settings
                        overloadSettings.Plugins = CombineWithDefaultSettings(overloadSettings.Plugins);
                        _settingsUtils.SaveSettings(overloadSettings.ToJsonString(), PowerLauncherSettings.ModuleName);
                    }
                    else
                    {
                        foreach (var setting in overloadSettings.Plugins)
                        {
                            var plugin = PluginManager.AllPlugins.FirstOrDefault(x => x.Metadata.ID == setting.Id);
                            if (plugin != null)
                            {
                                plugin.Metadata.Disabled      = setting.Disabled;
                                plugin.Metadata.ActionKeyword = setting.ActionKeyword;
                                plugin.Metadata.IsGlobal      = setting.IsGlobal;
                                if (plugin.Plugin is ISettingProvider)
                                {
                                    (plugin.Plugin as ISettingProvider).UpdateSettings(setting);
                                }
                            }
                        }
                    }

                    var openPowerlauncher = ConvertHotkey(overloadSettings.Properties.OpenPowerLauncher);
                    if (_settings.Hotkey != openPowerlauncher)
                    {
                        _settings.Hotkey = openPowerlauncher;
                    }

                    if (_settings.MaxResultsToShow != overloadSettings.Properties.MaximumNumberOfResults)
                    {
                        _settings.MaxResultsToShow = overloadSettings.Properties.MaximumNumberOfResults;
                    }

                    if (_settings.IgnoreHotkeysOnFullscreen != overloadSettings.Properties.IgnoreHotkeysInFullscreen)
                    {
                        _settings.IgnoreHotkeysOnFullscreen = overloadSettings.Properties.IgnoreHotkeysInFullscreen;
                    }

                    if (_settings.ClearInputOnLaunch != overloadSettings.Properties.ClearInputOnLaunch)
                    {
                        _settings.ClearInputOnLaunch = overloadSettings.Properties.ClearInputOnLaunch;
                    }

                    if (_settings.Theme != overloadSettings.Properties.Theme)
                    {
                        _settings.Theme = overloadSettings.Properties.Theme;
                        _themeManager.ChangeTheme(_settings.Theme, true);
                    }

                    if (_settings.StartupPosition != overloadSettings.Properties.Position)
                    {
                        _settings.StartupPosition = overloadSettings.Properties.Position;
                    }

                    retry = false;
                }

                // the settings application can hold a lock on the settings.json file which will result in a IOException.
                // This should be changed to properly synch with the settings app instead of retrying.
                catch (IOException e)
                {
                    if (retryCount > MaxRetries)
                    {
                        retry = false;
                        Log.Exception($"Failed to Deserialize PowerToys settings, Retrying {e.Message}", e, GetType());
                    }
                    else
                    {
                        Thread.Sleep(1000);
                    }
                }
                catch (JsonException e)
                {
                    if (retryCount > MaxRetries)
                    {
                        retry = false;
                        Log.Exception($"Failed to Deserialize PowerToys settings, Creating new settings as file could be corrupted {e.Message}", e, GetType());

                        // Settings.json could possibly be corrupted. To mitigate this we delete the
                        // current file and replace it with a correct json value.
                        _settingsUtils.DeleteSettings(PowerLauncherSettings.ModuleName);
                        CreateSettingsIfNotExists();
                        ErrorReporting.ShowMessageBox(Properties.Resources.deseralization_error_title, Properties.Resources.deseralization_error_message);
                    }
                    else
                    {
                        Thread.Sleep(1000);
                    }
                }
            }

            Monitor.Exit(_watcherSyncObject);
        }
Beispiel #17
0
 private void ThemeLight(object sender, RoutedEventArgs e)
 {
     this.currentTheme = Theme.Light;
     ThemeManager.ChangeTheme(this, this.currentAccent, Theme.Light);
 }
        public MainWindow()
        {
            System.Diagnostics.PresentationTraceSources.DataBindingSource.Switch.Level        = System.Diagnostics.SourceLevels.Critical;
            System.Diagnostics.PresentationTraceSources.ResourceDictionarySource.Switch.Level = System.Diagnostics.SourceLevels.Critical;
            InitializeComponent();
            ReturnToPage.Visibility = Visibility.Hidden;
            //Client.ExecutingDirectory = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            //Keep this this way that way the auto updator knows what to update
            var ExecutingDirectory = System.IO.Directory.GetParent(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location));

            Client.ExecutingDirectory           = ExecutingDirectory.ToString().Replace("file:\\", "");
            LCLog.WriteToLog.ExecutingDirectory = Client.ExecutingDirectory;
            LCLog.WriteToLog.LogfileName        = "LegendaryClient.Log";
            LCLog.WriteToLog.CreateLogFile();
            AppDomain.CurrentDomain.FirstChanceException += LCLog.Log.CurrentDomain_FirstChanceException;
            AppDomain.CurrentDomain.UnhandledException   += LCLog.Log.AppDomain_CurrentDomain;

            Client.InfoLabel = InfoLabel;
            Client.PVPNet    = new PVPNetConnection();
            Client.PVPNet.KeepDelegatesOnLogout = false;
            Client.PVPNet.OnError += Client.PVPNet_OnError;
            if (String.IsNullOrEmpty(Properties.Settings.Default.Theme))
            {
                Properties.Settings.Default.Theme = "pack://application:,,,/LegendaryClient;component/Controls/Steel.xaml";
            }
            myAccent = new Accent("AccentName", new Uri(Properties.Settings.Default.Theme));
            ThemeManager.ChangeTheme(this, myAccent, (Properties.Settings.Default.DarkTheme) ? Theme.Dark : Theme.Light);

            Client.ChatClient                    = new JabberClient();
            Client.FriendList                    = new FriendList();
            ChatContainer.Content                = Client.FriendList.Content;
            Client.notificationPage              = new NotificationPage();
            NotificationContainer.Content        = Client.notificationPage.Content;
            Client.statusPage                    = new StatusPage();
            StatusContainer.Content              = Client.statusPage.Content;
            NotificationOverlayContainer.Content = new FakePage().Content;

            Grid NotificationTempGrid = null;

            foreach (var x in NotificationOverlayContainer.GetChildObjects())
            {
                if (x is Grid)
                {
                    NotificationTempGrid = x as Grid;
                }
            }

            Client.PlayButton                   = PlayButton;
            Client.Pages                        = new List <Page>();
            Client.MainGrid                     = MainGrid;
            Client.BackgroundImage              = BackImage;
            Client.NotificationGrid             = NotificationTempGrid;
            Client.MainWin                      = this;
            Client.Container                    = Container;
            Client.OverlayContainer             = OverlayContainer;
            Client.NotificationContainer        = NotificationContainer;
            Client.ChatContainer                = ChatContainer;
            Client.StatusContainer              = StatusContainer;
            Client.ReturnButton                 = ReturnToPage;
            Client.NotificationOverlayContainer = NotificationOverlayContainer;
            Client.SoundPlayer                  = SoundPlayer;
            Client.AmbientSoundPlayer           = ASoundPlayer;
            Client.SwitchPage(new PatcherPage());

            if (!String.IsNullOrEmpty(Properties.Settings.Default.LoginPageImage) && Properties.Settings.Default.UseAsBackgroundImage)
            {
                if (File.Exists(Path.Combine(Client.ExecutingDirectory, "Assets", "champions", Properties.Settings.Default.LoginPageImage.Replace("\r\n", ""))))
                {
                    Client.BackgroundImage.Source = new BitmapImage(new Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "champions", Properties.Settings.Default.LoginPageImage), UriKind.Absolute));
                }
            }
        }
 public void SetThemeAsync(string theme)
 {
     ThemeManager.ChangeTheme(theme == "Light" ? AppTheme.Light : AppTheme.Dark);
 }
 private void Dark_Click(object sender, RoutedEventArgs e)
 {
     currentTheme = Theme.Dark;
     this.window_Grid.Background = null;
     ThemeManager.ChangeTheme(this, currentAccent, Theme.Dark);
 }
Beispiel #21
0
 private void CbBoxTheme_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     ThemeManager.ChangeTheme((ITheme)CbBoxTheme.SelectedItem);
 }
Beispiel #22
0
        /// <summary>
        /// アプリケーションがエンド ユーザーによって正常に起動されたときに呼び出されます。他のエントリ ポイントは、
        /// アプリケーションが特定のファイルを開くために起動されたときなどに使用されます。
        /// </summary>
        /// <param name="e">起動の要求とプロセスの詳細を表示します。</param>
        protected async override void OnLaunched(LaunchActivatedEventArgs e)
        {
#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif
            if (_localSettings.Values.ContainsKey(Constants.ThemeDefault))
            {
                var themeType = (ThemeTypes)_localSettings.Values[Constants.ThemeDefault];
                switch (themeType)
                {
                case ThemeTypes.YOSPOS:
                    ThemeManager.SetThemeManager(ElementTheme.Dark);
                    ThemeManager.ChangeTheme(new Uri("ms-appx:///Themes/Yospos.xaml"));
                    break;
                }
            }
            SystemNavigationManager.GetForCurrentView().BackRequested += BackPressed;
            RootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (RootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                RootFrame = new Frame();
                // Set the default language
                RootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0];

                RootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = RootFrame;
            }

            if (_localSettings.Values.ContainsKey(Constants.BookmarkBackground) && (bool)_localSettings.Values[Constants.BookmarkBackground])
            {
                BackgroundTaskUtils.UnregisterBackgroundTasks(BackgroundTaskUtils.BackgroundTaskName);
                var task = await
                           BackgroundTaskUtils.RegisterBackgroundTask(BackgroundTaskUtils.BackgroundTaskEntryPoint,
                                                                      BackgroundTaskUtils.BackgroundTaskName,
                                                                      new TimeTrigger(15, false),
                                                                      null);
            }

            var             localStorageManager = new LocalStorageManager();
            CookieContainer cookieTest          = await localStorageManager.LoadCookie("SACookies2.txt");

            if (cookieTest.Count <= 0)
            {
                if (!RootFrame.Navigate(typeof(LoginPage)))
                {
                    throw new Exception("Failed to create initial page");
                }
            }
            else
            {
                if (!RootFrame.Navigate(typeof(MainPage), e.Arguments))
                {
                    throw new Exception("Failed to create initial page");
                }
            }
            // Ensure the current window is active
            Window.Current.Activate();
        }
Beispiel #23
0
        internal void ChangeFlyoutTheme(Accent windowAccent, Theme windowTheme)
        {
            switch (this.Theme)
            {
            case Orm.Toolkit.Metro.Controls.FlyoutTheme.Adapt:
                ThemeManager.ChangeTheme(base.Resources, windowAccent, windowTheme);
                switch (windowTheme)
                {
                case Orm.Toolkit.Metro.Theme.Light:
                    base.SetResourceReference(Control.ForegroundProperty, "BlackColorBrush");
                    base.SetResourceReference(Control.BackgroundProperty, "FlyoutLightBrush");
                    goto Label_00B8;

                case Orm.Toolkit.Metro.Theme.Dark:
                    base.SetResourceReference(Control.ForegroundProperty, "BlackColorBrush");
                    base.SetResourceReference(Control.BackgroundProperty, "FlyoutDarkBrush");
                    goto Label_00B8;
                }
                break;

            case Orm.Toolkit.Metro.Controls.FlyoutTheme.Inverse:
                switch (windowTheme)
                {
                case Orm.Toolkit.Metro.Theme.Light:
                    ThemeManager.ChangeTheme(base.Resources, windowAccent, Orm.Toolkit.Metro.Theme.Dark);
                    base.Background  = (Brush)ThemeManager.LightResource["FlyoutDarkBrush"];
                    base.Foreground  = (Brush)ThemeManager.LightResource["WhiteColorBrush"];
                    this.ActualTheme = Orm.Toolkit.Metro.Theme.Dark;
                    return;

                case Orm.Toolkit.Metro.Theme.Dark:
                    ThemeManager.ChangeTheme(base.Resources, windowAccent, Orm.Toolkit.Metro.Theme.Light);
                    base.Background  = (Brush)ThemeManager.DarkResource["FlyoutLightBrush"];
                    base.Foreground  = (Brush)ThemeManager.DarkResource["WhiteColorBrush"];
                    this.ActualTheme = Orm.Toolkit.Metro.Theme.Light;
                    return;
                }
                return;

            case Orm.Toolkit.Metro.Controls.FlyoutTheme.Dark:
                ThemeManager.ChangeTheme(base.Resources, windowAccent, Orm.Toolkit.Metro.Theme.Dark);
                base.SetResourceReference(Control.BackgroundProperty, "FlyoutDarkBrush");
                base.SetResourceReference(Control.ForegroundProperty, "BlackColorBrush");
                this.ActualTheme = Orm.Toolkit.Metro.Theme.Dark;
                return;

            case Orm.Toolkit.Metro.Controls.FlyoutTheme.Light:
                ThemeManager.ChangeTheme(base.Resources, windowAccent, Orm.Toolkit.Metro.Theme.Light);
                base.SetResourceReference(Control.BackgroundProperty, "FlyoutLightBrush");
                base.SetResourceReference(Control.ForegroundProperty, "BlackColorBrush");
                this.ActualTheme = Orm.Toolkit.Metro.Theme.Light;
                return;

            case Orm.Toolkit.Metro.Controls.FlyoutTheme.Accent:
                ThemeManager.ChangeTheme(base.Resources, windowAccent, windowTheme);
                base.SetResourceReference(Control.BackgroundProperty, "HighlightBrush");
                base.SetResourceReference(Control.ForegroundProperty, "IdealForegroundColorBrush");
                this.ActualTheme = windowTheme;
                return;

            default:
                return;
            }
Label_00B8:
            this.ActualTheme = windowTheme;
        }
Beispiel #24
0
        private void ThemeDark(object sender, RoutedEventArgs e)
        {
            var theme = ThemeManager.DetectTheme(Application.Current);

            ThemeManager.ChangeTheme(Application.Current, theme.Item2, Theme.Dark);
        }
Beispiel #25
0
 public void ChangeAccentColor(string color)
 {
     Core.SettingsModel.Instance.AccentColor = color;
     ThemeManager.ChangeTheme(IoC.Get <ShellView>(),
                              ThemeManager.DefaultAccents.First(accent => accent.Name == color), SelectedTheme);
 }
Beispiel #26
0
 private void OnThemeChanged()
 {
     ThemeManager.ChangeTheme(new Uri(string.Format(Constants.ThemeFiles.ThemeFileFormat, Theme)));
 }
 /// <summary>
 /// Sets the current theme to one of the toolkit's valid themes.
 /// </summary>
 /// <param name="themeManager">The <see cref="ThemeManager"/>.</param>
 /// <param name="theme">The requested application theme.</param>
 public static void ChangeTheme(this ThemeManager themeManager, ApplicationTheme theme)
 {
     themeManager.ChangeTheme(theme.ToThemeName());
 }
 /// <summary>
 /// Themes the changed.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="ThemeChangedEventArgs"/> instance containing the event data.</param>
 public void ThemeChanged(
     object sender,
     ThemeChangedEventArgs e)
 {
     ThemeManager.ChangeTheme(this.Resources, e.Accent, e.Theme);
 }
 private void MiLightOrange(object sender, RoutedEventArgs e)
 {
     ThemeManager.ChangeTheme(this, ThemeManager.DefaultAccents.First(a => a.Name == "Orange"), Theme.Light);
 }
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     navegador.Navigate(new project.recso.bascula.frontend.wpf.inicio());
     this.Title += "  Version " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
     ThemeManager.ChangeTheme(this, ThemeManager.DefaultAccents.First(a => a.Name == "Green"), Theme.Dark);
 }