Inheritance: GridSubPanelBase
Exemple #1
0
        /// <summary>
        /// Draw the highlighted cells.
        /// </summary>
        /// <param name="panel"></param>
        /// <param name="graphics"></param>
        /// <param name="pRangeToRedraw">The range of cells that must be redrawed. Consider that can contains also not selected cells.</param>
        public virtual void DrawHighlight(GridSubPanel panel, DevAge.Drawing.GraphicsCache graphics, Range pRangeToRedraw)
        {
            if (mRange.IsEmpty() == false &&
                pRangeToRedraw.IntersectsWith(mRange))
            {
                System.Drawing.Rectangle rect = GetDrawingRectangle();
                if (rect != System.Drawing.Rectangle.Empty)
                {
                    System.Drawing.Rectangle rectangleToDraw = panel.RectangleGridToPanel(rect);

                    Border.DrawBorder(graphics, rectangleToDraw);
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Draw the specified Cell
        /// </summary>
        /// <param name="cellContext"></param>
        /// <param name="p_Panel"></param>
        /// <param name="e"></param>
        /// <param name="p_PanelDrawRectangle"></param>
        protected override void PaintCell(CellContext cellContext, GridSubPanel p_Panel,
                                          DevAge.Drawing.GraphicsCache graphics, Rectangle p_PanelDrawRectangle)
        {
            Range cellRange = PositionToCellRange(cellContext.Position);

            if (cellRange.Start == cellContext.Position)
            {
                base.PaintCell(cellContext, p_Panel, graphics, p_PanelDrawRectangle);
            }
            else             //Row/Col Span > 1
            {
                p_PanelDrawRectangle = p_Panel.RectangleGridToPanel(RangeToRectangle(cellRange));
                base.PaintCell(cellContext, p_Panel, graphics, p_PanelDrawRectangle);
            }
        }
Exemple #3
0
        /// <summary>
        /// Draw the selection using the SelectionColor property over the selected cells. Draw a Border around the selection using Border and BorderMode properties.
        /// </summary>
        /// <param name="p_Panel"></param>
        /// <param name="graphics"></param>
        /// <param name="pRangeToRedraw">The range of cells that must be redrawed. Consider that can contains also not selected cells.</param>
        public virtual void DrawSelectionMask(GridSubPanel p_Panel, DevAge.Drawing.GraphicsCache graphics, Range pRangeToRedraw)
        {
            if (IsEmpty())
            {
                return;
            }

            Region     oldClip       = graphics.Graphics.Clip;
            SolidBrush brushFillMask = graphics.BrushsCache.GetBrush(BackColor);

            try
            {
                graphics.Graphics.Clip = new Region(graphics.ClipRectangle);

                Range     rangeFocus = Range.Empty;
                Rectangle rectFocus  = Rectangle.Empty;
                if (m_ActivePosition.IsEmpty() == false && pRangeToRedraw.Contains(m_ActivePosition))
                {
                    rectFocus  = p_Panel.RectangleGridToPanel(Grid.PositionToRectangle(m_ActivePosition));
                    rangeFocus = Grid.PositionToCellRange(m_ActivePosition);
                }
                Cells.ICellVirtual cellFocus = Grid.GetCell(m_ActivePosition);

                //Draw selection mask and border
                //Draw each cell separately
                if ((m_MaskStyle & SelectionMaskStyle.DrawOnlyInitializedCells) == SelectionMaskStyle.DrawOnlyInitializedCells &&
                    (MaskStyle & SelectionMaskStyle.DrawSeletionOverCells) == SelectionMaskStyle.DrawSeletionOverCells)                      //Draw Over cells enabled?
                {
                    PositionCollection selectedCells = GetCellsPositions();
                    for (int i = 0; i < selectedCells.Count; i++)
                    {
                        //if must be redrawed, is is not the cell with the focus and contains a cell
                        if (pRangeToRedraw.Contains(selectedCells[i]) && rangeFocus.Contains(selectedCells[i]) == false &&
                            Grid.GetCell(selectedCells[i]) != null)
                        {
                            Rectangle rect = p_Panel.RectangleGridToPanel(Grid.PositionToRectangle(selectedCells[i]));
                            graphics.Graphics.FillRectangle(brushFillMask, rect);
                        }
                    }
                }
                //draw all the selected ranges (Default) //Draw Over cells enabled?
                else if ((MaskStyle & SelectionMaskStyle.DrawSeletionOverCells) == SelectionMaskStyle.DrawSeletionOverCells)
                {
                    RangeCollection selectedRanges = GetRanges();
                    for (int i = 0; i < selectedRanges.Count; i++)
                    {
                        Range range = selectedRanges[i];
                        if (range.IntersectsWith(pRangeToRedraw))
                        {
                            Rectangle rect = p_Panel.RectangleGridToPanel(Grid.RangeToRectangle(range));

                            if (range.Contains(m_ActivePosition))
                            {
                                Region region = new Region(rect);
                                region.Exclude(rectFocus);
                                graphics.Graphics.FillRegion(brushFillMask, region);
                            }
                            else
                            {
                                graphics.Graphics.FillRectangle(brushFillMask, rect);
                            }
                        }
                    }
                }

                //Draw focus mask and focus border (only if there is a fucus cell and is not in editng mode)
                CellContext focusCellContext = new CellContext(Grid, m_ActivePosition, cellFocus);
                if (cellFocus != null && focusCellContext.IsEditing() == false &&
                    pRangeToRedraw.Contains(m_ActivePosition))
                {
                    //Draw Over cells enabled?
                    if ((MaskStyle & SelectionMaskStyle.DrawSeletionOverCells) == SelectionMaskStyle.DrawSeletionOverCells)
                    {
                        if (m_FocusBackColor != Color.Transparent)
                        {
                            Brush focusBrush = graphics.BrushsCache.GetBrush(m_FocusBackColor);
                            graphics.Graphics.FillRectangle(focusBrush, rectFocus);
                        }
                    }
                }

                if (focusCellContext.IsEditing() == false)
                {
                    mRangeHighlight.DrawHighlight(p_Panel, graphics, pRangeToRedraw);
                }
            }
            finally
            {
                graphics.Graphics.Clip = oldClip;
            }
        }
Exemple #4
0
 public GridPaintEventArgs(System.Windows.Forms.PaintEventArgs pPaintEventArgs, GridSubPanel pPanel, System.Drawing.Rectangle pPanelDrawRectangle)
 {
     mPaintEventArgs     = pPaintEventArgs;
     mPanel              = pPanel;
     mPanelDrawRectangle = pPanelDrawRectangle;
 }