How to change AccentColors on VS2013-Theme?
Closed this issue · 10 comments
Hi I've added a demo for this in the demo application (see bottom screenshot here)
The necessary changes can be seen in this commit in case you want to debug it.
You can pickup the MLibTest demo application from CI
Please review the options 1-3 that I've mentioned in the comments of ResetAccentColorCommand
-> Line 118 - 140 to understand all options to achieve this.
Please let me know if you have more questions/issues about this...
I've already tried these.
IAppearanceManager
can be found under MLib.Interfaces
when these will be imported.
But the compiler can't find the Method GetService
.
Here is a basic sample:
using System.Windows;
using System.Windows.Media;
using DSTEd.Core;
using MLib.Interfaces;
using Xceed.Wpf.AvalonDock;
using Xceed.Wpf.AvalonDock.Layout;
namespace DSTEd.UI {
public partial class IDE : Window {
public IDE() {
InitializeComponent();
var appearance = GetService<IAppearanceManager>();
appearance.SetAccentColor(Color.FromRgb(255, 0, 0));
}
// [...]
}
The GetService() method belongs to the demo application - its defined in ModelBase and available in all viewmodel classes via inheritance (just open the demo App in Visual Studio and Press F12 to find the declaration).
The settings.Themes
bit refers to a collection of theme definitions that is initialized and maintained outside of the IAppearanceManager
itself. See line 53 and below in App.xaml.cs
:
lifeCycle.LoadConfigOnAppStartup(settings, appearance);
So, you could either do the same using the settings component or roll a different approach towards initiallizing and maintaining a collection of themes maintained in IThemeInfos
for setting the theme and AccentColor when needed.
Currently i've tried to copy the VS2013DarkTheme
to create an duplicate, i think that is easier.
Sure, you can just use the theming library: Xceed.Wpf.AvalonDock.Themes.VS2013 and then load the brush keys via:
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Xceed.Wpf.AvalonDock.Themes.VS2013;component/DarkBrushs.xaml" />
</ResourceDictionary.MergedDictionaries>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Xceed.Wpf.AvalonDock.Themes.VS2013;component/LightBrushs.xaml" />
</ResourceDictionary.MergedDictionaries>
and then you can set the accent color as you see fit, using this:
Application.Current.Resources[Xceed.Wpf.AvalonDock.Themes.VS2013.Themes.ResourceKeys.ControlAccentColorKey] = accentColor;
Application.Current.Resources[Xceed.Wpf.AvalonDock.Themes.VS2013.Themes.ResourceKeys.ControlAccentBrushKey] = new SolidColorBrush(accentColor);
OR you make a copy of one of the Brushs.xaml files above and input your own definitions ...
Oh, the second version is an really excelent try - These i had try to set the last hours.
Here is a skeleton of a theme: https://github.com/DST-Tools/DSTEd-Theme
OK, not sure what the $Name thing is - the repository also contains other test applications that can be used for demo loading resources file - just remove the comment here and change to dark
$NAME
is a placeholder. Read the readme :)
I have red the Readme but I still don't understand how it works :-) you generate the source code with PHP or AWK and then compile with VS or what? Whats the point of the placeholder?
Thats correct - No currently i've generate nothing. Later, i will provide scripts for that, sure.
For sample: you want to create an Theme, you create an copy of the skeleton and rename all $NAME
variables.
If you want to name your theme to Light
, Dark
, Colorful
or whatever, you replace these with $NAME
. After that, you can insert these files to your project and build it.