This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CustomPainter.cs
56 lines (51 loc) · 1.6 KB
/
CustomPainter.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
using System;
using System.Collections.Generic;
using System.Linq;
using DevExpress.XtraGrid.Views.Base;
using DevExpress.Utils.Drawing;
using System.Drawing;
namespace CustomGrid
{
public class CustomPainter : BaseViewPainter
{
public CustomPainter(CustomView view)
: base(view)
{
}
public override void Draw(ViewDrawArgs e)
{
CustomView view = (View as CustomView);
if (view.GridControl.IsDesignMode)
{
ShowTitle(e);
return;
}
view.ShowControl(e);
base.Draw(e);
DrawBorder(e, e.ViewInfo.Bounds);
}
protected virtual void ShowTitle(ViewDrawArgs e)
{
CustomView view = (View as CustomView);
string text = String.Format("{0}: {1}", view.LevelName, view.Name);
e.Cache.FillRectangle(Color.White, e.Bounds);
e.Cache.DrawRectangle(new Pen(Color.Gray, 1), e.Bounds);
Font font = new Font(view.GridControl.Font.FontFamily, 18);
e.Cache.DrawString(text, font, e.Cache.GetSolidBrush(Color.Gray), e.Bounds, StringFormat.GenericDefault);
}
}
public class CustomViewDrawArgs : ViewDrawArgs
{
public CustomViewDrawArgs(GraphicsCache graphicsCache, CustomViewInfo viewInfo, Rectangle bounds)
: base(graphicsCache, viewInfo, bounds)
{
}
public virtual new CustomViewInfo ViewInfo
{
get
{
return base.ViewInfo as CustomViewInfo;
}
}
}
}