示例#1
0
        public App(string settingsFilePath, List <AlertModel> alerts)
        {
            _settingsFilePath = settingsFilePath;

            _settings = SettingsFactory.GetSettings(_settingsFilePath);

            _themeResources = new ResourceDictionary();

            _shellView = CreateView <Views.ShellView, ViewModels.ShellViewModel>(this);

            _shellView.Topmost = _settings.General.TopMost;

            Accent   accent = SettingsFactory.GetAccent(_settings.General.ThemeAccent);
            AppTheme theme  = SettingsFactory.GetTheme(_settings.General.ThemeBase);

            _themeResources.MergedDictionaries.Add(accent.Resources);
            _themeResources.MergedDictionaries.Add(theme.Resources);

            _navigationJournal = new List <string>();

            _eventAggregator = new EventAggregator();

            _eventAggregator.GetEvent <Events.SettingsChangedEvent>().Subscribe(SettingsChangedEvent_Handler);
            _eventAggregator.GetEvent <Events.GeneralSettingsChangedEvent>().Subscribe(GeneralSettingsChangedEvent_Handler);
            _eventAggregator.GetEvent <Events.AlertRemovedEvent>().Subscribe(AlertRemovedEvent_Handler);

            _alerts = alerts;
        }
        public void Initialize(Application app, Theme theme, Accent accent)
        {
            this.InitializeCore(app, theme, accentDictionaries[accent]);

            this.Theme  = theme;
            this.Accent = accent;
        }
        public SchemeCreator(Point Origin, MaterialForm BaseFormToOverlay)
        {
            BackBrush = Brushes.Magenta;
            SetStyle(ControlStyles.SupportsTransparentBackColor, true);
            FormBorderStyle    = System.Windows.Forms.FormBorderStyle.None;
            CurrentHoveredPath = new GraphicsPath();
            //set the backcolor and transparencykey on same color.
            this.BackColor       = Color.Magenta;
            this.TransparencyKey = Color.Magenta;
            InitializeComponent();
            FillBrush           = new SolidBrush(MaterialSkinManager.Instance.GetApplicationBackgroundColor());
            _Origin             = Origin;
            _BaseForm           = BaseFormToOverlay;
            objAnimationManager = new AnimationManager()
            {
                Increment     = 0.015,
                AnimationType = AnimationType.EaseInOut
            };
            DoubleBuffered = true;
            objAnimationManager.OnAnimationProgress += sender => Invalidate();
            objAnimationManager.OnAnimationFinished += objAnimationManager_OnAnimationFinished;
            Visible       = false;
            _ActiveKey    = _PrimaryKey;
            _Primary      = Primary.Indigo500;
            _PrimaryDark  = Primary.Indigo700;
            _PrimaryLight = Primary.Indigo100;
            _Accent       = Accent.Pink200;
            _Text         = TextShade.WHITE;
            BaseFormToOverlay.LocationChanged += BaseFormToOverlay_LocationChanged;
            initColorHints();
            Size     = _BaseForm.Size;
            Location = _BaseForm.Location;

            MouseUp += SchemeCreator_MouseUp;
        }
        public void Initialize(Application app, Theme theme, ResourceDictionary accent)
        {
            this.InitializeCore(app, theme, this.currentAccentDictionary);

            this.Theme  = theme;
            this.Accent = Accent.Original;
        }
