Skip to content

Commit

Permalink
Add MenuButton control.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Kovalenko committed Oct 18, 2014
1 parent 145a7ba commit a89b067
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/editors/xrSdkControls/Controls/MenuButton.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using System.Drawing;
using System.Windows.Forms;

namespace XRay.SdkControls
{
public class MenuButton : Button
{
private ContextMenu menu = new ContextMenu();

protected override void OnClick(EventArgs e)
{
// for ContextMenuStrip
//var screenPoint = PointToScreen(new Point(Left, Bottom));
//var currentScreen = Screen.FromPoint(screenPoint);
//var flip = screenPoint.Y + menu.Size.Height > currentScreen.WorkingArea.Height;
//menu.Show(this, new Point(0, flip ? -menu.Height : Height));
menu.Show(this, new Point(0, Height));
base.OnClick(e);
}

protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
int arrowX = ClientRectangle.Width-14;
int arrowY = ClientRectangle.Height/2-1;
var brush = Enabled ? SystemBrushes.ControlText : SystemBrushes.ButtonShadow;
var arrowPoints = new []
{
new Point(arrowX, arrowY),
new Point(arrowX+7, arrowY),
new Point(arrowX+3, arrowY+4)
};
e.Graphics.FillPolygon(brush, arrowPoints);
}

public ContextMenu Menu
{
get { return menu; }
}
}
}
3 changes: 3 additions & 0 deletions src/editors/xrSdkControls/xrSdkControls.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Controls\MenuButton.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Controls\ColorPicker\ColorPicker.cs">
<SubType>UserControl</SubType>
</Compile>
Expand Down

0 comments on commit a89b067

Please sign in to comment.