ResourceProvider Class
- Namespace
TXTextControl.WPF
- Package
TXTextControl.from the private NuGet feed or Text Control Offline PackagesTextControl. WPF. SDK
- Assembly
TXTextControl.WPF. dll
- Install
dotnet add package TXTextControl..NET 8 and later. For .NET Framework, referenceTextControl. WPF. SDK TXTextControl.from the setup.WPF. dll
Description
The ResourceProvider class provides static methods to receive bitmaps or strings from sources that can be accessed via an assigned identifier.
Syntax
public class ResourceProviderPublic Class ResourceProviderExamples
The following examples shows how to create a System.Windows.Controls.Ribbon.RibbonSplitButton with the appearance of a ResourceProvider.FileMenuItem.TXITEM_Print button including two drop down items using the ResourceProvider class.
private void Window_Loaded(object sender, RoutedEventArgs e) {
// Get current Dpi value
PresentationSource source = PresentationSource.FromVisual(this);
double dpi = source.CompositionTarget.TransformToDevice.Transform(new Point(96.0, 96.0)).X;
// Create large print ribbon split button
RibbonSplitButton printButton = new RibbonSplitButton();
printButton.LargeImageSource = ResourceProvider.GetLargeIcon(ResourceProvider.FileMenuItem.TXITEM_Print.ToString(), dpi);
printButton.SmallImageSource = ResourceProvider.GetSmallIcon(ResourceProvider.FileMenuItem.TXITEM_Print.ToString(), dpi);
printButton.Label = ResourceProvider.GetText(ResourceProvider.FileMenuItem.TXITEM_Print.ToString());
printButton.KeyTip = ResourceProvider.GetKeyTip(ResourceProvider.FileMenuItem.TXITEM_Print.ToString());
// Create two drop down buttons
// 1. A Quick Print button
RibbonMenuItem printDropDownItem = new RibbonMenuItem();
printDropDownItem.ImageSource = ResourceProvider.GetSmallIcon(ResourceProvider.FileMenuItem.TXITEM_PrintQuick.ToString(), dpi);
printDropDownItem.Header = ResourceProvider.GetText(ResourceProvider.FileMenuItem.TXITEM_PrintQuick.ToString());
printDropDownItem.ToolTipTitle = ResourceProvider.GetToolTipTitle(ResourceProvider.FileMenuItem.TXITEM_PrintQuick.ToString());
printDropDownItem.ToolTipDescription = ResourceProvider.GetToolTipDescription(ResourceProvider.FileMenuItem.TXITEM_PrintQuick.ToString());
printButton.Items.Add(printDropDownItem);
// 2. A Print Preview Button
printDropDownItem = new RibbonMenuItem();
printDropDownItem.ImageSource = ResourceProvider.GetSmallIcon(ResourceProvider.FileMenuItem.TXITEM_PrintPreview.ToString(), dpi);
printDropDownItem.Header = ResourceProvider.GetText(ResourceProvider.FileMenuItem.TXITEM_PrintPreview.ToString());
printDropDownItem.ToolTipTitle = ResourceProvider.GetToolTipTitle(ResourceProvider.FileMenuItem.TXITEM_PrintPreview.ToString());
printDropDownItem.ToolTipDescription = ResourceProvider.GetToolTipDescription(ResourceProvider.FileMenuItem.TXITEM_PrintPreview.ToString());
printButton.Items.Add(printDropDownItem);
ribbonGroup.Items.Add(printButton);
}Private Sub Window_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
' Get current Dpi value
Dim source As PresentationSource = PresentationSource.FromVisual(Me)
Dim dpi As Double = source.CompositionTarget.TransformToDevice.Transform(New Point(96, 96)).X
' Create large ribbon split button
Dim printButton As RibbonSplitButton = New RibbonSplitButton)
printButton.LargeImageSource = ResourceProvider.GetLargeIcon(ResourceProvider.FileMenuItem.TXITEM_Print.ToString, dpi)
printButton.SmallImageSource = ResourceProvider.GetSmallIcon(ResourceProvider.FileMenuItem.TXITEM_Print.ToString, dpi)
printButton.Label = ResourceProvider.GetText(ResourceProvider.FileMenuItem.TXITEM_Print.ToString)
printButton.KeyTip = ResourceProvider.GetKeyTip(ResourceProvider.FileMenuItem.TXITEM_Print.ToString)
' Create two drop down buttons
' 1. A Quick Print button
Dim printDropDownItem As RibbonMenuItem = New RibbonMenuItem
printDropDownItem.ImageSource = ResourceProvider.GetSmallIcon(ResourceProvider.FileMenuItem.TXITEM_PrintQuick.ToString, dpi)
printDropDownItem.Header = ResourceProvider.GetText(ResourceProvider.FileMenuItem.TXITEM_PrintQuick.ToString)
printDropDownItem.ToolTipTitle = ResourceProvider.GetToolTipTitle(ResourceProvider.FileMenuItem.TXITEM_PrintQuick.ToString)
printDropDownItem.ToolTipDescription = ResourceProvider.GetToolTipDescription(ResourceProvider.FileMenuItem.TXITEM_PrintQuick.ToString)
printButton.Items.Add(printDropDownItem)
' 2. A Print Preview Button
printDropDownItem = New RibbonMenuItem
printDropDownItem.ImageSource = ResourceProvider.GetSmallIcon(ResourceProvider.FileMenuItem.TXITEM_PrintPreview.ToString, dpi)
printDropDownItem.Header = ResourceProvider.GetText(ResourceProvider.FileMenuItem.TXITEM_PrintPreview.ToString)
printDropDownItem.ToolTipTitle = ResourceProvider.GetToolTipTitle(ResourceProvider.FileMenuItem.TXITEM_PrintPreview.ToString)
printDropDownItem.ToolTipDescription = ResourceProvider.GetToolTipDescription(ResourceProvider.FileMenuItem.TXITEM_PrintPreview.ToString)
printButton.Items.Add(printDropDownItem)
ribbonGroup.Items.Add(printButton)
End SubThe following example includes a Resource Provider object in application diagnostics. The created object is then available to the surrounding document workflow.
Console.WriteLine(resourceProvider);
Console.WriteLine("Resource Provider is ready for use.");Console.WriteLine(resourceProvider)
Console.WriteLine("Resource Provider is ready for use.")Members
Methods
| Method | Description |
|---|---|
| GetKeyTip | Gets the key tip that is associated with an item and specified by the identifier parameter. Such an identifier can be the string conversion of an enumeration that is associated with an item (such as RibbonFormattingTab.RibbonItem.TXITEM_Paste). By default CultureInfo.CurrentUiCulture determines the language of the key tip resources. If no resource translation is provided, that corresponds to the current ui culture or the value of the culture parameter, the returned key tip is based on the English resources. |
| GetLargeIcon | Gets a System.Windows.Media.Imaging.BitmapSource of the large icon that is associated with an item and specified by an identifier or Scalable Vector Graphics (SVG) stream parameter. The identifier can be the string conversion of an enumeration that is associated with an item (such as RibbonFormattingTab.RibbonItem.TXITEM_Paste). The size of the returned large icon depends on the resolution that is specified by the dpi parameter or a specific framework element. The source of the large image is based on a grid of 32x32 Pixel and a resolution of 96 dpi. |
| GetSmallIcon | Gets a System.Windows.Media.Imaging.BitmapSource of the small icon that is associated with an item and specified by an identifier or Scalable Vector Graphics (SVG) stream parameter. The identifier can be the string conversion of an enumeration that is associated with an item (such as RibbonFormattingTab.RibbonItem.TXITEM_Paste). The size of the returned small icon depends on the resolution that is specified by the dpi parameter or a specific framework element. The source of the small image is based on a grid of 16x16 Pixel and a resolution of 96 dpi. |
| GetText | Gets the text that is associated with an item and specified by the identifier parameter. Such an identifier can be the string conversion of an enumeration that is associated with an item (such as RibbonFormattingTab.RibbonItem.TXITEM_Paste). By default CultureInfo.CurrentUiCulture determines the language of the text resources. If no resource translation is provided, that corresponds to the current ui culture or the value of the culture parameter, the returned text is based on the English resources. |
| GetToolTipDescription | Gets the tool tip description that is associated with an item and specified by the identifier parameter. Such an identifier can be the string conversion of an enumeration that is associated with an item (such as RibbonFormattingTab.RibbonItem.TXITEM_Paste). By default CultureInfo.CurrentUiCulture determines the language of the tool tip description resources. If no resource translation is provided, that corresponds to the current ui culture or the value of the culture paramter, the returned tool tip description is based on the English resources. |
| GetToolTipTitle | Gets the tool tip title that is associated with an item and specified by the identifier parameter. Such an identifier can be the string conversion of an enumeration that is associated with an item (such as RibbonFormattingTab.RibbonItem.TXITEM_Paste). By default CultureInfo.CurrentUiCulture determines the language of the tool tip title. If no resource translation is provided, that corresponds to the current ui culture or the value of the culture paramter, the returned tool tip title is based on the English resources. |
Enumerations
| Enumeration | Description |
|---|---|
| BarcodeItem | Each BarcodeItem represents a drop-down item inside the RibbonInsertTab's TXITEM_Insert_Barcode drop-down menu. The string conversion of each BarcodeItem can be passed as an identifier to static ResourceProvider methods to receive bitmaps or strings that are associated with the corresponding drop-down item. |
| FileMenuItem | Each FileMenuItem represents the identifier for a file menu item. The string conversion of each FileMenuItem can be passed as an identifier to static ResourceProvider methods to receive bitmaps or strings that are associated with the corresponding file menu item. |
| GeneralItem | Each GeneralItem represents the identifier for a general item. The string conversion of each GeneralItem can be passed as an identifier to static ResourceProvider methods to receive bitmaps or strings that are associated with the corresponding general item. |
| ShapeItem | Each ShapeItem represents a gallery item inside the RibbonInsertTab's TXITEM_InsertShape drop-down menu. The string conversion of each ShapeItem can be passed as an identifier to static ResourceProvider methods to receive bitmaps or strings that are associated with the corresponding gallery item. |