Intersect() public method

public Intersect ( Rect rect ) : void
rect Rect
return void
Beispiel #1
0
 private static bool RectsOverlap(Rect r1, Rect r2)
 {
     r1.Intersect(r2);
     if (r1.Width > 0 || r1.Height > 0)
         return true;
     return false;
 }
        public Point GetCoordinatesInView()
        {
            // TODO reasearch posibility to replace this code to GetClickablePoint()
            var visualRoot = WiniumVirtualRoot.Current.VisualRoot.Element;
            var element = this.Element;

            var point = element.TransformToVisual(visualRoot).TransformPoint(new Point(0, 0));
            var center = new Point(point.X + (int)(element.ActualWidth / 2), point.Y + (int)(element.ActualHeight / 2));
            var bounds = new Rect(point, new Size(element.ActualWidth, element.ActualHeight));
            var boundsInView = new Rect(new Point(0, 0), visualRoot.RenderSize);
            boundsInView.Intersect(bounds);

            var result = boundsInView.IsEmpty
                             ? center
                             : new Point(
                                   boundsInView.X + (int)(boundsInView.Width / 2), 
                                   boundsInView.Y + (int)(boundsInView.Height / 2));
            return ScreenCoordinatesHelper.LogicalPointToScreenPoint(result);
        }
Beispiel #3
0
        /// <summary>
        /// Gets the range.
        /// </summary>
        /// <param name="context">The context</param>
        /// <param name="x">The x</param>
        /// <param name="y">The y</param>
        /// <param name="width">The width</param>
        /// <param name="high">The height</param>
        /// <param name="blocks">The blocks</param>
        /// <param name="allSize">All sizes</param>
        /// <param name="buildInControlState">State of the build in control</param>
        /// <param name="horizontal">If set to <c>true</c>, [horizontal]</param>
        /// <param name="continuePage">If set to <c>true</c>, [continue page]</param>
        /// <returns></returns>
        internal virtual GcRangeBlock GetRange(GcReportContext context, int x, int y, int width, int high, List <GcBlock> blocks, Windows.Foundation.Size allSize, object buildInControlState, bool horizontal, bool continuePage)
        {
            List <GcRangeBlock> list = this.GetBuildInControlRange(context, x, y, width, high, buildInControlState, horizontal, continuePage);

            Windows.Foundation.Size size = allSize;
            Windows.Foundation.Rect rect = new Windows.Foundation.Rect(0.0, 0.0, size.Width, size.Height);
            if ((list != null) && (list.Count > 0))
            {
                foreach (GcRangeBlock block in list)
                {
                    rect.Union(new Windows.Foundation.Rect(block.X, block.Y, block.Width, block.Height));
                }
            }
            Windows.Foundation.Rect rect2 = new Windows.Foundation.Rect((double)x, (double)y, (double)width, (double)high);
            if (!IsIntersect(rect, rect2))
            {
                return(new GcRangeBlock(0.0, 0.0, 0.0, 0.0));
            }
            rect.Intersect(rect2);
            GcRangeBlock block2 = new GcRangeBlock(0.0, 0.0, (double)((int)Math.Ceiling(rect.Width)), (double)((int)Math.Ceiling(rect.Height)))
            {
                OffsetX = (int)rect.X,
                OffsetY = (int)rect.Y
            };

            if ((list != null) && (list.Count > 0))
            {
                foreach (GcRangeBlock block3 in list)
                {
                    block2.Blocks.Add(block3);
                }
            }
            foreach (GcBlock block4 in blocks)
            {
                if (block4.IntersectWith((double)((int)rect.X), (double)((int)rect.Y), (double)((int)rect.Width), (double)((int)rect.Height)))
                {
                    block2.Blocks.Add(block4.Clone());
                }
            }
            return(block2);
        }
Beispiel #4
0
        private Point PlacePopup(Rect window, Point[] target, Point[] flyout, PlacementMode placement)
        {
            Point[] pointArray;
            double y = 0.0;
            double x = 0.0;
            Rect bounds = GetBounds(target);
            Rect rect2 = GetBounds(flyout);
            double width = rect2.Width;
            double height = rect2.Height;
            if (placement == PlacementMode.Right)
            {
                double num5 = Math.Max(0.0, target[0].X);
                double num6 = window.Width - Math.Min(window.Width, target[1].X + 1.0);
                if ((num6 < width) && (num6 < num5))
                {
                    placement = PlacementMode.Left;
                }
            }
            else if (placement == PlacementMode.Left)
            {
                double num7 = window.Width - Math.Min(window.Width, target[1].X + 1.0);
                double num8 = Math.Max(0.0, target[0].X);
                if ((num8 < width) && (num8 < num7))
                {
                    placement = PlacementMode.Right;
                }
            }
            else if (placement == PlacementMode.Top)
            {
                double num9 = Math.Max(0.0, target[0].Y);
                double num10 = window.Height - Math.Min(window.Height, target[2].Y + 1.0);
                if ((num9 < height) && (num9 < num10))
                {
                    placement = PlacementMode.Bottom;
                }
            }
            else if (placement == PlacementMode.Bottom)
            {
                double num11 = Math.Max(0.0, target[0].Y);
                double num12 = window.Height - Math.Min(window.Height, target[2].Y + 1.0);
                if ((num12 < height) && (num12 < num11))
                {
                    placement = PlacementMode.Top;
                }
            }
            switch (placement)
            {
                case PlacementMode.Bottom:
                    pointArray = new Point[] { new Point(target[2].X, Math.Max((double)0.0, (double)(target[2].Y + 1.0))), new Point((target[3].X - width) + 1.0, Math.Max((double)0.0, (double)(target[2].Y + 1.0))), new Point(0.0, Math.Max((double)0.0, (double)(target[2].Y + 1.0))) };
                    break;

                case PlacementMode.Right:
                    pointArray = new Point[] { new Point(Math.Max((double)0.0, (double)(target[1].X + 1.0)), target[1].Y), new Point(Math.Max((double)0.0, (double)(target[3].X + 1.0)), (target[3].Y - height) + 1.0), new Point(Math.Max((double)0.0, (double)(target[1].X + 1.0)), 0.0) };
                    break;

                case PlacementMode.Left:
                    pointArray = new Point[] { new Point(Math.Min(window.Width, target[0].X) - width, target[1].Y), new Point(Math.Min(window.Width, target[2].X) - width, (target[3].Y - height) + 1.0), new Point(Math.Min(window.Width, target[0].X) - width, 0.0) };
                    break;

                case PlacementMode.Top:
                    pointArray = new Point[] { new Point(target[0].X, Math.Min(target[0].Y, window.Height) - height), new Point((target[1].X - width) + 1.0, Math.Min(target[0].Y, window.Height) - height), new Point(0.0, Math.Min(target[0].Y, window.Height) - height) };
                    break;

                default:
                    pointArray = new Point[] { new Point(0.0, 0.0) };
                    break;
            }
            double num13 = width * height;
            int index = 0;
            double num15 = 0.0;
            for (int i = 0; i < pointArray.Length; i++)
            {
                Rect rect3 = new Rect(pointArray[i].X, pointArray[i].Y, width, height);
                rect3.Intersect(window);
                double d = rect3.Width * rect3.Height;
                if (double.IsInfinity(d))
                {
                    index = pointArray.Length - 1;
                    break;
                }
                if (d > num15)
                {
                    index = i;
                    num15 = d;
                }
                if (d == num13)
                {
                    index = i;
                    break;
                }
            }
            // x = pointArray[index].X;
            x = pointArray[0].X; // TODO: taking this solves my horizontal nudging, but is a hack...keeping it though until a better solution
            y = pointArray[index].Y;
            if (index > 1)
            {
                if ((placement == PlacementMode.Left) || (placement == PlacementMode.Right))
                {
                    if (((y != target[0].Y) && (y != target[1].Y)) && (((y + height) != target[0].Y) && ((y + height) != target[1].Y)))
                    {
                        double num18 = bounds.Top + (bounds.Height / 2.0);
                        if ((num18 > 0.0) && ((num18 - 0.0) > (window.Height - num18)))
                        {
                            y = window.Height - height;
                        }
                        else
                        {
                            y = 0.0;
                        }
                    }
                }
                else if (((placement == PlacementMode.Top) || (placement == PlacementMode.Bottom)) && (((x != target[0].X) && (x != target[1].X)) && (((x + width) != target[0].X) && ((x + width) != target[1].X))))
                {
                    double num19 = bounds.Left + (bounds.Width / 2.0);
                    if ((num19 > 0.0) && ((num19 - 0.0) > (window.Width - num19)))
                    {
                        x = window.Width - width;
                    }
                    else
                    {
                        x = 0.0;
                    }
                }
            }

            _realizedPlacement = placement;

            return new Point(x, y);
        }
