/// <summary> /// </summary> /// <param name="targetItem"></param> /// <param name="minWidth"></param> /// <exception cref="ArgumentNullException"> /// <para> /// <paramref name="targetItem"/> is <see langword="null"/>. /// </para> /// </exception> public void SetNewWidth(ToolStripItem targetItem, int minWidth) { if (targetItem == null) { throw new ArgumentNullException("targetItem"); } if (targetItem.Owner == null) { return; } ToolStrip toolStrip = targetItem.Owner; int itemsWidth = 0; foreach (ToolStripItem item in toolStrip.Items) { if ( item != targetItem ) { itemsWidth += item.Width + 1; } } targetItem.Width = Math.Max(minWidth, toolStrip.Width - itemsWidth); NuGenInvoker.InvokeMethod(toolStrip, "OnSizeChanged", EventArgs.Empty); }
/// <summary> /// Invokes the GetStyle method of the specified <see cref="T:Control"/>. /// </summary> /// <param name="ctrl">Specifies the <see cref="T:Control"/> to invoke the GetStyle method for.</param> /// <param name="ctrlStyles">Specifies the control style to check.</param> /// <exception cref="T:System.ArgumentNullException"> /// <paramref name="ctrl"/> is <see langword="null"/>. /// </exception> private static bool InvokeGetStyle(Control ctrl, ControlStyles ctrlStyles) { if (ctrl == null) { throw new ArgumentNullException("ctrl"); } return((bool)NuGenInvoker.InvokeMethod(ctrl, "GetStyle", ctrlStyles)); }
/// <summary> /// Invokes the SetStyle method of the <see cref="T:Control"/>. /// </summary> /// <param name="ctrl">Specifies the <see cref="T:System.Windows.Forms.Control"/> to invoke the SetStyle method for.</param> /// <param name="ctrlStyles">Control styles to set.</param> /// <param name="value"><see langword="true"/> to apply the specified styles to the control; /// otherwise, <see langword="false"/>.</param> /// <exception cref="T:System.ArgumentNullException"> /// <paramref name="ctrl"/> is <see langword="null"/>. /// </exception> private static void InvokeSetStyle(Control ctrl, ControlStyles ctrlStyles, bool value) { if (ctrl == null) { throw new ArgumentNullException("ctrl"); } NuGenInvoker.InvokeMethod(ctrl, "SetStyle", ctrlStyles, value); }