ComponentOne Ribbon has a RibbonControlHost element which can add arbitrary controls to Ribbon. You can easily add a control by defining a new class inheriting C1.Win.C1Ribbon.RibbonControlHost. First, we will discuss using the same RibbonControlHost element to host C1Gauge in the C1Ribbon and C1StatusBar controls.
Create a new Winforms application. Add a C1RibbonForm in the application and place C1Ribbon and C1StatusBar control. For more information, see Creating a Ribbon Application Project.
In the GaugeHostControl class we will create a gauge object by loading an existing template xml file in the C1LinearGauge object. We will also handle the PointerDragMove event to handle the pointer dragging in the control. The class is as follows:
public class GaugeHostControl: C1.Win.C1Ribbon.RibbonControlHost
{
private C1LinearGauge linearGauge;
public GaugeHostControl()
: base(new C1.Win.C1Gauge.C1Gauge())
{
linearGauge = new C1LinearGauge();
XmlDocument doc = new XmlDocument();
doc.LoadXml(Properties.Resources.Ruler);
linearGauge.Load(doc);
C1Gauge.Gauges.Add(linearGauge);
C1Gauge.BackColor = System.Drawing.Color.Azure;
linearGauge.PointerDragMove += LinearGauge_PointerDragMove;
}
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public C1.Win.C1Gauge.C1Gauge C1Gauge
{
get { return (C1.Win.C1Gauge.C1Gauge)Control; }
}
private void LinearGauge_PointerDragMove(System.Object sender, PointerDragEventArgs e)
{
e.Pointer.UpdateValue(e.NewValue, 0.5);
}
}
After adding this class, build the application.
After the application is built, open the RibbonForm. The following are the simple steps that add GaugeHostControl in C1Ribbon.
Repeat the same steps with C1StatusBar to add the GaugesHostControl. At run time you will be able to interact with the C1Gauge element as you would a standard TextBox. Download Sample