-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.cs
63 lines (59 loc) · 3.03 KB
/
Form1.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
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.Utils;
using DevExpress.XtraBars;
using System.Drawing.Drawing2D;
namespace DXSample {
public partial class Main : XtraForm {
public Main() {
InitializeComponent();
}
private void RibbonControl1_CustomDrawItem(object sender, DevExpress.XtraBars.BarItemCustomDrawEventArgs e) {
if(e.RibbonItemInfo == null) return;
var link = e.RibbonItemInfo.Item as BarItemLink;
if(link is BarSubItemLink)
e.RibbonItemInfo.Appearance.ForeColor = Color.Red;
if(link.Item.Name == "barButtonItem1") {
if(e.State == DevExpress.XtraBars.ViewInfo.BarLinkState.Highlighted) {
using(var backBrush = new LinearGradientBrush(e.Bounds, Color.DarkGreen, Color.LightGreen,
LinearGradientMode.BackwardDiagonal))
e.Cache.FillRectangle(backBrush, e.Bounds);
e.Graphics.DrawLine(Pens.White, e.Bounds.Location, new Point(e.Bounds.Right, e.Bounds.Y));
e.Graphics.DrawLine(Pens.Black, new Point(e.Bounds.X, e.Bounds.Bottom), new Point(e.Bounds.Right, e.Bounds.Bottom));
e.Graphics.DrawLine(Pens.White, e.Bounds.Location, new Point(e.Bounds.X, e.Bounds.Bottom));
e.Graphics.DrawLine(Pens.Black, new Point(e.Bounds.Right, e.Bounds.Y), new Point(e.Bounds.Right, e.Bounds.Bottom));
}
else
e.Cache.FillRectangle(Brushes.LightSeaGreen, e.Bounds);
e.DrawText();
e.DrawGlyph();
e.Handled = true;
}
if(link.Item.Name == "barEditItem1") {
if(e.State == DevExpress.XtraBars.ViewInfo.BarLinkState.Highlighted) {
using(var backBrush = new LinearGradientBrush(e.Bounds, Color.DarkOrange, Color.LightYellow,
LinearGradientMode.BackwardDiagonal)) {
e.Cache.Graphics.FillRectangle(backBrush, e.Bounds);
e.Cache.Graphics.DrawLine(Pens.White, e.Bounds.Location, new Point(e.Bounds.Right, e.Bounds.Y));
e.Cache.Graphics.DrawLine(Pens.Black, new Point(e.Bounds.X, e.Bounds.Bottom), new Point(e.Bounds.Right, e.Bounds.Bottom));
e.Cache.Graphics.DrawLine(Pens.White, e.Bounds.Location, new Point(e.Bounds.X, e.Bounds.Bottom));
e.Cache.Graphics.DrawLine(Pens.Black, new Point(e.Bounds.Right, e.Bounds.Y), new Point(e.Bounds.Right, e.Bounds.Bottom));
}
}
else
e.Cache.FillRectangle(Brushes.Yellow, e.Bounds);
e.DrawText();
e.DrawGlyph();
e.DrawEditor();
e.Handled = true;
}
}
}
}