public async Task GetInverseAppThemeReturnsNullForMissingTheme()
        {
            await TestHost.SwitchToAppThread();

            var appTheme = new AppTheme("TestTheme", new Uri("pack://application:,,,/MVVMApps.Metro;component/Styles/Accents/BaseDark.xaml"));

            AppTheme theme = ThemeManager.GetInverseAppTheme(appTheme);

            Assert.Null(theme);
        }
Exemple #2
0
 private static void SetLightTheme()
 {
     _currentTheme = AppTheme.Light;
     _useLightIcons = false;
     _backgroundColor = Color.FromHex("EEFCED");
     _navBackgroundColor = Color.FromHex("C0D1CF");
     _textColor = Color.FromHex("686963");
     _headerColor = Color.FromHex("809DB5");
     _linkColor = Color.FromHex("DB5461");
     _frameColor = Color.FromHex("C0D1CF");
     _frameBorderColor = Color.FromHex("809DB5");
     _buttonBackgroundColor = Color.FromHex("C0D1CF");
     _buttonTextColor = Color.FromHex("DB5461");
 }
Exemple #3
0
 internal static void SetTheme(AppTheme theme)
 {
     switch (theme)
     {
         case AppTheme.Light:
             SetLightTheme();
             break;
         case AppTheme.Dark:
             SetDarkTheme();
             break;
         case AppTheme.Night:
             SetNightTheme();
             break;
         case AppTheme.Contrast:
             SetContrastTheme();
             break;
         default:
             SetLightTheme();
             break;
     }
 }
		void SetTheme(AppTheme themeType, Theme theme)
		{
			Settings.AppTheme = themeType;
			Theme.Current = theme;
			ThemeSelectorContainerView.Hidden = true;
		}
Exemple #5
0
        public AppTheme GetCurrentTheme()
        {
            var currentThemeName = PreferencesService?.GetPreferences()?.ThemeName;

            return(AppTheme.GenerateNew(currentThemeName ?? AppTheme.GenerateDefault().ThemeName));
        }
Exemple #6
0
        //-----------------------------------------------------------------------------------------------------------------------

        //***********************************************************************************************************************
        /// <summary>
        /// Génère les styles.
        /// </summary>
        //-----------------------------------------------------------------------------------------------------------------------
        private static string Generate()
        {
            //-------------------------------------------------------------------------------------------------------------------
            #region             // Implémentation de la Procédure
            //-------------------------------------------------------------------------------------------------------------------

            //-------------------------------------------------------------------------------------------------------------------
            try
            {
                //---------------------------------------------------------------------------------------------------------------
                AppTheme CurrentTheme = StyleSheets.Theme;

                string BodyBackColor = (CurrentTheme == AppTheme.Dark) ? "151515" : "EAEAEA";
                string BodyForeColor = (CurrentTheme == AppTheme.Dark) ? "FFF"    : "000";
                string BodyGrayColor = (CurrentTheme == AppTheme.Dark) ? "AAA"    : "444";
                string DateBackColor = (CurrentTheme == AppTheme.Dark) ? "A0A0A0" : "303030";
                string DateForeColor = (CurrentTheme == AppTheme.Dark) ? "000"    : "FFF";
                string SepaBackColor = (CurrentTheme == AppTheme.Dark) ? "999999" : "999999";
                string LinkForeColor = (CurrentTheme == AppTheme.Dark) ? "FFF"    : "0000EE";

                string Content = string.Empty;

                using (StringReader Sr = new StringReader(SR.GetResource("Global", "Cont.css")))
                {
                    string Line;

                    while ((Line = Sr.ReadLine()) != null)
                    {
                        if (Line.StartsWith("/"))
                        {
                            continue;
                        }
                        if (Line.Length == 0)
                        {
                            continue;
                        }

                        Content += Line;
                    }
                }
                //---------------------------------------------------------------------------------------------------------------

                //---------------------------------------------------------------------------------------------------------------
                switch (StyleSheets.TextLevel)
                {
                //-----------------------------------------------------------------------------------------------------------
                case TextLevel.Small: return(string.Format(Content,
                                                           BodyBackColor,
                                                           BodyForeColor,
                                                           BodyGrayColor,
                                                           DateBackColor,
                                                           DateForeColor,
                                                           SepaBackColor,
                                                           LinkForeColor,

                                                           14, 16, 10, 12,
                                                           18, 20, 10, 12, 14, 16,
                                                           18, 20, 12, 14,
                                                           18, 20, 16, 18));

                //-----------------------------------------------------------------------------------------------------------
                case TextLevel.Large: return(string.Format(Content,
                                                           BodyBackColor,
                                                           BodyForeColor,
                                                           BodyGrayColor,
                                                           DateBackColor,
                                                           DateForeColor,
                                                           SepaBackColor,
                                                           LinkForeColor,

                                                           20, 22, 16, 18,
                                                           24, 26, 16, 18, 20, 22,
                                                           24, 26, 18, 20,
                                                           24, 26, 22, 24));

                //-----------------------------------------------------------------------------------------------------------
                default: return(string.Format(Content,
                                              BodyBackColor,
                                              BodyForeColor,
                                              BodyGrayColor,
                                              DateBackColor,
                                              DateForeColor,
                                              SepaBackColor,
                                              LinkForeColor,

                                              16, 18, 12, 14,
                                              20, 22, 12, 14, 16, 18,
                                              20, 22, 14, 16,
                                              20, 22, 18, 20));
                    //-----------------------------------------------------------------------------------------------------------
                }
                //---------------------------------------------------------------------------------------------------------------
            }
            //-------------------------------------------------------------------------------------------------------------------
            catch {}
            //-------------------------------------------------------------------------------------------------------------------

            //-------------------------------------------------------------------------------------------------------------------
            return(string.Empty);

            //-------------------------------------------------------------------------------------------------------------------

            //-------------------------------------------------------------------------------------------------------------------
            #endregion
            //-------------------------------------------------------------------------------------------------------------------
        }
