/// <summary> /// Initialize a new instance of the ViewDrawRibbonGroupSeparator class. /// </summary> /// <param name="ribbon">Reference to owning ribbon control.</param> /// <param name="ribbonSeparator">Reference to group separator definition.</param> /// <param name="needPaint">Delegate for notifying paint requests.</param> public ViewDrawRibbonGroupSeparator(KryptonRibbon ribbon, KryptonRibbonGroupSeparator ribbonSeparator, NeedPaintHandler needPaint) { Debug.Assert(ribbon != null); Debug.Assert(ribbonSeparator != null); Debug.Assert(needPaint != null); _ribbon = ribbon; _ribbonSeparator = ribbonSeparator; _needPaint = needPaint; // Associate this view with the source component (required for design time selection) Component = _ribbonSeparator; if (_ribbon.InDesignMode) { // At design time we need to know when the user right clicks the label ContextClickController controller = new ContextClickController(); controller.ContextClick += OnContextClick; MouseController = controller; } // Define back reference to view for the separator definition _ribbonSeparator.SeparatorView = this; // Hook into changes in the ribbon separator definition _ribbonSeparator.PropertyChanged += OnSeparatorPropertyChanged; // Default the preferred size _lastShape = PaletteRibbonShape.Office2007; _preferredSize = _preferredSize2007; }
private void OnAddSep(object sender, EventArgs e) { if ((_ribbonGroup?.Ribbon != null) && _ribbonGroup.RibbonTab.Groups.Contains(_ribbonGroup)) { // Use a transaction to support undo/redo actions DesignerTransaction transaction = _designerHost.CreateTransaction("KryptonRibbonGroup AddSep"); try { // Get access to the Items property MemberDescriptor propertyItems = TypeDescriptor.GetProperties(_ribbonGroup)["Items"]; RaiseComponentChanging(propertyItems); // Get designer to create the new separator component KryptonRibbonGroupSeparator sep = (KryptonRibbonGroupSeparator)_designerHost.CreateComponent(typeof(KryptonRibbonGroupSeparator)); _ribbonGroup.Items.Add(sep); RaiseComponentChanged(propertyItems, null, null); } finally { // If we managed to create the transaction, then do it transaction?.Commit(); } } }
/// <summary> /// Initialize a new instance of the ViewDrawRibbonGroupSeparator class. /// </summary> /// <param name="ribbon">Reference to owning ribbon control.</param> /// <param name="ribbonSeparator">Reference to group separator definition.</param> /// <param name="needPaint">Delegate for notifying paint requests.</param> public ViewDrawRibbonGroupSeparator(KryptonRibbon ribbon, KryptonRibbonGroupSeparator ribbonSeparator, NeedPaintHandler needPaint) { Debug.Assert(ribbon != null); Debug.Assert(ribbonSeparator != null); Debug.Assert(needPaint != null); _ribbon = ribbon; _ribbonSeparator = ribbonSeparator; _needPaint = needPaint; // Associate this view with the source component (required for design time selection) Component = _ribbonSeparator; if (_ribbon.InDesignMode) { // At design time we need to know when the user right clicks the label ContextClickController controller = new ContextClickController(); controller.ContextClick += new MouseEventHandler(OnContextClick); MouseController = controller; } // Define back reference to view for the separator definition _ribbonSeparator.SeparatorView = this; // Hook into changes in the ribbon separator definition _ribbonSeparator.PropertyChanged += new PropertyChangedEventHandler(OnSeparatorPropertyChanged); // Default the preferred size _lastShape = PaletteRibbonShape.Office2007; _preferredSize = _preferredSize2007; }
/// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing) { // Must unhook to prevent memory leaks _ribbonSeparator.PropertyChanged -= OnSeparatorPropertyChanged; // Remove association with definition _ribbonSeparator.SeparatorView = null; _ribbonSeparator = null; } base.Dispose(disposing); }
/// <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) { Debug.Assert(component != null); // Validate the parameter reference if (component == null) { throw new ArgumentNullException(nameof(component)); } // Let base class do standard stuff base.Initialize(component); // Cast to correct type _ribbonSeparator = (KryptonRibbonGroupSeparator)component; _ribbonSeparator.DesignTimeContextMenu += OnContextMenu; // Get access to the services _designerHost = (IDesignerHost)GetService(typeof(IDesignerHost)); _changeService = (IComponentChangeService)GetService(typeof(IComponentChangeService)); // We need to know when we are being removed/changed _changeService.ComponentChanged += OnComponentChanged; }
/// <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) { Debug.Assert(component != null); // Validate the parameter reference if (component == null) throw new ArgumentNullException("component"); // Let base class do standard stuff base.Initialize(component); // Cast to correct type _ribbonSeparator = (KryptonRibbonGroupSeparator)component; _ribbonSeparator.DesignTimeContextMenu += new MouseEventHandler(OnContextMenu); // Get access to the services _designerHost = (IDesignerHost)GetService(typeof(IDesignerHost)); _changeService = (IComponentChangeService)GetService(typeof(IComponentChangeService)); // We need to know when we are being removed/changed _changeService.ComponentChanged += new ComponentChangedEventHandler(OnComponentChanged); }
/// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing) { // Must unhook to prevent memory leaks _ribbonSeparator.PropertyChanged -= new PropertyChangedEventHandler(OnSeparatorPropertyChanged); // Remove association with definition _ribbonSeparator.SeparatorView = null; _ribbonSeparator = null; } base.Dispose(disposing); }