The new TXText
╰ Windows.Forms Namespace
╰ ResourceProvider Class
The ResourceProvider class provides static methods to receive bitmaps or strings from sources that can be accessed via an assigned identifier. provides access to all high resolution images used in the built-in ribbon tabs and toolbars. Additionally, the ResourceProvider returns other built-in resources such as item descriptions and tooltips. This gives you access to a vector-based icon set with 800+ illustrations for our integrated button and ribbon bars. Depending on the selected DPI, the pixel-perfect bitmap in the requested size and resolution is returned for all various ribbon tabs and groups.
This way, you can use all TX Text Control resources in other user interface elements (such as the mini toolbar) to provide a consistent user experience.
The following code is used to create a new ribbon group with a button in the mini toolbar which is part of TX Text Control. A print button is inserted that prints the current document.
// default value | |
float m_DPI = 96; | |
public Form1() | |
{ | |
InitializeComponent(); | |
// use the system DPI | |
m_DPI = CreateGraphics().DpiX; | |
} | |
private void textControl1_TextMiniToolbarInitialized(object sender, | |
TXTextControl.MiniToolbarInitializedEventArgs e) | |
{ | |
// add separators to all groups | |
foreach (RibbonGroup group in e.MiniToolbar.RibbonGroups) | |
{ | |
group.ShowSeperator = true; | |
} | |
// create a new group | |
RibbonGroup rgPrint = new RibbonGroup() | |
{ | |
ShowSeperator = false | |
}; | |
// add new group to mini toolbar | |
e.MiniToolbar.RibbonGroups.Add(rgPrint); | |
// create new RibbonButton | |
RibbonButton rbPrint = new RibbonButton() | |
{ | |
// get the resources from the ResourceProvider | |
SmallIcon = ResourceProvider.GetSmallIcon("TXITEM_Print", m_DPI), | |
LargeIcon = ResourceProvider.GetLargeIcon("TXITEM_Print", m_DPI), | |
Text = ResourceProvider.GetText("TXITEM_Print"), | |
KeyTip = ResourceProvider.GetKeyTip("TXITEM_Print") | |
}; | |
// set the tool tip | |
rbPrint.ToolTip.Description = ResourceProvider.GetToolTipDescription("TXITEM_Print"); | |
rbPrint.ToolTip.Title = ResourceProvider.GetToolTipTitle("TXITEM_Print"); | |
// attached a click event | |
rbPrint.Click += RbPrint_Click; | |
// add a RibbonButton to the new group | |
rgPrint.RibbonItems.Add(rbPrint); | |
} | |
private void RbPrint_Click(object sender, EventArgs e) | |
{ | |
textControl1.Print("MyDocument"); | |
} |
The TXText
╰ Windows.Forms Namespace
╰ ResourceProvider Class
╰ GetSmallIcon Method
Gets a System.Drawing.Bitmap of the small icon that is associated with an item and specified by an identifier or a Scalable Vector Graphics (SVG) stream parameter. accepts the string identifier of the requested resource and the second parameter defines the required resolution. In the Form1 constructor, the DpiX property of a created Graphics object returns the current system resolution.
This way, the ResourceProvider always returns a pixel-perfect image based on the current resolution.