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; }
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) }; }
public static SW.Style ToolbarItemStyle(SW.FrameworkElement value) { if (value is SWC.ComboBox) { return((SW.Style)value.FindResource(SWC.ToolBar.ComboBoxStyleKey)); } else if (value is SWC.Primitives.ToggleButton) { return((SW.Style)value.FindResource(SWC.ToolBar.ToggleButtonStyleKey)); } else if (value is SWC.Separator) { return((SW.Style)value.FindResource(SWC.ToolBar.SeparatorStyleKey)); } return(value.Style); }
public EditorTabItem(System.Windows.FrameworkElement parent, ICanCloseAllDocumentsChecker canCloseAllDocumentsChecker, string filePath, IAppSettings appSettings) { this.HeaderTemplate = parent.FindResource("tabItemHeader") as DataTemplate; EditorTabContentViewModel = new EditorTabContentViewModel(filePath, appSettings); base.Content = new EditorTabContent(parent, EditorTabContentViewModel); EditorTabHeaderViewModel = new EditorTabHeaderViewModel(EditorTabContentViewModel, canCloseAllDocumentsChecker); this.DataContext = EditorTabHeaderViewModel; }
public EditorTabContent(System.Windows.FrameworkElement parent, EditorTabContentViewModel viewModel) { EditorTabContentViewModel = viewModel; this.ContentTemplate = parent.FindResource("editorDataTemplate") as DataTemplate; this.DataContext = viewModel; base.Loaded += OnEditorViewLoaded; }
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; }
// <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); }
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); }
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; }
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); }
private DataTemplate GetTemplate(string key, FrameworkElement element) { return element.FindResource(key) as DataTemplate; }
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; }
private DataTemplate GetTemplate(FrameworkElement element, string Name) { return element.FindResource(Name) as DataTemplate; }