示例#5
0
        public void LoadTheme()
        {
            // 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();

            AppTheme theme  = MahApps.Metro.ThemeManager.AppThemes.FirstOrDefault(t => t.Name.Equals(Properties.Settings.Default.ThemeName));
            Accent   accent = MahApps.Metro.ThemeManager.Accents.FirstOrDefault(a => a.Name.Equals(Properties.Settings.Default.AccentName));

            if ((theme != null) && (accent != null))
            {
                MahApps.Metro.ThemeManager.ChangeAppStyle(Application.Current, accent, theme);
            }
        }
        public void ChangeTheme()
        {
            Accent myAccent = new Accent("AccentName", new Uri(Properties.Settings.Default.Theme));

            ThemeManager.ChangeTheme(this, myAccent, (Properties.Settings.Default.DarkTheme) ? Theme.Dark : Theme.Light);
            Client.CurrentAccent = myAccent;
        }
        private static Uri CreateAccentResourceUri(Accent accent)
        {
            var uri = string.Format(@"pack://application:,,,/MetroRadiance;component/Themes/Accents/{0}.xaml", accent);
            Uri result;

            return(Uri.TryCreate(uri, UriKind.Absolute, out result) ? result : null);
        }
示例#8
0
        private void CB_Themes_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            int    index = CB_Themes.SelectedIndex;
            Accent acc   = ThemeManager.Accents.ElementAt(index);

            ThemeManager.ChangeAppStyle(Application.Current, acc, ThemeManager.DetectAppStyle().Item1);
        }
示例#9
0
        private void LoadTheme(Themes theme)
        {
            Primary   p   = (Primary)Enum.Parse(typeof(Primary), theme.Primary.ToString());
            Primary   dp  = (Primary)Enum.Parse(typeof(Primary), theme.DarkPrimary.ToString());
            Primary   lp  = (Primary)Enum.Parse(typeof(Primary), theme.LightPrimary.ToString());
            Accent    acc = (Accent)Enum.Parse(typeof(Accent), theme.Accent.ToString());
            TextShade ts  = (TextShade)Enum.Parse(typeof(TextShade), theme.TextShade.ToString());

            cbPrimary.SelectedIndex      = Array.IndexOf(Enum.GetValues(p.GetType()), p);
            cbDarkPrimary.SelectedIndex  = Array.IndexOf(Enum.GetValues(dp.GetType()), dp);
            cbLightPrimary.SelectedIndex = Array.IndexOf(Enum.GetValues(lp.GetType()), lp);

            cbAccent.SelectedIndex    = Array.IndexOf(Enum.GetValues(acc.GetType()), acc);
            cbTextShade.SelectedIndex = Array.IndexOf(Enum.GetValues(ts.GetType()), ts);

            if (MaterialSkinManager.Instance.Theme != (MaterialSkinManager.Themes)theme.Mode) //changing theme to the same theme is still expensive
            {
                MaterialSkinManager.Instance.Theme = (MaterialSkinManager.Themes)theme.Mode;
            }

            currentSelectedTheme = theme;
            Settings set = BLLocalDatabase.Setting.Settings;

            set.CurrentTheme = theme.Id;
            BLLocalDatabase.Setting.UpdateSettings(set);

            GC.Collect();
        }
        public void Initialize(Application app, Theme theme, Accent accent)
        {
            this.dispatcher = app.Dispatcher;

            var accentUri = CreateAccentResourceUri(accent);

            if (accentUri != null)
            {
                var accentResource = app.Resources.MergedDictionaries.FirstOrDefault(x => Uri.Compare(
                                                                                         x.Source,
                                                                                         accentUri,
                                                                                         UriComponents.AbsoluteUri,
                                                                                         UriFormat.Unescaped,
                                                                                         StringComparison.InvariantCultureIgnoreCase) == 0);

                if (accentResource == null)
                {
                    accentResource = new ResourceDictionary {
                        Source = accentUri
                    };
                    app.Resources.MergedDictionaries.Add(accentResource);
                }

                this.Initialize(app, theme, accentResource);
            }
        }