Exemple #7
0
 public AppThemeChangedEventArgs(AppTheme appTheme) =>
        protected override void OnCreate(Bundle savedInstanceState)
        {
            RequestWindowFeature(Android.Views.WindowFeatures.NoTitle);
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            AppTheme.SetThemeFullScreen(this);
            AppTheme.SetThemeNeedMenuKey(this);
            ActManager.Instance.CurrentActivity = this;

            mLicenseValid = App.Instance().CheckLicense();
            if (!mLicenseValid)
            {
                return;
            }

            if (this.Intent != null && this.Intent.Action != null)
            {
                filter = Intent.Action;
            }

            if (Build.VERSION.SdkInt > BuildVersionCodes.Q && !AppFileUtil.IsExternalStorageLegacy)
            {
                AppStorageManager storageManager = AppStorageManager.GetInstance(this);
                bool needPermission = storageManager.NeedManageExternalStoragePermission();
                if (!AppStorageManager.IsExternalStorageManager && needPermission)
                {
                    storageManager.RequestExternalStorageManager(this, REQUEST_EXTERNAL_STORAGE_MANAGER);
                }
                else if (!needPermission)
                {
                    CheckStorageState();
                }
            }
            else if (Build.VERSION.SdkInt > BuildVersionCodes.M)
            {
                CheckStorageState();
            }

            if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.N)
            {
                StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
                StrictMode.SetVmPolicy(builder.Build());
            }

            AppStorageManager.OpenTreeRequestCode = REQUEST_OPEN_DOCUMENT_TREE;
            LocalModule local = App.Instance().GetLocalModule(filter);

            local.SetAttachedActivity(this);
            App.Instance().CopyGuideFiles(local);
            local.SetFileItemEventListener(this);
            local.SetCompareListener(this);
            local.SetOnFilePathChangeListener(this);

            View      view   = local.GetContentView(this.ApplicationContext);
            ViewGroup parent = (ViewGroup)view.Parent;

            if (parent != null)
            {
                parent.RemoveView(view);
            }
            SetContentView(view);

            HandleIntent(this.Intent);
        }