Beispiel #5
0
        public static bool DetectRanges(Worksheet sheetView, int row, int column, int rowCount, int columnCount, out CellRange seriesName, out CellRange category, out CellRange data)
        {
            int num  = sheetView.RowCount;
            int num2 = sheetView.ColumnCount;

            if (((rowCount < 1) && (row != -1)) || ((columnCount < 1) && (column != -1)))
            {
                throw new ArgumentException("Cannot detect an empty cell range.");
            }
            TrimCellRange(sheetView, ref row, ref column, ref rowCount, ref columnCount);
            category   = null;
            seriesName = null;
            data       = null;
            if ((rowCount <= 0) || (columnCount <= 0))
            {
                return(false);
            }
            Windows.Foundation.Rect rect  = new Windows.Foundation.Rect((double)column, (double)row, (double)columnCount, (double)rowCount);
            Windows.Foundation.Rect rect2 = new Windows.Foundation.Rect(0.0, 0.0, (double)num2, (double)num);
            rect.Intersect(rect2);
            row         = (int)rect.Y;
            column      = (int)rect.X;
            rowCount    = (int)rect.Height;
            columnCount = (int)rect.Width;
            if ((row < 0) || (column < 0))
            {
                throw new ArgumentException("The cell range is invalid.");
            }
            if ((rowCount == 1) && (columnCount == 1))
            {
                if (!IsEmptyCell(sheetView, row, column))
                {
                    data = new CellRange(row, column, rowCount, columnCount);
                }
                return(false);
            }
            if (IsEmptyCell(sheetView, row, column))
            {
                int c = column + 1;
                int r = row + 1;
                while ((c < (column + columnCount)) && IsEmptyCell(sheetView, row, c))
                {
                    c++;
                }
                int num3 = c;
                int num4 = (column + columnCount) - num3;
                if (num4 == 0)
                {
                    while ((r < (row + rowCount)) && IsEmptyCell(sheetView, r, column))
                    {
                        r++;
                    }
                    if (r == (row + rowCount))
                    {
                        if (rowCount > 1)
                        {
                            if (columnCount > 1)
                            {
                                category   = new CellRange(row, column + 1, 1, columnCount - 1);
                                seriesName = new CellRange(row + 1, column, rowCount - 1, 1);
                                data       = new CellRange(row + 1, column + 1, rowCount - 1, columnCount - 1);
                            }
                            else
                            {
                                seriesName = new CellRange(row, column, 1, 1);
                                data       = new CellRange(row + 1, column, rowCount - 1, 1);
                            }
                        }
                        else
                        {
                            seriesName = new CellRange(row, column, 1, 1);
                            data       = new CellRange(row, column + 1, rowCount, columnCount - 1);
                        }
                    }
                    else if (columnCount > 1)
                    {
                        if ((columnCount > 1) && ((r - row) >= 1))
                        {
                            category = new CellRange(row, column + 1, r - row, columnCount - 1);
                        }
                        if ((rowCount > 1) && ((row + rowCount) > r))
                        {
                            seriesName = new CellRange(r, column, (row + rowCount) - r, 1);
                        }
                        data = new CellRange(r, column + 1, (row + rowCount) - r, columnCount - 1);
                    }
                    else
                    {
                        seriesName = null;
                        if (((rowCount > 1) && (r > row)) && (r < (row + rowCount)))
                        {
                            category = new CellRange(row, column, r - row, columnCount);
                        }
                        if ((r < (row + rowCount)) && (r > row))
                        {
                            data = new CellRange(r, column, (row + rowCount) - r, columnCount);
                        }
                        else
                        {
                            data = new CellRange(row, column, rowCount, columnCount);
                        }
                    }
                }
                else
                {
                    c--;
                    while ((r < (row + rowCount)) && IsEmptyCell(sheetView, r, c))
                    {
                        r++;
                    }
                    if (r == (row + rowCount))
                    {
                        if (rowCount > 1)
                        {
                            if ((columnCount > 1) && ((r - row) >= 1))
                            {
                                category = new CellRange(row, num3, 1, num4);
                            }
                            if ((rowCount > 1) && (columnCount > num4))
                            {
                                seriesName = new CellRange(row + 1, column, rowCount - 1, columnCount - num4);
                            }
                            data = new CellRange(row + 1, num3, rowCount - 1, num4);
                        }
                        else
                        {
                            seriesName = new CellRange(row, column, rowCount, num3 - column);
                            data       = new CellRange(row, num3, rowCount, num4);
                        }
                    }
                    else
                    {
                        if ((columnCount > 1) && ((r - row) >= 1))
                        {
                            category = new CellRange(row, num3, r - row, num4);
                        }
                        if (((rowCount > 1) && ((row + rowCount) > r)) && (columnCount > num4))
                        {
                            seriesName = new CellRange(r, column, (row + rowCount) - r, columnCount - num4);
                        }
                        data = new CellRange(r, num3, (row + rowCount) - r, num4);
                    }
                }
            }
            else
            {
                int num7 = (column + columnCount) - 1;
                int num8 = (row + rowCount) - 1;
                if ((columnCount > 1) && (rowCount > 1))
                {
                    int num9  = num7;
                    int num10 = 0;
                    while ((num9 >= column) && IsNumericData(sheetView.GetValue(num8, num9)))
                    {
                        num10++;
                        num9--;
                    }
                    bool flag = num10 == 0;
                    if (flag)
                    {
                        num10 = 1;
                        num9--;
                    }
                    int num11 = num7;
                    if (columnCount > 1)
                    {
                        num11 = num9 + 1;
                        num9  = num8 - 1;
                        int num12 = 1;
                        if (!flag)
                        {
                            while ((num9 >= row) && IsNumericData(sheetView.GetValue(num9, num7)))
                            {
                                num12++;
                                num9--;
                            }
                        }
                        if (((num10 > 0) && (num11 >= column)) && ((num9 + 1) > row))
                        {
                            category = new CellRange(row, num11, (num9 + 1) - row, num10);
                        }
                        if ((num12 > 0) && (num11 > column))
                        {
                            seriesName = new CellRange(num9 + 1, column, num12, num11 - column);
                        }
                        data = new CellRange(num9 + 1, num11, num12, num10);
                    }
                }
                else if (rowCount > 1)
                {
                    if (IsNumericData(sheetView.GetValue(row, column)))
                    {
                        data = new CellRange(row, column, rowCount, columnCount);
                    }
                    else
                    {
                        int num13 = 0;
                        int num14 = num8;
                        while ((num14 >= row) && IsNumericData(sheetView.GetValue(num14, column)))
                        {
                            num14--;
                            num13++;
                        }
                        if ((num14 == num8) && !IsNumericData(sheetView.GetValue(num14, column)))
                        {
                            num14--;
                        }
                        data = new CellRange(num14 + 1, column, num8 - num14, columnCount);
                        if (num14 >= row)
                        {
                            seriesName = new CellRange(row, column, (num14 - row) + 1, columnCount);
                        }
                    }
                }
                else if (IsNumericData(sheetView.GetValue(row, column)))
                {
                    data = new CellRange(row, column, rowCount, columnCount);
                }
                else
                {
                    int num15 = 0;
                    int num16 = num7;
                    while ((num16 >= column) && IsNumericData(sheetView.GetValue(row, num16)))
                    {
                        num16--;
                        num15++;
                    }
                    if ((num16 == num7) && !IsNumericData(sheetView.GetValue(row, num16)))
                    {
                        num16--;
                    }
                    data = new CellRange(row, num16 + 1, rowCount, num7 - num16);
                    if (num16 >= column)
                    {
                        seriesName = new CellRange(row, column, rowCount, (num16 - column) + 1);
                    }
                }
            }
            if ((((data != null) && (data.RowCount > data.ColumnCount)) && (data.RowCount > 1)) && ((data.ColumnCount > 1) || ((data.ColumnCount == 1) && ((seriesName != null) || (category != null)))))
            {
                bool flag2 = false;
                if (seriesName != null)
                {
                    flag2 = seriesName.Row == data.Row;
                }
                else if (category != null)
                {
                    flag2 = category.Column == data.Column;
                }
                if (flag2)
                {
                    CellRange range = category;
                    category   = seriesName;
                    seriesName = range;
                }
                return(true);
            }
            if (data != null)
            {
                if (data.RowCount == 1)
                {
                    return(false);
                }
                if (data.ColumnCount == 1)
                {
                    return(true);
                }
            }
            return(((seriesName != null) && (seriesName.Column == data.Column)) || ((category != null) && (category.Row == data.Row)));
        }
