protected override void Dispose(bool disposing)
{
if (disposing)
{
if (_ribbonGallery != null)
{
// Must unhook to prevent memory leaks
if (_ribbonGallery.LastGallery != null)
_ribbonGallery.LastGallery.Ribbon = null;
_ribbonGallery.MouseEnterControl -= new EventHandler(OnMouseEnterControl);
_ribbonGallery.MouseLeaveControl -= new EventHandler(OnMouseLeaveControl);
_ribbonGallery.ViewPaintDelegate = null;
_ribbonGallery.PropertyChanged -= new PropertyChangedEventHandler(OnGalleryPropertyChanged);
_ribbon.ViewRibbonManager.LayoutAfter -= new EventHandler(OnLayoutAction);
_ribbon.ViewRibbonManager.LayoutBefore -= new EventHandler(OnLayoutAction);
// Remove association with definition
_ribbonGallery.GalleryView = null;
_ribbonGallery = null;
}
}
base.Dispose(disposing);
}