示例#1
0
 private void contentPanel_Paint(object sender, PaintEventArgs e)
 {
     using (DevAge.Drawing.GraphicsCache graphics = new DevAge.Drawing.GraphicsCache(e.Graphics, e.ClipRectangle))
     {
         GetVisualElement().Draw(graphics, contentPanel.ClientRectangle);
     }
 }
示例#2
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            using (DevAge.Drawing.GraphicsCache graphics = new DevAge.Drawing.GraphicsCache(e.Graphics, e.ClipRectangle))
            {
                GridSubPanelType l_Type = ContainerType;
                if (l_Type == GridSubPanelType.TopLeft)
                {
                    m_GridContainer.OnTopLeftPanelPaint(graphics);
                }
                else if (l_Type == GridSubPanelType.Left)
                {
                    m_GridContainer.OnLeftPanelPaint(graphics);
                }
                else if (l_Type == GridSubPanelType.Top)
                {
                    m_GridContainer.OnTopPanelPaint(graphics);
                }
                else //scrollable
                {
                    m_GridContainer.OnScrollablePanelPaint(graphics);
                }
            }
        }
示例#3
0
 protected virtual void ExportCell(CellContext context, DevAge.Drawing.GraphicsCache graphics, System.Drawing.Rectangle rectangle)
 {
     if (context.Cell != null)
     {
         context.Cell.View.DrawCell(context, graphics, rectangle);
     }
 }
示例#4
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            if (Enabled)
            {
                if (m_Pressed)
                {
                    mDropDown.Style = DevAge.Drawing.ButtonStyle.Pressed;
                }
                else if (m_MouseOver)
                {
                    mDropDown.Style = DevAge.Drawing.ButtonStyle.Hot;
                }
                else
                {
                    mDropDown.Style = DevAge.Drawing.ButtonStyle.Normal;
                }
            }
            else
            {
                mDropDown.Style = DevAge.Drawing.ButtonStyle.Disabled;
            }

            using (DevAge.Drawing.GraphicsCache cache = new DevAge.Drawing.GraphicsCache(e.Graphics, e.ClipRectangle))
            {
                mDropDown.Draw(cache, Rectangle.Round(ClientRectangle));
            }
        }
示例#5
0
            protected override void OnDraw(DevAge.Drawing.GraphicsCache graphics, RectangleF area)
            {
                System.Drawing.Drawing2D.GraphicsState state = graphics.Graphics.Save();
                try
                {
                    float width2  = area.Width / 2;
                    float height2 = area.Height / 2;

                    //For a better drawing use the clear type rendering
                    graphics.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;

                    //Move the origin to the center of the cell (for a more easy rotation)
                    graphics.Graphics.TranslateTransform(area.X + width2, area.Y + height2);

                    graphics.Graphics.RotateTransform(Angle);
                    graphics.Graphics.TranslateTransform(-height2, 0); //-(area.Y + height2));

                    StringFormat.Alignment     = StringAlignment.Near;
                    StringFormat.LineAlignment = StringAlignment.Center;
                    graphics.Graphics.DrawString(Value, Font, graphics.BrushsCache.GetBrush(ForeColor), 0, 0, StringFormat);
                }
                finally
                {
                    graphics.Graphics.Restore(state);
                }
            }
示例#6
0
        protected override void OnPaint(PaintEventArgs e)
        {
            GridSubPanelType panelType = ContainerType;

            if (panelType == GridSubPanelType.Hidden)
            {
                return;
            }

            base.OnPaint(e);

            using (DevAge.Drawing.GraphicsCache graphics = new DevAge.Drawing.GraphicsCache(e.Graphics, e.ClipRectangle))
            {
                if (panelType == GridSubPanelType.TopLeft)
                {
                    m_GridContainer.OnTopLeftPanelPaint(graphics);
                }
                else if (panelType == GridSubPanelType.Left)
                {
                    m_GridContainer.OnLeftPanelPaint(graphics);
                }
                else if (panelType == GridSubPanelType.Top)
                {
                    m_GridContainer.OnTopPanelPaint(graphics);
                }
                else //scrollable
                {
                    m_GridContainer.OnScrollablePanelPaint(graphics);
                }
            }

            ////Use this code to test panels
            //e.Graphics.DrawEllipse(Pens.Black, ClientRectangle);
            //e.Graphics.DrawString(ContainerType.ToString(), Font, Brushes.Black, ClientRectangle);
        }
示例#7
0
        /// <summary>
        /// Draw the highlighted cells.
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="drawingRange">The range of cells that must be redrawed. Consider that can contains also not selected cells.</param>
        protected virtual void DrawHighlight(DevAge.Drawing.GraphicsCache graphics, Range drawingRange)
        {
            if (Region.IsEmpty() ||
                Region.IntersectsWith(drawingRange) == false)
            {
                return;
            }

            System.Drawing.Brush brush = graphics.BrushsCache.GetBrush(BackColor);

            foreach (Range rng in Region.GetRanges())
            {
                System.Drawing.Rectangle rectToDraw = Grid.RangeToRectangle(rng);
                if (rectToDraw == System.Drawing.Rectangle.Empty)
                {
                    continue;
                }

                System.Drawing.RectangleF contentRect = Border.GetContentRectangle(rectToDraw);

                graphics.Graphics.FillRectangle(brush, contentRect);

                Border.Draw(graphics, rectToDraw);
            }
        }
示例#8
0
文件: Image.cs 项目: zhuangyy/Motion
        public virtual void Export(GridVirtual grid, System.Drawing.Graphics graphics, 
                                Range rangeToExport, System.Drawing.Point destinationLocation)
        {
            if (rangeToExport.IsEmpty())
                return;

            System.Drawing.Point cellPoint = destinationLocation;

            System.Drawing.Point deltaPoint = destinationLocation;

            using (DevAge.Drawing.GraphicsCache graphicsCache = new DevAge.Drawing.GraphicsCache(graphics))
            {
                for (int r = rangeToExport.Start.Row; r <= rangeToExport.End.Row; r++)
                {
                    int rowHeight = grid.Rows.GetHeight(r);

                    for (int c = rangeToExport.Start.Column; c <= rangeToExport.End.Column; c++)
                    {
                        Rectangle cellRectangle;
                        Position pos = new Position(r, c);

                        Size cellSize = new Size(grid.Columns.GetWidth(c), rowHeight);

                        Range range = grid.PositionToCellRange(pos);

                        //support for RowSpan or ColSpan
                        //Note: for now I draw only the merged cell at the first position
                        // (this can cause a problem if you export partial range that contains a partial merged cells)
                        if ( range.ColumnsCount > 1 || range.RowsCount > 1)
                        {
                            //Is the first position
                            if (range.Start == pos)
                            {
                                Size rangeSize = grid.RangeToSize(range);

                                cellRectangle = new Rectangle(cellPoint,
                                                              rangeSize);
                            }
                            else
                                cellRectangle = Rectangle.Empty;
                        }
                        else
                        {
                            cellRectangle = new Rectangle(cellPoint, cellSize);
                        }

                        if (cellRectangle.IsEmpty == false)
                        {
                            Cells.ICellVirtual cell = grid.GetCell(pos);
                            CellContext context = new CellContext(grid, pos, cell);
                            ExportCell(context, graphicsCache, cellRectangle);
                        }

                        cellPoint = new Point(cellPoint.X + cellSize.Width, cellPoint.Y);
                    }

                    cellPoint = new Point(destinationLocation.X, cellPoint.Y + rowHeight);
                }
            }
        }
示例#9
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            if (BorderRound > 0)
            {
                e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            }

            DrawBorderAndFill(e.Graphics);

            bool disabledImage = false;

            Image image = mImage;

            if (Enabled == false)
            {
                if (mDisabledImage != null)
                {
                    image = mDisabledImage;
                }
                else
                {
                    disabledImage = true;
                }
            }
            else if (mIsMouseOver && mMouseOverImage != null)
            {
                image = mMouseOverImage;
            }

            Rectangle contentRect = ClientRectangle;

            if (BorderWidth > 0)
            {
                contentRect = new Rectangle(contentRect.X + BorderWidth, contentRect.Y + BorderWidth,
                                            contentRect.Width - BorderWidth * 2, contentRect.Height - BorderWidth * 2);
            }

            DevAge.Drawing.VisualElements.Container container    = new DevAge.Drawing.VisualElements.Container();
            DevAge.Drawing.VisualElements.TextGDI   textElement  = new DevAge.Drawing.VisualElements.TextGDI(Text);
            DevAge.Drawing.VisualElements.Image     imageElement = new DevAge.Drawing.VisualElements.Image(image);
            imageElement.AnchorArea  = new DevAge.Drawing.AnchorArea(mImageAlignment, mImageStretch);
            imageElement.Enabled     = !disabledImage;
            textElement.AnchorArea   = new DevAge.Drawing.AnchorArea(DevAge.Drawing.Utilities.StringFormatToContentAlignment(mStringFormat), false);
            textElement.StringFormat = mStringFormat;
            textElement.Font         = Font;
            textElement.ForeColor    = ForeColor;
            textElement.Enabled      = Enabled;
            container.Elements.Add(imageElement);
            container.Elements.Add(textElement);



            using (DevAge.Drawing.GraphicsCache cache = new DevAge.Drawing.GraphicsCache(e.Graphics, e.ClipRectangle))
            {
                container.Draw(cache, contentRect);
            }
        }
示例#10
0
 public RangePaintEventArgs(GridVirtual grid,
                            DevAge.Drawing.GraphicsCache graphicsCache,
                            Range drawingRange)
 {
     mGrid          = grid;
     mGraphicsCache = graphicsCache;
     mDrawingRange  = drawingRange;
 }
示例#11
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            using (DevAge.Drawing.GraphicsCache cache = new DevAge.Drawing.GraphicsCache(e.Graphics, e.ClipRectangle))
            {
                mEditablePanel.Draw(cache, ClientRectangle);
            }
        }
示例#12
0
		protected override void OnPaint(PaintEventArgs e)
		{
			base.OnPaint (e);

            using (DevAge.Drawing.GraphicsCache cache = new DevAge.Drawing.GraphicsCache(e.Graphics, e.ClipRectangle))
            {
                mEditablePanel.Draw(cache, ClientRectangle);
            }
		}
示例#13
0
                protected override void OnDraw(DevAge.Drawing.GraphicsCache graphics, RectangleF area)
                {
                    DevAge.Drawing.RoundedRectangle rounded = new DevAge.Drawing.RoundedRectangle(Rectangle.Round(area), Round);
                    using (System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush(area, Color.RoyalBlue, Color.WhiteSmoke, System.Drawing.Drawing2D.LinearGradientMode.Vertical))
                    {
                        graphics.Graphics.FillRegion(brush, new Region(rounded.ToGraphicsPath()));
                    }


                    //Border
                    DevAge.Drawing.Utilities.DrawRoundedRectangle(graphics.Graphics, rounded, Pens.RoyalBlue);
                }
示例#14
0
        private void Test_TextRenderer(Graphics gr)
        {
            DevAge.Drawing.VisualElements.TextRenderer text = new DevAge.Drawing.VisualElements.TextRenderer("Test text performance");

            using (DevAge.Drawing.GraphicsCache cache = new DevAge.Drawing.GraphicsCache(gr))
            {
                for (int i = 0; i < 1000; i++)
                {
                    text.Draw(cache, panelDraw.ClientRectangle);
                }
            }
        }
示例#15
0
        private void Test_RectangleBorder(Graphics gr)
        {
            DevAge.Drawing.RectangleBorder rct = 
                new DevAge.Drawing.RectangleBorder(new DevAge.Drawing.BorderLine(Color.Red, 3),
                                                new DevAge.Drawing.BorderLine(Color.Blue, 3));

            
            using (DevAge.Drawing.GraphicsCache cache = new DevAge.Drawing.GraphicsCache(gr))
            {
                for (int i = 0; i < 100; i++)
                    rct.Draw(cache, panelDraw.ClientRectangle);
            }
        }
示例#16
0
 /// <summary>
 /// ѕереопределенное отображение ¤чеек дл¤ раскраски
 /// </summary>
 protected override void PaintCell(DevAge.Drawing.GraphicsCache graphics,
                                   SourceGrid.CellContext cellContext,
                                   System.Drawing.RectangleF drawRectangle)
 {
     //if (cellContext.DisplayText != "")
     cellContext.Cell.View.BackColor = ColorCalcRGB(cellContext.DisplayText);
     //base.PaintCell(graphics, cellContext, drawRectangle);
     if (drawRectangle.Width > 0 && drawRectangle.Height > 0 &&
         cellContext.CanBeDrawn())
     {
         cellContext.Cell.View.DrawCell(cellContext, graphics, drawRectangle);
     }
 }
示例#17
0
文件: Grid.cs 项目: unixcrh/Motion
        protected override void PaintCell(DevAge.Drawing.GraphicsCache graphics, CellContext cellContext, RectangleF drawRectangle)
        {
            Range cellRange = PositionToCellRange(cellContext.Position);

            if (cellRange.ColumnsCount == 1 && cellRange.RowsCount == 1)
            {
                base.PaintCell(graphics, cellContext, drawRectangle);
            }
            else //Row/Col Span > 1
            {
                Rectangle spanRect = RangeToRectangle(cellRange);
                base.PaintCell(graphics, cellContext, spanRect);
            }
        }
示例#18
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);
                }
            }
        }
示例#19
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);
            }
        }
示例#20
0
        private void Test_RectangleBorder(Graphics gr)
        {
            DevAge.Drawing.RectangleBorder rct =
                new DevAge.Drawing.RectangleBorder(new DevAge.Drawing.BorderLine(Color.Red, 3),
                                                   new DevAge.Drawing.BorderLine(Color.Blue, 3));


            using (DevAge.Drawing.GraphicsCache cache = new DevAge.Drawing.GraphicsCache(gr))
            {
                for (int i = 0; i < 100; i++)
                {
                    rct.Draw(cache, panelDraw.ClientRectangle);
                }
            }
        }
示例#21
0
        public virtual void Export(GridVirtual grid, System.Drawing.Graphics graphics, Range rangeToExport, System.Drawing.Point destinationLocation)
        {
            if (rangeToExport.IsEmpty())
            {
                return;
            }

            System.Drawing.Point cellPoint = destinationLocation;

            System.Drawing.Point deltaPoint = destinationLocation;

            using (DevAge.Drawing.GraphicsCache graphicsCache = new DevAge.Drawing.GraphicsCache(graphics))
            {
                for (int r = rangeToExport.Start.Row; r <= rangeToExport.End.Row; r++)
                {
                    int rowHeight = grid.Rows.GetHeight(r);

                    for (int c = rangeToExport.Start.Column; c <= rangeToExport.End.Column; c++)
                    {
                        System.Drawing.Rectangle cellRectangle;
                        Position pos = new Position(r, c);

                        Range range = grid.PositionToCellRange(pos);
                        System.Drawing.Size cellSize = new System.Drawing.Size(grid.Columns.GetWidth(c), rowHeight);

                        if (range.ColumnsCount > 1 || range.RowsCount > 1) //support for RowSpan or ColSpan
                        {
                            System.Drawing.Rectangle rangeRectange = grid.RangeToRectangleRelative(rangeToExport.Start.Row, rangeToExport.Start.Column, range);
                            cellRectangle = new System.Drawing.Rectangle(new System.Drawing.Point(deltaPoint.X + rangeRectange.Location.X, deltaPoint.Y + rangeRectange.Location.Y), rangeRectange.Size);
                        }
                        else
                        {
                            cellRectangle = new System.Drawing.Rectangle(cellPoint, cellSize);
                        }

                        Cells.ICellVirtual cell    = grid.GetCell(pos);
                        CellContext        context = new CellContext(grid, pos, cell);
                        ExportCell(context, graphicsCache, cellRectangle);

                        cellPoint = new System.Drawing.Point(cellPoint.X + cellSize.Width, cellPoint.Y);
                    }

                    cellPoint = new System.Drawing.Point(destinationLocation.X, cellPoint.Y + rowHeight);
                }
            }
        }
示例#22
0
        private void Test_RectangleBorder2(Graphics gr)
        {
            DevAge.Drawing.RectangleBorder rct =
                new DevAge.Drawing.RectangleBorder(new DevAge.Drawing.BorderLine(Color.Red, 2),
                                                new DevAge.Drawing.BorderLine(Color.Blue, 2),
                                                new DevAge.Drawing.BorderLine(Color.Green, 2),
                                                new DevAge.Drawing.BorderLine(Color.YellowGreen, 2));

            using (DevAge.Drawing.GraphicsCache cache = new DevAge.Drawing.GraphicsCache(gr))
            {
                for (int i = 0; i < 100; i++)
                {
                    rct.Draw(cache, panelDraw.ClientRectangle);

                    Rectangle innerRect = panelDraw.ClientRectangle;
                    innerRect.Inflate(-10, -10);
                    rct.Draw(cache, innerRect);
                }
            }
        }
示例#23
0
        private void Test_RectangleBorder3(Graphics gr)
        {
            DevAge.Drawing.RectangleBorder rct =
                new DevAge.Drawing.RectangleBorder(new DevAge.Drawing.BorderLine(Color.Red, 3),
                                                   new DevAge.Drawing.BorderLine(Color.Blue, 3),
                                                   new DevAge.Drawing.BorderLine(Color.Green, 3),
                                                   new DevAge.Drawing.BorderLine(Color.YellowGreen, 3));

            using (DevAge.Drawing.GraphicsCache cache = new DevAge.Drawing.GraphicsCache(gr))
            {
                for (int i = 0; i < 100; i++)
                {
                    rct.Draw(cache, panelDraw.ClientRectangle);

                    Rectangle innerRect = panelDraw.ClientRectangle;
                    innerRect.Inflate(-10, -10);
                    rct.Draw(cache, innerRect);
                }
            }
        }
示例#24
0
        protected override void PaintCell(DevAge.Drawing.GraphicsCache graphics, CellContext cellContext, RectangleF drawRectangle)
        {
            Range cellRange = PositionToCellRange(cellContext.Position);

            if (cellRange.ColumnsCount == 1 && cellRange.RowsCount == 1)
            {
                base.PaintCell(graphics, cellContext, drawRectangle);
            }
            else //Row/Col Span > 1
            {
                //I draw the merged cell only if not already drawn otherwise drawing the same cell can cause some problem when using special drawing code (for example semi transparent background)
                if (mDrawnRange.Contains(cellRange) == false)
                {
                    Rectangle spanRect = RangeToRectangle(cellRange);
                    base.PaintCell(graphics, cellContext, spanRect);

                    mDrawnRange.Add(cellRange);
                }
            }
        }
示例#25
0
        private void Test_TextRenderer(Graphics gr)
        {
            DevAge.Drawing.VisualElements.TextRenderer text = new DevAge.Drawing.VisualElements.TextRenderer("Test text performance");

            using (DevAge.Drawing.GraphicsCache cache = new DevAge.Drawing.GraphicsCache(gr))
            {
                for (int i = 0; i < 1000; i++)
                    text.Draw(cache, panelDraw.ClientRectangle);
            }
        }
示例#26
0
		protected override void OnPaint(PaintEventArgs e)
		{
			base.OnPaint (e);

			if (Enabled)
			{
                if (m_Pressed)
                    mDropDown.Style = DevAge.Drawing.ButtonStyle.Pressed;
                else if (m_MouseOver)
                    mDropDown.Style = DevAge.Drawing.ButtonStyle.Hot;
                else
                    mDropDown.Style = DevAge.Drawing.ButtonStyle.Normal;
            }
			else
                mDropDown.Style = DevAge.Drawing.ButtonStyle.Disabled;

            using (DevAge.Drawing.GraphicsCache cache = new DevAge.Drawing.GraphicsCache(e.Graphics, e.ClipRectangle))
            {
                mDropDown.Draw(cache, Rectangle.Round(ClientRectangle));
            }
		}
示例#27
0
		protected override void OnPaint(PaintEventArgs e)
		{
			base.OnPaint(e);

			//NOTE: For now I draw all the visible cells (not only the invalidated cells).
			using (DevAge.Drawing.GraphicsCache grCache = new DevAge.Drawing.GraphicsCache(e.Graphics, e.ClipRectangle))
			{
				foreach (Range rng in GetVisibleRegion())
				{
					OnRangePaint(new RangePaintEventArgs(this, grCache, rng));
				}
			}
		}
示例#28
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;
            }
        }
示例#29
0
		protected override void OnPaint(PaintEventArgs e)
		{
			base.OnPaint (e);

			if (BorderRound > 0)
				e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

			DrawBorderAndFill(e.Graphics);

			bool disabledImage = false;

			Image image = mImage;
			if (Enabled == false)
			{
				if (mDisabledImage != null)
					image = mDisabledImage;
				else
					disabledImage = true;
			}
			else if (mIsMouseOver && mMouseOverImage != null)
				image = mMouseOverImage;

			Rectangle contentRect = ClientRectangle;
			if (BorderWidth > 0)
				contentRect = new Rectangle(contentRect.X + BorderWidth, contentRect.Y + BorderWidth,
											contentRect.Width - BorderWidth * 2, contentRect.Height - BorderWidth * 2);

            DevAge.Drawing.VisualElements.Container container = new DevAge.Drawing.VisualElements.Container();
            DevAge.Drawing.VisualElements.TextGDI textElement = new DevAge.Drawing.VisualElements.TextGDI(Text);
            DevAge.Drawing.VisualElements.Image imageElement = new DevAge.Drawing.VisualElements.Image(image);
            imageElement.AnchorArea = new DevAge.Drawing.AnchorArea(mImageAlignment, mImageStretch);
            imageElement.Enabled = !disabledImage;
            textElement.AnchorArea = new DevAge.Drawing.AnchorArea(DevAge.Drawing.Utilities.StringFormatToContentAlignment(mStringFormat), false);
            textElement.StringFormat = mStringFormat;
            textElement.Font = Font;
            textElement.ForeColor = ForeColor;
            textElement.Enabled = Enabled;
            container.Elements.Add(imageElement);
            container.Elements.Add(textElement);



            using (DevAge.Drawing.GraphicsCache cache = new DevAge.Drawing.GraphicsCache(e.Graphics, e.ClipRectangle))
            {
                container.Draw(cache, contentRect);
            }
		}
示例#30
0
 /// <summary>
 /// ѕереопределенное отображение ¤чеек дл¤ раскраски
 /// </summary>
 protected override void PaintCell(DevAge.Drawing.GraphicsCache graphics, SourceGrid.CellContext cellContext, System.Drawing.RectangleF drawRectangle)
 {
     //if (cellContext.DisplayText != "")
     cellContext.Cell.View.BackColor = ColorCalcRGB(cellContext.DisplayText);
     base.PaintCell(graphics, cellContext, drawRectangle);
 }