示例#11
0
        protected override void OnStartup(object sender, System.Windows.StartupEventArgs e)
        {
            base.OnStartup(sender, e);

            Application.DispatcherUnhandledException += (s, ex) => LogError(ex.Exception);

            Environment.CurrentDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);

            Accent accent = ThemeManager.DefaultAccents.First(a => a.Name == UserSettings.Appearance.AccentColor);
            ThemeManager.ChangeTheme(Application.MainWindow, accent, UserSettings.Appearance.Theme);

            IShell shell = Container.GetExportedValue<IShell>();
            UserSettings.Shell = shell;
            ISystemSettings settings = Container.GetExportedValue<ISystemSettings>();
            int storedActiveIndex = settings.ActiveTabIndex;

            if (UserSettings.Application.RememberOpenFiles)
                settings.OpenFiles.Apply(shell.FileNames.Add);

            if (e.Args.Length > 0)
            {
                var newFiles = e.Args.Except(shell.FileNames).ToList();
                newFiles.Apply(shell.FileNames.Add);
                shell.ActiveTabIndex = shell.FileNames.IndexOf(e.Args.Last());
            }
            else
            {
                shell.ActiveTabIndex = storedActiveIndex;
            }
        }
示例#12
0
        // Personalization
        private void UpdateThemeColor()
        {
            Color AppliedThemeColor = settings_modelview.AppliedThemeColor;
            bool  UseDarkTheme      = settings_modelview.UseDarkTheme;

            Accent new_accent = Utils.ThemeColorToAccent(AppliedThemeColor);

            ThemeManager.AddAccent(new_accent.Name, new_accent.Resources.Source);
            ThemeManager.ChangeAppStyle(Application.Current, new_accent, ThemeManager.GetAppTheme(UseDarkTheme ? "BaseDark" : "BaseLight"));

            // Update all charts to dark or light theme
            var all_plotmodels = this.FindChildren <PlotView>().ToList();

            for (int x = 0; x < all_plotmodels.Count; x++)
            {
                PlotView plot = all_plotmodels[x];

                PlotModel model = plot.Model;
                if (model != null)
                {
                    Utils.ApplyThemeToPlot(model, UseDarkTheme);
                    plot.Model.InvalidatePlot(true);
                }
            }

            var all_datetimeupdown = this.FindChildren <DateTimeUpDown>().ToList();

            for (int x = 0; x < all_datetimeupdown.Count; x++)
            {
                all_datetimeupdown[x].Foreground = UseDarkTheme ? Brushes.White : Brushes.Black;
            }
        }
        public virtual void SwitchThemeColor(String baseColor, String accentColor)
        {
            Accent   accent = ThemeManager.GetAccent(accentColor);
            AppTheme theme  = ThemeManager.GetAppTheme(baseColor);

            ThemeManager.ChangeAppStyle(Application.Current, accent, theme);
        }
示例#14
0
        private void ContextMenu_Loaded(object sender, RoutedEventArgs e)
        {
            if (OSVersion.IsWindows10)
            {
                var s   = sender as ContextMenu;
                var res = s.FindResource("SystemChromeLowBrush") as SolidColorBrush;
                var col = res.Color;

                if (!OSVersion.IsWindows10AprilUpdate)
                {
                    var c = res.Clone();
                    c.Opacity    = 0.66;
                    s.Background = c;
                }
                else
                {
                    col.A = 127;

                    var c = res.Clone();
                    c.Opacity    = 0.01;
                    s.Background = c;
                }

                var source = (HwndSource)PresentationSource.FromVisual(s);
                Accent.SetAccentState(source.Handle, AccentState.ACCENT_ENABLE_ACRYLICBLURBEHIND, col);
            }
        }
示例#15
0
        private void ApplyAppTheme(ProtectedSettings ProtectedSettings)
        {
            Tuple <AppTheme, Accent> currentTheme = ThemeManager.DetectAppStyle(Application.Current);

            if (currentTheme == null)
            {
                return;
            }
            AppTheme appTheme    = null;
            Accent   themeAccent = null;

            if (ProtectedSettings.AppTheme != null)
            {
                appTheme = ThemeManager.GetAppTheme(ProtectedSettings.AppTheme);
            }
            if (appTheme == null)
            {
                appTheme = currentTheme.Item1;
            }
            if (ProtectedSettings.ThemeAccent != null)
            {
                themeAccent = ThemeManager.GetAccent(ProtectedSettings.ThemeAccent);
            }
            if (themeAccent == null)
            {
                themeAccent = currentTheme.Item2;
            }
            ProtectedSettings.AppTheme    = appTheme.Name;
            ProtectedSettings.ThemeAccent = themeAccent.Name;
            ThemeManager.ChangeAppStyle(Application.Current, themeAccent, appTheme);
        }
