Exemplo n.º 1
0
 public static void Load()
 {
     // Load and apply TripLine style
     ThemeManager.AddAccent("TLineAccent", new Uri("pack://application:,,,/TLine.Style;component/TLineAccent.xaml"));
     ThemeManager.AddAppTheme("TLineTheme", new Uri("pack://application:,,,/TLine.Style;component/TLineTheme.xaml"));
     ThemeManager.ChangeAppStyle(Application.Current, ThemeManager.GetAccent("TLineAccent"), ThemeManager.GetAppTheme("TLineTheme"));
 }
Exemplo n.º 2
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            Logger.ReconfigFileTarget();

            // track possible exceptions
            AppDomain currentDomain = AppDomain.CurrentDomain;

            currentDomain.UnhandledException      += CurrentDomain_UnhandledException;
            Dispatcher.UnhandledException         += Dispatcher_UnhandledException;
            Current.DispatcherUnhandledException  += Dispatcher_UnhandledException;
            TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
            SystemEvents.UserPreferenceChanged    += SystemEvents_UserPreferenceChanged;

            // add custom accent and theme resource dictionaries to the ThemeManager
            ThemeManager.AddAccent("Spotify",
                                   new Uri("pack://application:,,,/Worktime;component/Resources/Custom/Accent/Spotify.xaml"));
            ThemeManager.AddAccent("Raspberry",
                                   new Uri("pack://application:,,,/Worktime;component/Resources/Custom/Accent/Raspberry.xaml"));
            ThemeManager.AddAccent("FireOrange",
                                   new Uri("pack://application:,,,/Worktime;component/Resources/Custom/Accent/FireOrange.xaml"));
            ThemeManager.AddAppTheme("BaseGray",
                                     new Uri("pack://application:,,,/Worktime;component/Resources/Custom/Theme/BaseGray.xaml"));

            // start the application
            Core.Initialize();
        }
Exemplo n.º 3
0
        protected override void OnStartup(StartupEventArgs e)
        {
            bool enableLogging = true;

            if (e.Args.Length > 0)
            {
                if (e.Args[0].ToLower() == "-nolog")
                {
                    enableLogging = false;
                }
            }

            if (enableLogging)
            {
                Log.Init("OatControl");
                Log.EnableLogging();
            }

            ThemeManager.AddAccent("RedAccent", new Uri("pack://application:,,,/OATControl;component/Resources/RedAccent.xaml"));
            ThemeManager.AddAppTheme("RedTheme", new Uri("pack://application:,,,/OATControl;component/Resources/RedTheme.xaml"));
            ThemeManager.AddAccent("RedControls", new Uri("pack://application:,,,/OATControl;component/Resources/RedControls.xaml"));

            // get the current app style (theme and accent) from the application
            // you can then use the current theme and custom accent instead set a new theme
            Tuple <AppTheme, Accent> appStyle = ThemeManager.DetectAppStyle(Application.Current);

            // now set the Green accent and dark theme
            ThemeManager.ChangeAppStyle(Application.Current,
                                        ThemeManager.GetAccent("RedAccent"),
                                        ThemeManager.GetAppTheme("RedTheme"));


            base.OnStartup(e);
        }
Exemplo n.º 4
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            Log.Debug("Started New Session Logging *******************************************************");


            ThemeManager.AddAppTheme("DarkTheme", new Uri("pack://application:,,,/Style/DarkTheme.xaml"));
            ThemeManager.AddAppTheme("LightTheme", new Uri("pack://application:,,,/Style/LightTheme.xaml"));

            EventManager.RegisterClassHandler(
                typeof(TextBox), TextBox.GotFocusEvent, new RoutedEventHandler(TextBox_GotFocus));
            EventManager.RegisterClassHandler(
                typeof(TextBox), TextBox.PreviewMouseDownEvent, new RoutedEventHandler(TextBox_PreviewMouseDown));

            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");


            FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement),
                                                               new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));

            // For catching Global uncaught exception
            AppDomain currentDomain = AppDomain.CurrentDomain;

            currentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledExceptionOccured);

            Log.Info("Application Startup");
            LogMachineDetails();
            LoadPreviousSessionParameters();
            app = new MainWindow();
            app.Show();
        }
