Skip to content

Commit a89b067

Browse files
author
Pavel Kovalenko
committed
Add MenuButton control.
1 parent 145a7ba commit a89b067

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using System;
2+
using System.Drawing;
3+
using System.Windows.Forms;
4+
5+
namespace XRay.SdkControls
6+
{
7+
public class MenuButton : Button
8+
{
9+
private ContextMenu menu = new ContextMenu();
10+
11+
protected override void OnClick(EventArgs e)
12+
{
13+
// for ContextMenuStrip
14+
//var screenPoint = PointToScreen(new Point(Left, Bottom));
15+
//var currentScreen = Screen.FromPoint(screenPoint);
16+
//var flip = screenPoint.Y + menu.Size.Height > currentScreen.WorkingArea.Height;
17+
//menu.Show(this, new Point(0, flip ? -menu.Height : Height));
18+
menu.Show(this, new Point(0, Height));
19+
base.OnClick(e);
20+
}
21+
22+
protected override void OnPaint(PaintEventArgs e)
23+
{
24+
base.OnPaint(e);
25+
int arrowX = ClientRectangle.Width-14;
26+
int arrowY = ClientRectangle.Height/2-1;
27+
var brush = Enabled ? SystemBrushes.ControlText : SystemBrushes.ButtonShadow;
28+
var arrowPoints = new []
29+
{
30+
new Point(arrowX, arrowY),
31+
new Point(arrowX+7, arrowY),
32+
new Point(arrowX+3, arrowY+4)
33+
};
34+
e.Graphics.FillPolygon(brush, arrowPoints);
35+
}
36+
37+
public ContextMenu Menu
38+
{
39+
get { return menu; }
40+
}
41+
}
42+
}

src/editors/xrSdkControls/xrSdkControls.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@
4949
<Reference Include="System.Xml" />
5050
</ItemGroup>
5151
<ItemGroup>
52+
<Compile Include="Controls\MenuButton.cs">
53+
<SubType>Component</SubType>
54+
</Compile>
5255
<Compile Include="Controls\ColorPicker\ColorPicker.cs">
5356
<SubType>UserControl</SubType>
5457
</Compile>

0 commit comments

Comments
 (0)