System.Drawing.Rectangle.Union C# (CSharp) Method

Union() public static method

public static Union ( System a, System b ) : System.Drawing.Rectangle
a System
b System
return System.Drawing.Rectangle
        public static System.Drawing.Rectangle Union(System.Drawing.Rectangle a, System.Drawing.Rectangle b) { throw null; }
    }

Same methods

Rectangle::Union ( Rectangle a, Rectangle b ) : Rectangle

Usage Example

        protected override void OnContentRendered(EventArgs e)
        {
            base.OnContentRendered(e);
            if (Shown)
            {
                return;
            }
            Shown = true;

            // make window span over all screens
            Rectangle totalSize = Rectangle.Empty;

            XOffset = 0;
            foreach (Screen screen in Screen.AllScreens)
            {
                // if bounds smaller 0 the screens are left next to primary screen
                if (screen.Bounds.X < 0)
                {
                    if (screen.Bounds.X < XOffset)
                    {
                        XOffset = screen.Bounds.X;
                    }
                }

                totalSize = Rectangle.Union(totalSize, screen.Bounds);
            }

            XOffset = Math.Abs(XOffset);

            Width  = totalSize.Width;
            Height = totalSize.Height;
            Left   = totalSize.Left;
            Top    = totalSize.Top;

            UpdateLayout();
        }