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


C# ResourceDictionary.Add方法代码示例

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


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

示例1: AdvancedEditWindow

 public AdvancedEditWindow(a_animes AnimeToChange, AniMoDBEntities db)
 {
     ResourceDictionary d = new ResourceDictionary();
     d.Add("vm", new AdvancedEditVM(db, AnimeToChange));
     this.Resources.MergedDictionaries.Add(d);
     InitializeComponent();
 }
开发者ID:mcgamer0070,项目名称:AniMoCity,代码行数:7,代码来源:AdvancedEditWindow.xaml.cs

示例2: Main

        public static void Main(string[] args)
        {
            var application = new Application();
            var resourceDictionary = new ResourceDictionary();
            resourceDictionary.Add("Dunno", new LinearGradientBrush());
            resourceDictionary.Add("Dunno1", new LinearGradientBrush(Color.FromRgb(0x35, 0x56, 0xc6), Color.FromRgb(0x20, 0x39, 0x77),
                    new Point(0, 0), new Point(0, 1)));
            resourceDictionary.Add("Dunno2", new LinearGradientBrush(Colors.Peru, Colors.Coral, new Point(0, 0), new Point(0, 1)));
            application.Resources = resourceDictionary;

            var cb = new ContainerBuilder();
            cb.RegisterModule<TurbinaModule>().RegisterModule<TurbinaNodesModule>();
            var container = cb.Build();

            application.Run(new MainWindow(container));
        }
开发者ID:misupov,项目名称:Turbina,代码行数:16,代码来源:Program.cs

示例3: ExportViewToXaml

    public static void ExportViewToXaml( ViewBase view, string fileName )
    {
      if( view == null )
        throw new ArgumentNullException( "view" );

      object value;
      DependencyProperty dp;
      ResourceDictionary resourceDictionary = new ResourceDictionary();
      Type viewType = view.GetType();
      Style viewStyle = new Style( viewType );

      foreach( FieldInfo fieldInfo in viewType.GetFields( BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Static ) )
      {
        dp = fieldInfo.GetValue( view ) as DependencyProperty;

        if( dp != null )
        {
          value = view.ReadLocalValue( dp );

          if( value != DependencyProperty.UnsetValue )
            viewStyle.Setters.Add( new Setter( dp, value ) );
        }
      }

      resourceDictionary.Add( viewType, viewStyle );

      XmlWriterSettings settings = new XmlWriterSettings();
      settings.Indent = true;
      settings.OmitXmlDeclaration = true;

      using( XmlWriter xmlWriter = XmlWriter.Create( fileName, settings ) )
      {
        XamlWriter.Save( resourceDictionary, xmlWriter );
      }
    }
开发者ID:omid55,项目名称:real_state_manager,代码行数:35,代码来源:ViewImportExportManager.cs

示例4: GetDictionary

        //private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
        public static ResourceDictionary GetDictionary(string relativePath = @"Resources\Dictionaries")
        {
            var mergedDictionary = new ResourceDictionary();
            string path = Path.Combine(HttpRuntime.AppDomainAppPath, relativePath);

            if (Directory.Exists(path))
                foreach (string fileName in Directory.GetFiles(path).Where(f => f.EndsWith(".xaml")))
                    using (var fs = new FileStream(fileName, FileMode.Open))
                    {
                        try
                        {
                            var xr = new XamlReader();

                            var tmp = (ResourceDictionary)XamlReader.Load(fs);
                            foreach (string key in tmp.Keys)
                                if (tmp[key] is Canvas)
                                {
                                    mergedDictionary.Add(key, tmp[key]);
                                }

                        }
                        catch (Exception)
                        {
                            //_logger.Error(ex.Message);
                        }
                    }
            else
                Directory.CreateDirectory(path);

            return mergedDictionary;
        }
开发者ID:kib357,项目名称:Ester2,代码行数:32,代码来源:ResourceDictionaries.cs

示例5: FillupResource

 public void FillupResource(ResourceDictionary res)
 {
     foreach (var fd in FrameDescriptions.Values)
     {
         res.Add(GetBrushResourceNameForDescriptor(fd.Descriptor),
             new SolidColorBrush(fd.HighlightColor));
     }
 }
