本文整理汇总了C#中MahApps.Metro.Accent类的典型用法代码示例。如果您正苦于以下问题:C# Accent类的具体用法?C# Accent怎么用?C# Accent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Accent类属于MahApps.Metro命名空间,在下文中一共展示了Accent类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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());
}
开发者ID:ProjectTako,项目名称:HearthstoneTracker,代码行数:7,代码来源:ThemeManager.cs
示例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);
}
开发者ID:Irdis,项目名称:VSTalk,代码行数:7,代码来源:ThemeManager.cs
示例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);
}
}
开发者ID:evilbaschdi,项目名称:ListFilesByDate,代码行数:35,代码来源:ApplicationStyle.cs
示例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);
}
开发者ID:ZyshchykMaksim,项目名称:MahApps.Metro,代码行数:7,代码来源:ThemeManager.cs
示例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);
}
开发者ID:polmbo,项目名称:SaveGameManager,代码行数:7,代码来源:PageSwitcher.xaml.cs
示例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];
}
开发者ID:tilv37,项目名称:SmartStorage-PC-WPF,代码行数:7,代码来源:MainWindow.xaml.cs
示例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);
}
开发者ID:pdsullivan,项目名称:MahApps.Metro,代码行数:7,代码来源:ThemeManager.cs
示例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());
}
开发者ID:BraveStarr1,项目名称:LegendaryClient,代码行数:58,代码来源:MainWindow.xaml.cs
示例9: App
public App()
: base()
{
Messenger.Default.Register<BalloonToolTipMessage>(this, HandleToolTipMessage);
//load possible assemblies
var n = new GoToMessage();
var a = new Accent();
DispatcherUnhandledException += OnDispatcherUnhandledException;
}
开发者ID:ericschultz,项目名称:gui,代码行数:9,代码来源:App.xaml.cs
示例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"));
}
开发者ID:CarverLab,项目名称:onCore.root,代码行数:9,代码来源:TenCentMailWindow.cs
示例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);
}
}
开发者ID:haashkanani,项目名称:code-samples,代码行数:56,代码来源:ThemeManagerHelper.cs
示例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);
}
开发者ID:icygit,项目名称:Orchestra,代码行数:56,代码来源:MahAppsHelper.cs
示例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;
}
开发者ID:aegisarma3,项目名称:chimera,代码行数:16,代码来源:MainWindow.xaml.cs
示例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);
}
}
开发者ID:stefan-schweiger,项目名称:MahApps.Metro,代码行数:46,代码来源:ThemeManager.cs
示例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());
}
开发者ID:rftiiv15,项目名称:LegendaryClient-Devtest,代码行数:42,代码来源:MainWindow.xaml.cs
示例16: OnThemeChanged
private static void OnThemeChanged(Accent newAccent, Theme newTheme)
{
SafeRaise.Raise(IsThemeChanged, Application.Current, new OnThemeChangedEventArgs() { Theme = newTheme, Accent = newAccent });
Action apply = () =>
{
if (SystemColors_InvalidateColors != null)
{
SystemColors_InvalidateColors.Invoke(null, null);
}
// See: https://github.com/MahApps/MahApps.Metro/issues/923
//var invalidateParameters = typeof(SystemParameters).GetMethod("InvalidateCache", BindingFlags.Static | BindingFlags.NonPublic, null, Type.EmptyTypes, null);
//if (invalidateParameters != null)
//{
// invalidateParameters.Invoke(null, null);
//}
if (SystemResources_OnThemeChanged != null)
{
SystemResources_OnThemeChanged.Invoke(null, null);
}
if (SystemResources_InvalidateResources != null)
{
SystemResources_InvalidateResources.Invoke(null, new object[] { false });
}
};
if (InvalidateSystemResourcesOnBackgroundThread)
{
Task.Factory.StartNew(apply);
}
else
{
apply();
}
}
开发者ID:pdsullivan,项目名称:MahApps.Metro,代码行数:38,代码来源:ThemeManager.cs
示例17: ChangeTheme
public void ChangeTheme()
{
var myAccent = new Accent("AccentName", new Uri(Settings.Default.Theme));
ThemeManager.ChangeAppStyle(Application.Current,
myAccent,
(Settings.Default.DarkTheme)
? ThemeManager.GetAppTheme("BaseDark")
: ThemeManager.GetAppTheme("BaseLight"));
var random = new Random().Next(-9000, 9000);
myAccent = new Accent(random.ToString(), new Uri(Settings.Default.Theme));
ThemeManager.ChangeAppStyle(Application.Current,
myAccent,
(Settings.Default.DarkTheme)
? ThemeManager.GetAppTheme("BaseDark")
: ThemeManager.GetAppTheme("BaseLight"));
Client.CurrentAccent = myAccent;
}
开发者ID:cooler-farmer,项目名称:LegendaryClient,代码行数:17,代码来源:MainWindow.xaml.cs
示例18: InitializeGui
private void InitializeGui()
{
ReturnToPage.Visibility = Visibility.Hidden;
Client.UserTitleBarLabel = UserTitleBarLabel;
Client.UserTitleBarImage = UserTitleBarImage;
Client.InfoLabel = InfoLabel;
if (string.IsNullOrEmpty(Settings.Default.Theme))
Settings.Default.Theme = "pack://application:,,,/LegendaryClient;component/Controls/Steel.xaml";
_myAccent = new Accent("AccentName", new Uri(Settings.Default.Theme));
ThemeManager.ChangeAppStyle(this,
_myAccent,
(Settings.Default.DarkTheme)
? ThemeManager.GetAppTheme("BaseDark")
: ThemeManager.GetAppTheme("BaseLight"));
ChatContainer.Content = Client.FriendList.Content;
Client.notificationPage = new NotificationPage();
NotificationContainer.Content = Client.notificationPage.Content;
Client.statusPage = new StatusPage();
StatusContainer.Content = Client.statusPage.Content;
NotificationOverlayContainer.Content = new Grid();
Grid notificationTempGrid = null;
foreach (var x in NotificationOverlayContainer.GetChildObjects().OfType<Grid>())
notificationTempGrid = x;
ChangeTheme();
Client.FullNotificationOverlayContainer = FullNotificationOverlayContainer;
Client.PlayButton = PlayButton;
Client.Pages = new List<Page>();
Client.MainGrid = MainGrid;
Client.BackgroundImage = BackImage;
Client.NotificationGrid = notificationTempGrid;
Client.MainWin = this;
Client.Container = Container;
Client.OverlayContainer = OverlayContainer;
Client.OverOverlayContainer = OverOverlayContainer;
Client.NotificationContainer = NotificationContainer;
Client.ChatContainer = ChatContainer;
Client.StatusContainer = StatusContainer;
Client.ReturnButton = ReturnToPage;
Client.inQueueTimer = inQueueTimer;
Client.NotificationOverlayContainer = NotificationOverlayContainer;
Client.SoundPlayer = SoundPlayer;
Client.AmbientSoundPlayer = ASoundPlayer;
Client.SwitchPage(new PatcherPage());
if (!string.IsNullOrEmpty(Settings.Default.LoginPageImage) && Settings.Default.UseAsBackgroundImage)
{
if (File.Exists(Path.Combine(Client.ExecutingDirectory, "Assets", "champions", Settings.Default.LoginPageImage.Replace("\r\n", ""))))
Client.BackgroundImage.Source =
new BitmapImage(new Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "champions", Settings.Default.LoginPageImage), UriKind.Absolute));
}
// screen resolution fix: because MainWindow height is bigger than some screen height
if (SystemParameters.WorkArea.Height < Height)
{
// resize LC to MinHeight -- a UI designer may edit this
SizeToContent = SizeToContent.Manual;
Width = MinWidth;
MinHeight = Height;
}
}
开发者ID:cooler-farmer,项目名称:LegendaryClient,代码行数:68,代码来源:MainWindow.xaml.cs
示例19: ChangeAppStyle
public static void ChangeAppStyle(ResourceDictionary resources, Accent newAccent, AppTheme newTheme)
{
if (resources == null) throw new ArgumentNullException("resources");
ApplyResourceDictionary(newAccent.Resources, resources);
ApplyResourceDictionary(newTheme.Resources, resources);
}
开发者ID:bygreencn,项目名称:MahApps.Metro,代码行数:7,代码来源:ThemeManager.cs
示例20: OnThemeChanged
private static void OnThemeChanged(Accent newAccent, AppTheme newTheme)
{
SafeRaise.Raise(IsThemeChanged, Application.Current, new OnThemeChangedEventArgs() { AppTheme = newTheme, Accent = newAccent });
}
开发者ID:bygreencn,项目名称:MahApps.Metro,代码行数:4,代码来源:ThemeManager.cs
注:本文中的MahApps.Metro.Accent类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论