Exemple #9
0
        private void ProcessAppThemeUpdate()
        {
            if (ViewModel.AppTheme == 0)
            {
                return;
            }

            if (_updatingAccent || !_initialized)
            {
                foreach (var accentButton in _accentButtons)
                {
                    accentButton.SetImageResource(0);
                }

                if ((ViewModel.AppTheme & AppTheme.Orange) == AppTheme.Orange)
                {
                    ColorOrangeAccentButton.SetImageResource(Resource.Drawable.icon_tick);
                    _selectedAccent = AppTheme.Orange;
                }
                else if ((ViewModel.AppTheme & AppTheme.Lime) == AppTheme.Lime)
                {
                    ColorLimeAccentButton.SetImageResource(Resource.Drawable.icon_tick);
                    _selectedAccent = AppTheme.Lime;
                }
                else if ((ViewModel.AppTheme & AppTheme.Cyan) == AppTheme.Cyan)
                {
                    ColorCyanAccentButton.SetImageResource(Resource.Drawable.icon_tick);
                    _selectedAccent = AppTheme.Cyan;
                }
                else if ((ViewModel.AppTheme & AppTheme.Purple) == AppTheme.Purple)
                {
                    ColorPurpleAccentButton.SetImageResource(Resource.Drawable.icon_tick);
                    _selectedAccent = AppTheme.Purple;
                }
                else if ((ViewModel.AppTheme & AppTheme.SkyBlue) == AppTheme.SkyBlue)
                {
                    ColorBlueAccentButton.SetImageResource(Resource.Drawable.icon_tick);
                    _selectedAccent = AppTheme.SkyBlue;
                }
                else if ((ViewModel.AppTheme & AppTheme.Red) == AppTheme.Red)
                {
                    ColorRedAccentButton.SetImageResource(Resource.Drawable.icon_tick);
                    _selectedAccent = AppTheme.Red;
                }
                else if ((ViewModel.AppTheme & AppTheme.Pink) == AppTheme.Pink)
                {
                    ColorPinkAccentButton.SetImageResource(Resource.Drawable.icon_tick);
                    _selectedAccent = AppTheme.Pink;
                }
            }

            if (_updatingTheme || !_initialized)
            {
                foreach (var radioButton in _radioButtons)
                {
                    radioButton.Checked = false;
                }

                if ((ViewModel.AppTheme & AppTheme.Dark) == AppTheme.Dark)
                {
                    DarkThemeRadioButton.Checked = true;
                    _selectedTheme = AppTheme.Dark;
                }
                else if ((ViewModel.AppTheme & AppTheme.Black) == AppTheme.Black)
                {
                    BlackThemeRadioButton.Checked = true;
                    _selectedTheme = AppTheme.Black;
                }
                else if ((ViewModel.AppTheme & AppTheme.Light) == AppTheme.Light)
                {
                    LightThemeRadioButton.Checked = true;
                    _selectedTheme = AppTheme.Light;
                }
            }

            _initialized = true;
        }
        public static void SetTheme(MainForm form, AppTheme theme)
        {
            Properties.Settings.Default.ThemeIndex = (int)theme;

            Label closeLabel   = form.Controls.Find("CloseLabel", true).FirstOrDefault() as Label,
                  closeLabel2  = form.Controls.Find("CloseLabel2", true).FirstOrDefault() as Label,
                  closeLabel3  = form.Controls.Find("CloseLabel3", true).FirstOrDefault() as Label,
                  refreshLabel = form.Controls.Find("RefreshLabel", true).FirstOrDefault() as Label;

            switch (theme)
            {
            case AppTheme.Monolith:
                Properties.Settings.Default.AppColourBg        = Color.Gray;
                Properties.Settings.Default.AppColourHover     = Color.FromArgb(120, 120, 120);
                Properties.Settings.Default.AppColourMenu      = Color.DimGray;
                Properties.Settings.Default.AppColourMenuHover = Color.FromArgb(116, 116, 116);
                Properties.Settings.Default.AppColourHighlight = Color.Silver;
                Properties.Settings.Default.AppColourText      = Color.WhiteSmoke;
                closeLabel.Image   = closeLabel2.Image = closeLabel3.Image = Properties.Resources.close_icon_alt;
                refreshLabel.Image = Properties.Resources.refresh_icon_alt;
                break;

            case AppTheme.Forest:
                Properties.Settings.Default.AppColourBg        = Color.PaleGreen;
                Properties.Settings.Default.AppColourHover     = Color.LightGreen;
                Properties.Settings.Default.AppColourMenu      = Color.LightGreen;
                Properties.Settings.Default.AppColourMenuHover = Color.FromArgb(121, 225, 121);
                Properties.Settings.Default.AppColourHighlight = Color.LimeGreen;
                Properties.Settings.Default.AppColourText      = Color.DarkGreen;
                closeLabel.Image   = closeLabel2.Image = closeLabel3.Image = Properties.Resources.close_icon;
                refreshLabel.Image = Properties.Resources.refresh_icon;
                break;

            case AppTheme.Azure:
                Properties.Settings.Default.AppColourBg        = Color.Azure;
                Properties.Settings.Default.AppColourHover     = Color.FromArgb(210, 255, 255);
                Properties.Settings.Default.AppColourMenu      = Color.LightCyan;
                Properties.Settings.Default.AppColourMenuHover = Color.FromArgb(200, 255, 255);
                Properties.Settings.Default.AppColourHighlight = Color.White;
                Properties.Settings.Default.AppColourText      = Color.DarkSlateGray;
                closeLabel.Image   = closeLabel2.Image = closeLabel3.Image = Properties.Resources.close_icon;
                refreshLabel.Image = Properties.Resources.refresh_icon;
                break;

            case AppTheme.Ghost:
                Properties.Settings.Default.AppColourBg        = Color.FromArgb(150, 127, 153);
                Properties.Settings.Default.AppColourHover     = Color.FromArgb(139, 127, 140);
                Properties.Settings.Default.AppColourMenu      = Color.FromArgb(172, 126, 178);
                Properties.Settings.Default.AppColourMenuHover = Color.FromArgb(161, 127, 166);
                Properties.Settings.Default.AppColourHighlight = Color.FromArgb(195, 126, 204);
                Properties.Settings.Default.AppColourText      = Color.White;
                closeLabel.Image   = closeLabel2.Image = closeLabel3.Image = Properties.Resources.close_icon_alt;
                refreshLabel.Image = Properties.Resources.refresh_icon_alt;
                break;
            }

            Properties.Settings.Default.Save();

            form.BackColor =
                form.Controls.Find("ShowsList", true).FirstOrDefault().BackColor                    =
                    form.Controls.Find("MainDriveTextbox", true).FirstOrDefault().BackColor         =
                        form.Controls.Find("Shortcut1Textbox", true).FirstOrDefault().BackColor     =
                            form.Controls.Find("Shortcut2Textbox", true).FirstOrDefault().BackColor =
                                Properties.Settings.Default.AppColourBg;

            form.Controls.Find("MenuPanel", true).FirstOrDefault().BackColor              =
                form.Controls.Find("GoButton", true).FirstOrDefault().BackColor           =
                    form.Controls.Find("RerollButton", true).FirstOrDefault().BackColor   =
                        form.Controls.Find("SaveButton", true).FirstOrDefault().BackColor =
                            Properties.Settings.Default.AppColourMenu;

            form.Controls.Find("TitleLabel", true).FirstOrDefault().BackColor                                  =
                form.Controls.Find("TitleLabel2", true).FirstOrDefault().BackColor                             =
                    form.Controls.Find("TitleLabel3", true).FirstOrDefault().BackColor                         =
                        form.Controls.Find("MinimiseLabel", true).FirstOrDefault().BackColor                   =
                            form.Controls.Find("MinimiseLabel2", true).FirstOrDefault().BackColor              =
                                form.Controls.Find("MinimiseLabel3", true).FirstOrDefault().BackColor          =
                                    form.Controls.Find("CloseLabel", true).FirstOrDefault().BackColor          =
                                        form.Controls.Find("CloseLabel2", true).FirstOrDefault().BackColor     =
                                            form.Controls.Find("CloseLabel3", true).FirstOrDefault().BackColor =
                                                Properties.Settings.Default.AppColourMenuHover;


            Button GoButton     = form.Controls.Find("GoButton", true).FirstOrDefault() as Button,
                   SaveButton   = form.Controls.Find("SaveButton", true).FirstOrDefault() as Button,
                   RerollButton = form.Controls.Find("RerollButton", true).FirstOrDefault() as Button;

            form.ForeColor =
                form.Controls.Find("ErrorLabel", true).FirstOrDefault().ForeColor    =
                    form.Controls.Find("ShowsList", true).FirstOrDefault().ForeColor =
                        GoButton.ForeColor             = GoButton.FlatAppearance.BorderColor =
                            SaveButton.ForeColor       = SaveButton.FlatAppearance.BorderColor =
                                RerollButton.ForeColor = RerollButton.FlatAppearance.BorderColor =
                                    form.Controls.Find("AutoplayButton", true).FirstOrDefault().ForeColor                                                                                         =
                                        form.Controls.Find("TitleLabel", true).FirstOrDefault().ForeColor                                                                                         =
                                            form.Controls.Find("TitleLabel2", true).FirstOrDefault().ForeColor                                                                                    =
                                                form.Controls.Find("TitleLabel3", true).FirstOrDefault().ForeColor                                                                                =
                                                    form.Controls.Find("MinimiseLabel", true).FirstOrDefault().ForeColor                                                                          =
                                                        form.Controls.Find("MinimiseLabel2", true).FirstOrDefault().ForeColor                                                                     =
                                                            form.Controls.Find("MinimiseLabel3", true).FirstOrDefault().ForeColor                                                                 =
                                                                form.Controls.Find("MainDriveLabel", true).FirstOrDefault().ForeColor                                                             =
                                                                    form.Controls.Find("MainDriveTextbox", true).FirstOrDefault().ForeColor                                                       =
                                                                        form.Controls.Find("BrowseMainButton", true).FirstOrDefault().ForeColor                                                   =
                                                                            form.Controls.Find("Shortcut1Label", true).FirstOrDefault().ForeColor                                                 =
                                                                                form.Controls.Find("Shortcut1Textbox", true).FirstOrDefault().ForeColor                                           =
                                                                                    form.Controls.Find("BrowseS1Button", true).FirstOrDefault().ForeColor                                         =
                                                                                        form.Controls.Find("Shortcut2Label", true).FirstOrDefault().ForeColor                                     =
                                                                                            form.Controls.Find("Shortcut2Textbox", true).FirstOrDefault().ForeColor                               =
                                                                                                form.Controls.Find("BrowseS2Button", true).FirstOrDefault().ForeColor                             =
                                                                                                    form.Controls.Find("ThemeLabel", true).FirstOrDefault().ForeColor                             =
                                                                                                        form.Controls.Find("MonolithLabel", true).FirstOrDefault().ForeColor                      =
                                                                                                            form.Controls.Find("AzureLabel", true).FirstOrDefault().ForeColor                     =
                                                                                                                form.Controls.Find("ForestLabel", true).FirstOrDefault().ForeColor                =
                                                                                                                    form.Controls.Find("GhostLabel", true).FirstOrDefault().ForeColor             =
                                                                                                                        form.Controls.Find("VersionNumberLabel", true).FirstOrDefault().ForeColor =
                                                                                                                            Properties.Settings.Default.AppColourText;

            SetThemeLabelFont(form, theme);

            form.Refresh();
        }
 protected BaseContentPage()
 {
     BindingContext       = ViewModel;
     this.BackgroundColor = Color.FromHex(AppTheme.PrimaryColor());
 }
