Exemplo n.º 1
0
            void DesignerPanel_Paint(object sender, PaintEventArgs e)
            {
                IUISelectionService selectionServ = this.DesignedControl.Site.GetService(typeof(IUISelectionService)) as IUISelectionService;

                if (selectionServ != null)
                {
                    selectionServ.PaintAdornments(this.DesignerPanel, e.Graphics);
                }
            }
        // Draws the design-time grid if DrawGrid == true
        //
        protected override void OnPaintAdornments(PaintEventArgs pe)
        {
            base.OnPaintAdornments(pe);

            bool drawGrid;
            Size gridSize;

            // in case WM_PAINT is received before the IDesignerFilter is invoked to add
            // those properties.
            try
            {
                drawGrid = (bool)GetValue(this.Component, "DrawGrid");
            }
            catch
            {
                drawGrid = this.DrawGrid;
            }
            try
            {
                gridSize = (Size)GetValue(this.Component, "GridSize");
            }
            catch
            {
                gridSize = this.GridSize;
            }

            if (drawGrid)
            {
                GraphicsState state = pe.Graphics.Save();
                pe.Graphics.TranslateTransform(this.Control.ClientRectangle.X,
                                               this.Control.ClientRectangle.Y);
                ControlPaint.DrawGrid(pe.Graphics, this.Control.ClientRectangle, gridSize, this.Control.BackColor);
                pe.Graphics.Restore(state);
            }

            IUISelectionService selection = this.GetService(typeof(IUISelectionService)) as IUISelectionService;

            if (selection != null)
            {
                selection.PaintAdornments(this.Control, pe.Graphics);
            }
        }