示例#16
0
 void DataChangeHandler(ApplicationData appData, object args)
 {
     if (_roamingSettingsService.ContainsKey(Key))
     {
         var hex = _roamingSettingsService.GetData(Key).ToString();
         Current = Accents.First(c => c.Hex.Equals(hex));
     }
 }
示例#17
0
        public void ChangeWindowAccent(Accent accent)
        {
            //get current app style
            Tuple <AppTheme, Accent> style = ThemeManager.DetectAppStyle(Application.Current);

            //set specific accent
            ThemeManager.ChangeAppStyle(Application.Current, accent, style.Item1);
        }
        private void ChangeTheme(AppTheme baseColour, Accent accentColour)
        {
            // change the theme for the main window so the update is immediate
            ThemeManager.ChangeAppStyle(Application.Current.MainWindow, accentColour, baseColour);

            // change the default theme for all future windows opened
            ThemeManager.ChangeAppStyle(Application.Current, accentColour, baseColour);
        }
示例#19
0
        private void ChangeTheme(string theme)
        {
            string[] parameters = theme.Split('/');
            Accent   accent     = ThemeManager.GetAccent(parameters[1]);
            AppTheme appTheme   = ThemeManager.GetAppTheme(parameters[0]);

            ThemeManager.ChangeAppStyle(Application.Current, accent, appTheme);
        }
示例#20
0
 public MetroStyle(Window window, string defaultAccent = "Blue", string defaultTheme = "BaseLight")
 {
     this.InitializeProperties();
     _window = window;
     Accent.LoadValue(defaultAccent);
     Theme.LoadValue(defaultTheme);
     SetAccentAndTheme(defaultAccent, defaultTheme, _window);
 }
示例#21
0
 public void doDefault()
 {
     accent = ThemeManager.GetAccent("Steel");
     theme  = ThemeManager.GetAppTheme("BaseDark");
     RaisePropertyChangedEvent("Accent");
     RaisePropertyChangedEvent("Theme");
     applyNewStyle();
 }
示例#22
0
 public ColorSchemeValues(Primary primary, Primary darkPrimary, Primary lightPrimary, Accent accent, TextShade textShade)
 {
     this.primary      = primary;
     this.darkPrimary  = darkPrimary;
     this.lightPrimary = lightPrimary;
     this.accent       = accent;
     this.textShade    = textShade;
 }
示例#23
0
    private GameObject getAccentWith(Sprite mask)
    {
        GameObject obj = Instantiate(accentPrefab);
        Accent     acc = obj.GetComponent <Accent>();

        acc.setMask(mask);
        return(obj);
    }
示例#24
0
        public void ChangeAccent(Accent accent)
        {
            var theme = MahApps.Metro.ThemeManager.DetectAppStyle(Application.Current);

            MahApps.Metro.ThemeManager.ChangeAppStyle(Application.Current, accent, theme.Item1);
            CurrentConfiguration.Accent = accent.Name;
            Task.Run(() => Save());
        }
示例#25
0
        protected virtual void ChangeTheme(object sender)
        {
            Tuple <AppTheme, Accent> theme = ThemeManager.DetectAppStyle(Application.Current);
            Accent accent = ThemeManager.GetAccent(this.Name);

            ThemeManager.ChangeAppStyle(Application.Current, accent, theme.Item1);
            SaveTheme(accent, theme.Item1);
        }
