private void hostedControl_SizeChanged(object sender, EventArgs e) { if (!this.AutoSize) { return; } RadHostItem.SizeSettingDirection settingDirection = this.sizeSettingDirection; switch (settingDirection) { case RadHostItem.SizeSettingDirection.None: case RadHostItem.SizeSettingDirection.FromHostedControl: this.sizeSettingDirection = RadHostItem.SizeSettingDirection.FromHostedControl; this.InvalidateMeasure(); if (this.IsDesignMode) { this.UpdateLayout(); } if (settingDirection != RadHostItem.SizeSettingDirection.None) { break; } this.sizeSettingDirection = RadHostItem.SizeSettingDirection.None; break; } }
protected override void ArrangeCore(RectangleF finalRect) { base.ArrangeCore(finalRect); if (this.sizeSettingDirection == RadHostItem.SizeSettingDirection.FromHostedControl) { return; } this.sizeSettingDirection = RadHostItem.SizeSettingDirection.ToHostedControl; Size size1 = Size.Round(finalRect.Size); Size size2 = this.hostedControl.Size; size2.Width = Math.Min(size2.Width, size1.Width); size2.Height = Math.Min(size2.Height, size1.Height); this.SetControlBounds(new Rectangle(this.LocationToControl(), new Size(this.StretchHorizontally ? size1.Width : size2.Width, this.StretchVertically ? size1.Height : size2.Height))); this.sizeSettingDirection = RadHostItem.SizeSettingDirection.None; }