Esempio n. 1
0
 public void PaintBuffer(PaintFunc paintFunc, SizeF scaleFactor)
 {
     Graphics g = EnsureGraphics();
     {
         if (region == null || !region.IsEmpty(g))
         {
             //using (SolidBrush b = new SolidBrush(Color.Transparent))
             //{
             //    bg.FillRectangle(b, clientRectangle);
             //}
             FluidPaintEventArgs ea = EnsurePaintEventArgs();
             ea.Graphics       = g;
             ea.Region         = region;
             g.Clip            = region;
             ea.ScaleFactor    = scaleFactor;
             ea.ControlBounds  = new Rectangle(0, 0, Width, Height);
             ea.DoubleBuffered = false;
             paintFunc(ea);
             if (region != null)
             {
                 region.MakeEmpty();
             }
         }
     }
 }
Esempio n. 2
0
        public void Paint(FluidPaintEventArgs e, FluidControl control, PaintFunc paintFunc, int alpha)
        {
            Rectangle dst = e.ControlBounds;

            //            Rectangle dst = control.Bounds;
            EnsureDBuffer(dst.Width, dst.Height);
            PaintBuffer(paintFunc, e.ScaleFactor);
            if (alpha >= 255)
            {
                e.Graphics.DrawImage(dbuffer, dst.X, dst.Y);
            }
            else
            {
                GdiExt.AlphaBlendImage(e.Graphics, dbuffer, dst.X, dst.Y, alpha, false);
            }
        }
Esempio n. 3
0
 public void Paint(FluidPaintEventArgs e, FluidControl control, PaintFunc paintFunc)
 {
     Paint(e, control, paintFunc, 255);
 }
Esempio n. 4
0
 public void PaintBuffer(PaintFunc paintFunc, SizeF scaleFactor)
 {
     Graphics g = EnsureGraphics();
     {
         if (region == null || !region.IsEmpty(g))
         {
             //using (SolidBrush b = new SolidBrush(Color.Transparent))
             //{
             //    bg.FillRectangle(b, clientRectangle);
             //}
             FluidPaintEventArgs ea = EnsurePaintEventArgs();
             ea.Graphics = g;
             ea.Region = region;
             g.Clip = region;
             ea.ScaleFactor = scaleFactor;
             ea.ControlBounds = new Rectangle(0, 0, Width, Height);
             ea.DoubleBuffered = false;
             paintFunc(ea);
             if (region != null) region.MakeEmpty();
         }
     }
 }
Esempio n. 5
0
 public void Paint(FluidPaintEventArgs e, FluidControl control, PaintFunc paintFunc)
 {
     Paint(e, control, paintFunc, 255);
 }
Esempio n. 6
0
 public void Paint(FluidPaintEventArgs e, FluidControl control, PaintFunc paintFunc, int alpha)
 {
     Rectangle dst = e.ControlBounds;
     //            Rectangle dst = control.Bounds;
     EnsureDBuffer(dst.Width, dst.Height);
     PaintBuffer(paintFunc, e.ScaleFactor);
     if (alpha >= 255)
     {
         e.Graphics.DrawImage(dbuffer, dst.X, dst.Y);
     }
     else
     {
         GdiExt.AlphaBlendImage(e.Graphics, dbuffer, dst.X, dst.Y, alpha, false);
     }
 }
