当前位置: 首页>>代码示例>>C#>>正文


C# ResourceDictionary.Remove方法代码示例

本文整理汇总了C#中System.Windows.ResourceDictionary.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# ResourceDictionary.Remove方法的具体用法?C# ResourceDictionary.Remove怎么用?C# ResourceDictionary.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.ResourceDictionary的用法示例。


在下文中一共展示了ResourceDictionary.Remove方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ApplyResourceDictionary

        private static void ApplyResourceDictionary(ResourceDictionary newRd, ResourceDictionary oldRd)
        {
            foreach (DictionaryEntry r in newRd)
            {
                if (oldRd.Contains(r.Key))
                    oldRd.Remove(r.Key);

                oldRd.Add(r.Key, r.Value);
            }
        }
开发者ID:ritics,项目名称:MahApps.Metro,代码行数:10,代码来源:ThemeManager.cs

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

示例3: SetThemeSource

        private void SetThemeSource(Uri source, bool useThemeAccentColor)
        {
            if (source == null) {
                throw new ArgumentNullException("source");
            }

            var oldThemeDict = GetThemeDictionary();
            var dictionaries = Application.Current.Resources.MergedDictionaries;
            var themeDict = new ResourceDictionary { Source = source };

            // if theme defines an accent color, use it
            var accentColor = themeDict[KeyAccentColor] as Color?;
            if (accentColor.HasValue) {
                // remove from the theme dictionary and apply globally if useThemeAccentColor is true
                themeDict.Remove(KeyAccentColor);

                if (useThemeAccentColor) {
                    ApplyAccentColor(accentColor.Value);
                }
            }

            // add new before removing old theme to avoid dynamicresource not found warnings
            dictionaries.Add(themeDict);

            // remove old theme
            if (oldThemeDict != null) {
                dictionaries.Remove(oldThemeDict);
            }

            OnPropertyChanged("ThemeSource");
        }
开发者ID:3A9C,项目名称:ITstep,代码行数:31,代码来源:AppearanceManager.cs

示例4: MergedDictionaries_KeyClashes

		public void MergedDictionaries_KeyClashes ()
		{
			var key = "Key";
			var value = new object ();
			var value1 = new object ();
			var value2 = new object ();

			var merge1 = new ResourceDictionary ();
			var merge2 = new ResourceDictionary ();
			ResourceDictionary main = new ResourceDictionary ();
			main.MergedDictionaries.Add (merge1);
			main.MergedDictionaries.Add (merge2);

			main.Add (key, value);
			merge1.Add (key, value1);
			merge2.Add (key, value2);
			
			// We ignore the values in the merged dictionaries if the main dictionary
			// has the key
			Assert.AreEqual (value, main [key], "#1");

			main.Remove (key);

			// We should look up the merged dictionaries in reverse order
			Assert.AreEqual (value2,main [key],  "#2");

			merge2.Remove (key);

			// Now we should find it in the first merged dictionary
			Assert.AreEqual (value1, main [key], "#3");
		}
开发者ID:dfr0,项目名称:moon,代码行数:31,代码来源:ResourceDictionaryTest.cs

示例5: Contains_TypeAndStringInResourceDictionary_TypeFirst

		public void Contains_TypeAndStringInResourceDictionary_TypeFirst()
		{
			var rd = new ResourceDictionary();
			rd.Add(typeof(Button), new Style { TargetType = typeof(Button) });
			rd.Add("System.Windows.Controls.Button", "System.Windows.Controls.Button");

			Assert.IsTrue(rd.Contains(typeof(Button)), "#1");
			Assert.IsTrue(rd.Contains("System.Windows.Controls.Button"), "#2");

			rd.Remove(typeof(Button));
			Assert.IsFalse(rd.Contains(typeof(Button)), "#3");
			Assert.IsTrue(rd.Contains("System.Windows.Controls.Button"), "#4");
		}
开发者ID:dfr0,项目名称:moon,代码行数:13,代码来源:ResourceDictionaryTest.cs

示例6: LoadResources

        private void LoadResources(string[] uriStrings)
        {
            foreach (string uri in uriStrings)
            {
                ResourceDictionary resources = new ResourceDictionary();
                resources.Source = new Uri(uri, UriKind.Relative);

                foreach (object key in resources.Keys)
                {
                    object value = resources[key];
                    resources.Remove(key);
                    this.Resources.Add(key, value);
                }
            }
        }
开发者ID:NBitionDevelopment,项目名称:WindowsPhoneFeedBoard,代码行数:15,代码来源:App.xaml.cs

示例7: SetThemeSource

        static void SetThemeSource(Uri source)
        {
            var oldThemeDict = GetThemeDictionary();
            var dictionaries = Application.Current.Resources.MergedDictionaries;
            var themeDict = new ResourceDictionary { Source = source };

            // if theme defines an accent color, use it
            var accentColor = themeDict[KeyAccentColor] as Color?;
            if (accentColor.HasValue)
                // remove from the theme dictionary and apply globally if useThemeAccentColor is true
                themeDict.Remove(KeyAccentColor);

            // add new before removing old theme to avoid dynamicresource not found warnings
            dictionaries.Add(themeDict);

            // remove old theme
            if (oldThemeDict != null) dictionaries.Remove(oldThemeDict);
        }
开发者ID:phamthaithinh,项目名称:Captura,代码行数:18,代码来源:AppearanceSettings.xaml.cs


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