Exemple #12
0
 public BaseNavigationPage(Page root) : base(root)
 {
     BarBackgroundColor = Color.FromHex(AppTheme.DefaultBarBackgroundColor());
     BackgroundColor    = Color.FromHex(AppTheme.DefaultBackgroundColor());
     BarTextColor       = Color.FromHex(AppTheme.DefaultTextColor());
 }
Exemple #13
0
 public void ApplyAppTheme()
 {
     MainPage.Parent = null;
     Resources       = new AppTheme();
     MainPage.Parent = this;              // Parent を再設定することにより View 内の DynamicResource プロパティを更新させる
 }
 public static OSAppTheme Convert(this AppTheme theme) => theme switch
 {
Exemple #15
0
 public override void ChangeTheme(AppTheme theme) => Root?.ChangeTheme(theme);
 private void LoadTheme(AppTheme theme)
 {
     ApplicationColorScheme = ColorSchemeCentral.FromAppTheme(theme);
 }
Exemple #17
0
 private static void SetContrastTheme()
 {
     _currentTheme = AppTheme.Contrast;
     _useLightIcons = true;
     _backgroundColor = Color.Black;
     _navBackgroundColor = Color.Black;
     _textColor = Color.Yellow;
     _headerColor = Color.Lime;
     _linkColor = Color.Red;
     _frameColor = Color.Black;
     _frameBorderColor = Color.Silver;
     _buttonBackgroundColor = Color.Yellow;
     _buttonTextColor = Color.Red;
 }
Exemple #18
0
 internal static int GetThemeIntValue(AppTheme theme)
 {
     return (int) theme;
 }
 static SystemColorHelper()
 {
     SystemEvents.UserPreferenceChanged += OnUserPreferencesChanged;
     WindowsTheme = GetWindowsTheme();
 }
Exemple #20
0
        //private ResourceDictionary _currentTheme;
        //public ResourceDictionary CurrentTheme
        //{
        //    get { return _currentTheme; }
        //    set
        //    {
        //        if (_currentTheme == value)
        //            return;

        //        if (_currentTheme != null)
        //            Application.Current.Resources.MergedDictionaries.Remove(_currentTheme);
        //        var currentThremeOld = _currentTheme;
        //        _currentTheme = value;

        //        if (_currentTheme != null)
        //            Application.Current.Resources.MergedDictionaries.Add(_currentTheme);
        //        this.RaisePropertyChanged(() => this.CurrentTheme);
        //        //if (CurrentThemeChanged != null)
        //        //    CurrentThemeChanged(this, new AdvancedPropertyChangedEventArgs(this, "CurrentTheme", currentThremeOld, _CurrentTheme));
        //        CurrentThemeChangedEvent.SendWith(new Tuple<ResourceDictionary, ResourceDictionary>(currentThremeOld, _currentTheme));
        //    }
        //}
        void ChangeTheme(AppTheme theme)
        {
            Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, (ThreadStart)(() =>
            {
                var owner = Application.Current.MainWindow;//Window.GetWindow(this);
                if (owner != null)
                {
                    owner.Resources.BeginInit();

                    if (owner.Resources.MergedDictionaries.Count > 0)
                    {
                        if (owner.Resources.MergedDictionaries[0].Source.OriginalString.StartsWith("pack://application:,,,/Fluent;component/Themes/"))
                        {
                            owner.Resources.MergedDictionaries.RemoveAt(0);
                        }
                    }
                    switch (theme)
                    {
                    case AppTheme.Office2010Black:
                        owner.Resources.MergedDictionaries.Insert(0, new ResourceDictionary {
                            Source = new Uri("pack://application:,,,/Fluent;component/Themes/Office2010/Black.xaml")
                        });
                        break;

                    case AppTheme.Office2010Blue:
                        owner.Resources.MergedDictionaries.Insert(0, new ResourceDictionary {
                            Source = new Uri("pack://application:,,,/Fluent;component/Themes/Office2010/Blue.xaml")
                        });
                        break;

                    case AppTheme.Office2010Silver:
                        owner.Resources.MergedDictionaries.Insert(0, new ResourceDictionary {
                            Source = new Uri("pack://application:,,,/Fluent;component/Themes/Office2010/Silver.xaml")
                        });
                        break;

                    case AppTheme.Office2013:
                        //owner.Resources.MergedDictionaries.Insert(0,new ResourceDictionary { Source = new Uri("pack://application:,,,/Fluent;component/Themes/Office2013/Generic.xaml") });
                        break;
                    }
                    owner.Resources.EndInit();
                }

                if (this.currentTheme != theme)
                {
                    Application.Current.Resources.BeginInit();
                    if (Application.Current.Resources.MergedDictionaries.Count > 0)
                    {
                        if (Application.Current.Resources.MergedDictionaries[0].Source.OriginalString.StartsWith("pack://application:,,,/Fluent;component/Themes/"))
                        {
                            Application.Current.Resources.MergedDictionaries.RemoveAt(0);
                        }
                    }
                    switch (theme)
                    {
                    case AppTheme.Office2010Black:
                    case AppTheme.Office2010Blue:
                    case AppTheme.Office2010Silver:
                        Application.Current.Resources.MergedDictionaries.Insert(0, new ResourceDictionary {
                            Source = new Uri("pack://application:,,,/Fluent;component/Themes/Generic.xaml")
                        });
                        break;

                    case AppTheme.Office2013:
                        Application.Current.Resources.MergedDictionaries.Insert(0, new ResourceDictionary {
                            Source = new Uri("pack://application:,,,/Fluent;component/Themes/Office2013/Generic.xaml")
                        });
                        break;
                    }

                    this.currentTheme = theme;
                    Application.Current.Resources.EndInit();

                    if (owner != null)
                    {
                        owner.Style = null;
                        owner.Style = owner.FindResource("RibbonWindowStyle") as Style;
                        owner.Style = null;
                    }
                }
            }));
        }
