Esempio n. 1
0
        internal void ShiftImageAndUpdateRest(IPainter painter, IndexedImage canvas, Point imageStartPoint, Size shiftDelta)
        {
            var pixelShift = new Size(shiftDelta.Width * CellSize, shiftDelta.Height * CellSize);

            ImageShifter.ShiftPixels(canvas, -pixelShift.Width, -pixelShift.Height);

            if (shiftDelta.Height != 0)
            {
                if (shiftDelta.Height < 0)                 // Shifting down - repaint rows at top
                {
                    using (painter.Clip(new Rectangle(0, 0, canvas.Size.Width, RulerWidth - pixelShift.Height)))
                    {
                        Paint(painter, canvas.Size, painter.ClipRect, imageStartPoint);
                    }
                }
                else                 // Shifting up - repaint rows at bottom
                {
                    using (painter.Clip(new Rectangle(0, canvas.Size.Height - pixelShift.Height, canvas.Size.Width, pixelShift.Height)))
                    {
                        Paint(painter, canvas.Size, painter.ClipRect, imageStartPoint);
                    }
                    if (ShowRulers)
                    {
                        using (painter.Clip(new Rectangle(0, 0, canvas.Size.Width, RulerWidth)))
                        {
                            Paint(painter, canvas.Size, painter.ClipRect, imageStartPoint);
                        }
                    }
                }
            }

            if (shiftDelta.Width != 0)
            {
                if (shiftDelta.Width < 0)                 // Shifting right - repaint columns at left
                {
                    using (painter.Clip(new Rectangle(0, 0, RulerWidth - pixelShift.Width, canvas.Size.Height)))
                    {
                        Paint(painter, canvas.Size, painter.ClipRect, imageStartPoint);
                    }
                }
                else                 // Shift left - repaint columns at right
                {
                    using (painter.Clip(new Rectangle(canvas.Size.Width - pixelShift.Width, 0, pixelShift.Width, canvas.Size.Height)))
                    {
                        Paint(painter, canvas.Size, painter.ClipRect, imageStartPoint);
                    }
                    if (ShowRulers)
                    {
                        using (painter.Clip(new Rectangle(0, 0, RulerWidth, canvas.Size.Height)))
                        {
                            Paint(painter, canvas.Size, painter.ClipRect, imageStartPoint);
                        }
                    }
                }
            }
        }