System.Windows.Rect.Union C# (CSharp) Method

Union() public method

public Union ( Rect rect ) : void
rect Rect
return void
        public void Union(Rect rect)
        {
            if (this.IsEmpty)
            {
                this = rect;
            }
            else if (!rect.IsEmpty)
            {
                double num2 = Math.Min(this.Left, rect.Left);
                double num = Math.Min(this.Top, rect.Top);
                if ((rect.Width == double.PositiveInfinity) || (this.Width == double.PositiveInfinity))
                {
                    this._width = double.PositiveInfinity;
                }
                else
                {
                    double num4 = Math.Max(this.Right, rect.Right);
                    this._width = Math.Max((double)(num4 - num2), (double)0.0);
                }
                if ((rect.Height == double.PositiveInfinity) || (this.Height == double.PositiveInfinity))
                {
                    this._height = double.PositiveInfinity;
                }
                else
                {
                    double num3 = Math.Max(this.Bottom, rect.Bottom);
                    this._height = Math.Max((double)(num3 - num), (double)0.0);
                }
                this._x = num2;
                this._y = num;
            }
        }

Same methods

Rect::Union ( Rect rect, Point point ) : Rect
Rect::Union ( Rect rect1, Rect rect2 ) : Rect
Rect::Union ( Point point ) : void

Usage Example

Example #1
0
 /// <summary>
 /// Sets the item's position according to its tikzitem's value
 /// </summary>
 public override bool AdjustPosition(double Resolution)
 {
     Rect r = new Rect(0, 0, 0, 0);
     bool hasone = false;
     foreach (OverlayShape o in children)
     {
         o.AdjustPosition(Resolution);
         Rect rr = o.View.GetBB();
         if (hasone)
             r.Union(rr);
         else
         {
             r = rr;
             hasone = true;
         }
     }
     if (hasone)
     {
         r.Inflate(20, 20);
         //r = new Rect(10, 10, 100, 100);
         View.SetSize( r.Width, r.Height);
         View.SetPosition(r.X, r.Y);
         return true;
     }
     else return false;
 }
All Usage Examples Of System.Windows.Rect::Union