예제 #1
0
        private void Render()
        {
            text = String.Empty;

            var g = buffer.Graphics;

            g.Clear(this.BackColor);

            if (!initialized || storage == null)
            {
                return;
            }

            int x = 0, y = 0;

            var view = zoom.Viewport;

            int colStart = Math.Max(0, view.Left);
            int rowStart = Math.Max(0, view.Top);
            int colEnd   = Math.Min(columns, view.Right);
            int rowEnd   = Math.Min(rows, view.Bottom);

            int size = zoom.BlockSize;

            if (rowStart < rowEnd && colStart < colEnd && zoom.Level > 2)
            {
                foreach (var item in storage.EnumerateSubmatrix(rowStart, rowEnd, colStart, colEnd))
                {
                    x = item.Column;
                    y = item.Row;

                    zoom.WorldToScreen(ref x, ref y);

                    g.FillRectangle(Brushes.Blue, x, y, size, size);
                }
            }
            else
            {
                foreach (var item in storage.Enumerate())
                {
                    x = item.Column;
                    y = item.Row;

                    zoom.WorldToScreen(ref x, ref y);

                    g.FillRectangle(Brushes.Blue, x, y, size, size);
                }
            }

            this.Invalidate();
        }