This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
/
CGrid.cs
139 lines (122 loc) · 4.47 KB
/
CGrid.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Views.Base;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraGrid.Views.Base.ViewInfo;
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
using DevExpress.XtraGrid.Registrator;
using DevExpress.XtraGrid.Columns;
using DevExpress.Data;
using DevExpress.XtraGrid.Views.Grid.Customization;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid.Drawing;
using DevExpress.Data.Filtering;
using DevExpress.XtraGrid.Views.Grid.Drawing;
using DevExpress.XtraGrid.Accessibility;
using DevExpress.Accessibility;
namespace CGrid
{
public class CGridControl : GridControl
{
protected override void RegisterAvailableViewsCore(InfoCollection collection)
{
base.RegisterAvailableViewsCore(collection);
collection.Add(new CGridViewInfoRegistrator());
}
protected override BaseView CreateDefaultView()
{
return CreateView("CGridView");
}
}
public class CGridView : GridView, IAccessibleGrid
{
public CGridView() : this(null) { }
public CGridView(GridControl gc)
: base(gc)
{
}
protected override string ViewName { get { return "CGridView"; } }
private string rowNameField;
public string RowNameField { get { return rowNameField; } set { rowNameField = value; OnPropertiesChanged(); } }
public string GetRowName(int rowHandle)
{
if (!this.IsDataRow(rowHandle)) return null;
return this.GetRowCellValue(rowHandle, RowNameField) as string;
}
protected override void RaiseCustomDrawRowIndicator(RowIndicatorCustomDrawEventArgs e)
{
if (e.Info != null)
{
e.Info.DisplayText = GetRowName(e.RowHandle);
}
base.RaiseCustomDrawRowIndicator(e);
}
public new int RowHandle2AccessibleIndex(int rowHandle)
{
return base.RowHandle2AccessibleIndex(rowHandle);
}
#region IAccessibleGrid Members
IAccessibleGridRow IAccessibleGrid.GetRow(int index)
{
int rowHandle = this.AccessibleIndex2RowHandle(index);
if (!this.IsValidRowHandle(rowHandle))
{
return null;
}
if (this.IsGroupRow(rowHandle))
{
return new GridAccessibleGroupRow(this, rowHandle);
}
return new GridAccessibleDataRowEx(this, rowHandle);
}
#endregion
}
public class CGridViewInfoRegistrator : GridInfoRegistrator
{
public override string ViewName { get { return "CGridView"; } }
public override BaseView CreateView(GridControl grid)
{
return new CGridView(grid as GridControl);
}
}
class GridAccessibleDataRowEx : GridAccessibleDataRow
{
public GridAccessibleDataRowEx(GridView view, int rowHandle) : base(view, rowHandle) { }
protected override string GetAccessibleRowName()
{
if (View is CGridView && this.View.IsDataRow(base.RowHandle))
{
string name = ((CGridView)View).GetRowName(RowHandle);
if (!string.IsNullOrEmpty(name))
return string.Format(this.GetString(AccStringId.GridRow), name);
}
return base.GetAccessibleRowName();
}
public override IAccessibleGridRowCell GetCell(int index)
{
if (index >= base.View.VisibleColumns.Count)
{
return null;
}
return new GridAccessibleRowCellEx(base.View, base.RowHandle, base.View.VisibleColumns[index]);
}
}
class GridAccessibleRowCellEx : GridAccessibleRowCell, IAccessibleGridRowCell
{
public GridAccessibleRowCellEx(GridView view, int rowHandle, GridColumn column) : base(view, rowHandle, column) { }
#region IAccessibleGridRowCell Members
string IAccessibleGridRowCell.GetName()
{
string str = (this.Column.GetTextCaption() == "") ? this.Column.ToolTip : this.Column.GetTextCaption();
string rowName = ((IAccessibleGrid)this.View).GetRow(((CGridView)this.View).RowHandle2AccessibleIndex(this.RowHandle)).GetName();
return (str + " " + rowName);
}
#endregion
}
}