Beispiel #6
0
 //Check collision with flower and butterfly
 public void CheckCollision()
 {
     // get rectangles
     Rect r1 = new Rect(butterfly.LocationX, butterfly.LocationY, butterfly.ActualWidth, butterfly.ActualHeight);
     Rect r2 = new Rect(flower.LocationX, flower.LocationY, flower.ActualWidth, flower.ActualHeight);
     // does intersect...
     r1.Intersect(r2);
     if(!r1.IsEmpty) //not empty --> intersect happened
     {
         //remove flower
         MyCanvas.Children.Remove(flower);
         //play tada
         mediaElement.Play();
         //Add a new flower
         AddFlower();
     }
 }
        public static void Blit(BitmapContext destContext, int dpw, int dph, Rect destRect, BitmapContext srcContext, Rect sourceRect, int sourceWidth)
        {
            const BlendMode blendMode = BlendMode.Alpha;

            int dw = (int)destRect.Width;
            int dh = (int)destRect.Height;

            Rect intersect = new Rect(0, 0, dpw, dph);
            intersect.Intersect(destRect);
            if (intersect.IsEmpty)
            {
                return;
            }
#if WPF
            var isPrgba = srcContext.Format == PixelFormats.Pbgra32 || srcContext.Format == PixelFormats.Prgba64 || srcContext.Format == PixelFormats.Prgba128Float;
#endif

            var sourcePixels = srcContext.Pixels;
            var destPixels = destContext.Pixels;
            int sourceLength = srcContext.Length;
            int sourceIdx = -1;
            int px = (int)destRect.X;
            int py = (int)destRect.Y;
            int x;
            int y;
            int idx;
            double ii;
            double jj;
            int sr = 0;
            int sg = 0;
            int sb = 0;
            int dr, dg, db;
            int sourcePixel;
            int sa = 0;
            int da;

            var sw = (int)sourceRect.Width;
            var sdx = sourceRect.Width / destRect.Width;
            var sdy = sourceRect.Height / destRect.Height;
            int sourceStartX = (int)sourceRect.X;
            int sourceStartY = (int)sourceRect.Y;
            int lastii, lastjj;
            lastii = -1;
            lastjj = -1;
            jj = sourceStartY;
            y = py;
            for (var j = 0; j < dh; j++)
            {
                if (y >= 0 && y < dph)
                {
                    ii = sourceStartX;
                    idx = px + y * dpw;
                    x = px;
                    sourcePixel = sourcePixels[0];

                    // Pixel by pixel copying
                    for (var i = 0; i < dw; i++)
                    {
                        if (x >= 0 && x < dpw)
                        {
                            if ((int)ii != lastii || (int)jj != lastjj)
                            {
                                sourceIdx = (int)ii + (int)jj * sourceWidth;
                                if (sourceIdx >= 0 && sourceIdx < sourceLength)
                                {
                                    sourcePixel = sourcePixels[sourceIdx];
                                    sa = ((sourcePixel >> 24) & 0xff);
                                    sr = ((sourcePixel >> 16) & 0xff);
                                    sg = ((sourcePixel >> 8) & 0xff);
                                    sb = ((sourcePixel) & 0xff);
                                }
                                else
                                {
                                    sa = 0;
                                }
                            }

                            if (sa > 0)
                            {
                                int destPixel = destPixels[idx];
                                da = ((destPixel >> 24) & 0xff);
                                if ((sa == 255 || da == 0))
                                {
                                    destPixels[idx] = sourcePixel;
                                }
                                else
                                {
                                    dr = ((destPixel >> 16) & 0xff);
                                    dg = ((destPixel >> 8) & 0xff);
                                    db = ((destPixel) & 0xff);
                                    var isa = 255 - sa;
#if NETFX_CORE
                                    // Special case for WinRT since it does not use pARGB (pre-multiplied alpha)
                                    destPixel = ((da & 0xff) << 24) |
                                                ((((sr * sa + isa * dr) >> 8) & 0xff) << 16) |
                                                ((((sg * sa + isa * dg) >> 8) & 0xff) <<  8) |
                                                (((sb * sa + isa * db) >> 8) & 0xff);
#elif WPF
                                    if (isPrgba)
                                    {
                                        destPixel = ((da & 0xff) << 24) |
                                                    (((((sr << 8) + isa * dr) >> 8) & 0xff) << 16) |
                                                    (((((sg << 8) + isa * dg) >> 8) & 0xff) << 8) |
                                                     ((((sb << 8) + isa * db) >> 8) & 0xff);
                                    }
                                    else
                                    {
                                        destPixel = ((da & 0xff) << 24) |
                                                    (((((sr * sa) + isa * dr) >> 8) & 0xff) << 16) |
                                                    (((((sg * sa) + isa * dg) >> 8) & 0xff) << 8) |
                                                     ((((sb * sa) + isa * db) >> 8) & 0xff);
                                    }
#else
                                    destPixel = ((da & 0xff) << 24) |
                                                (((((sr << 8) + isa * dr) >> 8) & 0xff) << 16) |
                                                (((((sg << 8) + isa * dg) >> 8) & 0xff) << 8) |
                                                 ((((sb << 8) + isa * db) >> 8) & 0xff);
#endif
                                    destPixels[idx] = destPixel;
                                }
                            }
                        }
                        x++;
                        idx++;
                        ii += sdx;
                    }
                }
                jj += sdy;
                y++;
            }

        }
        /// <summary>
        /// Copies (blits) the pixels from the WriteableBitmap source to the destination WriteableBitmap (this).
        /// </summary>
        /// <param name="bmp">The destination WriteableBitmap.</param>
        /// <param name="destRect">The rectangle that defines the destination region.</param>
        /// <param name="source">The source WriteableBitmap.</param>
        /// <param name="sourceRect">The rectangle that will be copied from the source to the destination.</param>
        /// <param name="color">If not Colors.White, will tint the source image. A partially transparent color and the image will be drawn partially transparent. If the BlendMode is ColorKeying, this color will be used as color key to mask all pixels with this value out.</param>
        /// <param name="blendMode">The blending mode <see cref="BlendMode"/>.</param>
        internal static void Blit(this WriteableBitmap bmp, Rect destRect, WriteableBitmap source, Rect sourceRect, Color color, BlendMode blendMode)
        {
            if (color.A == 0)
            {
                return;
            }
#if WPF
            var isPrgba = source.Format == PixelFormats.Pbgra32 || source.Format == PixelFormats.Prgba64 || source.Format == PixelFormats.Prgba128Float;
#endif
            var dw = (int)destRect.Width;
            var dh = (int)destRect.Height;

            using (var srcContext = source.GetBitmapContext(ReadWriteMode.ReadOnly))
            {
                using (var destContext = bmp.GetBitmapContext())
                {
                    var sourceWidth = srcContext.Width;
                    var dpw = destContext.Width;
                    var dph = destContext.Height;

                    var intersect = new Rect(0, 0, dpw, dph);
                    intersect.Intersect(destRect);
                    if (intersect.IsEmpty)
                    {
                        return;
                    }

                    var sourcePixels = srcContext.Pixels;
                    var destPixels = destContext.Pixels;
                    var sourceLength = srcContext.Length;

                    int sourceIdx = -1;
                    int px = (int)destRect.X;
                    int py = (int)destRect.Y;

                    int x;
                    int y;
                    int idx;
                    double ii;
                    double jj;
                    int sr = 0;
                    int sg = 0;
                    int sb = 0;
                    int dr, dg, db;
                    int sourcePixel;
                    int sa = 0;
                    int da;
                    int ca = color.A;
                    int cr = color.R;
                    int cg = color.G;
                    int cb = color.B;
                    bool tinted = color != Colors.White;
                    var sw = (int)sourceRect.Width;
                    var sdx = sourceRect.Width / destRect.Width;
                    var sdy = sourceRect.Height / destRect.Height;
                    int sourceStartX = (int)sourceRect.X;
                    int sourceStartY = (int)sourceRect.Y;
                    int lastii, lastjj;
                    lastii = -1;
                    lastjj = -1;
                    jj = sourceStartY;
                    y = py;
                    for (int j = 0; j < dh; j++)
                    {
                        if (y >= 0 && y < dph)
                        {
                            ii = sourceStartX;
                            idx = px + y * dpw;
                            x = px;
                            sourcePixel = sourcePixels[0];

                            // Scanline BlockCopy is much faster (3.5x) if no tinting and blending is needed,
                            // even for smaller sprites like the 32x32 particles. 
                            if (blendMode == BlendMode.None && !tinted)
                            {
                                sourceIdx = (int)ii + (int)jj * sourceWidth;
                                var offset = x < 0 ? -x : 0;
                                var xx = x + offset;
                                var wx = sourceWidth - offset;
                                var len = xx + wx < dpw ? wx : dpw - xx;
                                if (len > sw) len = sw;
                                if (len > dw) len = dw;
                                BitmapContext.BlockCopy(srcContext, (sourceIdx + offset) * 4, destContext, (idx + offset) * 4, len * 4);
                            }

                     // Pixel by pixel copying
                            else
                            {
                                for (int i = 0; i < dw; i++)
                                {
                                    if (x >= 0 && x < dpw)
                                    {
                                        if ((int)ii != lastii || (int)jj != lastjj)
                                        {
                                            sourceIdx = (int)ii + (int)jj * sourceWidth;
                                            if (sourceIdx >= 0 && sourceIdx < sourceLength)
                                            {
                                                sourcePixel = sourcePixels[sourceIdx];
                                                sa = ((sourcePixel >> 24) & 0xff);
                                                sr = ((sourcePixel >> 16) & 0xff);
                                                sg = ((sourcePixel >> 8) & 0xff);
                                                sb = ((sourcePixel) & 0xff);
                                                if (tinted && sa != 0)
                                                {
                                                    sa = (((sa * ca) * 0x8081) >> 23);
                                                    sr = ((((((sr * cr) * 0x8081) >> 23) * ca) * 0x8081) >> 23);
                                                    sg = ((((((sg * cg) * 0x8081) >> 23) * ca) * 0x8081) >> 23);
                                                    sb = ((((((sb * cb) * 0x8081) >> 23) * ca) * 0x8081) >> 23);
                                                    sourcePixel = (sa << 24) | (sr << 16) | (sg << 8) | sb;
                                                }
                                            }
                                            else
                                            {
                                                sa = 0;
                                            }
                                        }
                                        if (blendMode == BlendMode.None)
                                        {
                                            destPixels[idx] = sourcePixel;
                                        }
                                        else if (blendMode == BlendMode.ColorKeying)
                                        {
                                            sr = ((sourcePixel >> 16) & 0xff);
                                            sg = ((sourcePixel >> 8) & 0xff);
                                            sb = ((sourcePixel) & 0xff);

                                            if (sr != color.R || sg != color.G || sb != color.B)
                                            {
                                                destPixels[idx] = sourcePixel;
                                            }

                                        }
                                        else if (blendMode == BlendMode.Mask)
                                        {
                                            int destPixel = destPixels[idx];
                                            da = ((destPixel >> 24) & 0xff);
                                            dr = ((destPixel >> 16) & 0xff);
                                            dg = ((destPixel >> 8) & 0xff);
                                            db = ((destPixel) & 0xff);
                                            destPixel = ((((da * sa) * 0x8081) >> 23) << 24) |
                                                        ((((dr * sa) * 0x8081) >> 23) << 16) |
                                                        ((((dg * sa) * 0x8081) >> 23) << 8) |
                                                        ((((db * sa) * 0x8081) >> 23));
                                            destPixels[idx] = destPixel;
                                        }
                                        else if (sa > 0)
                                        {
                                            int destPixel = destPixels[idx];
                                            da = ((destPixel >> 24) & 0xff);
                                            if ((sa == 255 || da == 0) &&
                                                           blendMode != BlendMode.Additive
                                                           && blendMode != BlendMode.Subtractive
                                                           && blendMode != BlendMode.Multiply
                                               )
                                            {
                                                destPixels[idx] = sourcePixel;
                                            }
                                            else
                                            {
                                                dr = ((destPixel >> 16) & 0xff);
                                                dg = ((destPixel >> 8) & 0xff);
                                                db = ((destPixel) & 0xff);
                                                if (blendMode == BlendMode.Alpha)
                                                {
                                                    var isa = 255 - sa;
#if NETFX_CORE
                                                     // Special case for WinRT since it does not use pARGB (pre-multiplied alpha)
                                                     destPixel = ((da & 0xff) << 24) |
                                                                 ((((sr * sa + isa * dr) >> 8) & 0xff) << 16) |
                                                                 ((((sg * sa + isa * dg) >> 8) & 0xff) <<  8) |
                                                                  (((sb * sa + isa * db) >> 8) & 0xff);
#elif WPF
                                                    if (isPrgba)
                                                    {
                                                        destPixel = ((da & 0xff) << 24) |
                                                                    (((((sr << 8) + isa * dr) >> 8) & 0xff) << 16) |
                                                                    (((((sg << 8) + isa * dg) >> 8) & 0xff) <<  8) |
                                                                     ((((sb << 8) + isa * db) >> 8) & 0xff);
                                                    }
                                                    else
                                                    {
                                                        destPixel = ((da & 0xff) << 24) |
                                                                    (((((sr * sa) + isa * dr) >> 8) & 0xff) << 16) |
                                                                    (((((sg * sa) + isa * dg) >> 8) & 0xff) <<  8) |
                                                                     ((((sb * sa) + isa * db) >> 8) & 0xff);
                                                    }
#else
                                                        destPixel = ((da & 0xff) << 24) |
                                                                    (((((sr << 8) + isa * dr) >> 8) & 0xff) << 16) |
                                                                    (((((sg << 8) + isa * dg) >> 8) & 0xff) <<  8) |
                                                                     ((((sb << 8) + isa * db) >> 8) & 0xff);
#endif
                                                }
                                                else if (blendMode == BlendMode.Additive)
                                                {
                                                    int a = (255 <= sa + da) ? 255 : (sa + da);
                                                    destPixel = (a << 24) |
                                                       (((a <= sr + dr) ? a : (sr + dr)) << 16) |
                                                       (((a <= sg + dg) ? a : (sg + dg)) << 8) |
                                                       (((a <= sb + db) ? a : (sb + db)));
                                                }
                                                else if (blendMode == BlendMode.Subtractive)
                                                {
                                                    int a = da;
                                                    destPixel = (a << 24) |
                                                       (((sr >= dr) ? 0 : (sr - dr)) << 16) |
                                                       (((sg >= dg) ? 0 : (sg - dg)) << 8) |
                                                       (((sb >= db) ? 0 : (sb - db)));
                                                }
                                                else if (blendMode == BlendMode.Multiply)
                                                {
                                                    // Faster than a division like (s * d) / 255 are 2 shifts and 2 adds
                                                    int ta = (sa * da) + 128;
                                                    int tr = (sr * dr) + 128;
                                                    int tg = (sg * dg) + 128;
                                                    int tb = (sb * db) + 128;

                                                    int ba = ((ta >> 8) + ta) >> 8;
                                                    int br = ((tr >> 8) + tr) >> 8;
                                                    int bg = ((tg >> 8) + tg) >> 8;
                                                    int bb = ((tb >> 8) + tb) >> 8;

                                                    destPixel = (ba << 24) |
                                                                ((ba <= br ? ba : br) << 16) |
                                                                ((ba <= bg ? ba : bg) << 8) |
                                                                ((ba <= bb ? ba : bb));
                                                }

                                                destPixels[idx] = destPixel;
                                            }
                                        }
                                    }
                                    x++;
                                    idx++;
                                    ii += sdx;
                                }
                            }
                        }
                        jj += sdy;
                        y++;
                    }
                }
            }
        }
            private void UpdateImageSource(Rect updateRectangle)
            {
                if (Window.Current.Visible)
                {
                    var imageRectangle = new Rect(new Point(), _canvasImageSource.Size);
                    updateRectangle.Intersect(imageRectangle);

                    using (var drawingSession = _canvasImageSource.CreateDrawingSession(Colors.Transparent, updateRectangle))
                    {
                        drawingSession.DrawImage(_accumulationRenderTarget); // Render target has the composed frame
                    }
                }
            }
 // Check Collision of Flower and Butterfly
 public void CheckCollision()
 {
     // Get Rectangles
     Rect r1 = new Rect(butterfly.LocationX, butterfly.LocationY, butterfly.ActualWidth, butterfly.ActualHeight);
     Rect r2 = new Rect(flower.LocationX, flower.LocationY, flower.ActualWidth, flower.ActualHeight);
     // Does Intersect...
     r1.Intersect(r2);
     if (!r1.IsEmpty) // Not Empty --> Intersected
     {
         // Remove Flower
         MyCanvas.Children.Remove(flower);
         // Play Tada
         mediaElement.Play();
         // Add a New Flower
         AddFlower();
     }
 }
        internal bool IsUserVisible()
        {
            /* TODO: There is IsOffscreen method on AutomationPeer that can be used.
             * But it returns true even if currentElement is on another pivot (i.e. invisible)
             * var peer = FrameworkElementAutomationPeer.FromElement(this.Element);
             * return peer != null && peer.IsOffscreen();
             * This might improve speed but will make all non user interactable elements, like border, scrollbiew "invisible"
             */
            var visualRoot = WiniumVirtualRoot.Current.VisualRoot.Element;
            var currentElement = this.Element;

            var currentElementSize = new Size(currentElement.ActualWidth, currentElement.ActualHeight);

            // Check if currentElement is of zero size
            if (currentElementSize.Width <= 0 || currentElementSize.Height <= 0)
            {
                return false;
            }

            var zero = new Point(0, 0);

            var rect = new Rect(zero, currentElementSize);
            var bound = currentElement.TransformToVisual(visualRoot).TransformBounds(rect);
            var rootRect = new Rect(zero, visualRoot.RenderSize);
            rootRect.Intersect(bound);

            // Check if currentElement is offscreen. Save time on traversing tree if currentElement is not in root rect
            if (rootRect.IsEmpty)
            {
                return false;
            }

            while (true)
            {
                if (currentElement.Visibility != Visibility.Visible || !currentElement.IsHitTestVisible
                    || !(currentElement.Opacity > 0))
                {
                    return false;
                }

                var container = VisualTreeHelper.GetParent(currentElement) as FrameworkElement;
                if (container == null)
                {
                    return true;
                }

                if (container.RenderSize.IsEmpty)
                {
                    // There are some currentElements in UI tree that always return zero size, e.g. ContentControl, etc.
                    continue;
                }

                // FIXME we only check if currentElement is visible in parent and parent visible in his parent and so on
                // we do not actully check if any part of original currentElement is visible in grandparents
                currentElementSize = new Size(currentElement.ActualWidth, currentElement.ActualHeight);
                rect = new Rect(zero, currentElementSize);
                bound = currentElement.TransformToVisual(container).TransformBounds(rect);
                var containerRect = new Rect(zero, container.RenderSize);

                containerRect.Intersect(bound);

                // Check if currentElement is offscreen
                if (containerRect.IsEmpty)
                {
                    return false;
                }

                currentElement = container;
            }
        }
Beispiel #12
0
        //check collision with flower and butterfly
        public void CheckCollision()
        {
            //get rects
            Rect r1 = new Rect(butterfly.LocationX,butterfly.LocationY,butterfly.ActualWidth,butterfly.ActualHeight);
            Rect r2 = new Rect(flower.LocationX, flower.LocationY,flower.ActualWidth,flower.ActualHeight);

            //does intersect
            r1.Intersect(r2);
            if (!r1.IsEmpty) //not empty, intersect happened
            {
                // remove flower
                MyCanvas.Children.Remove(flower);
                // add a new flower
                AddFlower();
                //play sound
                mediaElement.Play();
                points++;
                textBlock.Text = points.ToString();
            }
        }
        private bool CheckBounds(Vector2 bounds)
        {
            foreach(var rect in MapManager.Map)
            {
                var rectPac = new Rect(x + dx, y + dy, size, size);
                rectPac.Intersect(rect);
                if(!rectPac.IsEmpty)
                    return false;
            }

            return true;

            //if (x < -size)
            //{
            //    x = bounds.X;
            //}
            //else if (x > bounds.X)
            //{
            //    x = 0;
            //}

            //if (y < -size)
            //{
            //    y = bounds.Y;
            //}
            //else if (y > bounds.Y)
            //{
            //    y = 0;
            //}
        }
Beispiel #14
0
 /// <summary>
 /// Checks if two rectangles overlapping 
 /// </summary>
 /// <param name="r1">First rectangle</param>
 /// <param name="r2">Second rectangle</param>
 /// <returns>True if rectangles overlapping</returns>
 private static bool RectsOverlap(Rect r1, Rect r2)
 {
     r1.Intersect(r2); // Saves intersection rectangle to r1
     if (r1.Width > 0 || r1.Height > 0)
         return true;
     else
         return false;
 }
        public bool consillionMouseAnother(Image at)
        {
            Rect r1 = new Rect(Canvas.GetLeft(Mouse), Canvas.GetTop(Mouse), Mouse.Width, Mouse.Height);
            Rect r2 = new Rect(Canvas.GetLeft(at), Canvas.GetTop(at), at.Width, at.Height);
            r1.Intersect(r2);

            if (!r1.IsEmpty)
            {
                createCheese();
                return true;
            }
            else
            {
                return false;
            }
        }
        public bool consillionMatrix(Image a)
        {
            Rect rt = new Rect(Canvas.GetLeft(a), Canvas.GetTop(a), a.Width, a.Height);
            Rect rt1 = new Rect(Canvas.GetLeft(rec1), Canvas.GetTop(rec1), rec1.Width, rec1.Height);
            rt.Intersect(rt1);
            if (!rt.IsEmpty)
            {
                return true;
            }
            else
            {
                rt = new Rect(Canvas.GetLeft(a), Canvas.GetTop(a), a.Width, a.Height);
                rt1 = new Rect(Canvas.GetLeft(rec2), Canvas.GetTop(rec2), rec2.Width, rec2.Height);
                rt.Intersect(rt1);
                if (!rt.IsEmpty)
                {
                    return true;
                }
                else
                {
                    rt = new Rect(Canvas.GetLeft(a), Canvas.GetTop(a), a.Width, a.Height);
                    rt1 = new Rect(Canvas.GetLeft(rec3), Canvas.GetTop(rec3), rec3.Width, rec3.Height);
                    rt.Intersect(rt1);
                    if (!rt.IsEmpty)
                    {
                        return true;
                    }
                    else
                    {
                        rt = new Rect(Canvas.GetLeft(a), Canvas.GetTop(a), a.Width, a.Height);
                        rt1 = new Rect(Canvas.GetLeft(rec4), Canvas.GetTop(rec4), rec4.Width, rec4.Height);
                        rt.Intersect(rt1);
                        if (!rt.IsEmpty)
                        {
                            return true;
                        }
                        else
                        {
                            rt = new Rect(Canvas.GetLeft(a), Canvas.GetTop(a), a.Width, a.Height);
                            rt1 = new Rect(Canvas.GetLeft(rec5), Canvas.GetTop(rec5), rec5.Width, rec5.Height);
                            rt.Intersect(rt1);
                            if (!rt.IsEmpty)
                            {
                                return true;
                            }
                            else
                            {
                                rt = new Rect(Canvas.GetLeft(a), Canvas.GetTop(a), a.Width, a.Height);
                                rt1 = new Rect(Canvas.GetLeft(rec6), Canvas.GetTop(rec6), rec6.Width, rec6.Height);
                                rt.Intersect(rt1);
                                if (!rt.IsEmpty)
                                {
                                    return true;
                                }
                                else
                                {

                                    rt = new Rect(Canvas.GetLeft(a), Canvas.GetTop(a), a.Width, a.Height);
                                    rt1 = new Rect(Canvas.GetLeft(rec7), Canvas.GetTop(rec7), rec7.Width, rec7.Height);
                                    rt.Intersect(rt1);
                                    if (!rt.IsEmpty)
                                    {
                                        return true;
                                    }
                                    else
                                    {
                                        rt = new Rect(Canvas.GetLeft(a), Canvas.GetTop(a), a.Width, a.Height);
                                        rt1 = new Rect(Canvas.GetLeft(rec8), Canvas.GetTop(rec8), rec8.Width, rec8.Height);
                                        rt.Intersect(rt1);
                                        if (!rt.IsEmpty)
                                        {
                                            return true;
                                        }
                                        else
                                        {
                                            rt = new Rect(Canvas.GetLeft(a), Canvas.GetTop(a), a.Width, a.Height);
                                            rt1 = new Rect(Canvas.GetLeft(rec9), Canvas.GetTop(rec9), rec9.Width, rec9.Height);
                                            rt.Intersect(rt1);
                                            if (!rt.IsEmpty)
                                            {
                                                return true;
                                            }
                                            else
                                            {
                                                rt = new Rect(Canvas.GetLeft(a), Canvas.GetTop(a), a.Width, a.Height);
                                                rt1 = new Rect(Canvas.GetLeft(rec10), Canvas.GetTop(rec10), rec10.Width, rec10.Height);
                                                rt.Intersect(rt1);
                                                if (!rt.IsEmpty)
                                                {
                                                    return true;
                                                }
                                                else
                                                {
                                                    rt = new Rect(Canvas.GetLeft(a), Canvas.GetTop(a), a.Width, a.Height);
                                                    rt1 = new Rect(Canvas.GetLeft(rec11), Canvas.GetTop(rec11), rec11.Width, rec11.Height);
                                                    rt.Intersect(rt1);
                                                    if (!rt.IsEmpty)
                                                    {
                                                        return true;
                                                    }
                                                    else
                                                    {
                                                        rt = new Rect(Canvas.GetLeft(a), Canvas.GetTop(a), a.Width, a.Height);
                                                        rt1 = new Rect(Canvas.GetLeft(rec12), Canvas.GetTop(rec12), rec12.Width, rec12.Height);
                                                        rt.Intersect(rt1);
                                                        if (!rt.IsEmpty)
                                                        {
                                                            return true;
                                                        }
                                                        else
                                                        {
                                                            rt = new Rect(Canvas.GetLeft(a), Canvas.GetTop(a), a.Width, a.Height);
                                                            rt1 = new Rect(Canvas.GetLeft(rec13), Canvas.GetTop(rec13), rec13.Width, rec13.Height);
                                                            rt.Intersect(rt1);
                                                            if (!rt.IsEmpty)
                                                            {
                                                                return true;
                                                            }
                                                            else
                                                            {
                                                                rt = new Rect(Canvas.GetLeft(a), Canvas.GetTop(a), a.Width, a.Height);
                                                                rt1 = new Rect(Canvas.GetLeft(rec14), Canvas.GetTop(rec14), rec14.Width, rec14.Height);
                                                                rt.Intersect(rt1);
                                                                if (!rt.IsEmpty)
                                                                {
                                                                    return true;
                                                                }
                                                                else
                                                                {
                                                                    rt = new Rect(Canvas.GetLeft(a), Canvas.GetTop(a), a.Width, a.Height);
                                                                    rt1 = new Rect(Canvas.GetLeft(rec15), Canvas.GetTop(rec15), rec15.Width, rec15.Height);
                                                                    rt.Intersect(rt1);
                                                                    if (!rt.IsEmpty)
                                                                    {
                                                                        return true;
                                                                    }
                                                                    else
                                                                    {
                                                                        rt = new Rect(Canvas.GetLeft(a), Canvas.GetTop(a), a.Width, a.Height);
                                                                        rt1 = new Rect(Canvas.GetLeft(rec16), Canvas.GetTop(rec16), rec16.Width, rec16.Height);
                                                                        rt.Intersect(rt1);
                                                                        if (!rt.IsEmpty)
                                                                        {
                                                                            return true;
                                                                        }
                                                                        else
                                                                        {
                                                                            rt = new Rect(Canvas.GetLeft(a), Canvas.GetTop(a), a.Width, a.Height);
                                                                            rt1 = new Rect(Canvas.GetLeft(rec17), Canvas.GetTop(rec17), rec17.Width, rec17.Height);
                                                                            rt.Intersect(rt1);
                                                                            if (!rt.IsEmpty)
                                                                            {
                                                                                return true;
                                                                            }
                                                                            else
                                                                            {
                                                                                rt = new Rect(Canvas.GetLeft(a), Canvas.GetTop(a), a.Width, a.Height);
                                                                                rt1 = new Rect(Canvas.GetLeft(rec18), Canvas.GetTop(rec18), rec18.Width, rec18.Height);
                                                                                rt.Intersect(rt1);
                                                                                if (!rt.IsEmpty)
                                                                                {
                                                                                    return true;
                                                                                }
                                                                                else
                                                                                {
                                                                                    rt = new Rect(Canvas.GetLeft(a), Canvas.GetTop(a), a.Width, a.Height);
                                                                                    rt1 = new Rect(Canvas.GetLeft(rec19), Canvas.GetTop(rec19), rec19.Width, rec19.Height);
                                                                                    rt.Intersect(rt1);
                                                                                    if (!rt.IsEmpty)
                                                                                    {
                                                                                        return true;
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        rt = new Rect(Canvas.GetLeft(a), Canvas.GetTop(a), a.Width, a.Height);
                                                                                        rt1 = new Rect(Canvas.GetLeft(rec20), Canvas.GetTop(rec20), rec20.Width, rec20.Height);
                                                                                        rt.Intersect(rt1);
                                                                                        if (!rt.IsEmpty)
                                                                                        {
                                                                                            return true;
                                                                                        }
                                                                                        else
                                                                                        {

                                                                                            rt = new Rect(Canvas.GetLeft(a), Canvas.GetTop(a), a.Width, a.Height);
                                                                                            rt1 = new Rect(Canvas.GetLeft(rec25), Canvas.GetTop(rec25), rec25.Width, rec25.Height);
                                                                                            rt.Intersect(rt1);
                                                                                            if (!rt.IsEmpty)
                                                                                            {
                                                                                                return true;
                                                                                            }
                                                                                            else
                                                                                            {
                                                                                                rt = new Rect(Canvas.GetLeft(a), Canvas.GetTop(a), a.Width, a.Height);
                                                                                                rt1 = new Rect(Canvas.GetLeft(rec26), Canvas.GetTop(rec26), rec26.Width, rec26.Height);
                                                                                                rt.Intersect(rt1);
                                                                                                if (!rt.IsEmpty)
                                                                                                {
                                                                                                    return true;
                                                                                                }
                                                                                                else
                                                                                                {
                                                                                                    rt = new Rect(Canvas.GetLeft(a), Canvas.GetTop(a), a.Width, a.Height);
                                                                                                    rt1 = new Rect(Canvas.GetLeft(rec27), Canvas.GetTop(rec27), rec27.Width, rec27.Height);
                                                                                                    rt.Intersect(rt1);
                                                                                                    if (!rt.IsEmpty)
                                                                                                    {
                                                                                                        return true;
                                                                                                    }
                                                                                                    else
                                                                                                    {
                                                                                                        rt = new Rect(Canvas.GetLeft(a), Canvas.GetTop(a), a.Width, a.Height);
                                                                                                        rt1 = new Rect(Canvas.GetLeft(rec28), Canvas.GetTop(rec28), rec28.Width, rec28.Height);
                                                                                                        rt.Intersect(rt1);
                                                                                                        if (!rt.IsEmpty)
                                                                                                        {
                                                                                                            return true;
                                                                                                        }
                                                                                                        else
                                                                                                        {
                                                                                                            rt = new Rect(Canvas.GetLeft(a), Canvas.GetTop(a), a.Width, a.Height);
                                                                                                            rt1 = new Rect(Canvas.GetLeft(rec29), Canvas.GetTop(rec29), rec29.Width, rec29.Height);
                                                                                                            rt.Intersect(rt1);
                                                                                                            if (!rt.IsEmpty)
                                                                                                            {
                                                                                                                return true;
                                                                                                            }
                                                                                                            else
                                                                                                            {
                                                                                                                rt = new Rect(Canvas.GetLeft(a), Canvas.GetTop(a), a.Width, a.Height);
                                                                                                                rt1 = new Rect(Canvas.GetLeft(rec30), Canvas.GetTop(rec30), rec30.Width, rec30.Height);
                                                                                                                rt.Intersect(rt1);
                                                                                                                if (!rt.IsEmpty)
                                                                                                                {
                                                                                                                    return true;
                                                                                                                }
                                                                                                                else
                                                                                                                {
                                                                                                                    rt = new Rect(Canvas.GetLeft(a), Canvas.GetTop(a), a.Width, a.Height);
                                                                                                                    rt1 = new Rect(Canvas.GetLeft(rec31), Canvas.GetTop(rec31), rec31.Width, rec31.Height);
                                                                                                                    rt.Intersect(rt1);
                                                                                                                    if (!rt.IsEmpty)
                                                                                                                    {
                                                                                                                        return true;
                                                                                                                    }
                                                                                                                    else
                                                                                                                    {
                                                                                                                        rt = new Rect(Canvas.GetLeft(a), Canvas.GetTop(a), a.Width, a.Height);
                                                                                                                        rt1 = new Rect(Canvas.GetLeft(rec32), Canvas.GetTop(rec32), rec32.Width, rec32.Height);
                                                                                                                        rt.Intersect(rt1);
                                                                                                                        if (!rt.IsEmpty)
                                                                                                                        {
                                                                                                                            return true;
                                                                                                                        }
                                                                                                                        else
                                                                                                                        {
                                                                                                                            rt = new Rect(Canvas.GetLeft(a), Canvas.GetTop(a), a.Width, a.Height);
                                                                                                                            rt1 = new Rect(Canvas.GetLeft(rec33), Canvas.GetTop(rec33), rec33.Width, rec33.Height);
                                                                                                                            rt.Intersect(rt1);
                                                                                                                            if (!rt.IsEmpty)
                                                                                                                            {
                                                                                                                                return true;
                                                                                                                            }
                                                                                                                            else
                                                                                                                            {
                                                                                                                                rt = new Rect(Canvas.GetLeft(a), Canvas.GetTop(a), a.Width, a.Height);
                                                                                                                                rt1 = new Rect(Canvas.GetLeft(rec34), Canvas.GetTop(rec34), rec34.Width, rec34.Height);
                                                                                                                                rt.Intersect(rt1);
                                                                                                                                if (!rt.IsEmpty)
                                                                                                                                {
                                                                                                                                    return true;
                                                                                                                                }
                                                                                                                                else
                                                                                                                                {
                                                                                                                                    rt = new Rect(Canvas.GetLeft(a), Canvas.GetTop(a), a.Width, a.Height);
                                                                                                                                    rt1 = new Rect(Canvas.GetLeft(rec35), Canvas.GetTop(rec35), rec35.Width, rec35.Height);
                                                                                                                                    rt.Intersect(rt1);
                                                                                                                                    if (!rt.IsEmpty)
                                                                                                                                    {
                                                                                                                                        return true;
                                                                                                                                    }
                                                                                                                                    else
                                                                                                                                    {
                                                                                                                                        rt = new Rect(Canvas.GetLeft(a), Canvas.GetTop(a), a.Width, a.Height);
                                                                                                                                        rt1 = new Rect(Canvas.GetLeft(rec36), Canvas.GetTop(rec36), rec6.Width, rec36.Height);
                                                                                                                                        rt.Intersect(rt1);
                                                                                                                                        if (!rt.IsEmpty)
                                                                                                                                        {
                                                                                                                                            return true;
                                                                                                                                        }
                                                                                                                                        else
                                                                                                                                        {
                                                                                                                                            rt = new Rect(Canvas.GetLeft(a), Canvas.GetTop(a), a.Width, a.Height);
                                                                                                                                            rt1 = new Rect(Canvas.GetLeft(rec37), Canvas.GetTop(rec37), rec37.Width, rec37.Height);
                                                                                                                                            rt.Intersect(rt1);
                                                                                                                                            if (!rt.IsEmpty)
                                                                                                                                            {
                                                                                                                                                return true;
                                                                                                                                            }
                                                                                                                                            else
                                                                                                                                            {
                                                                                                                                                rt = new Rect(Canvas.GetLeft(a), Canvas.GetTop(a), a.Width, a.Height);
                                                                                                                                                rt1 = new Rect(Canvas.GetLeft(rec38), Canvas.GetTop(rec38), rec38.Width, rec38.Height);
                                                                                                                                                rt.Intersect(rt1);
                                                                                                                                                if (!rt.IsEmpty)
                                                                                                                                                {
                                                                                                                                                    return true;
                                                                                                                                                }
                                                                                                                                                else
                                                                                                                                                {
                                                                                                                                                    rt = new Rect(Canvas.GetLeft(a), Canvas.GetTop(a), a.Width, a.Height);
                                                                                                                                                    rt1 = new Rect(Canvas.GetLeft(rec39), Canvas.GetTop(rec39), rec39.Width, rec39.Height);
                                                                                                                                                    rt.Intersect(rt1);
                                                                                                                                                    if (!rt.IsEmpty)
                                                                                                                                                    {
                                                                                                                                                        return true;
                                                                                                                                                    }
                                                                                                                                                    else
                                                                                                                                                    {
                                                                                                                                                        rt = new Rect(Canvas.GetLeft(a), Canvas.GetTop(a), a.Width, a.Height);
                                                                                                                                                        rt1 = new Rect(Canvas.GetLeft(rec40), Canvas.GetTop(rec40), rec40.Width, rec40.Height);
                                                                                                                                                        rt.Intersect(rt1);
                                                                                                                                                        if (!rt.IsEmpty)
                                                                                                                                                        {
                                                                                                                                                            return true;
                                                                                                                                                        }
                                                                                                                                                        else
                                                                                                                                                        {
                                                                                                                                                            return false;
                                                                                                                                                        }
                                                                                                                                                    }
                                                                                                                                                }
                                                                                                                                            }
                                                                                                                                        }
                                                                                                                                    }
                                                                                                                                }
                                                                                                                            }
                                                                                                                        }
                                                                                                                    }
                                                                                                                }
                                                                                                            }
                                                                                                        }

                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }