Exemple #1
0
        private void ChangeColorScheme(ColorScheme scheme)
        {
            PaletteHelper paletteHelper = new PaletteHelper();
            ITheme        theme         = paletteHelper.GetTheme();

            theme.SetBaseTheme(scheme.Theme == Config.Theme.Dark ? MaterialDesignThemes.Wpf.Theme.Dark : MaterialDesignThemes.Wpf.Theme.Light);
            var swatches = new SwatchesProvider().Swatches;

            if (swatches.Where(x => x.ExemplarHue != null).Select(x => x.Name).Contains(scheme.PrimaryHue))
            {
                theme.SetPrimaryColor(swatches.First(x => x.Name == scheme.PrimaryHue).ExemplarHue.Color);
            }
            if (swatches.Where(x => x.AccentExemplarHue != null).Select(x => x.Name).Contains(scheme.AccentHue))
            {
                theme.SetSecondaryColor(swatches.First(x => x.Name == scheme.AccentHue).AccentExemplarHue.Color);
            }
            paletteHelper.SetTheme(theme);

            ResourceDictionary oldThemeResourceDictionary = Application.Current.Resources.MergedDictionaries
                                                            .Where(resourceDictionary => resourceDictionary != null && resourceDictionary.Source != null)
                                                            .SingleOrDefault(resourceDictionary => Regex.IsMatch(resourceDictionary.Source.OriginalString, @"(\/MaterialDesignExtensions;component\/Themes\/MaterialDesign)((Light)|(Dark))Theme\."));

            string             newThemeSource             = $"pack://application:,,,/MaterialDesignExtensions;component/Themes/MaterialDesign{(scheme.Theme == Config.Theme.Dark ? "Dark" : "Light")}Theme.xaml";
            ResourceDictionary newThemeResourceDictionary = new ResourceDictionary()
            {
                Source = new Uri(newThemeSource)
            };

            Application.Current.Resources.MergedDictionaries.Remove(oldThemeResourceDictionary);
            Application.Current.Resources.MergedDictionaries.Add(newThemeResourceDictionary);
        }
Exemple #2
0
        protected override void OnStartup(StartupEventArgs e)
        {
            // Ensure that only one instance of the application can run at any time
            if (e.Args.Any(a => a == Constants.IgnoreMutexFlag))
            {
                if (!SingleInstance.Start())
                {
                    SingleInstance.ShowFirstInstance();
                    Shutdown(0);
                    return;
                }
            }

            ConfigureLogging();
            LogTo.Info("Application start");
            LogEnvironmentInfo();

            DispatcherHelper.Initialize();
            ProxyServer.Start(Kernel.Get <ITwitterContextList>());

            Scheduler = Kernel.Get <IScheduler>();
            Scheduler.Start();

            base.OnStartup(e);

            CentralHandler = new CentralMessageHandler(Kernel);

            var conf    = Kernel.Get <IConfig>();
            var palette = new PaletteHelper();

            palette.SetLightDark(conf.Visual.UseDarkTheme);
            palette.ReplaceAccentColor(conf.Visual.AccentColor);
            palette.ReplacePrimaryColor(conf.Visual.PrimaryColor);

            var swatches = new SwatchesProvider().Swatches.ToArray();

            var resDict = new ResourceDictionary();

            resDict.BeginInit();
            {
                resDict.Add("HashtagBrush",
                            new SolidColorBrush(swatches.First(s => s.Name == conf.Visual.HashtagColor).ExemplarHue.Color));
                resDict.Add("LinkBrush",
                            new SolidColorBrush(swatches.First(s => s.Name == conf.Visual.LinkColor).ExemplarHue.Color));
                resDict.Add("MentionBrush",
                            new SolidColorBrush(swatches.First(s => s.Name == conf.Visual.MentionColor).ExemplarHue.Color));
                resDict.Add("GlobalFontSize", (double)conf.Visual.FontSize);
            }
            resDict.EndInit();

            Resources.MergedDictionaries.Add(resDict);
            ChangeLanguage(conf);
        }