示例#26
0
        public MainWindow()
        {
            InitializeComponent();

            SwitchPage.Visibility     = Visibility.Hidden;
            Client.ExecutingDirectory = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

            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;
#if !DEBUG
#endif

            Client.InfoLabel = InfoLabel;
            Client.StartHeartbeat();
            Client.PVPNet = new PVPNetConnection();
            Client.PVPNet.KeepDelegatesOnLogout = false;
            Client.PVPNet.OnError += Client.PVPNet_OnError;

            Steel = new Accent("Steel", new Uri("pack://application:,,,/LegendaryClient;component/Controls/Steel.xaml"));
            if (Properties.Settings.Default.DarkTheme)
            {
                ThemeManager.ChangeTheme(this, Steel, Theme.Dark);
            }

            Client.ChatClient       = new JabberClient();
            ChatContainer.Content   = new ChatPage().Content;
            StatusContainer.Content = new 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.NotificationGrid             = NotificationTempGrid;
            Client.MainWin                      = this;
            Client.Container                    = Container;
            Client.OverlayContainer             = OverlayContainer;
            Client.ChatContainer                = ChatContainer;
            Client.StatusContainer              = StatusContainer;
            Client.LobbyButton                  = SwitchPage;
            Client.NotificationOverlayContainer = NotificationOverlayContainer;
            Client.SoundPlayer                  = SoundPlayer;
            Client.AmbientSoundPlayer           = ASoundPlayer;
            Client.SwitchPage(new PatcherPage());

            this.Closing += new System.ComponentModel.CancelEventHandler(this.MainWindow_Closing);
        }
 public void serialClose()
 {
     currentAccent = ThemeManager.DefaultAccents.First(x => x.Name == "Blue");
     ThemeManager.ChangeTheme(System.Windows.Application.Current, currentAccent, currentTheme);
     StatusRing.IsActive  = false;
     serialFlag           = true;
     StatusTextBlock.Text = "关闭成功";
     SwitchButton.Count   = "打开串口";
 }
示例#28
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ThemeViewModel"/> class.
        /// </summary>
        /// <param name="accent">The accent.</param>
        public ThemeViewModel(Accent accent)
            : base(false)
        {
            Argument.IsNotNull(() => accent);

            ColorName        = accent.Name;
            ColorBrush       = accent.Resources["AccentColorBrush"] as Brush;
            BorderColorBrush = ColorBrush;
        }
示例#29
0
        public MainWindow()
        {
            InitializeComponent();
            Accent   accent = ThemeManager.Accents.First(a => a.Name.Equals("orange", StringComparison.OrdinalIgnoreCase));
            AppTheme theme  = ThemeManager.AppThemes.First(a => a.Name.Equals("BaseLight", StringComparison.OrdinalIgnoreCase));

            ThemeManager.ChangeAppStyle(App.Current, accent, theme);
            Loaded += WindowLoaded;
        }
