/// <summary> /// Measures the size of the panel on the mode specified by the event object /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <returns></returns> /// public override Size MeasureSize(object sender, RibbonElementMeasureSizeEventArgs e) { if (Site != null && Site.DesignMode && Owner != null) { //when in design mode just paint the name of this control int Width = Convert.ToInt32(e.Graphics.MeasureString(Site.Name, Owner.Font).Width); int Height = 20; SetLastMeasuredSize(new System.Drawing.Size(Width, Height)); } else if (ctl == null || !Visible) { SetLastMeasuredSize(new System.Drawing.Size(0, 0)); } else { ctl.Visible = false; if (_lastSizeMode != e.SizeMode) { _lastSizeMode = e.SizeMode; RibbonHostSizeModeHandledEventArgs hev = new RibbonHostSizeModeHandledEventArgs(e.Graphics, e.SizeMode); OnSizeModeChanging(ref hev); } SetLastMeasuredSize(new System.Drawing.Size(ctl.Size.Width, ctl.Size.Height)); } return(LastMeasuredSize); }
/// <summary> /// Raises the SizeModeChanged event /// </summary> /// <param name="e"></param> public virtual void OnSizeModeChanging(ref RibbonHostSizeModeHandledEventArgs e) { if (SizeModeChanging != null) { SizeModeChanging(this, e); } }
private void ribbonHost3_SizeModeChanging(object sender, RibbonHostSizeModeHandledEventArgs e) { //This is where you set the size of the control for each sizemode. This is really important when //the control resides directly in a panel. This is not needed if the control is hosted in a dropdown //like the month calendar example. switch (e.SizeMode) { case RibbonElementSizeMode.Large: { dataGridView1.Width = 250; break; } case RibbonElementSizeMode.Medium: { dataGridView1.Width = 75; break; } case RibbonElementSizeMode.Compact: { dataGridView1.Visible = false; break; } default: { break; } } }
public override Size MeasureSize(object sender, RibbonElementMeasureSizeEventArgs e) { var design = ((Site?.DesignMode ?? false) || IsOpenInVisualStudioDesigner()); if (design && (Owner != null)) { var width = Convert.ToInt32(e.Graphics.MeasureString(Site.Name, Owner.Font).Width); const int height = 20; if ((width == LastMeasuredSize.Width) && (height == LastMeasuredSize.Height)) { return(LastMeasuredSize); } SetLastMeasuredSize(new Size(width, height)); } else if ((_ctl == null) || !Visible) { SetLastMeasuredSize(new Size(0, 0)); } else { if ((_lastSizeMode == e.SizeMode) && (_ctl.Size.Width == LastMeasuredSize.Width) && (_ctl.Size.Height == LastMeasuredSize.Height)) { return(LastMeasuredSize); } _ctl.Visible = false; if (_lastSizeMode != e.SizeMode) { _lastSizeMode = e.SizeMode; var hev = new RibbonHostSizeModeHandledEventArgs(e.Graphics, e.SizeMode); OnSizeModeChanging(ref hev); } SetLastMeasuredSize(new Size(_ctl.Size.Width, _ctl.Size.Height)); } return(LastMeasuredSize); }
/// <summary> /// Raises the <see cref="SizeModeChanged"/> event /// </summary> /// <param name="e"></param> public virtual void OnSizeModeChanging(ref RibbonHostSizeModeHandledEventArgs e) { if (SizeModeChanging != null) { SizeModeChanging(this, e); } }
/// <summary> /// Measures the size of the panel on the mode specified by the event object /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <returns></returns> public override System.Drawing.Size MeasureSize(object sender, RibbonElementMeasureSizeEventArgs e) { if (Site != null && Site.DesignMode && Owner != null) { //when in design mode just paint the name of this control int Width = Convert.ToInt32(e.Graphics.MeasureString(Site.Name, Owner.Font).Width); int Height = 20; SetLastMeasuredSize(new System.Drawing.Size(Width, Height)); } else if (ctl == null || !Visible) SetLastMeasuredSize(new System.Drawing.Size(0, 0)); else { ctl.Visible = false; if (_lastSizeMode != e.SizeMode) { _lastSizeMode = e.SizeMode; RibbonHostSizeModeHandledEventArgs hev = new RibbonHostSizeModeHandledEventArgs(e.Graphics, e.SizeMode); OnSizeModeChanging(ref hev); } SetLastMeasuredSize(new System.Drawing.Size(ctl.Size.Width + 2, ctl.Size.Height + 2)); } return LastMeasuredSize; }
public virtual void OnSizeModeChanging(ref RibbonHostSizeModeHandledEventArgs e) { SizeModeChanging?.Invoke(this, e); }