示例#31
0
文件: Events.cs 项目: zhuangyy/Motion
 public RangePaintEventArgs(GridVirtual grid,
                         DevAge.Drawing.GraphicsCache graphicsCache,
                         Range drawingRange)
 {
     mGrid = grid;
     mGraphicsCache = graphicsCache;
     mDrawingRange = drawingRange;
 }
示例#32
0
 private void contentPanel_Paint(object sender, PaintEventArgs e)
 {
     using (DevAge.Drawing.GraphicsCache graphics = new DevAge.Drawing.GraphicsCache(e.Graphics, e.ClipRectangle))
     {
         GetVisualElement().Draw(graphics, contentPanel.ClientRectangle);
     }
 }
示例#33
0
        public virtual void Export(GridVirtual grid, System.Drawing.Graphics graphics,
                                   Range rangeToExport, System.Drawing.Point destinationLocation)
        {
            if (rangeToExport.IsEmpty())
            {
                return;
            }

            System.Drawing.Point cellPoint = destinationLocation;

            using (DevAge.Drawing.GraphicsCache graphicsCache = new DevAge.Drawing.GraphicsCache(graphics))
            {
                for (int r = rangeToExport.Start.Row; r <= rangeToExport.End.Row; r++)
                {
                    int rowHeight = grid.Rows.GetHeight(r);

                    for (int c = rangeToExport.Start.Column; c <= rangeToExport.End.Column; c++)
                    {
                        Rectangle cellRectangle;
                        Position  pos = new Position(r, c);

                        Size cellSize = new Size(grid.Columns.GetWidth(c), rowHeight);

                        Range range = grid.PositionToCellRange(pos);

                        //support for RowSpan or ColSpan
                        //Note: for now I draw only the merged cell at the first position
                        // (this can cause a problem if you export partial range that contains a partial merged cells)
                        if (range.ColumnsCount > 1 || range.RowsCount > 1)
                        {
                            //Is the first position
                            if (range.Start == pos)
                            {
                                Size rangeSize = grid.RangeToSize(range);

                                cellRectangle = new Rectangle(cellPoint,
                                                              rangeSize);
                            }
                            else
                            {
                                cellRectangle = Rectangle.Empty;
                            }
                        }
                        else
                        {
                            cellRectangle = new Rectangle(cellPoint, cellSize);
                        }

                        if (cellRectangle.IsEmpty == false)
                        {
                            Cells.ICellVirtual cell    = grid.GetCell(pos);
                            CellContext        context = new CellContext(grid, pos, cell);
                            ExportCell(context, graphicsCache, cellRectangle);
                        }

                        cellPoint = new Point(cellPoint.X + cellSize.Width, cellPoint.Y);
                    }

                    cellPoint = new Point(destinationLocation.X, cellPoint.Y + rowHeight);
                }
            }
        }
示例#34
0
        protected override void OnPaint(PaintEventArgs e)
        {
            GridSubPanelType panelType = ContainerType;
            if (panelType == GridSubPanelType.Hidden)
                return;

            base.OnPaint(e);

            using (DevAge.Drawing.GraphicsCache graphics = new DevAge.Drawing.GraphicsCache(e.Graphics, e.ClipRectangle))
            {
                if (panelType == GridSubPanelType.TopLeft)
                    m_GridContainer.OnTopLeftPanelPaint(graphics);
                else if (panelType == GridSubPanelType.Left)
                    m_GridContainer.OnLeftPanelPaint(graphics);
                else if (panelType == GridSubPanelType.Top)
                    m_GridContainer.OnTopPanelPaint(graphics);
                else //scrollable
                    m_GridContainer.OnScrollablePanelPaint(graphics);
            }

            ////Use this code to test panels
            //e.Graphics.DrawEllipse(Pens.Black, ClientRectangle);
            //e.Graphics.DrawString(ContainerType.ToString(), Font, Brushes.Black, ClientRectangle);
        }