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


C# FrameworkElement.FindResource方法代码示例

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


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

示例1: SetupElementCaches

        public void SetupElementCaches(FrameworkElement uie)
        {
            if (_setup) return;

            FfDefault = (FontFamily) uie.FindResource("DefaultFont"); //get & cache
            FfEmoticon = (FontFamily) uie.FindResource("Emoticon"); //get & cache
            FfUisymbol = (FontFamily) uie.FindResource("DefaultSymbol"); //get & cache
            FfWebsymbol = (FontFamily) uie.FindResource("WebSymbols"); //get & cache

            FsDefault = (double) uie.FindResource("DefaultFontSize"); //get & cache

            BrForeground = (Brush) uie.FindResource("BaseColour"); //get & cache
            BrHover = (Brush) uie.FindResource("HoverColour"); //get & cache
            BrBase = (Brush) uie.FindResource("BaseColour"); //get & cache
            BrText = (Brush) uie.FindResource("TextColour"); //get & cache
            BrTransparent = (Brush) uie.FindResource("TransparentColour"); //get & cache

            WordProcessors = CompositionManager.GetAll<IWordTransfomProvider>().OrderBy(tp => tp.Priority);
                //get & cache
            SentenceProcessors = CompositionManager.GetAll<IParagraphTransfomProvider>().OrderBy(tp => tp.Priority);
                //get & cache
            MediaProcessors = CompositionManager.GetAll<IMediaProvider>(); //get & cache
            UrlExpanders = CompositionManager.Get<IUrlExpandService>(); //get & cache
            ApplicationSettings = CompositionManager.Get<IApplicationSettingsProvider>(); //get & cache
            AdditonalTextSmarts = CompositionManager.GetAll<IAdditonalTextSmarts>(); //get & cache
            GlobalExcludeSettings = CompositionManager.Get<IGlobalExcludeSettings>(); //get & cache

            _setup = true;
        }
开发者ID:nickhodge,项目名称:MahTweets.LawrenceHargrave,代码行数:29,代码来源:TextProcessorEngine.cs

示例2: GetContainer

        internal static DependencyObject GetContainer(FrameworkElement frameworkElement, object item)
        {
            if (item is MenuItemSeparator)
                return new Separator { Style = (Style)frameworkElement.FindResource(SeparatorStyleKey) };

            string styleKey = (item is CheckableMenuItem) ? "CheckableMenuItem" : "MenuItem";
            return new MenuItem { Style = (Style)frameworkElement.FindResource(styleKey) };
        }
开发者ID:lukebuehler,项目名称:gemini,代码行数:8,代码来源:MenuItem.cs

示例3: Init

 public static void Init(FrameworkElement element)
 {
     _resultStyle = element.FindResource("Result") as Style;
     _resultPartStyle = element.FindResource("ResultPart") as Style;
     _resultKindStyle = element.FindResource("ResultKind") as Style;
     _commandStyle = element.FindResource("Command") as Style;
     _commandPartStyle = element.FindResource("CommandPart") as Style;
     _commandSelected = element.FindResource("SelectedCommand") as Style;
     _resultSelected = element.FindResource("SelectedResult") as Style;
 }
开发者ID:shellscape,项目名称:Lumen,代码行数:10,代码来源:Styles.cs

示例4: GetDouble

 // <summary>
 // Looks up a double based on the specified key, returning specified fallback value if not found
 // </summary>
 // <param name="element">Element to use as the starting point</param>
 // <param name="key">Key to look up</param>
 // <param name="fallbackValue">Fallback value to return if key is not found</param>
 // <returns>Double from the resource or fallback value if not found</returns>
 public static double GetDouble(FrameworkElement element, string key, double fallbackValue) 
 {
     if (element == null) 
     {
         throw FxTrace.Exception.ArgumentNull("element");
     }
     if (string.IsNullOrEmpty(key)) 
     {
         throw FxTrace.Exception.ArgumentNull("key");
     }
     return (double)(element.FindResource(key) ?? fallbackValue);
 }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:19,代码来源:ResourceUtilities.cs