Exemple #21
0
        protected override void OnStartup(StartupEventArgs e)
        {
            if (e.Args.Contains("-ToastActivated"))
            {
                return;
            }

            if (!Debugger.IsAttached)
            {
                this.DispatcherUnhandledException += this.OnDispatcherUnhandledException;
            }

            OperatingSystem OS = Environment.OSVersion;

            if (OS.Version.Major <= 5)
            {
                MessageBox.Show(MiscRes.UnsupportedOSError, MiscRes.NoticeMessageTitle, MessageBoxButton.OK, MessageBoxImage.Warning);
                MessageBox.Show(MiscRes.UnsupportedOSError, MiscRes.NoticeMessageTitle, MessageBoxButton.OK, MessageBoxImage.Warning);
                this.Shutdown();
                return;
            }

#if PSEUDOLOCALIZER_ENABLED
            Delay.PseudoLocalizer.Enable(typeof(CommonRes));
            Delay.PseudoLocalizer.Enable(typeof(MainRes));
            Delay.PseudoLocalizer.Enable(typeof(EnumsRes));
            Delay.PseudoLocalizer.Enable(typeof(EncodingRes));
            Delay.PseudoLocalizer.Enable(typeof(OptionsRes));
            Delay.PseudoLocalizer.Enable(typeof(PreviewRes));
            Delay.PseudoLocalizer.Enable(typeof(LogRes));
            Delay.PseudoLocalizer.Enable(typeof(SubtitleRes));
            Delay.PseudoLocalizer.Enable(typeof(QueueTitlesRes));
            Delay.PseudoLocalizer.Enable(typeof(ChapterMarkersRes));
            Delay.PseudoLocalizer.Enable(typeof(MiscRes));
#endif

            JsonSettings.SetDefaultSerializationSettings();

            Ioc.SetUp();

            try
            {
                Database.Initialize();
            }
            catch (Exception)
            {
                Environment.Exit(0);
            }

            Config.EnsureInitialized(Database.Connection);

            var interfaceLanguageCode = Config.InterfaceLanguageCode;
            if (!string.IsNullOrWhiteSpace(interfaceLanguageCode))
            {
                var cultureInfo = new CultureInfo(interfaceLanguageCode);
                Thread.CurrentThread.CurrentCulture       = cultureInfo;
                Thread.CurrentThread.CurrentUICulture     = cultureInfo;
                CultureInfo.DefaultThreadCurrentCulture   = cultureInfo;
                CultureInfo.DefaultThreadCurrentUICulture = cultureInfo;
            }

            Stopwatch sw = Stopwatch.StartNew();

            if (Config.UseCustomPreviewFolder && FileUtilities.HasWriteAccessOnFolder(Config.PreviewOutputFolder))
            {
                Environment.SetEnvironmentVariable("TMP", Config.PreviewOutputFolder, EnvironmentVariableTarget.Process);
                FileUtilities.OverrideTempFolder = true;
                FileUtilities.TempFolderOverride = Config.PreviewOutputFolder;
            }

            var updater = StaticResolver.Resolve <IUpdater>();

            sw.Stop();
            System.Diagnostics.Debug.WriteLine("Startup time: " + sw.Elapsed);

            updater.HandlePendingUpdate();

            try
            {
                // Check if we're a secondary instance
                IsPrimaryInstance = mutex.WaitOne(TimeSpan.Zero, true);
            }
            catch (AbandonedMutexException)
            {
            }

            this.GlobalInitialize();

            this.appThemeService = StaticResolver.Resolve <IAppThemeService>();
            this.appThemeService.AppThemeObservable.Subscribe(appTheme =>
            {
                if (appTheme != this.currentTheme)
                {
                    this.currentTheme = appTheme;
                    this.ChangeTheme(new Uri($"/Themes/{appTheme}.xaml", UriKind.Relative));

                    bool isDark = appTheme == AppTheme.Dark;

                    string fluentTheme = isDark ? "Dark" : "Light";
                    ThemeManager.ChangeTheme(this, fluentTheme + ".Cobalt");

                    Color ribbonTextColor = isDark ? Colors.White : Colors.Black;
                    this.Resources["Fluent.Ribbon.Brushes.LabelTextBrush"] = new SolidColorBrush(ribbonTextColor);
                }
            });

            var mainVM = new MainViewModel();
            StaticResolver.Resolve <IWindowManager>().OpenWindow(mainVM);
            mainVM.OnLoaded();

            if (e.Args.Length > 0)
            {
                mainVM.HandlePaths(new List <string> {
                    e.Args[0]
                });
            }

            if (!Utilities.IsPortable && IsPrimaryInstance)
            {
                AutomationHost.StartListening();
            }

            base.OnStartup(e);
        }