Exemplo n.º 5
0
        protected override void OnStartup(StartupEventArgs e)
        {
            Log.Info("        =============  Started New Session Logging  =============        ");


            ThemeManager.AddAppTheme("TINTED", new Uri("pack://application:,,,/Themes/Tinted.xaml"));
            ThemeManager.AddAppTheme("NIGHT", new Uri("pack://application:,,,/Themes/Night.xaml"));
            ThemeManager.AddAppTheme("DAY", new Uri("pack://application:,,,/Themes/Day.xaml"));


            EventManager.RegisterClassHandler(
                typeof(TextBox), TextBox.PreviewMouseDownEvent, new RoutedEventHandler(TextBox_PreviewMouseDown));
            EventManager.RegisterClassHandler(
                typeof(TextBox), TextBox.GotFocusEvent, new RoutedEventHandler(TextBox_GotFocus));

            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
            DTO.AppLocalize = new EZLocalize(App.Current.Resources, "en", null, "Languages\\", "Interface");


            FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement),
                                                               new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));

            LoadPreviousSessionParameters();

            // For catching Global uncaught exception
            AppDomain currentDomain = AppDomain.CurrentDomain;

            currentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledExceptionOccured);

            Log.Info("Application Startup");
            LogMachineDetails();
        }
Exemplo n.º 6
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            // Global exception handling
            Current.DispatcherUnhandledException += AppDispatcherUnhandledException;

            string procName = Process.GetCurrentProcess().ProcessName;

            // get the list of all processes by that name

            Process[] processes = Process.GetProcessesByName(procName);

            if (processes.Length > 1)
            {
                MessageBox.Show(TranslationStrings.LabelApplicationAlreadyRunning);
                Shutdown(-1);
                return;
            }

            ThemeManager.AddAccent("Astro", new Uri("pack://application:,,,/CameraControl;component/Resources/AstroAccent.xaml"));
            ThemeManager.AddAppTheme("Black", new Uri("pack://application:,,,/CameraControl;component/Resources/AstroTheme.xaml"));

            ServiceProvider.Branding = Branding.LoadBranding();
            if (ServiceProvider.Branding.ShowStartupScreen)
            {
                _startUpWindow = new StartUpWindow();
                _startUpWindow.Show();
            }

            Task.Factory.StartNew(InitApplication);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Application.Startup" /> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.StartupEventArgs" /> that contains the event data.</param>
        protected override void OnStartup(StartupEventArgs e)
        {
            //// get the current app style (theme and accent) from the application
            //// you can then use the current theme and custom accent instead set a new theme
            //Tuple<AppTheme, Accent> appStyle = ThemeManager.DetectAppStyle(Application.Current);

            //// now set the Green accent and dark theme
            //ThemeManager.ChangeAppStyle(Application.Current,
            //                            ThemeManager.GetAccent("White"),
            //                            ThemeManager.GetAppTheme("BaseLight")); // or appStyle.Item1

            // add custom accent and theme resource dictionaries to the ThemeManager
            // you should replace MahAppsMetroThemesSample with your application name
            // and correct place where your custom accent lives
            //ThemeManager.AddAccent("CustomStyle", new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/CustomStyle.xaml"));

            ThemeManager.AddAppTheme("CustomStyle", new Uri("pack://application:,,,/SDN.SimpleAccounting;component/Resources/CustomStyle.xaml"));

            var theme = ThemeManager.DetectAppStyle(Application.Current);

            ThemeManager.ChangeAppStyle(Application.Current, theme.Item2, ThemeManager.GetAppTheme("CustomStyle"));

            base.OnStartup(e);
            SDNBootStrapper strapper = new SDNBootStrapper();

            strapper.Run();
        }