Exemple #3
0
        protected override void OnStartup(StartupEventArgs e)
        {
            if (!SingleInstance.Start())
            {
                SingleInstance.ShowFirstInstance();
                Shutdown(0);
                return;
            }

            DispatcherHelper.Initialize();
            Kernel = new Kernel();

            base.OnStartup(e);
            ConfigureLogging();
            LogTo.Info("Application start");
            LogEnvironmentInfo();

            var conf    = Kernel.Get <IConfig>();
            var palette = new PaletteHelper();

            palette.SetLightDark(conf.Visual.UseDarkTheme);
            palette.ReplaceAccentColor(conf.Visual.AccentColor);
            palette.ReplacePrimaryColor(conf.Visual.PrimaryColor);

            var swatches = new SwatchesProvider().Swatches.ToArray();

            var resDict = new ResourceDictionary();

            resDict.BeginInit();
            {
                resDict.Add("HashtagBrush",
                            new SolidColorBrush(swatches.First(s => s.Name == conf.Visual.HashtagColor).ExemplarHue.Color));
                resDict.Add("LinkBrush",
                            new SolidColorBrush(swatches.First(s => s.Name == conf.Visual.LinkColor).ExemplarHue.Color));
                resDict.Add("MentionBrush",
                            new SolidColorBrush(swatches.First(s => s.Name == conf.Visual.MentionColor).ExemplarHue.Color));
                resDict.Add("GlobalFontSize", (double)conf.Visual.FontSize);
            }
            resDict.EndInit();

            Resources.MergedDictionaries.Add(resDict);

            ChangeLanguage(conf.General.Language);
        }
Exemple #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="args"></param>
        private void RegisterEditorController(StartupEventArgs args)
        {
            EditorController.Register(xtmfMainWindow, () =>
            {
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    var swatches = new SwatchesProvider().Swatches;

                    if (EditorController.Runtime.Configuration.PrimaryColour != null)
                    {
                        var swatch = swatches.First(s =>
                                                    s.Name == EditorController.Runtime.Configuration.PrimaryColour);
                        new PaletteHelper().ReplacePrimaryColor(swatch);
                    }
                    else
                    {
                        var swatch = new SwatchesProvider().Swatches.First(s => s.Name.ToLower() == "blue");
                        new PaletteHelper().ReplacePrimaryColor(swatch);
                        EditorController.Runtime.Configuration.PrimaryColour = swatch.Name;
                    }


                    if (EditorController.Runtime.Configuration.AccentColour != null)
                    {
                        var swatch = swatches.First(s => s.Name == EditorController.Runtime.Configuration.AccentColour);
                        new PaletteHelper().ReplaceAccentColor(swatch);
                        EditorController.Runtime.Configuration.AccentColour = swatch.Name;
                    }
                    else
                    {
                        var swatch = swatches.First(s => s.Name.ToLower() == "amber");
                        new PaletteHelper().ReplaceAccentColor(swatch);
                    }

                    if (EditorController.Runtime.Configuration.IsDarkTheme)
                    {
                        new PaletteHelper().SetLightDark(true);
                    }
                    else
                    {
                        new PaletteHelper().SetLightDark(false);
                    }

                    if (EditorController.Runtime.Configuration.IsDisableTransitionAnimations)
                    {
                        TransitionAssist.SetDisableTransitions(Gui.MainWindow.Us, false);
                    }



                    xtmfMainWindow.UpdateRecentProjectsMenu();

                    if (EditorController.Runtime.Configuration.IsDarkTheme)
                    {
                        new PaletteHelper().SetLightDark(true);
                    }
                    xtmfMainWindow.Show();

                    /*if (args.Args.Contains("--remote-host"))
                     * {
                     *  //use remote host even though a debugger may be attached.
                     *  EditorController.Runtime.Configuration.RemoteHost = true;
                     *
                     * } */

                    EditorController.Runtime.Configuration.LoadModules(() =>
                    {
                        xtmfMainWindow.IsEnabled          = true;
                        xtmfMainWindow.StatusDisplay.Text = "Ready";
                    });
                }));
            }, false);
        }