// *********************************************************************** // Assembly : Construction // Author : flythink // Created : 06-29-2020 // // Last Modified By : flythink // Last Modified On : 09-01-2020 // *********************************************************************** // // Copyright (c) jindongfang. All rights reserved. // // // *********************************************************************** using System.Windows.Forms; using DevExpress.Utils; using DevExpress.Utils.Extensions; using DevExpress.XtraVerticalGrid.Rows; using Label = DevExpress.XtraVerticalGrid.Native.Label; namespace GeoSigma { using DevExpress.XtraEditors; using DevExpress.XtraEditors.Container; using DevExpress.XtraEditors.Drawing; using DevExpress.XtraEditors.Repository; using DevExpress.XtraEditors.ViewInfo; using DevExpress.XtraVerticalGrid; using DevExpress.XtraVerticalGrid.Editors; using DevExpress.XtraVerticalGrid.Events; using DevExpress.XtraVerticalGrid.Painters; using DevExpress.XtraVerticalGrid.ViewInfo; using System.ComponentModel; using System.Drawing; /// /// Class CustomPropertyGridControl. /// Implements the /// /// public class CustomPropertyGridControl : PropertyGridControl { /// /// Creates the helper. /// /// EditorContainerHelper. protected override EditorContainerHelper CreateHelper() { return new CustomPGridEditorContainerHelper(this); } /// /// Creates the painter core. /// /// The event helper. /// VGridPainter. protected override VGridPainter CreatePainterCore(PaintEventHelper eventHelper) { return new CustomVGridPainter(eventHelper); } /// /// Class CustomPGridEditorContainerHelper. /// Implements the /// /// public class CustomPGridEditorContainerHelper : PGridEditorContainerHelper { /// /// Initializes a new instance of the class. /// /// The grid. public CustomPGridEditorContainerHelper(VGridControlBase grid) : base(grid) { } /// /// Updates the editor. /// /// The ritem. /// The arguments. /// BaseEdit. public override BaseEdit UpdateEditor(RepositoryItem ritem, UpdateEditorInfoArgs args) { BaseEdit editor = base.UpdateEditor(ritem, args); return editor; } } /// /// Class CustomVGridPainter. /// Implements the /// /// public class CustomVGridPainter : VGridPainter { /// /// Initializes a new instance of the class. /// /// The event helper. public CustomVGridPainter(PaintEventHelper eventHelper) : base(eventHelper) { } protected override void DrawRowValueCellCore(CustomDrawRowValueCellEventArgs e, BaseEditPainter pb, BaseEditViewInfo bvi, BaseViewInfo vi) { if (e.Row is PGridColorEditorRow && e.CellValue != null) { Color color = (Color)(e.CellValue); //using (SolidBrush brush = new SolidBrush(color)) //{ // var b = e.Bounds; // e.Graphics.FillRectangle(brush, b); //} e.Appearance.BackColor = color; e.Appearance.TextOptions.SetHAlignment(HorzAlignment.Center); } base.DrawRowValueCellCore(e, pb, bvi, vi); } } } }