Exemple #22
0
        protected override void OnRequestedThemeChanged(AppTheme newValue)
        {
            base.OnRequestedThemeChanged(newValue);

            Resources?.Reload();
        }
Exemple #23
0
 private static void InitializeCommonEssentials()
 {
     NetworkAccess networkAccess = Connectivity.NetworkAccess;
     DeviceIdiom   deviceIdiom   = DeviceInfo.Idiom;
     AppTheme      appTheme      = AppInfo.RequestedTheme;
 }
 void SetTheme(AppTheme themeType, Theme theme)
 {
     Settings.AppTheme = themeType;
     Theme.Current     = theme;
     ThemeSelectorContainerView.Hidden = true;
 }
        void changeTheme(ThemePageModel theme)
        {
            var appTheme = new AppTheme(_services);

            appTheme.SetTheme(theme.Theme);
        }
Exemple #26
0
 public static Theme FromMahTheme(AppTheme appTheme)
 {
     return(appTheme.Name == "BaseDark" ? Theme.Dark : Theme.Light);
 }
Exemple #27
0
 public virtual void OnApplyTheme(
     AppTheme theme)
 {
 }
Exemple #28
0
        /// <summary>
        /// Reads current theme id from the local storage and loads it.
        /// </summary>
        public static void LoadTheme()
        {
            AppTheme currentTheme = CurrentTheme();

            ChangeTheme(currentTheme);
        }