开发者ID:NpoSaut,项目名称:CanFlashlight,代码行数:8,代码来源:ProtocolDescription.cs

示例6: ChangeRd

 private void ChangeRd(ResourceDictionary rd, string newKey, object newValue)
 {
     if (!rd.Contains(newKey))
     {
         rd.Add(newKey, newValue);
         SaveChange();
     }
 }
开发者ID:ClemensT,项目名称:WPF-Samples,代码行数:8,代码来源:MainWindow.cs

示例7: CreateAccentColorResourceDictionary

        public static ResourceDictionary CreateAccentColorResourceDictionary(this Color color)
        {
            if (_accentColorResourceDictionary != null)
            {
                return _accentColorResourceDictionary;
            }
            var resourceDictionary = new ResourceDictionary();

            resourceDictionary.Add("NotificationAccentColor", color);

            resourceDictionary.Add("NotificationAccentColorBrush", new SolidColorBrush((Color) resourceDictionary["NotificationAccentColor"]));

            var application = Application.Current;
            var applicationResources = application.Resources;
            applicationResources.MergedDictionaries.Insert(0, resourceDictionary);

            _accentColorResourceDictionary = resourceDictionary;
            return applicationResources;
        }
开发者ID:punker76,项目名称:Orc.Notifications,代码行数:19,代码来源:ColorExtensions.cs

示例8: WrapInResourceDictionary

 public static ResourceDictionary WrapInResourceDictionary(object obj)
 {
     var rd = new ResourceDictionary();
     var list = obj as IEnumerable;
     if (list != null)
     {
         int i = 1;
         foreach (var o in list)
         {
             rd.Add("Model" + i, o);
             i++;
         }
     }
     else
     {
         rd.Add("Model", obj);
     }
     return rd;
 }
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:19,代码来源:XamlExporter.cs

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

示例10: Tests

        public Tests()
        {
            if (applicationService == null)
            {
                Console.WriteLine("Initialisation des Tests");

                Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary
                {
                    Source =
                        new Uri(
                        "/Proteca.SilverlightUnitTest;component/Assets/Styles.xaml",
                        UriKind.RelativeOrAbsolute)
                });
                Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary
                {
                    Source =
                        new Uri(
                        "/Proteca.SilverlightUnitTest;component/Assets/GridView.xaml",
                        UriKind.RelativeOrAbsolute)
                });
                Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary
                {
                    Source =
                        new Uri(
                        "/Proteca.SilverlightUnitTest;component/Assets/Boutons.xaml",
                        UriKind.RelativeOrAbsolute)
                });
                Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary
                {
                    Source =
                        new Uri(
                        "/Proteca.SilverlightUnitTest;component/Assets/TileView.xaml",
                        UriKind.RelativeOrAbsolute)
                });
                ResourceDictionary dic = new ResourceDictionary();
                dic.Add("ApplicationResources", new Proteca.Silverlight.ApplicationResources());
                Application.Current.Resources.MergedDictionaries.Add(dic);

                if (Application.Current.Resources.Any(r => r.Key.ToString() == "ServiceHostAdress"))
                {
                    Application.Current.Resources.Remove("ServiceHostAdress");
                }
                Application.Current.Resources.Add("ServiceHostAdress", "http://verd174:90/");
                if (!Application.Current.Resources.Any(r => r.Key.ToString() == "DebugLogin"))
                {
                    Application.Current.Resources.Add("DebugLogin", "n.cossard");
                }

                if (applicationService == null)
                {
                    applicationService = new ApplicationService();
                    applicationService.StartService(null);
                }
            }
        }
开发者ID:JeanNguon,项目名称:Projet,代码行数:55,代码来源:Tests.cs

