コード例 #1
0
            public static GridRenderSetting Default()
            {
                GridRenderSetting gs = new GridRenderSetting();

                gs.init();
                return(gs);
            }
コード例 #2
0
        private void renderBox(IRenderer r, ref Rectangle bounds,
                               double xStep, double yStep, int x, int y,
                               int boxWidth, int boxHeight, int component,
                               Font font, Font guideFont,
                               GridRenderSetting gridSetting)
        {
            //location
            int x1 = (int)Math.Ceiling(bounds.Left + xStep * x);
            int x2 = (int)Math.Ceiling(bounds.Left + xStep * (x + 1));
            int y1 = (int)Math.Ceiling(bounds.Top + yStep * y);
            int y2 = (int)Math.Ceiling(bounds.Top + yStep * (y + 1));

            switch (component)
            {
            case 0:     //background
                r.FillRectangle(gridSetting.fillColor, x1, y1, boxWidth, boxHeight);
                break;

            case 1:     //foreground
                switch (gridSetting.outlineStyle)
                {
                case OutlineStyleEnum.NoOutline:
                    break;

                case OutlineStyleEnum.Square:
                    r.DrawRectangle(gridSetting.outlineColor, 1, x1, y1, boxWidth, boxHeight);
                    break;

                case OutlineStyleEnum.Beveled:
                    break;
                }

                if ((this[x, y] != null) && gridSetting.letterVisible)
                {
                    using (Font renderFont = new Font(font, gridSetting.FontStyle))
                    {
                        r.DrawString(gridSetting.letterColor, this[x, y].Value.ToString(), renderFont, x1 + 3, y1);
                    }
                }
                break;

            case 2:     //guide
                string text = gridSetting.guideText;
                if (text != null)
                {
                    r.DrawString(Color.Gray, text, guideFont, x1 + 1, y1);
                }
                break;
            }
        }
コード例 #3
0
        //----------------------------------------------------------------------------------
        // rendering
        //----------------------------------------------------------------------------------
        public void Render(IRenderer r, Rectangle bounds)
        {
            using (Font guideFont = new Font("Consolas", 8))
            {
                using (Font font = new Font("Consolas", 16))
                {
                    r.FillRectangle(Color.White, bounds);

                    double xStep = (bounds.Width / (double)Width);
                    double yStep = (bounds.Height / (double)Height);

                    int boxWidth  = (int)Math.Ceiling(xStep);
                    int boxHeight = (int)Math.Ceiling(yStep);

                    GridRenderSetting[,] gridSettings = new GridRenderSetting[Width, Height];

                    for (int component = 0; component < 3; component++)
                    {
                        //populate the edges
                        for (int x = 0; x < Width; x++)
                        {
                            for (int y = 0; y < Height; y++)
                            {
                                //first time, get setting
                                if (component == 0)
                                {
                                    gridSettings[x, y] = (customiseCell != null) ? customiseCell(x, y, this[x, y]) : GridRenderSetting.Default();
                                }

                                renderBox(r, ref bounds, xStep, yStep, x, y, boxWidth, boxHeight, component, font, guideFont, gridSettings[x, y]);
                            }
                        }
                    }
                }
            }
        }