Exemplo n.º 8
0
        protected override void OnStartup(StartupEventArgs e)
        {
            try
            {
                var fileName = Path.Combine(Definitions.Directories.SLM.Cache, "CustomTheme.xaml");
                if (!File.Exists(fileName))
                {
                    CreateThemeFrom("CustomTheme.xaml", ThemeManager.GetAppTheme("BaseDark").Resources);
                }
                else
                {
                    ThemeManager.AddAppTheme("CustomTheme", new Uri(fileName, UriKind.Absolute));
                }

                ThemeManager.ChangeAppStyle(Current,
                                            ThemeManager.GetAccent(Steam_Library_Manager.Properties.Settings.Default.ThemeAccent),
                                            ThemeManager.GetAppTheme(Steam_Library_Manager.Properties.Settings.Default.BaseTheme));

                base.OnStartup(e);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                Definitions.SLM.RavenClient.Capture(new SharpRaven.Data.SentryEvent(ex));
            }
        }
Exemplo n.º 9
0
                public void loadStyles()
                {
                    list_Accents.Clear();
                    list_Themes.Clear();

                    String currentDir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
                    String accentsDir = Path.Combine(currentDir, DataEx.dir_Accents);
                    String themesDir  = Path.Combine(currentDir, DataEx.dir_Themes);

                    foreach (String accentXaml in Directory.GetFiles(accentsDir, "*.xaml", SearchOption.TopDirectoryOnly))
                    {
                        String accentName = accentXaml.Replace(accentsDir, String.Empty).Replace(".xaml", String.Empty);

                        ThemeManager.AddAccent(accentName, new Uri(accentXaml, UriKind.Absolute));
                        list_Accents.Add(accentName);
                    }

                    foreach (String themeXaml in Directory.GetFiles(themesDir, "*.xaml", SearchOption.TopDirectoryOnly))
                    {
                        String themeName = themeXaml.Replace(themesDir, String.Empty).Replace(".xaml", String.Empty);

                        ThemeManager.AddAppTheme(themeName, new Uri(themeXaml, UriKind.Absolute));
                        list_Themes.Add(themeName);
                    }
                }