示例11: GetItemContainerStyle

 private static Style GetItemContainerStyle()
 {
     Style listBoxItemStyle = new Style(typeof(ListBoxItem));
     listBoxItemStyle.Setters.Add(new Setter(ListBox.FocusVisualStyleProperty, null));   // убираем рамку из точек вокруг выделенного элемента
     listBoxItemStyle.Setters.Add(new Setter(ListBox.PaddingProperty, new Thickness(0)));    // убираем отступы от края родительского элемента
     listBoxItemStyle.Setters.Add(new Setter(ListBoxItem.MarginProperty, new Thickness(0, 0, 0, 1)));    // добавляем отступ снизу каждого элемента
     ResourceDictionary resources = new ResourceDictionary();
     resources.Add(SystemColors.HighlightBrushKey, new SolidColorBrush(Colors.Transparent));
     listBoxItemStyle.Resources = resources;
     return listBoxItemStyle;
 }
开发者ID:Genotoxicity,项目名称:KSPE3Lib,代码行数:11,代码来源:ApplicationSelectingWindow.cs

示例12: Register

        public static void Register(ResourceDictionary resources)
        {
            var buttonTemplate = new FrameworkElementFactory(typeof(ButtonTemplate));

            var controlTemplate = new ControlTemplate(typeof(ToggleButton));
            controlTemplate.VisualTree = buttonTemplate;

            var style = new Style(typeof(ToggleButton));
            style.Setters.Add(new Setter(Control.TemplateProperty, controlTemplate));

            resources.Add(typeof(ToggleButton), style);
        }
开发者ID:kswoll,项目名称:restless,代码行数:12,代码来源:ToggleButtonStyle.cs

示例13: CreateRemoteAgent

        /// <summary>
        /// Create a remote agent with the given name
        /// </summary>
        public static RemoteAgentTag CreateRemoteAgent(string agentName, ITextView view, IEditorFormatMap formatMap)
        {
            Dictionary<string, RemoteAgentTag> existingAgents = GetExistingAgents(view);

            RemoteAgentTag agent;
            if (existingAgents.TryGetValue(agentName, out agent))
                return agent;

            var brushes = _brushes[existingAgents.Count % _brushes.Count];

            ResourceDictionary agentDictionary = new ResourceDictionary();
            agentDictionary.Add(MarkerFormatDefinition.BorderId, brushes.Item1);
            agentDictionary.Add(MarkerFormatDefinition.FillId, brushes.Item2);

            formatMap.AddProperties(agentName, agentDictionary);

            agent = new RemoteAgentTag(agentName);
            existingAgents[agentName] = agent;

            return agent;
        }
开发者ID:NoahRic,项目名称:TypingAgent,代码行数:24,代码来源:RemoteAgentTag.cs

示例14: Register

        public static void Register(ResourceDictionary resources)
        {
            var textBoxTemplate = new FrameworkElementFactory(typeof(TextBoxTemplate));
            textBoxTemplate.AppendChild(new FrameworkElementFactory(typeof(ScrollViewer), "PART_ContentHost"));

            var controlTemplate = new ControlTemplate(typeof(TextBox));
            controlTemplate.VisualTree = textBoxTemplate;

            var style = new Style(typeof(TextBox));
            style.Setters.Add(new Setter(Control.TemplateProperty, controlTemplate));

            resources.Add(typeof(TextBox), style);
        }
开发者ID:kswoll,项目名称:restless,代码行数:13,代码来源:TextBoxStyle.cs

示例15: TemplateAndStyleFindDefaultTest

        public void TemplateAndStyleFindDefaultTest()
        {
            Style style = new Style { TargetType = typeof(Control) };
            style.Setters.Add(new Setter { Property = new DependencyPropertyPathElement(FrameworkElement.WidthProperty), Value = 100 });

            string text = @"
            <ControlTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' TargetType='{x:Type Control}'>
                <FrameworkElement/>
            </ControlTemplate>";

            ControlTemplate controlTemplate = XamlLoader.Load(XamlParser.Parse(text)) as ControlTemplate;

            ResourceDictionary resources = new ResourceDictionary();
            resources.Add(new StyleKey(typeof(Control)), style);
            resources.Add(new TemplateKey(typeof(Control)), controlTemplate);

            Control control = new Control();
            control.Resources = resources;

            Assert.AreEqual(style, control.Style);
            Assert.AreEqual(controlTemplate, control.Template);
        }
开发者ID:highzion,项目名称:Granular,代码行数:22,代码来源:FrameworkTemplateTest.cs


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