private Bitmap CreateFieldBitmap(GridControlBase grid, int rowIndex, int colIndex) { string fieldName = Grid[rowIndex]; GridStyleInfo style = new GridStyleInfo(); style.CellIdentity = new GridStyleInfoIdentity(grid.Model[rowIndex, colIndex].CellIdentity.Data, new GridCellPos(rowIndex, colIndex), true); style.CellType = GridCellTypeName.Header; style.HorizontalAlignment = GridHorizontalAlignment.Center; style.VerticalAlignment = GridVerticalAlignment.Middle; style.WrapText = false; style.Trimming = StringTrimming.EllipsisCharacter; style.Text = fieldName; Graphics g = null; Size size = new Size(120, 22); Rectangle bounds = new Rectangle(Point.Empty, size); GridCellRendererBase headerCellRenderer = grid.CellRenderers[GridCellTypeName.Header]; Bitmap bm = new Bitmap(Math.Max(1, size.Width), Math.Max(1, size.Height)); try { g = Graphics.FromImage(bm); BrushPaint.FillRectangle(g, bounds, style.Interior); headerCellRenderer.Draw(g, bounds, rowIndex, colIndex, style); } finally { if (g != null) { g.Dispose(); } } return(bm); }
private void treeViewAdv3_BeforeNodePaint(object sender, TreeNodeAdvPaintEventArgs e) { //Draw the BackGround color for the Selected node if (e.Selected) { BrushPaint.FillRectangle(e.Graphics, e.Bounds, br); e.ForeColor = SystemColors.WindowText; } }
///<summary> ///Renders the Column type Sparkline. ///</summary> ///<param name="paint">The <see cref="System.Windows.Forms.PaintEventArgs"/> instance containing the event data.</param> ///<param name="sparkline">The Sparkline.</param> public void DrawSparkColumn(Graphics paint, Syncfusion.Windows.Forms.Chart.SparkLine sparkline) { int areaMarginX = 3; int areaMarginY = 3; var isNegative = false; int centerY = sparkline.ControlHeight / 2; double firstPointX = 0, firstPointY = 0; double areaWidth = sparkline.ControlWidth - areaMarginX * areaMarginX; double areaHeight = sparkline.ControlHeight - areaMarginY * areaMarginX; SparkLineSource sparkLineSource = new SparkLineSource(); var sourceList = (List <object>)sparkLineSource.GetSourceList(sparkline.Source, sparkline); if (sourceList.Count == 0) { return; } double lineInterval = areaWidth / (sourceList.Count); double lineRange = sparkline.HighPoint - 0; int valueY = 0; sparkline.NegativeItem = new double[sourceList.Count]; for (int k = 0; k < sourceList.Count; k++) { double Value = Convert.ToDouble(sourceList[k]); valueY = (int)Math.Abs(Value); if (Value < 0) { isNegative = true; } firstPointX = this.Sparkline.Location.X + lineInterval * k + (lineInterval / 2); firstPointY = this.Sparkline.Location.Y + (areaHeight * Value / lineRange); if (!isNegative) { if (Value > 0) { Rectangle rect = new Rectangle(((int)(areaMarginX + firstPointX - lineInterval / 2)), (int)(areaHeight - firstPointY), (int)(lineInterval), (int)Math.Abs(Value)); BrushInfo interior = GetInteriorColumn(Value, sparkline, isNegative); rect.Y = rect.Y - (int)Math.Abs(Value); BrushPaint.FillRectangle(paint, rect, interior); } } else { lineRange = sparkline.HighPoint - sparkline.LowPoint; firstPointX = this.Sparkline.Location.X + lineInterval * k + (lineInterval / 2); firstPointY = this.Sparkline.Location.Y + (areaHeight * Value / lineRange); Rectangle rect = new Rectangle((int)(areaMarginX + firstPointX - lineInterval / 2 + sparkline.ColumnStyle.ColumnSpace), (int)(firstPointY + areaMarginY), (int)(lineInterval), (int)Math.Abs(Value)); BrushInfo interior = GetInteriorColumn(Value, sparkline, isNegative); BrushPaint.FillRectangle(paint, rect, interior); } } }
protected override void DrawHeader(PaintEventArgs e) { Graphics g = e.Graphics; Rectangle header_rect = this.GetHeaderRect(); Font font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold);//, System.Drawing.GraphicsUnit.Point, ((byte)(0))); #region GradientBar appearance BrushInfo bf = new BrushInfo(GradientStyle.Vertical, color1); BrushPaint.FillRectangle(g, header_rect, bf); #endregion #region Set Image for Expander Rectangle rect = new Rectangle(this.ExpanderButton.Bounds.X - 10, this.ExpanderButton.Bounds.Y - 5, this.GetHeaderButtonSize().Height + 10, this.GetHeaderButtonSize().Width + 10); #region Embedding image as a resource Assembly asm = this.GetType().Assembly; Stream Xpand_str = asm.GetManifestResourceStream("TaskBar.Button-up.png"); Stream Collapse_str = asm.GetManifestResourceStream("TaskBar.Button-down.png"); #endregion if (this.Collapsed) { Image img = Image.FromStream(Collapse_str); g.DrawImage(img, rect); } else { Image img = Image.FromStream(Xpand_str); g.DrawImage(img, rect); } #endregion #region Border Pen pen = new Pen(Color.FromArgb(117, 135, 185), 3); g.DrawRectangle(pen, header_rect); #endregion #region Draw Text Brush bu = new SolidBrush(Color.White); g.DrawString(this.Text, font, bu, header_rect.X + 10, header_rect.Y + 5); #endregion }
///<summary> ///Renders the Column type Sparkline. ///</summary> ///<param name="paint">The <see cref="System.Windows.Forms.PaintEventArgs"/> instance containing the event data.</param> ///<param name="sparkline">The spakrline.</param> public void DrawSparkWinLossColumn(Graphics paint, Syncfusion.Windows.Forms.Chart.SparkLine sparkline) { SparkLineSource sparkLineSource = new SparkLineSource(); int areaMarginX = 3; int areaMarginY = 3; var sourceList = (List <object>)sparkLineSource.GetSourceList(sparkline.Source, sparkline); if (sourceList.Count > 0) { double areaWidth = sparkline.ControlWidth - areaMarginX * 2; double areaHeight = sparkline.ControlHeight - areaMarginY * 2; double areaHeightCenter = areaHeight / 2; int valueY = 0, pointY = 0; double lineInterval = areaWidth / (sourceList.Count); for (int i = 0; i < sourceList.Count; i++) { double Value = Convert.ToDouble(sourceList[i]); double firstPointX = this.Sparkline.Location.X + lineInterval * i + (lineInterval / 2); double firstPointY = this.Sparkline.Location.Y + (lineInterval / 2); if (Value > 0) { valueY = (int)Math.Abs(Value); Rectangle rect = new Rectangle((int)(areaMarginX + firstPointX - lineInterval / 2 + sparkline.ColumnStyle.ColumnSpace), (int)(firstPointY + lineInterval), (int)(lineInterval - sparkline.ColumnStyle.ColumnSpace * 2), (int)Math.Abs(Value)); BrushInfo interior = GetInteriorWinLoss(Value, sparkline); rect.Y = rect.Y - (int)Math.Abs(Value); BrushPaint.FillRectangle(paint, rect, interior); pointY = rect.Y + (int)Math.Abs(Value); } else { Rectangle rect = new Rectangle((int)(areaMarginX + firstPointX - lineInterval / 2 + sparkline.ColumnStyle.ColumnSpace), pointY, (int)(lineInterval - sparkline.ColumnStyle.ColumnSpace * 2), (int)Math.Abs(Value)); BrushInfo interior = GetInteriorWinLoss(Value, sparkline); BrushPaint.FillRectangle(paint, rect, interior); } } } }