Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Last active July 10, 2019 09:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjoerntx/753cc5558621bc40223fa50dcc331b18 to your computer and use it in GitHub Desktop.
Save bjoerntx/753cc5558621bc40223fa50dcc331b18 to your computer and use it in GitHub Desktop.
// 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");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment