예제 #1
0
        public static bool RotatedFigureIntersectsWithOtherBlocks(int id, Figure figure, Canvas canvas)
        {
            foreach (TextBlock block in canvas.Children)
            {
                if (figure.Blocks.Contains(block))
                {
                    continue;
                }

                double left = Canvas.GetLeft(block);
                double top  = Canvas.GetTop(block);

                for (int i = 0; i < figure.Blocks.Count; i++)
                {
                    int leftOffset = figure.Left + figure.GetLeftOffset(i, id);
                    int topOffset  = figure.Top + figure.GetTopOffset(i, id);
                    if (((leftOffset == left) && (topOffset == top)) || ((leftOffset < 0) || (leftOffset >= canvas.Width)))
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }