本文整理汇总了C#中MahApps.Metro.Accent类的典型用法代码示例。如果您正苦于以下问题:C# Accent类的具体用法?C# Accent怎么用?C# Accent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Accent类属于MahApps.Metro命名空间,在下文中一共展示了Accent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ChangeAccent
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());
}
示例2: ChangeTheme
public static void ChangeTheme(ResourceDictionary r, Accent accent, Theme theme)
{
ThemeIsDark = (theme == Theme.Dark);
var themeResource = (theme == Theme.Light) ? LightResource : DarkResource;
ApplyResourceDictionary(themeResource, r);
ApplyResourceDictionary(accent.Resources, r);
}
示例3: Load
/// <summary>
/// </summary>
public void Load()
{
if (!string.IsNullOrWhiteSpace(Properties.Settings.Default.Accent))
{
_styleAccent = ThemeManager.GetAccent(Properties.Settings.Default.Accent);
}
if (!string.IsNullOrWhiteSpace(Properties.Settings.Default.Theme))
{
_styleTheme = ThemeManager.GetAppTheme(Properties.Settings.Default.Theme);
}
_mainWindow.Accent.SelectedValue = _styleAccent.Name;
switch (_styleTheme.Name)
{
case "BaseDark":
_mainWindow.Dark.IsChecked = true;
_mainWindow.Light.IsChecked = false;
break;
case "BaseLight":
_mainWindow.Dark.IsChecked = false;
_mainWindow.Light.IsChecked = true;
break;
}
SetStyle();
foreach (var accent in ThemeManager.Accents)
{
_mainWindow.Accent.Items.Add(accent.Name);
}
}
示例4: ChangeTheme
public static void ChangeTheme(Window window, Accent newAccent, Theme newTheme)
{
if (window == null) throw new ArgumentNullException("window");
var oldTheme = DetectTheme(window);
ChangeTheme(window.Resources, oldTheme, newAccent, newTheme);
}
示例5: ChangeTheme
private void ChangeTheme(object sender, RoutedEventArgs e)
{
this.currentAccent = ThemeManager.DefaultAccents.First(x => x.Name == "Green");
ThemeManager.ChangeTheme(App.Current, this.currentAccent, this.currentTheme);
ThemeManager.ChangeTheme(this, this.currentAccent, this.currentTheme);
//ThemeManager.ChangeTheme((ResourceDictionary)this.FindResource("CurrentAccent"), this.currentAccent, Theme.Light);
}
示例6: SkinButton_Click
private void SkinButton_Click(object sender, RoutedEventArgs e)
{
Int32 i = random.Next(0,21);
currentAccent = ThemeManager.DefaultAccents.First(x => x.Name == accentAll[i]);
ThemeManager.ChangeTheme(Application.Current, currentAccent, currentTheme);
Application.Current.Properties["currentAccent"] = accentAll[i];
}
示例7: ChangeTheme
public static void ChangeTheme(Application app, Accent newAccent, Theme newTheme)
{
if (app == null) throw new ArgumentNullException("app");
var oldTheme = DetectTheme(app);
ChangeTheme(app.Resources, oldTheme, newAccent, newTheme);
}
示例8: MainWindow
public MainWindow()
{
InitializeComponent();
Client.ExecutingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
//Set up logging before we do anything
AppDomain.CurrentDomain.FirstChanceException += CurrentDomain_FirstChanceException;
if (File.Exists(Path.Combine(Client.ExecutingDirectory, "lcdebug.log")))
{
File.Delete(Path.Combine(Client.ExecutingDirectory, "lcdebug.log"));
}
AppDomain.CurrentDomain.FirstChanceException += CurrentDomain_FirstChanceException;
if (File.Exists(Path.Combine(Client.ExecutingDirectory, "lcdebug.log")))
{
File.Delete(Path.Combine(Client.ExecutingDirectory, "lcdebug.log"));
}
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;
NotificationContainer.Content = new NotificationsPage().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.NotificationContainer = NotificationContainer;
Client.NotificationOverlayContainer = NotificationOverlayContainer;
Client.SwitchPage(new PatcherPage());
}
示例9: App
public App()
: base()
{
Messenger.Default.Register<BalloonToolTipMessage>(this, HandleToolTipMessage);
//load possible assemblies
var n = new GoToMessage();
var a = new Accent();
DispatcherUnhandledException += OnDispatcherUnhandledException;
}
示例10: TenCentMailWindow
protected TenCentMailWindow()
{
var accent = new Accent("TenCentMail", new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/TenCentMail.xaml"));
ThemeManager.ChangeTheme(this, accent, Theme.Light);
WindowStartupLocation = WindowStartupLocation.CenterOwner;
Width = 516;
Loaded += (sender, e) => MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
SetBinding(DialogCloser.DialogResultProperty, new Binding("DialogResult"));
}
示例11: CreateAppStyleBy
public static void CreateAppStyleBy(Color color, bool changeImmediately = false)
{
// create a runtime accent resource dictionary
var resourceDictionary = new ResourceDictionary();
resourceDictionary.Add("HighlightColor", color);
resourceDictionary.Add("AccentColor", Color.FromArgb((byte)(204), color.R, color.G, color.B));
resourceDictionary.Add("AccentColor2", Color.FromArgb((byte)(153), color.R, color.G, color.B));
resourceDictionary.Add("AccentColor3", Color.FromArgb((byte)(102), color.R, color.G, color.B));
resourceDictionary.Add("AccentColor4", Color.FromArgb((byte)(51), color.R, color.G, color.B));
resourceDictionary.Add("HighlightBrush", new SolidColorBrush((Color)resourceDictionary["HighlightColor"]));
resourceDictionary.Add("AccentColorBrush", new SolidColorBrush((Color)resourceDictionary["AccentColor"]));
resourceDictionary.Add("AccentColorBrush2", new SolidColorBrush((Color)resourceDictionary["AccentColor2"]));
resourceDictionary.Add("AccentColorBrush3", new SolidColorBrush((Color)resourceDictionary["AccentColor3"]));
resourceDictionary.Add("AccentColorBrush4", new SolidColorBrush((Color)resourceDictionary["AccentColor4"]));
resourceDictionary.Add("WindowTitleColorBrush", new SolidColorBrush((Color)resourceDictionary["AccentColor"]));
resourceDictionary.Add("ProgressBrush", new LinearGradientBrush(
new GradientStopCollection(new[]
{
new GradientStop((Color)resourceDictionary["HighlightColor"], 0),
new GradientStop((Color)resourceDictionary["AccentColor3"], 1)
}),
new Point(0.001, 0.5), new Point(1.002, 0.5)));
resourceDictionary.Add("CheckmarkFill", new SolidColorBrush((Color)resourceDictionary["AccentColor"]));
resourceDictionary.Add("RightArrowFill", new SolidColorBrush((Color)resourceDictionary["AccentColor"]));
resourceDictionary.Add("IdealForegroundColor", Colors.White);
resourceDictionary.Add("IdealForegroundColorBrush", new SolidColorBrush((Color)resourceDictionary["IdealForegroundColor"]));
resourceDictionary.Add("AccentSelectedColorBrush", new SolidColorBrush((Color)resourceDictionary["IdealForegroundColor"]));
// applying theme to MahApps
var resDictName = string.Format("ApplicationAccent_{0}.xaml", color.ToString().Replace("#", string.Empty));
var fileName = Path.Combine(Path.GetTempPath(), resDictName);
using (var writer = System.Xml.XmlWriter.Create(fileName, new System.Xml.XmlWriterSettings { Indent = true }))
{
System.Windows.Markup.XamlWriter.Save(resourceDictionary, writer);
writer.Close();
}
resourceDictionary = new ResourceDictionary() { Source = new Uri(fileName, UriKind.Absolute) };
var newAccent = new Accent { Name = resDictName, Resources = resourceDictionary };
ThemeManager.AddAccent(newAccent.Name, newAccent.Resources.Source);
if (changeImmediately)
{
var application = Application.Current;
var applicationTheme = ThemeManager.AppThemes.First(x => string.Equals(x.Name, "BaseLight"));
ThemeManager.ChangeAppStyle(application, newAccent, applicationTheme);
}
}
示例12: ApplyTheme
/// <summary>
/// Sets the theme color of the application. This method dynamically creates an in-memory resource
/// dictionary containing the accent colors used by MahApps.
/// </summary>
public static void ApplyTheme()
{
//<Color x:Key="HighlightColor">
// #800080
//</Color>
//<Color x:Key="AccentColor">
// #CC800080
//</Color>
//<Color x:Key="AccentColor2">
// #99800080
//</Color>
//<Color x:Key="AccentColor3">
// #66800080
//</Color>
//<Color x:Key="AccentColor4">
// #33800080
//</Color>
//<SolidColorBrush x:Key="HighlightBrush" Color="{StaticResource HighlightColor}" />
//<SolidColorBrush x:Key="AccentColorBrush" Color="{StaticResource AccentColor}" />
//<SolidColorBrush x:Key="AccentColorBrush2" Color="{StaticResource AccentColor2}" />
//<SolidColorBrush x:Key="AccentColorBrush3" Color="{StaticResource AccentColor3}" />
//<SolidColorBrush x:Key="AccentColorBrush4" Color="{StaticResource AccentColor4}" />
//<SolidColorBrush x:Key="WindowTitleColorBrush" Color="{StaticResource AccentColor}" />
//<SolidColorBrush x:Key="AccentSelectedColorBrush" Color="White" />
//<LinearGradientBrush x:Key="ProgressBrush" EndPoint="0.001,0.5" StartPoint="1.002,0.5">
// <GradientStop Color="{StaticResource HighlightColor}" Offset="0" />
// <GradientStop Color="{StaticResource AccentColor3}" Offset="1" />
//</LinearGradientBrush>
//<SolidColorBrush x:Key="CheckmarkFill" Color="{StaticResource AccentColor}" />
//<SolidColorBrush x:Key="RightArrowFill" Color="{StaticResource AccentColor}" />
//<Color x:Key="IdealForegroundColor">
// Black
//</Color>
//<SolidColorBrush x:Key="IdealForegroundColorBrush" Color="{StaticResource IdealForegroundColor}" />
// Theme is always the 0-index of the resources
var application = Application.Current;
var applicationResources = application.Resources;
var resourceDictionary = applicationResources.MergedDictionaries[0];
var applicationTheme = ThemeManager.AppThemes.First(x => string.Equals(x.Name, "BaseLight"));
// Insert to get the best MahApps performance (when looking up themes)
applicationResources.MergedDictionaries.Insert(1, applicationTheme.Resources);
Log.Debug("Applying theme to MahApps");
var newAccent = new Accent { Resources = resourceDictionary };
ThemeManager.ChangeAppStyle(application, newAccent, applicationTheme);
}
示例13: SetTheme
private Accent SetTheme(Accent t)
{
Accent c = currTheme;
if (currTheme != t)
{
currTheme = t;
Application.Current.Dispatcher.Invoke(() =>
{
var themestr = (repository.LatestManifest != null && repository.LatestManifest.darkTheme) ?
"BaseDark" : "BaseLight";
ThemeManager.ChangeAppStyle(Application.Current, t, ThemeManager.GetAppTheme(themestr));
});
}
return c;
}
示例14: ChangeTheme
private static void ChangeTheme(ResourceDictionary resources, Tuple<Theme, Accent> oldThemeInfo, Accent accent, Theme newTheme)
{
if (oldThemeInfo != null)
{
var oldAccent = oldThemeInfo.Item2;
if (oldAccent != null && oldAccent.Name != accent.Name)
{
var accentResource = resources.MergedDictionaries.FirstOrDefault(d => d.Source == oldAccent.Resources.Source);
if (accentResource != null) {
var ok = resources.MergedDictionaries.Remove(accentResource);
// really need this???
foreach (DictionaryEntry r in accentResource)
{
if (resources.Contains(r.Key))
resources.Remove(r.Key);
}
resources.MergedDictionaries.Add(accent.Resources);
}
}
var oldTheme = oldThemeInfo.Item1;
if (oldTheme != null && oldTheme != newTheme)
{
var oldThemeResource = (oldTheme == Theme.Light) ? LightResource : DarkResource;
var md = resources.MergedDictionaries.FirstOrDefault(d => d.Source == oldThemeResource.Source);
if (md != null)
{
var ok = resources.MergedDictionaries.Remove(md);
var newThemeResource = (newTheme == Theme.Light) ? LightResource : DarkResource;
// really need this???
foreach (DictionaryEntry r in oldThemeResource)
{
if (resources.Contains(r.Key))
resources.Remove(r.Key);
}
resources.MergedDictionaries.Add(newThemeResource);
}
}
}
else
{
ChangeTheme(resources, accent, newTheme);
}
}
示例15: MainWindow
public MainWindow()
{
InitializeComponent();
Client.ExecutingDirectory = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
Client.InfoLabel = InfoLabel;
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.NotificationOverlayContainer = NotificationOverlayContainer;
Client.SwitchPage(new PatcherPage());
}