/// <summary> /// The button look is determined in this override. /// </summary> /// <param name="e"></param> protected override void PaintForeground(GridPaintEventArgs e) { if ((Control.MouseButtons == MouseButtons.Left) && (this.RectangleToScreen(e.ClientRectangle).Contains(Control.MousePosition))) { ControlPaint.DrawButton(e.Graphics, e.DisplayRectangle, ButtonState.Pushed); } else { ControlPaint.DrawButton(e.Graphics, e.DisplayRectangle, ButtonState.Normal); } using (SolidBrush brush = new SolidBrush(this.GetDisplayVisualStyle(VisualGridElementState.Idle).ForeColor)) { Rectangle textRectangle = e.DisplayRectangle; textRectangle.Inflate(-2, -2); if ((textRectangle.Height > 0) && (textRectangle.Width > 0)) { // Paint a fixed text e.Graphics.DrawString("编辑", this.Font, brush, textRectangle); // For text that follows the value of the cell, you could do someting like the following : // e.Graphics.DrawString( this.GetTextToPaint(), this.Font, brush, textRectangle ); } } }
/// <summary> /// /// </summary> /// <param name="e"></param> protected override void PaintForeground(GridPaintEventArgs e) { FilterRow filterRow = this.Row as FilterRow; if (filterRow == null) { return; } Image filterIcon = FilterRowSelector.FilterUnAppliedImage; if (filterRow.Enabled) { filterIcon = FilterRowSelector.FilterAppliedImage; } Rectangle rectangle = this.DisplayRectangle; int left = rectangle.Left; int top = rectangle.Top; left += (int)(rectangle.Width - filterIcon.Width) / 2; top += (int)(rectangle.Height - filterIcon.Height) / 2; e.Graphics.DrawImage(filterIcon, new Point(left, top)); }
/// <summary> /// PaintCellForeground /// </summary> /// <param name="cell"></param> /// <param name="e"></param> /// <param name="handled"></param> protected override void PaintCellForeground(Cell cell, GridPaintEventArgs e, ref bool handled) { bool value = false; if ((cell.Value != null) && (cell.Value != DBNull.Value) && (cell.Value != cell.NullValue)) { value = (bool)Convert.ChangeType(cell.Value, typeof(bool)); } handled = true; if (m_paintWhenTrue && !value) { return; } if (!m_paintWhenTrue && value) { return; } int x = e.DisplayRectangle.X; int y = e.DisplayRectangle.Y + ((e.DisplayRectangle.Height - m_image.Height) / 2); e.Graphics.DrawImage(m_image, x, y); }
protected override void PaintForeground(GridPaintEventArgs e) { int width = 0; int lastColumn = 0; if (this.ParentGrid.FixedColumnSplitter != null) { width = this.ParentGrid.FixedColumnSplitter.Width; } int lastWidth = width; for (int j = 0; j < m_columns.Length; j++) { for (int i = 0; i < m_columns[j]; i++) { width += this.ParentGrid.Columns[lastColumn].Width; lastColumn++; } e.Graphics.DrawLine(this.GridControl.GridLinePen, e.DisplayRectangle.X + width - 1, 0, e.DisplayRectangle.X + width - 1, this.Height); StringFormat drawFormat = new StringFormat(); drawFormat.Alignment = StringAlignment.Center; drawFormat.LineAlignment = StringAlignment.Center; e.Graphics.DrawString(m_captions[j], this.GridControl.Font, new SolidBrush(e.DisplayVisualStyle.ForeColor), new RectangleF(e.DisplayRectangle.X + lastWidth, 0, e.DisplayRectangle.X + width - lastWidth, this.Height), drawFormat); lastWidth = width; } }
protected override void PaintCellBackground(Cell cell, GridPaintEventArgs e, ref bool handled) { bool? v = Feng.Utils.ConvertHelper.ToBoolean(cell.Value); bool cellValue = v.HasValue ? v.Value : false; if (cellValue) { if (m_backColorEnable.HasValue) { e.Graphics.FillRectangle(new SolidBrush(m_backColorEnable.Value), e.DisplayRectangle); handled = true; } else { base.PaintCellBackground(cell, e, ref handled); } } else { if (m_backColorDisable.HasValue) { e.Graphics.FillRectangle(new SolidBrush(m_backColorDisable.Value), e.DisplayRectangle); handled = true; } else { base.PaintCellBackground(cell, e, ref handled); } } }
/// <summary> /// PaintForeground /// </summary> /// <param name="e"></param> protected override void PaintForeground(GridPaintEventArgs e) { base.PaintForeground(e); int intGroupUIState = 0; if (!this.ParentGroup.Collapsed) { intGroupUIState |= Xceed.UI.GroupUIState.Expanded; } Xceed.UI.GroupUIState groupUIState = new Xceed.UI.GroupUIState(intGroupUIState); Color color = this.BackColor; foreach (Xceed.Grid.DataRow row in this.ParentGroup.GetSortedDataRows(true)) { if (!string.IsNullOrEmpty(row.ErrorDescription)) { color = Color.Red; break; } } using (Brush brush = new SolidBrush(color)) { e.Graphics.FillRectangle(brush, new Rectangle(0, 0, 15, 36)); } this.Theme.PaintGroup(e.Graphics, new Rectangle(2, e.ClientRectangle.Bottom - 15, 12, 12), groupUIState, 1); }
// Paints the foreground of the NumberedRowSelector. protected override void PaintForeground(GridPaintEventArgs e) { Xceed.Grid.DataRow dataRow = this.Row as Xceed.Grid.DataRow; // Only paint the datarows if (dataRow != null) { int number = 0; number = dataRow.Index + 1; // number = dataRow.ParentGroup.GetSortedDataRows( false ).IndexOf( dataRow ); // It is recommended to use the color returned from GetForeColorToPaint() // rather than the ForeColor property directly. using (SolidBrush brush = new SolidBrush(this.GetDisplayVisualStyle(Xceed.Grid.VisualGridElementState.InactiveSelection).ForeColor)) { Rectangle offsetRectangle = this.ClientRectangle; offsetRectangle.Offset(0, 1); e.Graphics.DrawString(number.ToString(), s_font, brush, offsetRectangle); } } else { // Not a DataRow, so let the base class paint itself. base.PaintForeground(e); } }
protected override void PaintCellBackground(Cell cell, GridPaintEventArgs e, ref bool handled) { bool?v = Feng.Utils.ConvertHelper.ToBoolean(cell.Value); bool cellValue = v.HasValue ? v.Value : false; if (cellValue) { if (m_backColorEnable.HasValue) { e.Graphics.FillRectangle(new SolidBrush(m_backColorEnable.Value), e.DisplayRectangle); handled = true; } else { base.PaintCellBackground(cell, e, ref handled); } } else { if (m_backColorDisable.HasValue) { e.Graphics.FillRectangle(new SolidBrush(m_backColorDisable.Value), e.DisplayRectangle); handled = true; } else { base.PaintCellBackground(cell, e, ref handled); } } }
/// <summary> /// PaintCellForeground /// </summary> /// <param name="cell"></param> /// <param name="e"></param> /// <param name="handled"></param> protected override void PaintCellForeground(Cell cell, GridPaintEventArgs e, ref bool handled) { m_imageLeftCount = 0; m_imageRightCount = 0; string value = null; if ((cell.Value != null) && (cell.Value != DBNull.Value) && (cell.Value != cell.NullValue)) { value = (string)Convert.ChangeType(cell.Value, typeof(string)); } if (string.IsNullOrEmpty(value)) { return; } string[] ss = value.Split(new char[] { '/', '-' }, StringSplitOptions.RemoveEmptyEntries); if (ss.Length < 2) { return; } int?leftCount = Feng.Utils.ConvertHelper.ToInt(ss[0]); int?rightCount = Feng.Utils.ConvertHelper.ToInt(ss[1]); int x = e.DisplayRectangle.X; int y = e.DisplayRectangle.Y + ((e.DisplayRectangle.Height - m_imageLeft.Height) / 2); if (leftCount.HasValue) { for (int i = 0; i < leftCount.Value; i++) { e.Graphics.DrawImage(m_imageLeft, x, y); x += m_imageLeft.Width; } m_imageLeftCount += leftCount.Value; } if (rightCount.HasValue) { for (int i = 0; i < rightCount.Value; i++) { e.Graphics.DrawImage(m_imageRight, x, y); x += m_imageRight.Width; } m_imageRightCount += rightCount.Value; } handled = true; }
/// <summary> /// PaintCellForeground /// </summary> /// <param name="cell"></param> /// <param name="e"></param> /// <param name="handled"></param> protected override void PaintCellForeground(Cell cell, GridPaintEventArgs e, ref bool handled) { m_imageLeftCount = 0; m_imageRightCount = 0; string value = null; if ((cell.Value != null) && (cell.Value != DBNull.Value) && (cell.Value != cell.NullValue)) { value = (string)Convert.ChangeType(cell.Value, typeof(string)); } if (string.IsNullOrEmpty(value)) return; string[] ss = value.Split(new char[] { '/', '-' }, StringSplitOptions.RemoveEmptyEntries); if (ss.Length < 2) return; int? leftCount = Feng.Utils.ConvertHelper.ToInt(ss[0]); int? rightCount = Feng.Utils.ConvertHelper.ToInt(ss[1]); int x = e.DisplayRectangle.X; int y = e.DisplayRectangle.Y + ((e.DisplayRectangle.Height - m_imageLeft.Height) / 2); if (leftCount.HasValue) { for (int i = 0; i < leftCount.Value; i++) { e.Graphics.DrawImage(m_imageLeft, x, y); x += m_imageLeft.Width; } m_imageLeftCount += leftCount.Value; } if (rightCount.HasValue) { for (int i = 0; i < rightCount.Value; i++) { e.Graphics.DrawImage(m_imageRight, x, y); x += m_imageRight.Width; } m_imageRightCount += rightCount.Value; } handled = true; }
/// <summary> /// PaintCellForeground /// </summary> /// <param name="cell"></param> /// <param name="e"></param> /// <param name="handled"></param> protected override void PaintCellForeground(Cell cell, GridPaintEventArgs e, ref bool handled) { bool value = false; if ((cell.Value != null) && (cell.Value != DBNull.Value) && (cell.Value != cell.NullValue)) { value = (bool)Convert.ChangeType(cell.Value, typeof(bool)); } handled = true; if (m_paintWhenTrue && !value) return; if (!m_paintWhenTrue && value) return; int x = e.DisplayRectangle.X; int y = e.DisplayRectangle.Y + ((e.DisplayRectangle.Height - m_image.Height) / 2); e.Graphics.DrawImage(m_image, x, y); }
/// <summary> /// /// </summary> /// <param name="e"></param> protected override void PaintForeground(GridPaintEventArgs e) { FilterRow filterRow = this.Row as FilterRow; if (filterRow == null) { return; } Image filterIcon = s_searchImage; Rectangle rectangle = this.DisplayRectangle; int left = rectangle.Left; int top = rectangle.Top; left += (int) (rectangle.Width - filterIcon.Width) / 2; top += (int) (rectangle.Height - filterIcon.Height) / 2; e.Graphics.DrawImage(filterIcon, new Point(left, top)); }
/// <summary> /// PaintBorders /// </summary> /// <param name="e"></param> protected override void PaintBorders(GridPaintEventArgs e) { GroupBase currentGroup = this.ParentGroup; if (currentGroup == null) { base.PaintBorders(e); return; } GridControl gridControl = this.GridControl; if (gridControl == null) { return; } Rectangle paintRectangle = e.DisplayRectangle; Borders borders = this.Borders; int left = e.ClientRectangle.Left; //int right = paintRectangle.Right + borders.Right - 1; //int top = paintRectangle.Top - borders.Top; int bottom = paintRectangle.Bottom + borders.Bottom - borders.Bottom; // Horizontal (bottom) gridline. if (borders.Bottom > 0) { //GroupMargin groupMargin = currentGroup.SideMargin; int bottomBorderWidth = e.BottomBorderWidth - (left - paintRectangle.Left); if (bottomBorderWidth > 0) { using (SolidBrush brush = new SolidBrush(Color.FromArgb(165, 164, 189))) { e.Graphics.FillRectangle(brush, left, bottom, bottomBorderWidth, borders.Bottom); } } } }
/// <summary> /// PaintCellForeground /// </summary> /// <param name="cell"></param> /// <param name="e"></param> /// <param name="handled"></param> protected override void PaintCellForeground(Cell cell, GridPaintEventArgs e, ref bool handled) { m_imageCount = 0; if ((cell.Value != null) && (cell.Value != DBNull.Value) && (cell.Value != cell.NullValue)) { m_imageCount = (int)Convert.ChangeType(cell.Value, typeof(int)); } int x = e.DisplayRectangle.X; int y = e.DisplayRectangle.Y + ((e.DisplayRectangle.Height - m_image.Height) / 2); //int imageHeight = ImageViewer.m_Image.Height; for (int i = 1; i <= m_imageCount; i++) { e.Graphics.DrawImage(m_image, x, y); x += m_image.Width; } handled = true; }
protected override void PaintBackground(GridPaintEventArgs e) { base.PaintBackground(e); }
/// <summary> /// PaintCellBackground /// </summary> /// <param name="cell"></param> /// <param name="e"></param> /// <param name="handled"></param> protected override void PaintCellBackground(Cell cell, GridPaintEventArgs e, ref bool handled) { handled = true; }
///// <summary> ///// ��Stream���Image ///// </summary> ///// <param name="stream"></param> //private static void LoadImage(Stream stream) //{ // m_Image = new Bitmap(new Bitmap(stream), new Size(16, 16)); //} ///// <summary> ///// ���ļ�����Image ///// </summary> ///// <param name="fileName"></param> //public static void LoadImage(string fileName) //{ // m_Image = new Bitmap(new Bitmap(fileName), new Size(16, 16)); //} /// <summary> /// PaintCellBackground /// </summary> /// <param name="cell"></param> /// <param name="e"></param> /// <param name="handled"></param> protected override void PaintCellBackground(Cell cell, GridPaintEventArgs e, ref bool handled) { // Notify the cell that its background has been painted by the CellViewerManager. handled = true; }
protected override void PaintCellForeground(Cell cell, GridPaintEventArgs e, ref bool handled) { string value = cell.GetDisplayText(); if (string.IsNullOrEmpty(value)) { return; } handled = true; Graphics g = e.Graphics; Font font = cell.Font; PointF origin = new PointF(0, 0); string[] ss = value.Split(new char[] { '-' }); string[] texts = new string[ss.Length]; Color[] paintColors = new Color[ss.Length]; float allLength = 0; for (int i = 0; i < ss.Length; ++i) { string s = ss[i]; string[] ss2 = s.Split(new char[] { '/' }); if (ss2.Length == 1) { texts[i] = s; paintColors[i] = m_colors[i % m_colors.Length]; } else { texts[i] = ss2[1]; paintColors[i] = m_colors[Convert.ToInt32(ss2[0])]; } SizeF sizeTxt = g.MeasureString(texts[i], font, origin, sFormat); allLength += sizeTxt.Width; } Rectangle r = e.DisplayRectangle; r.Inflate(-1, -1); float nowOffset = 0; switch (e.DisplayVisualStyle.HorizontalAlignment) { case HorizontalAlignment.Left: break; case HorizontalAlignment.Center: nowOffset = (e.DisplayRectangle.Width - allLength) / 2; break; case HorizontalAlignment.Right: nowOffset = e.DisplayRectangle.Width - allLength; break; } for (int i = 0; i < ss.Length; ++i) { // http://weblogs.asp.net/israelio/archive/2006/07/30/DrawString-_2F00_-MeasureString-Offset-Problem-Solved-_2100_.aspx origin = new PointF(nowOffset, 0); SizeF sizeTxt = g.MeasureString(texts[i], font, origin, sFormat); using (SolidBrush brush = new SolidBrush(paintColors[i])) { RectangleF rectangleTxt = (RectangleF)r; rectangleTxt.Width = sizeTxt.Width; rectangleTxt.Offset(nowOffset, 0f); nowOffset += sizeTxt.Width; g.DrawString(texts[i], font, brush, rectangleTxt, sFormat); } } }
/// <summary> /// PaintCellBackground /// </summary> /// <param name="cell"></param> /// <param name="e"></param> /// <param name="handled"></param> protected override void PaintCellBackground(Cell cell, GridPaintEventArgs e, ref bool handled) { // Notify the cell that its background has been painted by the CellViewerManager. handled = true; }
protected override void PaintCellForeground(Cell cell, GridPaintEventArgs e, ref bool handled) { string value = cell.GetDisplayText(); if (string.IsNullOrEmpty(value)) return; handled = true; Graphics g = e.Graphics; Font font = cell.Font; PointF origin = new PointF(0, 0); string[] ss = value.Split(new char[] { '-'}); string[] texts = new string[ss.Length]; Color[] paintColors = new Color[ss.Length]; float allLength = 0; for (int i = 0; i < ss.Length; ++i) { string s = ss[i]; string[] ss2 = s.Split(new char[] { '/' }); if (ss2.Length == 1) { texts[i] = s; paintColors[i] = m_colors[i % m_colors.Length]; } else { texts[i] = ss2[1]; paintColors[i] = m_colors[Convert.ToInt32(ss2[0])]; } SizeF sizeTxt = g.MeasureString(texts[i], font, origin, sFormat); allLength += sizeTxt.Width; } Rectangle r = e.DisplayRectangle; r.Inflate(-1, -1); float nowOffset = 0; switch (e.DisplayVisualStyle.HorizontalAlignment) { case HorizontalAlignment.Left: break; case HorizontalAlignment.Center: nowOffset = (e.DisplayRectangle.Width - allLength) / 2; break; case HorizontalAlignment.Right: nowOffset = e.DisplayRectangle.Width - allLength; break; } for(int i=0; i<ss.Length; ++i) { // http://weblogs.asp.net/israelio/archive/2006/07/30/DrawString-_2F00_-MeasureString-Offset-Problem-Solved-_2100_.aspx origin = new PointF(nowOffset, 0); SizeF sizeTxt = g.MeasureString(texts[i], font, origin, sFormat); using (SolidBrush brush = new SolidBrush(paintColors[i])) { RectangleF rectangleTxt = (RectangleF)r; rectangleTxt.Width = sizeTxt.Width; rectangleTxt.Offset(nowOffset, 0f); nowOffset += sizeTxt.Width; g.DrawString(texts[i], font, brush, rectangleTxt, sFormat); } } }
bool ICellViewer.PaintCellValue( GridPaintEventArgs e, Cell cell ) { var row = cell.ParentRow as DataRow; var grupp = row.Tag as PlataDM.Grupp; if ( grupp.GruppTyp!=GruppTyp.GruppNormal ) return false; if ( Global.GrpNoPhoto_Reasons_Complete.Contains(grupp.EjFotoOrsak1) ) return false; if ( !string.IsNullOrEmpty(grupp.EjFotoOrsak1) ) if ( !_fFreeTextColumn || (grupp.EjFotoOrsak2!=null && grupp.EjFotoOrsak2.Length>=5) ) return false; e.Graphics.FillRectangle( Brushes.Red, e.ClientRectangle ); if ( _fFreeTextColumn && string.IsNullOrEmpty(grupp.EjFotoOrsak2) ) { e.Graphics.DrawString( "kommentar måste anges!", cell.Font, Brushes.Yellow, e.ClientRectangle ); return true; } return false; }