示例#1
0
 public static IDisposable CreateTransactionIf(bool condition, Control controlToLayout, Control elementCausingLayout, string property)
 {
     if (condition)
     {
         return(new LayoutTransaction(controlToLayout, elementCausingLayout, property));
     }
     CommonProperties.xClearPreferredSizeCache(elementCausingLayout);
     return(new NullLayoutTransaction());
 }
示例#2
0
 public static void DoLayout(Control elementToLayout, Control elementCausingLayout, string property)
 {
     if (elementCausingLayout != null)
     {
         CommonProperties.xClearPreferredSizeCache(elementCausingLayout);
         if (elementToLayout != null)
         {
             CommonProperties.xClearPreferredSizeCache(elementToLayout);
             elementToLayout.PerformLayout(elementCausingLayout, property);
         }
     }
 }
示例#3
0
 public static void DoLayoutIf(bool condition, Control elementToLayout, Control elementCausingLayout, string property)
 {
     if (!condition)
     {
         if (elementCausingLayout != null)
         {
             CommonProperties.xClearPreferredSizeCache(elementCausingLayout);
         }
     }
     else
     {
         DoLayout(elementToLayout, elementCausingLayout, property);
     }
 }
示例#4
0
 private void InstallNewImage(System.Drawing.Image value, ImageInstallationType installationType)
 {
     this.StopAnimate();
     this.image = value;
     LayoutTransaction.DoLayoutIf(this.AutoSize, this, this, PropertyNames.Image);
     this.Animate();
     if (installationType != ImageInstallationType.ErrorOrInitial)
     {
         this.AdjustSize();
     }
     this.imageInstallationType = installationType;
     base.Invalidate();
     CommonProperties.xClearPreferredSizeCache(this);
 }
示例#5
0
        internal override void ResetScaling(int newDpi)
        {
            base.ResetScaling(newDpi);
            CommonProperties.xClearPreferredSizeCache(this);
            scaledDefaultImageSize                = DpiHelper.LogicalToDeviceUnits(DefaultImageSize, newDpi);
            scaledDefaultImageMarginWidth         = DpiHelper.LogicalToDeviceUnits(DefaultImageMarginWidth, newDpi) + 1;         // 1px for border
            scaledDefaultImageAndCheckMarginWidth = DpiHelper.LogicalToDeviceUnits(DefaultImageAndCheckMarginWidth, newDpi) + 1; // 1px for border

            scaledImagePadding = DpiHelper.LogicalToDeviceUnits(ImagePadding, newDpi);
            scaledTextPadding  = DpiHelper.LogicalToDeviceUnits(TextPadding, newDpi);
            scaledCheckPadding = DpiHelper.LogicalToDeviceUnits(CheckPadding, newDpi);
            scaledArrowPadding = DpiHelper.LogicalToDeviceUnits(ArrowPadding, newDpi);
            scaledArrowSize    = DpiHelper.LogicalToDeviceUnits(ArrowSize, newDpi);
        }
示例#6
0
 public LayoutTransaction(Control controlToLayout, Control controlCausingLayout, string property, bool resumeLayout)
 {
     CommonProperties.xClearPreferredSizeCache(controlCausingLayout);
     this._controlToLayout = controlToLayout;
     this._resumeLayout    = resumeLayout;
     if (this._controlToLayout != null)
     {
         this._controlToLayout.SuspendLayout();
         CommonProperties.xClearPreferredSizeCache(this._controlToLayout);
         if (resumeLayout)
         {
             this._controlToLayout.PerformLayout(new LayoutEventArgs(controlCausingLayout, property));
         }
     }
 }
 protected override void OnRightToLeftChanged(EventArgs e)
 {
     base.OnRightToLeftChanged(e);
     if (this.HasDropDownItems)
     {
         if (this.DropDown.Visible)
         {
             LayoutTransaction.DoLayout(this.DropDown, this, PropertyNames.RightToLeft);
         }
         else
         {
             CommonProperties.xClearPreferredSizeCache(this.DropDown);
             this.DropDown.LayoutRequired = true;
         }
     }
 }
示例#8
0
 protected override void OnRightToLeftChanged(EventArgs e)
 {
     base.OnRightToLeftChanged(e);
     if (HasDropDownItems)
     {
         // only perform a layout on a visible dropdown - otherwise clear the preferred size cache.
         if (DropDown.Visible)
         {
             LayoutTransaction.DoLayout(DropDown, this, PropertyNames.RightToLeft);
         }
         else
         {
             CommonProperties.xClearPreferredSizeCache(DropDown);
             DropDown.LayoutRequired = true;
         }
     }
 }
 public void Insert(int index, ToolStripItem value)
 {
     this.CheckCanAddOrInsertItem(value);
     this.SetOwner(value);
     base.InnerList.Insert(index, value);
     if (this.itemsCollection && (this.owner != null))
     {
         if (this.owner.IsHandleCreated)
         {
             LayoutTransaction.DoLayout(this.owner, value, PropertyNames.Parent);
         }
         else
         {
             CommonProperties.xClearPreferredSizeCache(this.owner);
         }
         this.owner.OnItemAdded(new ToolStripItemEventArgs(value));
     }
 }
 /// <include file='doc\ToolStripItemCollection.uex' path='docs/doc[@for="ToolStripItemCollection.Insert"]/*' />
 /// <devdoc>
 /// <para>[To be supplied.]</para>
 /// </devdoc>
 public void Insert(int index, ToolStripItem value)
 {
     CheckCanAddOrInsertItem(value);
     SetOwner(value);
     InnerList.Insert(index, value);
     if (itemsCollection && owner != null)
     {
         if (owner.IsHandleCreated)
         {
             LayoutTransaction.DoLayout(owner, value, PropertyNames.Parent);
         }
         else
         {
             // next time we fetch the preferred size, recalc it.
             CommonProperties.xClearPreferredSizeCache(owner);
         }
         owner.OnItemAdded(new ToolStripItemEventArgs(value));
     }
 }