• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Metro.AppTheme类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中MahApps.Metro.AppTheme的典型用法代码示例。如果您正苦于以下问题:C# AppTheme类的具体用法?C# AppTheme怎么用?C# AppTheme使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AppTheme类属于MahApps.Metro命名空间,在下文中一共展示了AppTheme类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: 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


示例2: GetInverseAppThemeReturnsNullForMissingTheme

        public async Task GetInverseAppThemeReturnsNullForMissingTheme()
        {
            await TestHost.SwitchToAppThread();

            var appTheme = new AppTheme("TestTheme", new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseDark.xaml"));

            AppTheme theme = ThemeManager.GetInverseAppTheme(appTheme);

            Assert.Null(theme);
        }
开发者ID:RiderOfTheli,项目名称:MahApps.Metro,代码行数:10,代码来源:ThemeManagerTest.cs


示例3: SwitchTheme

        public void SwitchTheme(AppTheme newTheme)
        {
            Tuple<MahApps.Metro.AppTheme, Accent> appStyle = ThemeManager.DetectAppStyle(Current);

            switch (newTheme) {

                case AppTheme.Light:
                    ThemeManager.ChangeAppStyle(
                        Current,
                        ThemeManager.GetAccent("Blue"),
                        ThemeManager.GetAppTheme("BaseLight"));
                    return;

                case AppTheme.Dark:
                    ThemeManager.ChangeAppStyle(
                        Current,
                        ThemeManager.GetAccent("Green"),
                        ThemeManager.GetAppTheme("BaseDark"));
                    return;

                default:
                    throw new NotImplementedException();
            }
        }
开发者ID:Art-Stea1th,项目名称:Universal-NSC,代码行数:24,代码来源:App.xaml.cs


示例4: ChangeAppStyle

        private static void ChangeAppStyle(ResourceDictionary resources, Tuple<AppTheme, Accent> oldThemeInfo, Accent newAccent, AppTheme newTheme)
        {
            var themeChanged = false;
            if (oldThemeInfo != null)
            {
                var oldAccent = oldThemeInfo.Item2;
                if (oldAccent != null && oldAccent.Name != newAccent.Name)
                {
                    var oldAccentResource = resources.MergedDictionaries.FirstOrDefault(d => d.Source == oldAccent.Resources.Source);
                    if (oldAccentResource != null)
                    {
                        resources.MergedDictionaries.Add(newAccent.Resources);
                        var ok = resources.MergedDictionaries.Remove(oldAccentResource);

                        themeChanged = true;
                    }
                }

                var oldTheme = oldThemeInfo.Item1;
                if (oldTheme != null && oldTheme != newTheme)
                {
                    var oldThemeResource = resources.MergedDictionaries.FirstOrDefault(d => d.Source == oldTheme.Resources.Source);
                    if (oldThemeResource != null)
                    {
                        resources.MergedDictionaries.Add(newTheme.Resources);
                        var ok = resources.MergedDictionaries.Remove(oldThemeResource);

                        themeChanged = true;
                    }
                }
            }
            else
            {
                ChangeAppStyle(resources, newAccent, newTheme);

                themeChanged = true;
            }

            if (themeChanged)
            {
                OnThemeChanged(newAccent, newTheme);
            }
        }
开发者ID:bygreencn,项目名称:MahApps.Metro,代码行数:43,代码来源:ThemeManager.cs


示例5: GetInverseAppTheme

        /// <summary>
        /// Gets the inverse <see cref="AppTheme" /> of the given <see cref="AppTheme"/>.
        /// This method relies on the "Dark" or "Light" affix to be present.
        /// </summary>
        /// <param name="appTheme">The app theme.</param>
        /// <returns>The inverse <see cref="AppTheme"/> or <c>null</c> if it couldn't be found.</returns>
        /// <remarks>
        /// Returns BaseLight, if BaseDark is given or vice versa.
        /// Custom Themes must end with "Dark" or "Light" for this to work, for example "CustomDark" and "CustomLight".
        /// </remarks>
        public static AppTheme GetInverseAppTheme(AppTheme appTheme)
        {
            if (appTheme == null)
                throw new ArgumentNullException("appTheme");

            if (appTheme.Name.EndsWith("dark", StringComparison.InvariantCultureIgnoreCase))
            {
                return GetAppTheme(appTheme.Name.ToLower().Replace("dark", String.Empty) + "light");
            }

            if (appTheme.Name.EndsWith("light", StringComparison.InvariantCultureIgnoreCase))
            {
                return GetAppTheme(appTheme.Name.ToLower().Replace("light", String.Empty) + "dark");
            }

            return null;
        }
开发者ID:bygreencn,项目名称:MahApps.Metro,代码行数:27,代码来源:ThemeManager.cs


示例6: OpenSettings_Click

        private void OpenSettings_Click(object sender, RoutedEventArgs e)
        {
            if (!SettingsFlyout.IsOpen)
            {
                SettingsUsername.Text = getSelfName();
                SettingsStatus.Text = getSelfStatusMessage();
                SettingsNospam.Text = tox.GetNospam().ToString();

                var style = ThemeManager.DetectAppStyle(Application.Current);
                var accent = ThemeManager.GetAccent(style.Item2.Name);
                oldAccent = accent;
                if (accent != null)
                    AccentComboBox.SelectedItem = AccentComboBox.Items.Cast<AccentColorMenuData>().Single(a => a.Name == style.Item2.Name);

                var theme = ThemeManager.GetAppTheme(style.Item1.Name);
                oldAppTheme = theme;
                if (theme != null)
                    AppThemeComboBox.SelectedItem = AppThemeComboBox.Items.Cast<AppThemeMenuData>().Single(a => a.Name == style.Item1.Name);

                ViewModel.UpdateDevices();

                foreach(var item in VideoDevicesComboBox.Items)
                {
                    var device = (VideoMenuData)item;
                    if (device.Name == config.VideoDevice)
                    {
                        VideoDevicesComboBox.SelectedItem = item;
                        break;
                    }
                }

                if (InputDevicesComboBox.Items.Count - 1 >= config.InputDevice)
                    InputDevicesComboBox.SelectedIndex = config.InputDevice;

                if (OutputDevicesComboBox.Items.Count - 1 >= config.OutputDevice)
                    OutputDevicesComboBox.SelectedIndex = config.OutputDevice;

                ChatLogCheckBox.IsChecked = config.EnableChatLogging;
                HideInTrayCheckBox.IsChecked = config.HideInTray;
                PortableCheckBox.IsChecked = config.Portable;
                AudioNotificationCheckBox.IsChecked = config.EnableAudioNotifications;
                AlwaysNotifyCheckBox.IsChecked = config.AlwaysNotify;
	            SpellcheckCheckBox.IsChecked = config.EnableSpellcheck;
				SpellcheckLanguageComboBox.SelectedItem = Enum.GetName(typeof(SpellcheckLanguage), config.SpellcheckLanguage);
                FilterAudioCheckbox.IsChecked = config.FilterAudio;

                if (!string.IsNullOrEmpty(config.ProxyAddress))
                    SettingsProxyAddress.Text = config.ProxyAddress;

                if (config.ProxyPort != 0)
                    SettingsProxyPort.Text = config.ProxyPort.ToString();

                foreach (ComboBoxItem item in ProxyTypeComboBox.Items)
                {
                    if ((ToxProxyType)int.Parse((string)item.Tag) == config.ProxyType)
                    {
                        ProxyTypeComboBox.SelectedItem = item;
                        break;
                    }
                }
            }

            SettingsFlyout.IsOpen = !SettingsFlyout.IsOpen;
        }
开发者ID:WELL-E,项目名称:Toxy-WPF,代码行数:64,代码来源:MainWindow.xaml.cs


示例7: 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


示例8: DetectThemeFromResources

        private static bool DetectThemeFromResources(ref AppTheme detectedTheme, ResourceDictionary dict)
        {
            var enumerator = dict.MergedDictionaries.GetEnumerator();
            while (enumerator.MoveNext())
            {
                var currentRd = enumerator.Current;

                AppTheme matched = null;
                if ((matched = GetAppTheme(currentRd)) != null)
                {
                    detectedTheme = matched;
                    enumerator.Dispose();
                    return true;
                }

                if (DetectThemeFromResources(ref detectedTheme, currentRd))
                {
                    return true;
                }
            }

            enumerator.Dispose();
            return false;
        }
开发者ID:bygreencn,项目名称:MahApps.Metro,代码行数:24,代码来源:ThemeManager.cs


示例9: ChangeAppStyle

 /// <summary>
 /// Sets the style of the specified <see cref="Application" /><paramref name="application" />
 /// </summary>
 /// <remarks>Miguel Santana 2015/05/03</remarks>
 /// <param name="application"></param>
 /// <param name="accentColor"></param>
 /// <param name="themeColor"></param>
 public static void ChangeAppStyle(this Application application, Accent accentColor, AppTheme themeColor = null)
 {
     ThemeManager.ChangeAppStyle(application, accentColor, themeColor ?? DefaultTheme);
 }
开发者ID:soupernothing,项目名称:capstone_stuff,代码行数:11,代码来源:WindowHelper.cs


示例10: SetTheme

        /// <summary>
        ///     Theme of application style.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="routedEventArgs"></param>
        public void SetTheme(object sender, RoutedEventArgs routedEventArgs)
        {
            // get the theme from the current application
            var style = ThemeManager.DetectAppStyle(Application.Current);

            var radiobutton = (RadioButton)sender;
            _styleTheme = style.Item1;

            switch (radiobutton.Name)
            {
                case "Dark":
                    _styleTheme = ThemeManager.GetAppTheme("BaseDark");
                    break;

                case "Light":
                    _styleTheme = ThemeManager.GetAppTheme("BaseLight");
                    break;

                default:
                    _styleTheme = style.Item1;
                    break;
            }

            SetStyle();
        }
开发者ID:evilbaschdi,项目名称:ListFilesByDate,代码行数:30,代码来源:ApplicationStyle.cs


示例11: GetAppTheme

 /// <summary>
 /// Gets app theme with the given app theme and theme type (light or dark).
 /// </summary>
 /// <param name="currentAppTheme"></param>
 /// <param name="theme"></param>
 /// <returns>AppTheme</returns>
 public static AppTheme GetAppTheme(AppTheme currentAppTheme, Theme theme)
 {
     return GetAppTheme(currentAppTheme.Name, theme);
 }
开发者ID:hksonngan,项目名称:MahApps.Metro,代码行数:10,代码来源:ThemeManager.cs


示例12: DarkButtonClick

 private void DarkButtonClick(object sender, RoutedEventArgs e)
 {
     currentTheme = ThemeManager.AppThemes.First(x => x.Name == "BaseDark");
     ThemeManager.ChangeAppStyle(Application.Current, currentAccent, currentTheme);
 }
开发者ID:Tide,项目名称:MahApps.Metro,代码行数:5,代码来源:MainWindow.xaml.cs


示例13: DetectThemeFromAppResources

        internal static bool DetectThemeFromAppResources(out AppTheme detectedTheme)
        {
            detectedTheme = null;

            return DetectThemeFromResources(ref detectedTheme, Application.Current.Resources);
        }
开发者ID:bygreencn,项目名称:MahApps.Metro,代码行数:6,代码来源:ThemeManager.cs


示例14: LightButtonClick

 private void LightButtonClick(object sender, RoutedEventArgs e)
 {
     currentTheme = ThemeManager.DefaultAppThemes.First(x => x.Name == "BaseLight");
     ThemeManager.ChangeTheme(Application.Current, currentAccent, currentTheme);
 }
开发者ID:hksonngan,项目名称:MahApps.Metro,代码行数:5,代码来源:MainWindow.xaml.cs


示例15: GetThemeFromResources

        internal static bool GetThemeFromResources(AppTheme presetTheme, ResourceDictionary dict, ref Tuple<AppTheme, Accent> detectedAccentTheme)
        {
            AppTheme currentTheme = presetTheme;

            Accent matched = null;
            if ((matched = GetAccent(dict)) != null)
            {
                detectedAccentTheme = Tuple.Create<AppTheme, Accent>(currentTheme, matched);
                return true;
            }

            foreach (ResourceDictionary rd in dict.MergedDictionaries)
            {
                if (GetThemeFromResources(presetTheme, rd, ref detectedAccentTheme))
                    return true;
            }

            return false;
        }
开发者ID:bygreencn,项目名称:MahApps.Metro,代码行数:19,代码来源:ThemeManager.cs


示例16: doDefault

 public void doDefault()
 {
     accent = ThemeManager.GetAccent("Steel");
     theme = ThemeManager.GetAppTheme("BaseDark");
     RaisePropertyChangedEvent("Accent");
     RaisePropertyChangedEvent("Theme");
     applyNewStyle();
 }
开发者ID:berkay2578,项目名称:nfsw-server,代码行数:8,代码来源:AppSettings.cs


示例17: InitializeThemeObject

 public void InitializeThemeObject()
 {
     Light = ThemeManager.GetAppTheme("BaseLight");
     CurrentAccent = ThemeManager.GetAccent("Blue");
 }
开发者ID:tuktik,项目名称:Trackball-Project--15-10-15-,代码行数:5,代码来源:MainWindow.xaml.cs


示例18: OpenSettings_Click

        private void OpenSettings_Click(object sender, RoutedEventArgs e)
        {
            userPressedSave = false;
            if (!SettingsFlyout.IsOpen)
            {
                SettingsUsername.Text = tox.GetSelfName();
                SettingsStatus.Text = tox.GetSelfStatusMessage();
                SettingsNospam.Text = tox.GetNospam().ToString();

                Tuple<AppTheme, Accent> style = ThemeManager.DetectAppStyle(System.Windows.Application.Current);
                Accent accent = ThemeManager.GetAccent(style.Item2.Name);
                oldAccent = accent;
                if (accent != null)
                    AccentComboBox.SelectedItem = AccentComboBox.Items.Cast<AccentColorMenuData>().Single(a => a.Name == style.Item2.Name);

                AppTheme theme = ThemeManager.GetAppTheme(style.Item1.Name);
                oldAppTheme = theme;
                if (theme != null)
                    AppThemeComboBox.SelectedItem = AppThemeComboBox.Items.Cast<AppThemeMenuData>().Single(a => a.Name == style.Item1.Name);
            }

            SettingsFlyout.IsOpen = !SettingsFlyout.IsOpen;
        }
开发者ID:RealShine,项目名称:Toxy,代码行数:23,代码来源:MainWindow.xaml.cs



注:本文中的MahApps.Metro.AppTheme类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Controls.Flyout类代码示例发布时间:2022-05-26
下一篇:
C# Metro.Accent类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap