You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
126 lines
4.8 KiB
C#
126 lines
4.8 KiB
C#
// ***********************************************************************
|
|
// Assembly : Construction
|
|
// Author : flythink
|
|
// Created : 06-29-2020
|
|
//
|
|
// Last Modified By : flythink
|
|
// Last Modified On : 09-01-2020
|
|
// ***********************************************************************
|
|
// <copyright file="CustomPropertyGridControl.cs" company="jindongfang">
|
|
// Copyright (c) jindongfang. All rights reserved.
|
|
// </copyright>
|
|
// <summary></summary>
|
|
// ***********************************************************************
|
|
|
|
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;
|
|
|
|
/// <summary>
|
|
/// Class CustomPropertyGridControl.
|
|
/// Implements the <see cref="DevExpress.XtraVerticalGrid.PropertyGridControl" />
|
|
/// </summary>
|
|
/// <seealso cref="DevExpress.XtraVerticalGrid.PropertyGridControl" />
|
|
public class CustomPropertyGridControl : PropertyGridControl
|
|
{
|
|
/// <summary>
|
|
/// Creates the helper.
|
|
/// </summary>
|
|
/// <returns>EditorContainerHelper.</returns>
|
|
protected override EditorContainerHelper CreateHelper()
|
|
{
|
|
return new CustomPGridEditorContainerHelper(this);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Creates the painter core.
|
|
/// </summary>
|
|
/// <param name="eventHelper">The event helper.</param>
|
|
/// <returns>VGridPainter.</returns>
|
|
protected override VGridPainter CreatePainterCore(PaintEventHelper eventHelper)
|
|
{
|
|
return new CustomVGridPainter(eventHelper);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Class CustomPGridEditorContainerHelper.
|
|
/// Implements the <see cref="DevExpress.XtraVerticalGrid.Editors.PGridEditorContainerHelper" />
|
|
/// </summary>
|
|
/// <seealso cref="DevExpress.XtraVerticalGrid.Editors.PGridEditorContainerHelper" />
|
|
public class CustomPGridEditorContainerHelper : PGridEditorContainerHelper
|
|
{
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="CustomPGridEditorContainerHelper" /> class.
|
|
/// </summary>
|
|
/// <param name="grid">The grid.</param>
|
|
public CustomPGridEditorContainerHelper(VGridControlBase grid)
|
|
: base(grid)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Updates the editor.
|
|
/// </summary>
|
|
/// <param name="ritem">The ritem.</param>
|
|
/// <param name="args">The arguments.</param>
|
|
/// <returns>BaseEdit.</returns>
|
|
public override BaseEdit UpdateEditor(RepositoryItem ritem, UpdateEditorInfoArgs args)
|
|
{
|
|
BaseEdit editor = base.UpdateEditor(ritem, args);
|
|
return editor;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Class CustomVGridPainter.
|
|
/// Implements the <see cref="DevExpress.XtraVerticalGrid.Painters.VGridPainter" />
|
|
/// </summary>
|
|
/// <seealso cref="DevExpress.XtraVerticalGrid.Painters.VGridPainter" />
|
|
public class CustomVGridPainter : VGridPainter
|
|
{
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="CustomVGridPainter" /> class.
|
|
/// </summary>
|
|
/// <param name="eventHelper">The event helper.</param>
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
} |