private void OnAddCluster(object sender, EventArgs e)
{
if ((_ribbonLines != null) &&
(_ribbonLines.Ribbon != null) &&
_ribbonLines.RibbonGroup.Items.Contains(_ribbonLines))
{
// Use a transaction to support undo/redo actions
DesignerTransaction transaction = _designerHost.CreateTransaction("KryptonRibbonGroupLines AddCluster");
try
{
// Get access to the Items property
MemberDescriptor propertyItems = TypeDescriptor.GetProperties(_ribbonLines)["Items"];
RaiseComponentChanging(propertyItems);
// Get designer to create a cluster with buttons
KryptonRibbonGroupCluster cluster = (KryptonRibbonGroupCluster)_designerHost.CreateComponent(typeof(KryptonRibbonGroupCluster));
_ribbonLines.Items.Add(cluster);
// Get access to the Cluster.Items property
MemberDescriptor propertyClusterItems = TypeDescriptor.GetProperties(cluster)["Items"];
RaiseComponentChanging(propertyClusterItems);
// Get designer to create three new button components
KryptonRibbonGroupClusterButton button1 = (KryptonRibbonGroupClusterButton)_designerHost.CreateComponent(typeof(KryptonRibbonGroupClusterButton));
KryptonRibbonGroupClusterButton button2 = (KryptonRibbonGroupClusterButton)_designerHost.CreateComponent(typeof(KryptonRibbonGroupClusterButton));
cluster.Items.Add(button1);
cluster.Items.Add(button2);
RaiseComponentChanged(propertyClusterItems, null, null);
RaiseComponentChanged(propertyItems, null, null);
}
finally
{
// If we managed to create the transaction, then do it
if (transaction != null)
transaction.Commit();
}
}
}