本文整理汇总了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;
}
示例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) };
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例8: GetTemplate
private DataTemplate GetTemplate(string key, FrameworkElement element)
{
return element.FindResource(key) as DataTemplate;
}
示例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;
}
示例10: GetTemplate
private DataTemplate GetTemplate(FrameworkElement element, string Name)
{
return element.FindResource(Name) as DataTemplate;
}