Exemple #29
0
 void SetAppTheme(AppTheme theme)
 {
     mockAppInfo.RequestedTheme = theme;
     ((IApplication)app).ThemeChanged();
 }
 public static ElementTheme ToPlatformTheme(this AppTheme theme) =>
 theme.DarkMode switch
 {
     false => ElementTheme.Light,
Exemple #31
0
 public override void ChangeTheme(AppTheme theme)
 {
 }
Exemple #32
0
 private static void SetNightTheme()
 {
     _currentTheme = AppTheme.Night;
     _useLightIcons = false;
     _backgroundColor = Color.FromHex("2A0000");
     _navBackgroundColor = Color.FromHex("360000");
     _textColor = Color.FromHex("730000");
     _headerColor = Color.FromHex("A80000");
     _linkColor = Color.FromHex("6B2B2B");
     _frameColor = Color.FromHex("460303");
     _frameBorderColor = Color.FromHex("A80000");
     _buttonBackgroundColor = Color.FromHex("460303");
     _buttonTextColor = Color.FromHex("6B2B2B");
 }
Exemple #33
0
 public abstract void ChangeTheme(AppTheme theme);
Exemple #34
0
 private static void SetDarkTheme()
 {
     _currentTheme = AppTheme.Dark;
     _useLightIcons = true;
     _backgroundColor = Color.FromHex("21252B");
     _navBackgroundColor = Color.FromHex("282C34");
     _textColor = Color.FromHex("9EA6B5");
     _headerColor = Color.FromHex("BFC8D7");
     _linkColor = Color.FromHex("548AF7");
     _frameColor = Color.FromHex("282C34");
     _frameBorderColor = Color.FromHex("9EA6B5");
     _buttonBackgroundColor = Color.FromHex("282C34");
     _buttonTextColor = Color.FromHex("548AF7");
 }
Exemple #35
0
        internal void ChangeFlyoutTheme(Accent windowAccent, AppTheme windowTheme)
        {
            // Beware: Über-dumb code ahead!
            switch (this.Theme)
            {
                case FlyoutTheme.Accent:
                    ThemeManager.ChangeTheme(this.Resources, windowAccent, windowTheme);
                    this.SetResourceReference(BackgroundProperty, "HighlightBrush");
                    this.SetResourceReference(ForegroundProperty, "IdealForegroundColorBrush");
                    this.ActualTheme = windowTheme;
                break;

                case FlyoutTheme.Adapt:
                    ThemeManager.ChangeTheme(this.Resources, windowAccent, windowTheme);
                    switch (windowTheme.Theme)
                    {
                        case Metro.Theme.Dark:
                            this.SetResourceReference(ForegroundProperty, "BlackColorBrush");
                            this.SetResourceReference(BackgroundProperty, "FlyoutDarkBrush");
                            break;

                        case Metro.Theme.Light:
                            this.SetResourceReference(ForegroundProperty, "BlackColorBrush");
                            this.SetResourceReference(BackgroundProperty, "FlyoutLightBrush");
                            break;
                    }
                    this.ActualTheme = windowTheme;
                    break;

                case FlyoutTheme.Inverse:
                    switch (windowTheme.Theme)
                    {
                        case Metro.Theme.Dark: {
                            var newTheme = ThemeManager.GetAppTheme(windowTheme, Metro.Theme.Light);
                            ThemeManager.ChangeTheme(this.Resources, windowAccent, newTheme);
                            this.Background = (Brush)windowTheme.Resources["FlyoutLightBrush"];
                            this.Foreground = (Brush)windowTheme.Resources["WhiteColorBrush"];
                            this.ActualTheme = newTheme;
                            break;
                        }

                        case Metro.Theme.Light: {
                            var newTheme = ThemeManager.GetAppTheme(windowTheme, Metro.Theme.Dark);
                            ThemeManager.ChangeTheme(this.Resources, windowAccent, newTheme);
                            this.Background = (Brush)windowTheme.Resources["FlyoutDarkBrush"];
                            this.Foreground = (Brush)windowTheme.Resources["WhiteColorBrush"];
                            this.ActualTheme = newTheme;
                            break;
                        }
                    }
                    break;
                
                case FlyoutTheme.Dark: {
                    var newTheme = ThemeManager.GetAppTheme(windowTheme, Metro.Theme.Dark);
                    ThemeManager.ChangeTheme(this.Resources, windowAccent, newTheme);
                    this.SetResourceReference(BackgroundProperty, "FlyoutDarkBrush");
                    this.SetResourceReference(ForegroundProperty, "BlackColorBrush");
                    this.ActualTheme = newTheme;
                    break;
                }

                case FlyoutTheme.Light: {
                    var newTheme = ThemeManager.GetAppTheme(windowTheme, Metro.Theme.Light);
                    ThemeManager.ChangeTheme(this.Resources, windowAccent, newTheme);
                    this.SetResourceReference(BackgroundProperty, "FlyoutLightBrush");
                    this.SetResourceReference(ForegroundProperty, "BlackColorBrush");
                    this.ActualTheme = newTheme;
                    break;
                }
            }
        }
Exemple #36
0
        private void detectCurrentTheme()
        {
            Color lightThemeBackground = Color.FromArgb(255, 255, 255, 255);
            Color darkThemeBackground = Color.FromArgb(255, 0, 0, 0);
            SolidColorBrush backgroundBrush  = Application.Current.Resources["PhoneBackgroundBrush"] as SolidColorBrush;

            if (backgroundBrush.Color == lightThemeBackground)
                m_currentTheme = AppTheme.Light;
            else if (backgroundBrush.Color == darkThemeBackground)
                m_currentTheme = AppTheme.Dark;
            else
                Debug.WriteLine("Warning: Could not get current background theme color!");
        }
Exemple #37
0
 public static void ChangeAppTheme(AppTheme newAppTheme)
 {
     ThemeManager.ChangeAppStyle(Application.Current,
                                 ThemeManager.GetAccent(SettingsHandler.GetAppAccentAsString()),
                                 ThemeManager.GetAppTheme(SettingsHandler.CovertAppThemeToString(newAppTheme)));
 }
Exemple #38
0
 private void LightButtonClick(object sender, RoutedEventArgs e)
 {
     currentTheme = ThemeManager.DefaultAppThemes.First(x => x.Name == "BaseLight");
     ThemeManager.ChangeAppStyle(Application.Current, currentAccent, currentTheme);
 }
Exemple #39
0
 public bool Equals(ApplicationDesign obj)
 {
     return(AccentColor.Equals(obj.AccentColor) && AppTheme.Equals(obj.AppTheme) &&
            ApplicationBackground != null && ApplicationBackground.Equals(obj.ApplicationBackground));
 }
Exemple #40
0
        internal void ChangeFlyoutTheme(Accent windowAccent, AppTheme windowTheme)
        {
            // Beware: Über-dumb code ahead!
            switch (this.Theme)
            {
                case FlyoutTheme.Accent:
                    ThemeManager.ChangeAppStyle(this.Resources, windowAccent, windowTheme);
                    this.SetResourceReference(BackgroundProperty, "HighlightBrush");
                    this.SetResourceReference(ForegroundProperty, "IdealForegroundColorBrush");
                    break;

                case FlyoutTheme.Adapt:
                    ThemeManager.ChangeAppStyle(this.Resources, windowAccent, windowTheme);
                    break;

                case FlyoutTheme.Inverse:
                    AppTheme inverseTheme = ThemeManager.GetInverseAppTheme(windowTheme);

                    if (inverseTheme == null)
                        throw new InvalidOperationException("The inverse flyout theme only works if the window theme abides the naming convention. " +
                                                            "See ThemeManager.GetInverseAppTheme for more infos");

                    ThemeManager.ChangeAppStyle(this.Resources, windowAccent, inverseTheme);
                    break;

                case FlyoutTheme.Dark:
                    ThemeManager.ChangeAppStyle(this.Resources, windowAccent, ThemeManager.GetAppTheme("BaseDark"));
                    break;

                case FlyoutTheme.Light:
                    ThemeManager.ChangeAppStyle(this.Resources, windowAccent, ThemeManager.GetAppTheme("BaseLight"));
                    break;
            }
        }
Exemple #41
0
 /// <summary>
 /// Sets the style of the specified <see cref="Application" /><paramref name="application" />
 /// </summary>
 /// <remarks>Miguel Santana 2015/05/03</remarks>
 /// <param name="application"></param>
 /// <param name="accentColor"></param>
 /// <param name="themeColor"></param>
 public static void ChangeAppStyle(this Application application, Accent accentColor, AppTheme themeColor = null)
 {
     ThemeManager.ChangeAppStyle(application, accentColor, themeColor ?? DefaultTheme);
 }