Esempio n. 7
0
        public void Paint(PaintFunc paintFunc,
                          System.Drawing.Graphics g, System.Drawing.Rectangle clipBounds,
                          System.Drawing.Rectangle cellBounds, int rowIndex,
                          DataGridViewElementStates cellState, object value,
                          object formattedValue, string errorText,
                          DataGridViewCellStyle cellStyle,
                          DataGridViewAdvancedBorderStyle advancedBorderStyle,
                          DataGridViewPaintParts paintParts)
        {
            //Rectangle spanBaseRect = cellBounds;

            /*
             * bool drawContentInSpanedCell = false;
             * int spanBaseXOffset = 0;
             * int spanBaseYOffset = 0;
             * if (SpanPos != SpanPosition.NoSpan)
             * {
             *  int horScrollOffset=_targetView.HorizontalScrollingOffset;
             *  int x = 0;
             *  for(int i=0; i<SpanBaseCell.ColumnIndex; i++){
             *      x+= _targetView.Columns[i].Width;
             *  }
             *  spanBaseXOffset = x - horScrollOffset;
             *
             *  int vertScrollOffset = _targetView.VerticalScrollingOffset;
             *  int y = 0;
             *  for (int i = 0; i < SpanBaseCell.RowIndex; i++)
             *  {
             *      y += _targetView.Rows[i].Height;
             *  }
             *  spanBaseYOffset = y - vertScrollOffset;
             *
             *
             *  spanBaseRect = GetSpanBaseRect();
             *  if (clipBounds.Width <= (spanBaseRect.Width+1))
             *  {
             *      clipBounds.Width = spanBaseRect.Width;// _targetView.Width - _targetView.RowHeadersWidth;//spanBaseRect.Width;//
             *      clipBounds.X = spanBaseRect.X;// _targetView.RowHeadersWidth;//spanBaseRect.X;//
             *      //clipBounds.Height = spanBaseRect.Height;
             *      //clipBounds.Y = spanBaseRect.Y;
             *
             *  }
             *
             *  if (clipBounds.Height <= (spanBaseRect.Height+1))
             *  {
             *      clipBounds.Height = spanBaseRect.Height-1;// _targetView.Height - _targetView.ColumnHeadersHeight;//spanBaseRect.Height;//
             *      clipBounds.Y = spanBaseRect.Y;// _targetView.ColumnHeadersHeight;//spanBaseRect.Y;//
             *      drawContentInSpanedCell = true;
             *      //clipBounds.X = spanBaseRect.X;
             *      //clipBounds.Width = spanBaseRect.Width;
             *  }
             *
             * }
             */
            //PaintSpanedCell(g);
            if (SpanPos == SpanPosition.NoSpan)
            {
                paintParts = DataGridViewPaintParts.All;
                paintFunc
                (
                    g,
                    clipBounds,
                    cellBounds,
                    rowIndex,
                    cellState,
                    value,
                    formattedValue,
                    _targetCell.ToolTipText,
                    cellStyle,
                    advancedBorderStyle,
                    paintParts);
            }
            else if (SpanPos == SpanPosition.Spanned)
            {
                try
                {
                    paintParts = DataGridViewPaintParts.Background | DataGridViewPaintParts.SelectionBackground;// DataGridViewPaintParts.Background | DataGridViewPaintParts.SelectionBackground | DataGridViewPaintParts.ContentBackground;
                    DataGridViewCellStyle cStyle = cellStyle;


                    paintFunc
                    (
                        g,
                        clipBounds,
                        cellBounds,
                        rowIndex,
                        cellState,//(SpanBaseCell as DataGridViewCell).State,
                        (SpanBaseCell as DataGridViewCell).Value,
                        (SpanBaseCell as DataGridViewCell).FormattedValue,
                        SpanBaseCell.ToolTipText,
                        cellStyle,
                        advancedBorderStyle,
                        paintParts);

                    DataGridViewCell cell = _targetCell as DataGridViewCell;
                    int m_nLeftColumn     = SpanBaseCell.ColumnIndex;
                    int m_nRightColumn    = SpanBaseCell.ColumnIndex + SpanBaseCell.Span.ColSpanSize - 1;
                    int m_nTopRow         = SpanBaseCell.RowIndex;
                    int m_nBottomRow      = SpanBaseCell.RowIndex + SpanBaseCell.Span.RowSpanSize - 1;

                    int    widMergeIndex = cell.ColumnIndex - m_nLeftColumn;
                    int    higMergeIndex = cell.RowIndex - m_nTopRow;
                    int    i             = 0;
                    int    nWidth        = 0;
                    int    nWidthLeft    = 0;
                    int    nHeight       = 0;
                    int    nHeightTop    = 0;
                    string strText       = null;

                    Pen pen = new Pen(Brushes.Black);

                    // Draw the background
                    //g.FillRectangle(new SolidBrush(SystemColors.Control), cellBounds);

                    // Draw the separator for rows
                    Color backColor = (cell.Selected) ? cellStyle.SelectionBackColor : cellStyle.BackColor;
                    if (cell.RowIndex == m_nBottomRow)
                    {
                        g.DrawLine(new Pen(new SolidBrush(SystemColors.ControlDark)), cellBounds.Left, cellBounds.Bottom - 1, cellBounds.Right, cellBounds.Bottom - 1);
                    }
                    else
                    {
                        g.DrawLine(new Pen(new SolidBrush(backColor)), cellBounds.Left, cellBounds.Bottom - 1, cellBounds.Right, cellBounds.Bottom - 1);
                    }

                    // Draw the right vertical line for the cell
                    if (cell.ColumnIndex == m_nRightColumn)
                    {
                        g.DrawLine(new Pen(new SolidBrush(SystemColors.ControlDark)), cellBounds.Right - 1, cellBounds.Top, cellBounds.Right - 1, cellBounds.Bottom);
                    }
                    else
                    {
                        g.DrawLine(new Pen(new SolidBrush(backColor)), cellBounds.Right - 1, cellBounds.Top, cellBounds.Right - 1, cellBounds.Bottom);
                    }

                    // Draw the text

                    StringFormat sf = new StringFormat();
                    sf.Alignment     = StringAlignment.Center;
                    sf.LineAlignment = StringAlignment.Center;
                    sf.Trimming      = StringTrimming.EllipsisCharacter;

                    // Determine the total width of the merged cell
                    nWidth = 0;
                    for (i = m_nLeftColumn; i <= m_nRightColumn; i++)
                    {
                        nWidth += cell.OwningRow.Cells[i].Size.Width;
                    }

                    // Determine the width before the current cell.
                    nWidthLeft = 0;
                    for (i = m_nLeftColumn; i <= cell.ColumnIndex - 1; i++)
                    {
                        nWidthLeft += cell.OwningRow.Cells[i].Size.Width;
                    }

                    nHeight = 0;
                    for (i = m_nTopRow; i <= m_nBottomRow; i++)
                    {
                        nHeight += cell.DataGridView.Rows[i].Cells[_targetCell.ColumnIndex].Size.Height;
                    }

                    // Determine the width before the current cell.
                    nHeightTop = 0;
                    for (i = m_nTopRow; i <= cell.RowIndex - 1; i++)
                    {
                        nHeightTop += cell.DataGridView.Rows[i].Cells[_targetCell.ColumnIndex].Size.Height;
                    }

                    if (cell is EasyGridTextBoxCell)
                    {
                        RectangleF rectDest = RectangleF.Empty;
                        // Retrieve the text to be displayed
                        strText = SpanBaseCell.Value.ToString();

                        rectDest = new RectangleF(cellBounds.Left - nWidthLeft, cellBounds.Top - nHeightTop, nWidth, nHeight);
                        g.DrawString(strText, cell.DataGridView.DefaultCellStyle.Font,
                                     new SolidBrush(cell.DataGridView.DefaultCellStyle.ForeColor), rectDest, sf);
                    }
                    else

                    {
                        paintParts = DataGridViewPaintParts.ContentForeground;
                        Rectangle rectDest = new Rectangle(cellBounds.Left - nWidthLeft, cellBounds.Top - nHeightTop, nWidth, nHeight);

                        paintFunc
                        (
                            g,
                            clipBounds,
                            rectDest,
                            rowIndex,
                            cellState,// GetSpanedCellState(),
                            (SpanBaseCell as DataGridViewCell).Value,
                            (SpanBaseCell as DataGridViewCell).FormattedValue,
                            SpanBaseCell.ToolTipText,
                            cellStyle,
                            advancedBorderStyle,
                            paintParts);
                    }
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(ex.ToString());
                }

                /*
                 * //if (drawContentInSpanedCell)
                 * {
                 *  (_targetCell as DataGridViewCell).Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
                 *
                 *  paintParts = DataGridViewPaintParts.Background| DataGridViewPaintParts.SelectionBackground;// DataGridViewPaintParts.Background | DataGridViewPaintParts.SelectionBackground | DataGridViewPaintParts.ContentBackground;
                 *
                 *  paintFunc
                 *     (
                 *     g,
                 * clipBounds,
                 * spanBaseRect,
                 * rowIndex,
                 * cellState,// GetSpanedCellState(),
                 * (SpanBaseCell as DataGridViewCell).Value,
                 * (SpanBaseCell as DataGridViewCell).Value,
                 * SpanBaseCell.ToolTipText,
                 * cellStyle,
                 * advancedBorderStyle,
                 * paintParts);
                 *
                 *  //if (drawContentInSpanedCell) paintParts = paintParts | DataGridViewPaintParts.ContentForeground;
                 *  //(SpanBaseCell as DataGridViewCell).Style.State |= cellState;
                 *  EasyGridTextBoxCell cell = _targetCell as EasyGridTextBoxCell;
                 *
                 *  int stringWid = 0;
                 *  EasyGridViewParent view = (_targetView as EasyGridViewParent);
                 *  for (int i = SpanBaseCell.ColumnIndex; i < _targetView.Columns.Count; i++)
                 *  {
                 *      if (view.Rows[SpanBaseCell.RowIndex].EasyCells[i].Span.SpanBaseCell.Equals(SpanBaseCell))
                 *      {
                 *          stringWid += _targetView.Columns[i].Width;
                 *      }
                 *      else
                 *      {
                 *          break;
                 *      }
                 *  }
                 *  int stringHeight = 0;
                 *  for (int i = SpanBaseCell.RowIndex; i < _targetView.Rows.Count; i++)
                 *  {
                 *      if (view.Rows[i].EasyCells[SpanBaseCell.ColumnIndex].Span.SpanBaseCell.Equals(SpanBaseCell))
                 *      {
                 *          stringHeight += _targetView.Rows[i].Height;
                 *      }
                 *      else
                 *      {
                 *          break;
                 *      }
                 *  }
                 *
                 *  g.DrawString(SpanBaseCell.Value.ToString(),
                 *      cell.Font,
                 *      new SolidBrush(cell.DataGridView.DefaultCellStyle.ForeColor),
                 *      new PointF(spanBaseXOffset+cell.Style.Padding.Left,
                 *          (float)CellFunctions.CenterTextY(
                 *              cell.Size.Height,
                 *              spanBaseRect.Y, g, cell.Font)
                 *      )
                 *  );
                 *  //if (clipBounds.Width > 0) RedrawSpanCell = false;//한번 그리고 나면 다시 초기화..
                 * }
                 */
            }
            else if (SpanPos == SpanPosition.SpanBase)
            {
                paintParts = DataGridViewPaintParts.Background | DataGridViewPaintParts.SelectionBackground;// DataGridViewPaintParts.Background | DataGridViewPaintParts.SelectionBackground | DataGridViewPaintParts.ContentBackground;

                paintFunc
                (
                    g,
                    clipBounds,
                    cellBounds,
                    rowIndex,
                    cellState,// GetSpanedCellState(),
                    (SpanBaseCell as DataGridViewCell).Value,
                    (SpanBaseCell as DataGridViewCell).Value,
                    SpanBaseCell.ToolTipText,
                    cellStyle,
                    advancedBorderStyle,
                    paintParts);

                DataGridViewCell cell = _targetCell as DataGridViewCell;
                int m_nLeftColumn     = SpanBaseCell.ColumnIndex;
                int m_nRightColumn    = SpanBaseCell.ColumnIndex + SpanBaseCell.Span.ColSpanSize - 1;
                int m_nTopRow         = SpanBaseCell.RowIndex;
                int m_nBottomRow      = SpanBaseCell.RowIndex + SpanBaseCell.Span.RowSpanSize - 1;

                int    widMergeIndex = cell.ColumnIndex - m_nLeftColumn;
                int    higMergeIndex = cell.RowIndex - m_nTopRow;
                int    i             = 0;
                int    nWidth        = 0;
                int    nWidthLeft    = 0;
                int    nHeight       = 0;
                int    nHeightTop    = 0;
                string strText       = null;

                Pen pen = new Pen(Brushes.Black);

                // Draw the background
                //g.FillRectangle(new SolidBrush(SystemColors.Control), cellBounds);

                // Draw the separator for rows
                Color backColor = (cell.Selected) ? cellStyle.SelectionBackColor : cellStyle.BackColor;

                if (cell.RowIndex == m_nBottomRow)
                {
                    g.DrawLine(new Pen(new SolidBrush(SystemColors.ControlDark)), cellBounds.Left, cellBounds.Bottom - 1, cellBounds.Right, cellBounds.Bottom - 1);
                }
                else
                {
                    g.DrawLine(new Pen(new SolidBrush(backColor)), cellBounds.Left, cellBounds.Bottom - 1, cellBounds.Right, cellBounds.Bottom - 1);
                }

                // Draw the right vertical line for the cell
                if (cell.ColumnIndex == m_nRightColumn)
                {
                    g.DrawLine(new Pen(new SolidBrush(SystemColors.ControlDark)), cellBounds.Right - 1, cellBounds.Top, cellBounds.Right - 1, cellBounds.Bottom);
                }
                else
                {
                    g.DrawLine(new Pen(new SolidBrush(backColor)), cellBounds.Right - 1, cellBounds.Top, cellBounds.Right - 1, cellBounds.Bottom);
                }

                // Draw the text
                RectangleF   rectDest = RectangleF.Empty;
                StringFormat sf       = new StringFormat();
                sf.Alignment     = StringAlignment.Center;
                sf.LineAlignment = StringAlignment.Center;
                sf.Trimming      = StringTrimming.EllipsisCharacter;

                // Determine the total width of the merged cell
                nWidth = 0;
                for (i = m_nLeftColumn; i <= m_nRightColumn; i++)
                {
                    nWidth += cell.OwningRow.Cells[i].Size.Width;
                }

                // Determine the width before the current cell.
                nWidthLeft = 0;
                for (i = m_nLeftColumn; i <= cell.ColumnIndex - 1; i++)
                {
                    nWidthLeft += cell.OwningRow.Cells[i].Size.Width;
                }

                nHeight = 0;
                for (i = m_nTopRow; i <= m_nBottomRow; i++)
                {
                    nHeight += cell.DataGridView.Rows[i].Cells[_targetCell.ColumnIndex].Size.Height;
                }

                // Determine the width before the current cell.
                nHeightTop = 0;
                for (i = m_nTopRow; i <= cell.RowIndex - 1; i++)
                {
                    nHeightTop += cell.DataGridView.Rows[i].Cells[_targetCell.ColumnIndex].Size.Height;
                }

                if (cell is EasyGridTextBoxCell)
                {
                    // Retrieve the text to be displayed
                    strText = SpanBaseCell.Value.ToString();

                    rectDest = new RectangleF(cellBounds.Left - nWidthLeft, cellBounds.Top - nHeightTop, nWidth, nHeight);
                    g.DrawString(strText, cellStyle.Font, new SolidBrush(cellStyle.ForeColor), rectDest, sf);
                }
                else

                {
                    Rectangle rect = new Rectangle(cellBounds.Left - nWidthLeft, cellBounds.Top - nHeightTop, nWidth, nHeight);

                    paintParts = DataGridViewPaintParts.ContentForeground;
                    paintFunc
                    (
                        g,
                        clipBounds,
                        rect,
                        rowIndex,
                        cellState,// GetSpanedCellState(),
                        (SpanBaseCell as DataGridViewCell).Value,
                        (SpanBaseCell as DataGridViewCell).Value,
                        SpanBaseCell.ToolTipText,
                        cellStyle,
                        advancedBorderStyle,
                        paintParts);
                }
            }
        }