示例#30
0
        public async Task GetAccentIsCaseInsensitive()
        {
            await TestHost.SwitchToAppThread();

            Accent accent = ThemeManager.GetAccent("blue");

            Assert.NotNull(accent);
            Assert.Equal(new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml"), accent.Resources.Source);
        }
示例#31
0
        public void Change(Accent accent)
        {
            SolidColorBrush brush = null;
            switch (accent)
            {
                case Accent.Purple:
                    brush = new SolidColorBrush(Color.FromRgb(104, 33, 122));
                    break;
                case Accent.Blue:
                    brush = new SolidColorBrush(Color.FromRgb(0, 122, 204));
                    break;
                case Accent.Orange:
                    brush = new SolidColorBrush(Color.FromRgb(202, 81, 0));
                    break;
            }

            app.Resources["AccentBrushKey"] = brush;
        }
示例#32
0
		public void Initialize(Application app, Theme theme, Accent accent)
		{
			this.dispatcher = app.Dispatcher;

			var accentUri = CreateAccentResourceUri(accent);
			if (accentUri != null)
			{
				var accentResource = app.Resources.MergedDictionaries.FirstOrDefault(x => Uri.Compare(
					x.Source,
					accentUri,
					UriComponents.AbsoluteUri,
					UriFormat.Unescaped,
					StringComparison.InvariantCultureIgnoreCase) == 0);

				if (accentResource == null)
				{
					accentResource = new ResourceDictionary { Source = accentUri };
					app.Resources.MergedDictionaries.Add(accentResource);
				}

				this.Initialize(app, theme, accentResource);
			}
		}
		/// <summary>
		/// Defines the Color Scheme to be used for all forms.
		/// </summary>
		/// <param name="primary">The primary color, a -500 color is suggested here.</param>
		/// <param name="darkPrimary">A darker version of the primary color, a -700 color is suggested here.</param>
		/// <param name="lightPrimary">A lighter version of the primary color, a -100 color is suggested here.</param>
		/// <param name="accent">The accent color, a -200 color is suggested here.</param>
		/// <param name="textShade">The text color, the one with the highest contrast is suggested.</param>
		public ColorScheme(Primary primary, Primary darkPrimary, Primary lightPrimary, Accent accent, TextShade textShade)
        {
            //Color
            PrimaryColor = ((int) primary).ToColor();
            DarkPrimaryColor = ((int) darkPrimary).ToColor();
            LightPrimaryColor = ((int) lightPrimary).ToColor();
            AccentColor = ((int) accent).ToColor();
			TextColor = ((int) textShade).ToColor();

            //Pen
            PrimaryPen = new Pen(PrimaryColor);
            DarkPrimaryPen = new Pen(DarkPrimaryColor);
            LightPrimaryPen = new Pen(LightPrimaryColor);
            AccentPen = new Pen(AccentColor);
            TextPen = new Pen(TextColor);

            //Brush
            PrimaryBrush = new SolidBrush(PrimaryColor);
            DarkPrimaryBrush = new SolidBrush(DarkPrimaryColor);
            LightPrimaryBrush = new SolidBrush(LightPrimaryColor);
            AccentBrush = new SolidBrush(AccentColor);
            TextBrush = new SolidBrush(TextColor);
        }
示例#34
0
 private static Uri CreateAccentResourceUri(Accent accent)
 {
     var param = new Dictionary<string, string>
     {
         { "accent", accent.ToString() },
     };
     return accentTemplate.BindByName(templateBaseUri, param);
 }
示例#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;
                }
            }
        }
示例#36
0
		private static Uri CreateAccentResourceUri(Accent accent)
		{
			var uri = string.Format(@"pack://application:,,,/MetroRadiance;component/Themes/Accents/{0}.xaml", accent);
			Uri result;
			return Uri.TryCreate(uri, UriKind.Absolute, out result) ? result : null;
		}
示例#37
0
		public void ChangeAccent(ResourceDictionary resource)
		{
			this.dispatcher.Invoke(() => this.ChangeAccentCore(resource));
			this.Accent = Accent.Original;
		}
示例#38
0
		public void ChangeAccent(Accent accent)
		{
			var uri = CreateAccentResourceUri(accent);
			if (uri != null)
			{
				this.dispatcher.Invoke(() =>
				{
					var resource = new ResourceDictionary { Source = uri };
					this.ChangeAccentCore(resource);
				});
				this.Accent = accent;
			}
		}
