/// <summary> /// Initializes the designer with the specified component. /// </summary> /// <param name="component">The IComponent to associate the designer with.</param> public override void Initialize(IComponent component) { // Validate the parameter reference if (component == null) { throw new ArgumentNullException(nameof(component)); } // Let base class do standard stuff base.Initialize(component); // The resizing handles around the control need to change depending on the // value of the AutoSize and AutoSizeMode properties. When in AutoSize you // do not get the resizing handles, otherwise you do. AutoResizeHandles = true; // Cast to correct type _monthCalendar = component as KryptonMonthCalendar; if (_monthCalendar != null) { // Hook into header event _monthCalendar.GetViewManager().MouseUpProcessed += OnCalendarMouseUp; _monthCalendar.GetViewManager().DoubleClickProcessed += OnCalendarDoubleClick; } // Acquire service interfaces _designerHost = (IDesignerHost)GetService(typeof(IDesignerHost)); _changeService = (IComponentChangeService)GetService(typeof(IComponentChangeService)); _selectionService = (ISelectionService)GetService(typeof(ISelectionService)); // We need to know when we are being removed _changeService.ComponentRemoving += OnComponentRemoving; }
/// <summary> /// Releases all resources used by the component. /// </summary> /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param> protected override void Dispose(bool disposing) { if (_monthCalendar != null) { // Unhook from events _monthCalendar.GetViewManager().MouseUpProcessed -= OnCalendarMouseUp; _monthCalendar.GetViewManager().DoubleClickProcessed -= OnCalendarDoubleClick; } _changeService.ComponentRemoving -= OnComponentRemoving; // Must let base class do standard stuff base.Dispose(disposing); }