// *********************************
// Message from Original Author:
//
// 2008 Jose Menendez Poo
// Please give me credit if you use this code. It's all I ask.
// Contact me for more info: menendezpoo@gmail.com
// *********************************
//
// Original project from http://ribbon.codeplex.com/
// Continue to support and maintain by http://officeribbon.codeplex.com/
using System.ComponentModel;
using System.Windows.Forms.Classes.Collections;
namespace System.Windows.Forms
{
///
/// Represents a collection of RibbonPanel objects
///
public sealed class RibbonPanelCollection
: RibbonCollectionBase
{
///
/// Creates a new RibbonPanelCollection
///
/// RibbonTab that contains this panel collection
/// ownerTab is null
public RibbonPanelCollection(RibbonTab ownerTab)
: base(null)
{
OwnerTab = ownerTab ?? throw new ArgumentNullException(nameof(ownerTab));
}
///
/// Gets the Ribbon that contains this panel collection
///
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public override Ribbon Owner => base.Owner ?? OwnerTab.Owner;
///
/// Gets the RibbonTab that contains this panel collection
///
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public RibbonTab OwnerTab { get; private set; }
internal override void SetOwner(RibbonPanel item)
{
item.SetOwner(Owner);
item.SetOwnerTab(OwnerTab);
}
internal override void ClearOwner(RibbonPanel item)
{
item.ClearOwner();
}
///
/// Notifies the and about changes in the .
///
internal override void UpdateRegions()
{
try
{
OwnerTab.UpdatePanelsRegions();
if (Owner != null && Owner.IsDisposed == false)
{
Owner.UpdateRegions();
Owner.Invalidate();
}
}
catch
{
// ignored
}
}
///
/// Sets the value of the Owner Property
///
internal override void SetOwner(Ribbon owner)
{
base.SetOwner(owner);
foreach (RibbonPanel panel in this)
{
panel.SetOwner(owner);
}
}
///
/// Sets the value of the OwnerTab Property
///
internal void SetOwnerTab(RibbonTab ownerTab)
{
OwnerTab = ownerTab;
foreach (RibbonPanel panel in this)
{
panel.SetOwnerTab(OwnerTab);
}
}
}
}