示例#39
0
        internal IDisposable Register(ResourceDictionary rd, Theme theme, Accent accent)
        {
            var allDictionaries = EnumerateDictionaries(rd).ToArray();

            var themeDic = GetThemeResource(theme);
            var targetThemeDic = allDictionaries.FirstOrDefault(x => CheckThemeResourceUri(x.Source));
            if (targetThemeDic == null)
            {
                targetThemeDic = themeDic;
                rd.MergedDictionaries.Add(targetThemeDic);
            }
            else
            {
                foreach (var key in themeDic.Keys.OfType<string>().Where(x => targetThemeDic.Contains(x)))
                {
                    targetThemeDic[key] = themeDic[key];
                }
            }
            this.themeResources.Add(targetThemeDic);

            var accentDic = GetAccentResource(accent);
            var targetAccentDic = allDictionaries.FirstOrDefault(x => CheckAccentResourceUri(x.Source));
            if (targetAccentDic == null)
            {
                targetAccentDic = accentDic;
                rd.MergedDictionaries.Add(targetAccentDic);
            }
            else
            {
                foreach (var key in accentDic.Keys.OfType<string>().Where(x => targetAccentDic.Contains(x)))
                {
                    targetAccentDic[key] = accentDic[key];
                }
            }
            this.accentResources.Add(targetAccentDic);

            // Unregister したいときは戻り値の IDisposable を Dispose() してほしい
            return Disposable.Create(() =>
            {
                this.themeResources.Remove(targetThemeDic);
                this.accentResources.Remove(targetAccentDic);
            });
        }
示例#40
0
        public void ChangeAccent(Accent accent)
        {
            if (this.Accent == accent) return;

            this.InvokeOnUIDispatcher(() => this.ChangeAccentCore(accent));
            this.Accent = accent;
        }
示例#41
0
 public void ChangeAccent(Accent accent)
 {
     Data.Settings.Current.WindowTheme_Accent = accent;
     ChangeAccent();
 }
示例#42
0
		public void Initialize(Application app, Theme theme, ResourceDictionary accent)
		{
			this.InitializeCore(app, theme, this.currentAccentDictionary);

			this.Theme = theme;
			this.Accent = Accent.Original;
		}
示例#43
0
        public void ChangeAccent(Accent accent)
        {
            if (!this.initialized || this.Accent == accent) return;

            this.dispatcher.Invoke(() => this.ChangeAccentCore(accentDictionaries[accent]));
            this.Accent = accent;
        }
示例#44
0
 private void UpdateListener(Accent accent)
 {
     if (accent == Accent.Windows)
     {
         if (this.windowsAccentListener == null)
         {
             // アクセントが Windows 依存で、リスナーが未登録だったら購読する
             this.windowsAccentListener = WindowsTheme.Accent.RegisterListener(x => this.ChangeAccentCore(x));
         }
     }
     else if (this.windowsAccentListener != null)
     {
         // アクセントが Windows 依存でないのにリスナーが登録されてたら解除する
         this.windowsAccentListener.Dispose();
         this.windowsAccentListener = null;
     }
 }
示例#45
0
 private void ChangeAccentCore(Accent accent)
 {
     this.ChangeAccentCore(GetAccentResource(accent));
 }