Exemplo n.º 10
0
        public static void CreateThemeFrom(string ThemeName, ResourceDictionary resourceDictionary)
        {
            try
            {
                FileInfo fileName = new FileInfo(Path.Combine(Definitions.Directories.SLM.Cache, ThemeName));

                if (!fileName.Directory.Exists)
                {
                    fileName.Directory.Create();
                }

                using (var writer = System.Xml.XmlWriter.Create(fileName.FullName, new System.Xml.XmlWriterSettings {
                    Indent = true
                }))
                {
                    System.Windows.Markup.XamlWriter.Save(resourceDictionary, writer);
                }

                ThemeManager.AddAppTheme(ThemeName.Replace(".xaml", ""), new Uri(fileName.FullName, UriKind.Absolute));
                ThemeManager.ChangeAppStyle(Current, ThemeManager.GetAccent(Steam_Library_Manager.Properties.Settings.Default.ThemeAccent), ThemeManager.GetAppTheme(Steam_Library_Manager.Properties.Settings.Default.BaseTheme));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 11
0
        protected override void OnStartup(StartupEventArgs e)
        {
            ThemeManager.AddAppTheme("DarkTheme", new Uri("pack://application:,,,/KnobUI;component/Style/DarkTheme.xaml"));
            ThemeManager.AddAppTheme("LightTheme", new Uri("pack://application:,,,/KnobUI;component/Style/LightTheme.xaml"));


            base.OnStartup(e);
        }
Exemplo n.º 12
0
 public void OnContraste(Window window)
 {
     ThemeManager.AddAccent("AltoContraste", new Uri("pack://application:,,,/Skin/Skin.xaml"));
     ThemeManager.AddAppTheme("FondoAltoContraste", new Uri("pack://application:,,,/Skin/Tema.xaml"));
     ThemeManager.ChangeAppStyle(window,
                                 ThemeManager.GetAccent("AltoContraste"),
                                 ThemeManager.GetAppTheme("FondoAltoContraste"));
 }
Exemplo n.º 13
0
        protected override void OnStartup(StartupEventArgs e)
        {
            ThemeManager.AddAccent("CustomLime", new Uri("pack://application:,,,/CSGODemosManager;component/Resources/Accents/CustomLime.xaml"));
            ThemeManager.AddAppTheme("Dark", new Uri("pack://application:,,,/CSGODemosManager;component/Resources/Accents/ThemeDark.xaml"));
            ThemeManager.AddAppTheme("Light", new Uri("pack://application:,,,/CSGODemosManager;component/Resources/Accents/ThemeLight.xaml"));
            Accent   accent = ThemeManager.GetAccent("CustomLime");
            AppTheme theme  = ThemeManager.GetAppTheme(Settings.Default.Theme);

            ThemeManager.ChangeAppStyle(Current, accent, theme);
            base.OnStartup(e);
        }
Exemplo n.º 14
0
        protected override void OnStartup(StartupEventArgs e)
        {
            ThemeManager.AddAccent("GtMpRed", new Uri("pack://application:,,,/Resources/Accents/GtMpRed.xaml"));
            ThemeManager.AddAppTheme("GtMpRed", new Uri("pack://application:,,,/Resources/Themes/GtMpRed.xaml"));

            // now change app style to the custom accent and current theme
            ThemeManager.ChangeAppStyle(Current,
                                        ThemeManager.GetAccent("GtMpRed"),
                                        ThemeManager.GetAppTheme("GtMpRed"));

            base.OnStartup(e);
        }
Exemplo n.º 15
0
        protected override void OnStartup(StartupEventArgs e)
        {
            // add custom accent and theme resource dictionaries
            ThemeManager.AddAccent("CustomAccent1", new Uri("pack://application:,,,/FFXIVTrainer;component/CustomAccents/CustomAccent1.xaml"));
            ThemeManager.AddAccent("CustomAccent2", new Uri("pack://application:,,,/FFXIVTrainer;component/CustomAccents/CustomAccent2.xaml"));
            ThemeManager.AddAppTheme("CustomTheme", new Uri("pack://application:,,,/FFXIVTrainer;component/CustomAccents/CustomTheme.xaml"));

            // create custom accents
            ThemeManagerHelper.CreateAppStyleBy(Colors.Red);
            ThemeManagerHelper.CreateAppStyleBy(Colors.GreenYellow);
            ThemeManagerHelper.CreateAppStyleBy(Colors.Indigo, true);
            base.OnStartup(e);
        }
Exemplo n.º 16
0
        protected override void OnStartup(StartupEventArgs e)
        {
            // add custom accent and theme resource dictionaries
            ThemeManager.AddAppTheme("LightTheme", new Uri(@"pack://*****:*****@"pack://application:,,,/Resources\Themes\DarkTheme.xaml"));
            ThemeManager.AddAccent("LightThemeAccent", new Uri(@"pack://*****:*****@"pack://application:,,,/Resources\Themes\DarkThemeAccent.xaml"));

            ThemeManager.ChangeAppStyle(Application.Current,
                                        ThemeManager.GetAccent(Settings.Default.LightTheme ? "LightThemeAccent" : "DarkThemeAccent"),
                                        ThemeManager.GetAppTheme(Settings.Default.LightTheme ? "LightTheme" : "DarkTheme"));

            base.OnStartup(e);
        }
Exemplo n.º 17
0
        public MainWindow()
        {
            InitializeComponent();

#if false
            ThemeManager.AddAccent("HsGrayAccent", new Uri("Style/GrayAccent.xaml"));
            ThemeManager.AddAppTheme("HsDarkTheme", new Uri("Style/HsDarkTheme.xaml"));

            // load theme & accent from sqlite
            string accentName = "HsGrayAccent", themeName = "HsDarkTheme";
            var    appTheme  = MahApps.Metro.ThemeManager.GetAppTheme(themeName);
            var    appAccent = MahApps.Metro.ThemeManager.GetAccent(accentName);
            ThemeManager.ChangeAppStyle(Application.Current, appAccent, appTheme);
#endif
        }
Exemplo n.º 18
0
 private void BtnSacuvajPromene_Click(object sender, RoutedEventArgs e)
 {
     ThemeManager.AddAccent("Yellow", new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/Yellow.xaml"));
     ThemeManager.AddAccent("Green", new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/Green.xaml"));
     ThemeManager.AddAppTheme("BaseDark", new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseDark.xaml"));
     ThemeManager.AddAppTheme("BaseLight", new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml"));
     if (cbBojaBG.IsChecked == true)
     {
         ThemeManager.ChangeAppStyle(Application.Current, ThemeManager.GetAccent("Yellow"), ThemeManager.GetAppTheme("BaseDark"));
     }
     else
     {
         ThemeManager.ChangeAppStyle(Application.Current, ThemeManager.GetAccent("Green"), ThemeManager.GetAppTheme("BaseLight"));
     }
     this.Close();
 }
Exemplo n.º 19
0
        /// <summary>Setup Sidekick themes.</summary>
        /// <exception cref="System.InvalidOperationException">
        ///   Sidekick ThemeManager is already
        ///   initialized.
        /// </exception>
        public static void Initialize()
        {
            if (ThemeManager.AppThemes.Any(t => SidekickThemes.Contains(t.Name)))
            {
                throw new InvalidOperationException("Sidekick ThemeManager is already initialized.");
            }

            foreach (var theme in SidekickThemes)
            {
                var resourceAddress =
                    new Uri(
                        $"pack://application:,,,/Sidekick.Windows;component/Styles/Themes/{theme}.xaml");

                ThemeManager.AddAppTheme(theme, resourceAddress);
            }
        }
Exemplo n.º 20
0
        protected override void OnStartup(StartupEventArgs e)
        {
            try
            {
                SetupExceptionHandling();

                var fileName = Path.Combine(Definitions.Directories.SLM.Cache, "CustomTheme.xaml");
                if (!File.Exists(fileName))
                {
                    CreateThemeFrom("CustomTheme.xaml", ThemeManager.GetAppTheme("BaseDark").Resources);
                }
                else
                {
                    var tryCount = 0;
                    while (fileName.IsFileLocked())
                    {
                        tryCount++;
                        Task.Delay(1000);

                        if (tryCount > 5)
                        {
                            base.OnStartup(e);
                            MessageBox.Show("CustomTheme.xaml is locked/not accessible. Skipping the custom theme loading.");
                            break;
                        }
                    }

                    ThemeManager.AddAppTheme("CustomTheme", new Uri(fileName, UriKind.Absolute));
                }

                ThemeManager.ChangeAppStyle(Current,
                                            ThemeManager.GetAccent(Steam_Library_Manager.Properties.Settings.Default.ThemeAccent),
                                            ThemeManager.GetAppTheme(Steam_Library_Manager.Properties.Settings.Default.BaseTheme));

                base.OnStartup(e);
            }
            catch (UnauthorizedAccessException ex)
            {
                base.OnStartup(e);
                MessageBox.Show(ex.ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                Definitions.SLM.RavenClient.Capture(new SharpRaven.Data.SentryEvent(ex));
            }
        }
Exemplo n.º 21
0
        protected override void OnStartup(StartupEventArgs e)
        {
            // add custom accent and theme resource dictionaries
            ThemeManager.AddAccent("BankAStyle", new Uri("pack://application:,,,/BankA.Wpf;component/Resources/BankAStyle.xaml"));
            ThemeManager.AddAppTheme("BankATheme", new Uri("pack://application:,,,/BankA.Wpf;component/Resources/BankATheme.xaml"));

            // get the theme from the current application
            var theme = ThemeManager.DetectAppStyle(Application.Current);

            // now use the custom accent
            ThemeManager.ChangeAppStyle(Application.Current,
                                        ThemeManager.GetAccent("BankAStyle"), ThemeManager.GetAppTheme("BankATheme"));
//                                    theme.Item1);

            base.OnStartup(e);

            base.OnStartup(e);
        }
Exemplo n.º 22
0
        public static void Initialize(Application app)
        {
            Themes.ForEach(theme => ThemeManager.AddAppTheme(theme, GetUriForTheme(theme)));
            Themes.ForEach(theme => ThemeManager.AddAccent(theme, GetUriForTheme(theme)));

            preferenceSubscription = PreferenceStore.Default.Subscribe(ObservePreferenceChange);
            SystemParameters.StaticPropertyChanged += DetectHighContrastProperty;

            Prefs.UI.Theme.UseHighContrast.SetValue(SystemParameters.HighContrast);

            var themeToLoad = Prefs.UI.Theme.UseHighContrast.GetValue()
                ? HighContrastThemeName
                : Prefs.UI.Theme.ThemeName.GetValue();

            // MahApps' theme-switching code doesn't work w/o a theme already loaded, so
            // load the right one from prefs by merging the resource dictionary in by hand.
            app.Resources.MergedDictionaries.Add(GetThemeResourceDictionary(themeToLoad));
        }
Exemplo n.º 23
0
        protected override void OnStartup(StartupEventArgs e)
        {
            ThemeManager.AddAccent("RedAccent", new Uri("pack://application:,,,/OATControl;component/Resources/RedAccent.xaml"));
            ThemeManager.AddAppTheme("RedTheme", new Uri("pack://application:,,,/OATControl;component/Resources/RedTheme.xaml"));
            ThemeManager.AddAccent("RedControls", new Uri("pack://application:,,,/OATControl;component/Resources/RedControls.xaml"));

            // get the current app style (theme and accent) from the application
            // you can then use the current theme and custom accent instead set a new theme
            Tuple <AppTheme, Accent> appStyle = ThemeManager.DetectAppStyle(Application.Current);

            // now set the Green accent and dark theme
            ThemeManager.ChangeAppStyle(Application.Current,
                                        ThemeManager.GetAccent("RedAccent"),
                                        ThemeManager.GetAppTheme("RedTheme"));


            base.OnStartup(e);
        }
Exemplo n.º 24
0
        protected override void OnStartup(StartupEventArgs e)
        {
            int theme = IOData.LireDonnesTheme();

            ThemeManager.AddAccent("AccentL", new Uri("pack://application:,,,/ProjetWPF;component/Theme/Accent1.xaml"));
            ThemeManager.AddAppTheme("ThemeL", new Uri("pack://application:,,,/ProjetWPF;component/Theme/LightTheme.xaml"));
            ThemeManager.AddAccent("AccentD", new Uri("pack://application:,,,/ProjetWPF;component/Theme/Accent2.xaml"));
            ThemeManager.AddAppTheme("ThemeD", new Uri("pack://application:,,,/ProjetWPF;component/Theme/DarkTheme.xaml"));
            if (theme < 2)
            {
                ThemeManager.ChangeAppStyle(Application.Current, ThemeManager.GetAccent("AccentL"), ThemeManager.GetAppTheme("ThemeL"));
            }
            else
            {
                ThemeManager.ChangeAppStyle(Application.Current, ThemeManager.GetAccent("AccentD"), ThemeManager.GetAppTheme("ThemeD"));
            }
            base.OnStartup(e);
        }
Exemplo n.º 25
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            // add custom accent and theme resource dictionaries
            ThemeManager.AddAccent("CustomAccent1", new Uri("pack://application:,,,/SpaSolutions;component/CustomAccents/CustomAccent1.xaml"));
            ThemeManager.AddAccent("CustomAccent2", new Uri("pack://application:,,,/SpaSolutions;component/CustomAccents/CustomAccent2.xaml"));
            ThemeManager.AddAppTheme("CustomTheme", new Uri("pack://application:,,,/SpaSolutions;component/CustomAccents/CustomTheme.xaml"));

            // create custom accents
            ThemeManagerHelper.CreateAppStyleBy(Colors.Red);
            ThemeManagerHelper.CreateAppStyleBy(Colors.GreenYellow);
            ThemeManagerHelper.CreateAppStyleBy(Colors.Indigo, true);
            var window = new MainWindow()
            {
                DataContext = MainWindowViewModel.Instance
            };

            window.Show();
        }
Exemplo n.º 26
0
        public MainRegionViewModel(ILocalConfiguration localConfiguration, IRegionManager regionManager, IEventAggregator eventAggregator, ILoginUserService loginUserService, IUserManageService userManageService, ISignalProcess signalProcess)
        {
            _localConfiguration = localConfiguration;
            _regionManager      = regionManager;
            _eventAggregator    = eventAggregator;
            _loginUserService   = loginUserService;
            _userManageService  = userManageService;
            _signalProcess      = signalProcess;

            ThemeManager.AddAppTheme("BaseGray", new Uri("pack://application:,,,/AIC.Resources;component/Styles/BaseGray.xaml"));

            // create accent color menu items for the demo
            this.AccentColors = ThemeManager.Accents
                                .Select(a => new AccentColorMenuData()
            {
                Name = a.Name, ColorBrush = a.Resources["AccentColorBrush"] as Brush
            })
                                .ToList();


            // create metro theme color menu items for the demo
            this.AppThemes = ThemeManager.AppThemes
                             .Select(a => new AppThemeMenuData()
            {
                Name = a.Name, BorderColorBrush = a.Resources["BlackColorBrush"] as Brush, ColorBrush = a.Resources["WhiteColorBrush"] as Brush
            })
                             .ToList();

            MenuManageList = _loginUserService.MenuManageList;
            ExceptionModel = _loginUserService.ExceptionModel;

            readDataTimer.Tick    += new EventHandler(timeCycle);
            readDataTimer.Interval = new TimeSpan(0, 0, 0, 1);
            readDataTimer.Start();

            WhenPropertyChanged.Where(o => o.ToString() == "Alarm").Subscribe(OnAlarmGradeChanged);

            _eventAggregator.GetEvent <LoginEvent>().Subscribe(LoginFinishEvent);

            getTree();
        }
Exemplo n.º 27
0
        /// <summary>
        /// Load Appearance (AppTheme and Accent) from the user settings.
        /// </summary>
        public static void Load()
        {
            // Add custom themes
            foreach (string file in Directory.GetFiles(ThemesFilePath))
            {
                string fileName = Path.GetFileName(file);

                // Theme
                if (fileName.EndsWith(CostomThemeFileExtension))
                {
                    ThemeManager.AddAppTheme(fileName.Substring(0, fileName.Length - CostomThemeFileExtension.Length), new Uri(file));
                }

                // Accent
                if (fileName.EndsWith(CostomAccentFileExtension))
                {
                    ThemeManager.AddAccent(fileName.Substring(0, fileName.Length - CostomAccentFileExtension.Length), new Uri(file));
                }
            }

            // Change the AppTheme if it is not empty and different from the currently loaded
            string appThemeName = SettingsManager.Current.Appearance_AppTheme;

            if (!string.IsNullOrEmpty(appThemeName) && appThemeName != ThemeManager.DetectAppStyle().Item1.Name)
            {
                ChangeAppTheme(appThemeName);
            }

            // Change the Accent if it is not empty and different from the currently loaded
            string accentName = SettingsManager.Current.Appearance_Accent;

            if (!string.IsNullOrEmpty(accentName) && accentName != ThemeManager.DetectAppStyle().Item2.Name)
            {
                ChangeAccent(accentName);
            }

            MetroDialog.CustomResourceDictionary = new ResourceDictionary
            {
                Source = new Uri("NETworkManager;component/Resources/Styles/MetroDialogStyles.xaml", UriKind.RelativeOrAbsolute)
            };
        }
Exemplo n.º 28
0
        protected override void OnStartup(StartupEventArgs e)
        {
            AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionCrash;
            try
            {
                ProxyRoutines.SetProxy(false);
            }
            catch (Exception ex)
            {
                UnhandledExceptionCrash(this, new UnhandledExceptionEventArgs(ex, false));
            }
            ThemeManager.AddAccent("BlueDoc", GetResourceUri("Resources/Accents/Blue.xaml"));
            ThemeManager.AddAppTheme("DarkDoc", GetResourceUri("Resources/Themes/Dark.xaml"));
            ThemeManager.AddAppTheme("LightDoc", GetResourceUri("Resources/Themes/Light.xaml"));
            var theme = Settings.Default.Theme;

            ChangeLocale(Settings.Default.Locale);
            ThemeManager.ChangeAppStyle(Current, ThemeManager.GetAccent("BlueDoc"), ThemeManager.GetAppTheme(theme + "Doc"));
            SplashViewModel.Args = e.Args;
            base.OnStartup(e);
        }
Exemplo n.º 29
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            Task.Run(() => AutoUpdateService.DeleteUpdater());
            if (e.Args.Contains("/updated"))
            {
                StatusService.Current.Notify("アップデートが完了しました。");
            }

            DispatcherHelper.UIDispatcher = this.Dispatcher;
            Setting.Load();

            ThemeManager.AddAppTheme("McsDark", new Uri(mcsDarkTheme, UriKind.Relative));
            ThemeManager.AddAppTheme("McsLight", new Uri(mcsLightTheme, UriKind.Relative));
            var accent = ThemeManager.GetAccent("Yellow");
            var theme  = ThemeManager.GetAppTheme("McsDark");

            ThemeManager.ChangeAppStyle(Current, accent, theme);

            MainViewModel   = new MainWindowViewModel();
            this.MainWindow = new MainWindow()
            {
                DataContext = MainViewModel
            };

            MainView = this.MainWindow as MainWindow;
            MainViewModel.InitializeCommandBinding(MainView);

            Observable.FromEvent <MouseButtonEventHandler, MouseButtonEventArgs>(
                h => (sender, args) => h(args),
                h => this.MainWindow.MouseLeftButtonDown += h,
                h => this.MainWindow.MouseLeftButtonDown -= h)
            .Where(m => m.ButtonState == MouseButtonState.Pressed)
            .Subscribe(_ => this.MainWindow.DragMove());

            this.MainWindow.Show();
        }
Exemplo n.º 30
0
        public static ResourceDictionary CreateTheme(string baseColorScheme, Color accentBaseColor, string name = null, bool changeImmediately = false)
        {
            name = name ?? $"RuntimeTheme_{baseColorScheme}_{accentBaseColor.ToString().Replace("#", string.Empty)}";

            var generatorParameters  = GetGeneratorParameters();
            var themeTemplateContent = GetThemeTemplateContent();

            var variant     = generatorParameters.BaseColorSchemes.First(x => x.Name == baseColorScheme);
            var colorScheme = new ColorScheme();

            colorScheme.Name = accentBaseColor.ToString().Replace("#", string.Empty);
            var values = colorScheme.Values;

            values.Add("AccentBaseColor", accentBaseColor.ToString());
            values.Add("AccentColor", Color.FromArgb(204, accentBaseColor.R, accentBaseColor.G, accentBaseColor.B).ToString());
            values.Add("AccentColor2", Color.FromArgb(153, accentBaseColor.R, accentBaseColor.G, accentBaseColor.B).ToString());
            values.Add("AccentColor3", Color.FromArgb(102, accentBaseColor.R, accentBaseColor.G, accentBaseColor.B).ToString());
            values.Add("AccentColor4", Color.FromArgb(51, accentBaseColor.R, accentBaseColor.G, accentBaseColor.B).ToString());

            values.Add("HighlightColor", accentBaseColor.ToString());
            values.Add("IdealForegroundColor", IdealTextColor(accentBaseColor).ToString());

            var xamlContent = new ColorSchemeGenerator().GenerateColorSchemeFileContent(generatorParameters, variant, colorScheme, themeTemplateContent, name, name);

            var resourceDictionary = (ResourceDictionary)XamlReader.Parse(xamlContent);

            ThemeManager.AddAppTheme(name, resourceDictionary);

            // Apply theme
            if (changeImmediately)
            {
                ThemeManager.ChangeAppTheme(Application.Current, name);
            }

            return(resourceDictionary);
        }