Esempio n. 8
0
        private void Repaint()
        {
            Graphics g = Graphics.FromImage(img);

            g.Clear(Color.White);

            if (!isCalculate)
            {
                pictureBoxPaint.Image = img;
                return;
            }

            // Create start and sweep angles.
            float startAngle = 90f - (float)alfa / 2f;
            float sweepAngle = (float)alfa;

            float centerX;
            float centerY;

            float scale;

            if (L2 < Ha) // scale by Ha
            {
                scale   = (img.Height - 200) / ((float)Ha);
                centerX = (float)Ha / 2 * scale + 100;
                centerY = (float)(Ha - Rb) * scale + 100;
            }
            else if (L2 >= Rb * 1.9) // scale by Rb
            {
                scale   = (img.Width - 100) / ((float)Rb * 2);
                centerX = (float)Rb * scale + 50;
                centerY = (float)Rb * scale;
            }
            else // scale by L2
            {
                scale   = (img.Width - 200) / ((float)L2);
                centerX = (float)L2 / 2 * scale + 100;
                centerY = (float)(L2 - Rb) * scale + 100;
            }

            // Draw big pie
            float w = 2 * (float)Rb * scale;
            float h = 2 * (float)Rb * scale;
            float x = centerX - w / 2f;
            float y = centerY - h / 2f;

            g.DrawPie(blackPen, x, y, w, h, startAngle, sweepAngle);

            // Draw small pie
            w = 2 * (float)Rk * scale;
            h = 2 * (float)Rk * scale;
            x = centerX - w / 2f;
            y = centerY - h / 2f;
            g.DrawPie(blackPen, x, y, w, h, startAngle, sweepAngle);

            g.FillEllipse(new SolidBrush(Color.White), x + 1, y + 1, w - 2, h - 2);

            foreach (var item in checkBoxsAndFuncs)
            {
                CheckBox  checkBox  = item.Key;
                PaintFunc paintFunc = item.Value;
                if (checkBox.Checked)
                {
                    paintFunc(g, scale, centerX, centerY);
                }
            }

            pictureBoxPaint.Image = img;
        }