示例5: SearchTickAdorner

        public SearchTickAdorner(double adornerY, FrameworkElement adornedElement)
            : base(adornedElement)
        {
            _brush = adornedElement.FindResource(new ComponentResourceKey(typeof(ExplorerContent), "SearchResultBrush")) as Brush;
            var tooltip = new ToolTip();
            tooltip.Content = null;
            ToolTip = tooltip;

            _tickSize = GetTickSize(adornedElement);

            // The center point of of the adorner shape that will be rendered
            _center = new Point(adornedElement.ActualWidth / 2, adornerY);
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:13,代码来源:SearchTickAdorner.cs

示例6: GetInline

        private static Inline GetInline(FrameworkElement element, InlineDescription description)
        {
            Style style = null;
            if (!string.IsNullOrEmpty(description.StyleName))
            {
                style = element.FindResource(description.StyleName) as Style;
                if (style == null)
                    throw new InvalidOperationException("The style '" + description.StyleName + "' cannot be found");
            }

            Inline inline = null;
            switch (description.Type)
            {
                case InlineType.Run:
                    var run = new Run(description.Text);
                    inline = run;
                    break;

                case InlineType.LineBreak:
                    var lineBreak = new LineBreak();
                    inline = lineBreak;
                    break;

                case InlineType.Span:
                    var span = new Span();
                    inline = span;
                    break;

                case InlineType.Bold:
                    var bold = new Bold();
                    inline = bold;
                    break;

                case InlineType.Italic:
                    var italic = new Italic();
                    inline = italic;
                    break;

                case InlineType.Hyperlink:
                    var hyperlink = new Hyperlink();
                    inline = hyperlink;
                    break;

                case InlineType.Underline:
                    var underline = new Underline();
                    inline = underline;
                    break;
            }

            if (inline != null)
            {
                var span = inline as Span;
                if (span != null)
                {
                    var childInlines =
                        description.Inlines.Select(inlineDescription => GetInline(element, inlineDescription))
                            .Where(childInline => childInline != null)
                            .ToList();

                    span.Inlines.AddRange(childInlines);
                }

                if (style != null)
                    inline.Style = style;
            }

            return inline;
        }
开发者ID:robertiagar,项目名称:Windows-10-Login-Background-Changer,代码行数:68,代码来源:InlineExpression.cs

示例7: ShowWaitDialog

 public static void ShowWaitDialog(FrameworkElement target)
 {
     var overlayTemplate = target.FindResource("FakeProgressOverlay");
     // windows do not have an adorner layer, try their first (and only) child
     // else this is not working
     // hooray for voodoo
     if (target is Window)
         target = LogicalTreeHelper.GetChildren(target).OfType<FrameworkElement>().FirstOrDefault();
     target.SetValue(ContentAdorner.AdornerContentTemplateProperty, overlayTemplate);
 }
开发者ID:jrgcubano,项目名称:zetbox,代码行数:10,代码来源:ContentAdorner.cs

示例8: GetTemplate

 private DataTemplate GetTemplate(string key, FrameworkElement element)
 {
     return element.FindResource(key) as DataTemplate;
 }
开发者ID:SneakyMax,项目名称:Cortex-Command-Mod-Manager,代码行数:4,代码来源:ModListItemTemplateSelector.cs

示例9: UpdateBackground

        public static void UpdateBackground(FrameworkElement anyElement, ref object backgroundContent) {
            if (!Instance.Enabled) {
                backgroundContent = ((FrameworkElement)backgroundContent)?.Tag ?? backgroundContent;
                return;
            }

            var rectangle = backgroundContent as Rectangle;
            var visualBrush = rectangle?.Fill as VisualBrush;

            if (visualBrush == null) {
                visualBrush = (VisualBrush)anyElement.FindResource(@"FancyBackgroundBrush");
                rectangle = new Rectangle {
                    Fill = visualBrush,
                    Tag = backgroundContent
                };

                backgroundContent = rectangle;
            }

            var frameworkElement = (FrameworkElement)visualBrush.Visual;
            var backgroundImage0 = (Image)LogicalTreeHelper.FindLogicalNode(frameworkElement, @"BackgroundImage0");
            var backgroundImage1 = (Image)LogicalTreeHelper.FindLogicalNode(frameworkElement, @"BackgroundImage1");
            if (backgroundImage0 == null || backgroundImage1 == null) return;

            var state = frameworkElement.Tag as int? ?? 0;
            (state == 0 ? backgroundImage1 : backgroundImage0).Source = UriToCachedImageConverter.Convert(Instance.BackgroundFilename);
            VisualStateManager.GoToElementState(backgroundImage1, @"State" + state, true);
            frameworkElement.Tag = 1 - state;
        }
开发者ID:gro-ove,项目名称:actools,代码行数:29,代码来源:FancyBackgroundManager.cs

示例10: GetTemplate

 private DataTemplate GetTemplate(FrameworkElement element, string Name)
 {
     return element.FindResource(Name) as DataTemplate;
 }
开发者ID:David-Desmaisons,项目名称:MusicCollection,代码行数:4,代码来源:FoundItemTemplateSelector.cs


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