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
/
MyGroupControl.cs
47 lines (42 loc) · 1.92 KB
/
MyGroupControl.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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.Utils.Drawing;
using DevExpress.Skins;
using DevExpress.Utils;
namespace WindowsApplication3 {
public class MyGroupControl : GroupControl {
protected override ObjectPainter CreatePainter() {
if (LookAndFeel.ActiveStyle == DevExpress.LookAndFeel.ActiveLookAndFeelStyle.Skin) return new MyGroupObjectPainter(this, LookAndFeel.ActiveLookAndFeel);
return base.CreatePainter();
}
}
public class MyGroupObjectPainter : SkinGroupObjectPainter {
public MyGroupObjectPainter(IPanelControlOwner owner, ISkinProvider provider) : base(owner, provider) { }
protected override Size CalcCaptionTextSize(GroupObjectInfoArgs info) {
int left, top, right, bottom;
CalcContentMargins(info, out left, out top, out right, out bottom);
int width = info.Bounds.Width - left - right;
int height = info.Bounds.Height - top - bottom;
Size size = info.AppearanceCaption.CalcTextSize(info.Cache,
info.AppearanceCaption.GetStringFormat(GetTextOptions()), info.Caption,
IsVerticalCaption(info) ? height : width).ToSize();
return size;
}
protected override void CalcCaptionElementsNormal(GroupObjectInfoArgs info, Rectangle caption) {
int left, top, right, bottom;
CalcContentMargins(info, out left, out top, out right, out bottom);
base.CalcCaptionElementsNormal(info, caption);
Rectangle rect = info.TextBounds;
int textOffset = (caption.Height - (top + info.TextBounds.Height + bottom)) / 2;
rect.Y -= textOffset;
rect.Size = CalcCaptionTextSize(info);
info.TextBounds = rect;
}
}
}