forked from sergiisyrovatchenko/SQLIndexManager
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGridMethod.cs
More file actions
87 lines (74 loc) · 2.48 KB
/
Copy pathGridMethod.cs
File metadata and controls
87 lines (74 loc) · 2.48 KB
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
using System;
using System.Drawing;
using System.Windows.Forms;
using DevExpress.XtraGrid.Views.Base;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
using SQLIndexManager.Properties;
namespace SQLIndexManager {
public class GridMethod: Control {
public static void GridRowCellStyle(object sender, RowCellStyleEventArgs e) {
if (e.RowHandle == ((GridView)sender).FocusedRowHandle) {
e.Appearance.BackColor = Color.Silver;
}
}
public static void GridDoubleClick(object sender, EventArgs e) {
GridView obj = (GridView)sender;
Point pt = obj.GridControl.PointToClient(MousePosition);
GridHitInfo info = obj.CalcHitInfo(pt);
if (info.Column == null || info.Column.Caption == Resources.Fix || info.Column.Caption == Resources.Selection)
return;
if (info.InRow || info.InRowCell) {
if (obj.IsRowSelected(info.RowHandle))
obj.UnselectRow(info.RowHandle);
else
obj.SelectRow(info.RowHandle);
}
}
public static void GridColumnDisplayText(object sender, CustomColumnDisplayTextEventArgs e) {
switch (e.Column.FieldName) {
case "TotalSize":
case "DataSize":
case "DataFreeSize":
case "LogSize":
case "LogFreeSize":
case "PagesCount":
case "PagesCountBefore":
case "UnusedPagesCount":
if (e.Value != null)
e.DisplayText = (Convert.ToDecimal(e.Value) * 8).FormatSize() + " ";
break;
case "Fragmentation":
case "PageSpaceUsed":
case "StatsSampled":
if (e.Value != null)
e.DisplayText = $"{e.Value:n1} % ";
break;
case "CreateDate":
case "ModifyDate":
case "IndexStats":
case "LastUsage":
case "LastWrite":
case "LastRead":
if (e.Value != null)
e.DisplayText = $"{((DateTime)e.Value).ToLocalTime():dd/MM/yy HH:mm}";
break;
case "RowsCount":
case "RowsSampled":
case "TotalUpdates":
case "TotalScans":
case "TotalSeeks":
case "TotalLookups":
e.DisplayText = $"{e.Value:n0} ";
break;
case "FixType":
e.DisplayText = ((IndexOp)e.Value).Description();
break;
case "Duration":
if (e.Value != null)
e.DisplayText = $"{new DateTime(0).AddMilliseconds(Convert.ToInt64(e.Value)):mm:ss.fff}";
break;
}
}
}
}