示例#46
0
        public void Initialize(Application app, Theme theme, Accent accent)
        {
            this.InitializeCore(app, theme, accentDictionaries[accent]);

            this.Theme = theme;
            this.Accent = accent;
        }
        internal MainWindowViewModel()
        {
            r_Page = new InitializationPageViewModel(this);
            GameInformation = new GameInformationViewModel(this);

            ApiService.SubscribeOnce("api_start2", delegate
            {
                IsGameStarted = true;
                OnPropertyChanged(nameof(IsGameStarted));
            });

            ShowSessionToolCommand = new DelegatedCommand(() => WindowService.Instance.Show<SessionToolWindow>(r_SessionTool));

            ApiService.Subscribe("api_req_map/start", _ => ThemeManager.Instance.ChangeAccent(Accent.Brown));
            KanColleGame.Current.ReturnedFromSortie += _ => ThemeManager.Instance.ChangeAccent(Accent.Blue);

            Preference.Instance.Game.DisableHeavyDamageBlinkingWarning.Subscribe(rpValue =>
            {
                if (SortieInfo.Current == null)
                    return;

                if (!rpValue)
                    ThemeManager.Instance.ChangeAccent(Accent.Brown);
            });

            r_BlinkingBrownAccent = new Accent("BlinkingBrown", new Uri("pack://application:,,,/HeavenlyWind;component/Themes/Accents/BlinkingBrown.xaml"));

            PropertyChangedEventListener.FromSource(NotificationService.Instance)
                .Add(nameof(NotificationService.Instance.IsBlinking), delegate
                {
                    if (NotificationService.Instance.IsBlinking)
                        ThemeManager.Instance.ChangeAccent(r_BlinkingBrownAccent);
                });

            UISetZoomCommand = new DelegatedCommand<double>(SetZoom);
            UIZoomInCommand = new DelegatedCommand(() => SetZoom(Preference.Instance.UI.Zoom.Value + .05));
            UIZoomOutCommand = new DelegatedCommand(() => SetZoom(Preference.Instance.UI.Zoom.Value - .05));

            UIZoomFactors = new[] { .25, .5, .75, 1.0, 1.25, 1.5, 1.75, 2.0, 3.0, 4.0 }.Select(r => new UIZoomInfo(r, UISetZoomCommand)).ToArray();

            ShowConstructionHistoryCommand = new DelegatedCommand(() => WindowService.Instance.Show<ConstructionHistoryWindow>());
            ShowDevelopmentHistoryCommand = new DelegatedCommand(() => WindowService.Instance.Show<DevelopmentHistoryWindow>());
            ShowSortieHistoryCommand = new DelegatedCommand(() => WindowService.Instance.Show<SortieHistoryWindow>());
            ShowExpeditionHistoryCommand = new DelegatedCommand(() => WindowService.Instance.Show<ExpeditionHistoryWindow>());
            ShowScrappingHistoryCommand = new DelegatedCommand(() => WindowService.Instance.Show<ScrappingHistoryWindow>());
            ShowResourceHistoryCommand = new DelegatedCommand(() => WindowService.Instance.Show<ResourceHistoryWindow>());
            ShowSortieConsumptionHistoryCommand = new DelegatedCommand(() => WindowService.Instance.Show<SortieConsumptionHistoryWindow>());
            ShowSortieStatisticCommand = new DelegatedCommand(() => WindowService.Instance.Show<SortieStatisticWindow>());
        }
示例#48
0
        /// <summary>
        /// テーマ機能を有効化します。テーマまたはアクセントが変更されたとき、<paramref name="app"/>
        /// で指定した WPF アプリケーション内のテーマ関連リソースは自動的に書き換えられます。
        /// </summary>
        /// <param name="app">テーマ関連リソースを含む WPF アプリケーション。</param>
        /// <param name="theme">初期値として使用するテーマ。</param>
        /// <param name="accent">初期値として使用するアクセント。</param>
        /// <returns><paramref name="app"/> をリソースの書き換え対象から外すときに使用する <see cref="IDisposable"/> オブジェクト。</returns>
        public IDisposable Register(Application app, Theme theme, Accent accent)
        {
            this.dispatcher = app.Dispatcher;

            var disposable = this.Register(app.Resources, theme, accent);

            this.Theme = theme;
            this.Accent = accent;

            return disposable;
        }
示例#49
0
 private static ResourceDictionary GetAccentResource(Accent accent)
 {
     return accent.Specified != null
         ? new ResourceDictionary { Source = CreateAccentResourceUri(accent.Specified.Value), }
         : GetAccentResource(accent.Color ?? WindowsTheme.Accent.Current);
 }
示例#50
0
 public void Initialize(Application app, Theme theme, Accent accent)
 {
     this.Register(app, theme, accent);
 }
示例#51
0
		public void ChangeAccent(ResourceDictionary accent)
		{
			if (!this.initialized) return;

			this.dispatcher.Invoke(() => this.ChangeAccentCore(accent));
			this.Accent = Accent.Original;
		}
示例#52
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;
            }
        }
示例#53
0
        public AddonProject()
        {
            projectLocation = null;

            catalog = new Catalog();
            accent = new Accent();
            theme = new Theme();
            language = new Language();
            memoryPatch = new MemoryPatch();
        }