Commit 1e44aa56 kwwwvagaa

重绘右键菜单

1 个父辈 c2dc238a
...@@ -132,6 +132,7 @@ namespace HZH_Controls.Controls ...@@ -132,6 +132,7 @@ namespace HZH_Controls.Controls
/// </summary> /// </summary>
/// <value>The current time.</value> /// <value>The current time.</value>
[Description("时间"), Category("自定义")] [Description("时间"), Category("自定义")]
[Localizable(true)]
public DateTime CurrentTime public DateTime CurrentTime
{ {
get { return currentTime; } get { return currentTime; }
...@@ -147,11 +148,16 @@ namespace HZH_Controls.Controls ...@@ -147,11 +148,16 @@ namespace HZH_Controls.Controls
/// </summary> /// </summary>
private void SetTimeToControl() private void SetTimeToControl()
{ {
this.txtYear.Text = currentTime.Year.ToString(); var y = CurrentTime.Year;
this.txtMonth.Text = currentTime.Month.ToString().PadLeft(2, '0'); var M = CurrentTime.Month;
this.txtDay.Text = currentTime.Day.ToString().PadLeft(2, '0'); var d = CurrentTime.Day;
this.txtHour.Text = currentTime.Hour.ToString().PadLeft(2, '0'); var h = CurrentTime.Hour;
this.txtMinute.Text = currentTime.Minute.ToString().PadLeft(2, '0'); var m = CurrentTime.Minute;
this.txtYear.Text = y.ToString();
this.txtMonth.Text = M.ToString().PadLeft(2, '0');
this.txtDay.Text = d.ToString().PadLeft(2, '0');
this.txtHour.Text = h.ToString().PadLeft(2, '0');
this.txtMinute.Text = m.ToString().PadLeft(2, '0');
} }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="UCDatePickerExt" /> class. /// Initializes a new instance of the <see cref="UCDatePickerExt" /> class.
......
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
namespace HZH_Controls.Controls
{
public sealed class ControlPaintEx
{
public static void DrawCheckedFlag(Graphics graphics, Rectangle rect, Color color)
{
PointF[] points = new PointF[3];
points[0] = new PointF(
rect.X + rect.Width / 4.5f,
rect.Y + rect.Height / 2.5f);
points[1] = new PointF(
rect.X + rect.Width / 2.5f,
rect.Bottom - rect.Height / 3f);
points[2] = new PointF(
rect.Right - rect.Width / 4.0f,
rect.Y + rect.Height / 4.5f);
using (Pen pen = new Pen(color, 2F))
{
graphics.DrawLines(pen, points);
}
}
public static void DrawGlass(
Graphics g, RectangleF glassRect, int alphaCenter, int alphaSurround)
{
DrawGlass(g, glassRect, Color.White, alphaCenter, alphaSurround);
}
public static void DrawGlass(
Graphics g,
RectangleF glassRect,
Color glassColor,
int alphaCenter,
int alphaSurround)
{
using (GraphicsPath path = new GraphicsPath())
{
path.AddEllipse(glassRect);
using (PathGradientBrush brush = new PathGradientBrush(path))
{
brush.CenterColor = Color.FromArgb(alphaCenter, glassColor);
brush.SurroundColors = new Color[] {
Color.FromArgb(alphaSurround, glassColor) };
brush.CenterPoint = new PointF(
glassRect.X + glassRect.Width / 2,
glassRect.Y + glassRect.Height / 2);
g.FillPath(brush, path);
}
}
}
public static void DrawBackgroundImage(
Graphics g,
Image backgroundImage,
Color backColor,
ImageLayout backgroundImageLayout,
Rectangle bounds,
Rectangle clipRect)
{
DrawBackgroundImage(
g,
backgroundImage,
backColor,
backgroundImageLayout,
bounds,
clipRect,
Point.Empty,
RightToLeft.No);
}
public static void DrawBackgroundImage(
Graphics g,
Image backgroundImage,
Color backColor,
ImageLayout backgroundImageLayout,
Rectangle bounds,
Rectangle clipRect,
Point scrollOffset)
{
DrawBackgroundImage(
g,
backgroundImage,
backColor,
backgroundImageLayout,
bounds,
clipRect,
scrollOffset,
RightToLeft.No);
}
public static void DrawBackgroundImage(
Graphics g,
Image backgroundImage,
Color backColor,
ImageLayout backgroundImageLayout,
Rectangle bounds,
Rectangle clipRect,
Point scrollOffset,
RightToLeft rightToLeft)
{
if (g == null)
{
throw new ArgumentNullException("g");
}
if (backgroundImageLayout == ImageLayout.Tile)
{
using (TextureBrush brush = new TextureBrush(backgroundImage, WrapMode.Tile))
{
if (scrollOffset != Point.Empty)
{
Matrix transform = brush.Transform;
transform.Translate((float)scrollOffset.X, (float)scrollOffset.Y);
brush.Transform = transform;
}
g.FillRectangle(brush, clipRect);
return;
}
}
Rectangle rect = CalculateBackgroundImageRectangle(
bounds,
backgroundImage,
backgroundImageLayout);
if ((rightToLeft == RightToLeft.Yes) &&
(backgroundImageLayout == ImageLayout.None))
{
rect.X += clipRect.Width - rect.Width;
}
using (SolidBrush brush2 = new SolidBrush(backColor))
{
g.FillRectangle(brush2, clipRect);
}
if (!clipRect.Contains(rect))
{
if ((backgroundImageLayout == ImageLayout.Stretch) ||
(backgroundImageLayout == ImageLayout.Zoom))
{
rect.Intersect(clipRect);
g.DrawImage(backgroundImage, rect);
}
else if (backgroundImageLayout == ImageLayout.None)
{
rect.Offset(clipRect.Location);
Rectangle destRect = rect;
destRect.Intersect(clipRect);
Rectangle rectangle3 = new Rectangle(Point.Empty, destRect.Size);
g.DrawImage(
backgroundImage,
destRect,
rectangle3.X,
rectangle3.Y,
rectangle3.Width,
rectangle3.Height,
GraphicsUnit.Pixel);
}
else
{
Rectangle rectangle4 = rect;
rectangle4.Intersect(clipRect);
Rectangle rectangle5 = new Rectangle(
new Point(rectangle4.X - rect.X, rectangle4.Y - rect.Y),
rectangle4.Size);
g.DrawImage(
backgroundImage,
rectangle4,
rectangle5.X,
rectangle5.Y,
rectangle5.Width,
rectangle5.Height,
GraphicsUnit.Pixel);
}
}
else
{
ImageAttributes imageAttr = new ImageAttributes();
imageAttr.SetWrapMode(WrapMode.TileFlipXY);
g.DrawImage(
backgroundImage,
rect,
0,
0,
backgroundImage.Width,
backgroundImage.Height,
GraphicsUnit.Pixel,
imageAttr);
imageAttr.Dispose();
}
}
internal static Rectangle CalculateBackgroundImageRectangle(
Rectangle bounds,
Image backgroundImage,
ImageLayout imageLayout)
{
Rectangle rectangle = bounds;
if (backgroundImage != null)
{
switch (imageLayout)
{
case ImageLayout.None:
rectangle.Size = backgroundImage.Size;
return rectangle;
case ImageLayout.Tile:
return rectangle;
case ImageLayout.Center:
{
rectangle.Size = backgroundImage.Size;
Size size = bounds.Size;
if (size.Width > rectangle.Width)
{
rectangle.X = (size.Width - rectangle.Width) / 2;
}
if (size.Height > rectangle.Height)
{
rectangle.Y = (size.Height - rectangle.Height) / 2;
}
return rectangle;
}
case ImageLayout.Stretch:
rectangle.Size = bounds.Size;
return rectangle;
case ImageLayout.Zoom:
{
Size size2 = backgroundImage.Size;
float num = ((float)bounds.Width) / ((float)size2.Width);
float num2 = ((float)bounds.Height) / ((float)size2.Height);
if (num >= num2)
{
rectangle.Height = bounds.Height;
rectangle.Width = (int)((size2.Width * num2) + 0.5);
if (bounds.X >= 0)
{
rectangle.X = (bounds.Width - rectangle.Width) / 2;
}
return rectangle;
}
rectangle.Width = bounds.Width;
rectangle.Height = (int)((size2.Height * num) + 0.5);
if (bounds.Y >= 0)
{
rectangle.Y = (bounds.Height - rectangle.Height) / 2;
}
return rectangle;
}
}
}
return rectangle;
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;
namespace HZH_Controls.Controls
{
public static class GraphicsPathHelper
{
/// <summary>
/// 建立带有圆角样式的路径。
/// </summary>
/// <param name="rect">用来建立路径的矩形。</param>
/// <param name="_radius">圆角的大小。</param>
/// <param name="style">圆角的样式。</param>
/// <param name="correction">是否把矩形长宽减 1,以便画出边框。</param>
/// <returns>建立的路径。</returns>
public static GraphicsPath CreatePath(
Rectangle rect, int radius, RoundStyle style, bool correction)
{
GraphicsPath path = new GraphicsPath();
int radiusCorrection = correction ? 1 : 0;
switch (style)
{
case RoundStyle.None:
path.AddRectangle(rect);
break;
case RoundStyle.All:
path.AddArc(rect.X, rect.Y, radius, radius, 180, 90);
path.AddArc(
rect.Right - radius - radiusCorrection,
rect.Y,
radius,
radius,
270,
90);
path.AddArc(
rect.Right - radius - radiusCorrection,
rect.Bottom - radius - radiusCorrection,
radius,
radius, 0, 90);
path.AddArc(
rect.X,
rect.Bottom - radius - radiusCorrection,
radius,
radius,
90,
90);
break;
case RoundStyle.Left:
path.AddArc(rect.X, rect.Y, radius, radius, 180, 90);
path.AddLine(
rect.Right - radiusCorrection, rect.Y,
rect.Right - radiusCorrection, rect.Bottom - radiusCorrection);
path.AddArc(
rect.X,
rect.Bottom - radius - radiusCorrection,
radius,
radius,
90,
90);
break;
case RoundStyle.Right:
path.AddArc(
rect.Right - radius - radiusCorrection,
rect.Y,
radius,
radius,
270,
90);
path.AddArc(
rect.Right - radius - radiusCorrection,
rect.Bottom - radius - radiusCorrection,
radius,
radius,
0,
90);
path.AddLine(rect.X, rect.Bottom - radiusCorrection, rect.X, rect.Y);
break;
case RoundStyle.Top:
path.AddArc(rect.X, rect.Y, radius, radius, 180, 90);
path.AddArc(
rect.Right - radius - radiusCorrection,
rect.Y,
radius,
radius,
270,
90);
path.AddLine(
rect.Right - radiusCorrection, rect.Bottom - radiusCorrection,
rect.X, rect.Bottom - radiusCorrection);
break;
case RoundStyle.Bottom:
path.AddArc(
rect.Right - radius - radiusCorrection,
rect.Bottom - radius - radiusCorrection,
radius,
radius,
0,
90);
path.AddArc(
rect.X,
rect.Bottom - radius - radiusCorrection,
radius,
radius,
90,
90);
path.AddLine(rect.X, rect.Y, rect.Right - radiusCorrection, rect.Y);
break;
case RoundStyle.BottomLeft:
path.AddArc(
rect.X,
rect.Bottom - radius - radiusCorrection,
radius,
radius,
90,
90);
path.AddLine(rect.X, rect.Y, rect.Right - radiusCorrection, rect.Y);
path.AddLine(
rect.Right - radiusCorrection,
rect.Y,
rect.Right - radiusCorrection,
rect.Bottom - radiusCorrection);
break;
case RoundStyle.BottomRight:
path.AddArc(
rect.Right - radius - radiusCorrection,
rect.Bottom - radius - radiusCorrection,
radius,
radius,
0,
90);
path.AddLine(rect.X, rect.Bottom - radiusCorrection, rect.X, rect.Y);
path.AddLine(rect.X, rect.Y, rect.Right - radiusCorrection, rect.Y);
break;
}
path.CloseFigure();
return path;
}
}
}
\ No newline at end of file \ No newline at end of file
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing.Drawing2D;
using System.Drawing;
namespace HZH_Controls.Controls
{
public class InterpolationModeGraphics : IDisposable
{
private InterpolationMode _oldMode;
private Graphics _graphics;
public InterpolationModeGraphics(Graphics graphics)
: this(graphics, InterpolationMode.HighQualityBicubic)
{
}
public InterpolationModeGraphics(
Graphics graphics, InterpolationMode newMode)
{
_graphics = graphics;
_oldMode = graphics.InterpolationMode;
graphics.InterpolationMode = newMode;
}
#region IDisposable 成员
public void Dispose()
{
_graphics.InterpolationMode = _oldMode;
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
namespace HZH_Controls.Controls
{
public class ProfessionalToolStripRendererEx
: ToolStripRenderer
{
private static readonly int OffsetMargin = 24;
private const int m_radius = 2;
private const int m_borderRadius = 2;
private string _menuLogoString = "";
private ToolStripColorTable _colorTable;
public ProfessionalToolStripRendererEx()
: base()
{
}
public ProfessionalToolStripRendererEx(
ToolStripColorTable colorTable) : base()
{
_colorTable = colorTable;
}
public string MenuLogoString
{
get { return _menuLogoString; }
set { _menuLogoString = value; }
}
protected virtual ToolStripColorTable ColorTable
{
get
{
if (_colorTable == null)
{
_colorTable = new ToolStripColorTable();
}
return _colorTable;
}
}
protected override void OnRenderToolStripBackground(
ToolStripRenderEventArgs e)
{
ToolStrip toolStrip = e.ToolStrip;
Graphics g = e.Graphics;
Rectangle bounds = e.AffectedBounds;
if (toolStrip is ToolStripDropDown)
{
RegionHelper.CreateRegion(toolStrip, bounds, m_borderRadius);
using (SolidBrush brush = new SolidBrush(ColorTable.BackNormal))
{
g.FillRectangle(brush, bounds);
}
}
else if (toolStrip is MenuStrip)
{
RenderHelper.RenderBackgroundInternal(
g,
bounds,
ColorTable.Base,
ColorTable.Border,
RoundStyle.None,
0,
.35f,
false,
false);
}
else
{
base.OnRenderToolStripBackground(e);
}
}
protected override void OnRenderImageMargin(
ToolStripRenderEventArgs e)
{
ToolStrip toolStrip = e.ToolStrip;
Graphics g = e.Graphics;
Rectangle bounds = e.AffectedBounds;
if (toolStrip is ToolStripDropDown)
{
bool bDrawLogo = NeedDrawLogo(toolStrip);
bool bRightToLeft = toolStrip.RightToLeft == RightToLeft.Yes;
Rectangle imageBackRect = bounds;
imageBackRect.Width = OffsetMargin;
if (bDrawLogo)
{
Rectangle logoRect = bounds;
logoRect.Width = OffsetMargin;
if (bRightToLeft)
{
logoRect.X -= 2;
imageBackRect.X = logoRect.X - OffsetMargin;
}
else
{
logoRect.X += 2;
imageBackRect.X = logoRect.Right;
}
logoRect.Y += 1;
logoRect.Height -= 2;
using (LinearGradientBrush brush = new LinearGradientBrush(
logoRect,
ColorTable.BackHover,
ColorTable.BackNormal,
90f))
{
Blend blend = new Blend();
blend.Positions = new float[] { 0f, .2f, 1f };
blend.Factors = new float[] { 0f, 0.1f, .9f };
brush.Blend = blend;
logoRect.Y += 1;
logoRect.Height -= 2;
using (GraphicsPath path =
GraphicsPathHelper.CreatePath(logoRect, 8, RoundStyle.All, false))
{
using (SmoothingModeGraphics sg = new SmoothingModeGraphics(g))
{
g.FillPath(brush, path);
}
}
}
StringFormat sf = new StringFormat(StringFormatFlags.NoWrap);
Font font = new Font(
toolStrip.Font.FontFamily, 11, FontStyle.Bold);
sf.Alignment = StringAlignment.Near;
sf.LineAlignment = StringAlignment.Center;
sf.Trimming = StringTrimming.EllipsisCharacter;
g.TranslateTransform(logoRect.X, logoRect.Bottom);
g.RotateTransform(270f);
if (!string.IsNullOrEmpty(MenuLogoString))
{
Rectangle newRect = new Rectangle(
0, 0, logoRect.Height, logoRect.Width);
using (Brush brush = new SolidBrush(ColorTable.Fore))
{
using (TextRenderingHintGraphics tg =
new TextRenderingHintGraphics(g))
{
g.DrawString(
MenuLogoString,
font,
brush,
newRect,
sf);
}
}
}
g.ResetTransform();
}
else
{
if (bRightToLeft)
{
imageBackRect.X -= 3;
}
else
{
imageBackRect.X += 3;
}
}
imageBackRect.Y += 2;
imageBackRect.Height -= 4;
using (SolidBrush brush = new SolidBrush(ColorTable.DropDownImageBack))
{
g.FillRectangle(brush, imageBackRect);
}
Point ponitStart;
Point pointEnd;
if (bRightToLeft)
{
ponitStart = new Point(imageBackRect.X, imageBackRect.Y);
pointEnd = new Point(imageBackRect.X, imageBackRect.Bottom);
}
else
{
ponitStart = new Point(imageBackRect.Right - 1, imageBackRect.Y);
pointEnd = new Point(imageBackRect.Right - 1, imageBackRect.Bottom);
}
using (Pen pen = new Pen(ColorTable.DropDownImageSeparator))
{
g.DrawLine(pen, ponitStart, pointEnd);
}
}
else
{
base.OnRenderImageMargin(e);
}
}
protected override void OnRenderToolStripBorder(
ToolStripRenderEventArgs e)
{
ToolStrip toolStrip = e.ToolStrip;
Graphics g = e.Graphics;
Rectangle bounds = e.AffectedBounds;
if (toolStrip is ToolStripDropDown)
{
using (SmoothingModeGraphics sg = new SmoothingModeGraphics(g))
{
using (GraphicsPath path =
GraphicsPathHelper.CreatePath(bounds, 8, RoundStyle.All, true))
{
using (Pen pen = new Pen(ColorTable.DropDownImageSeparator))
{
path.Widen(pen);
g.DrawPath(pen, path);
}
}
}
bounds.Inflate(-1, -1);
using (GraphicsPath innerPath = GraphicsPathHelper.CreatePath(
bounds, 8, RoundStyle.All, true))
{
using (Pen pen = new Pen(ColorTable.BackNormal))
{
g.DrawPath(pen, innerPath);
}
}
}
else if (toolStrip is StatusStrip)
{
using (Pen pen = new Pen(ColorTable.Border))
{
e.Graphics.DrawRectangle(
pen, 0, 0, e.ToolStrip.Width - 1, e.ToolStrip.Height - 1);
}
}
else if (toolStrip is MenuStrip)
{
base.OnRenderToolStripBorder(e);
}
else
{
using (Pen pen = new Pen(ColorTable.Border))
{
g.DrawRectangle(
pen, 0, 0, e.ToolStrip.Width - 1, e.ToolStrip.Height - 1);
}
}
}
protected override void OnRenderMenuItemBackground(
ToolStripItemRenderEventArgs e)
{
ToolStrip toolStrip = e.ToolStrip;
ToolStripItem item = e.Item;
if (!item.Enabled)
{
return;
}
Graphics g = e.Graphics;
Rectangle rect = new Rectangle(Point.Empty, e.Item.Size);
if (toolStrip is MenuStrip)
{
if (item.Selected)
{
RenderHelper.RenderBackgroundInternal(
g,
rect,
ColorTable.BackHover,
ColorTable.BackHover,
RoundStyle.All,
m_radius,
true,
true);
}
else if (item.Pressed)
{
RenderHelper.RenderBackgroundInternal(
g,
rect,
ColorTable.BackPressed,
ColorTable.BackPressed,
RoundStyle.All,
m_radius,
true,
true);
}
else
{
base.OnRenderMenuItemBackground(e);
}
}
else if (toolStrip is ToolStripDropDown)
{
bool bDrawLogo = NeedDrawLogo(toolStrip);
int offsetMargin = bDrawLogo ? OffsetMargin : 0;
if (item.RightToLeft == RightToLeft.Yes)
{
rect.X += 4;
}
else
{
rect.X += offsetMargin + 4;
}
rect.Width -= offsetMargin + 8;
rect.Height--;
if (item.Selected)
{
RenderHelper.RenderBackgroundInternal(
g,
rect,
ColorTable.BackHover,
ColorTable.BackHover,
RoundStyle.All,
m_radius,
true,
true);
}
else
{
base.OnRenderMenuItemBackground(e);
}
}
else
{
base.OnRenderMenuItemBackground(e);
}
}
protected override void OnRenderItemImage(
ToolStripItemImageRenderEventArgs e)
{
ToolStrip toolStrip = e.ToolStrip;
Graphics g = e.Graphics;
if (toolStrip is ToolStripDropDown &&
e.Item is ToolStripMenuItem)
{
bool bDrawLogo = NeedDrawLogo(toolStrip);
int offsetMargin = bDrawLogo ? OffsetMargin : 0;
ToolStripMenuItem item = (ToolStripMenuItem)e.Item;
if (item.Checked)
{
return;
}
Rectangle rect = e.ImageRectangle;
if (e.Item.RightToLeft == RightToLeft.Yes)
{
rect.X -= offsetMargin + 2;
}
else
{
rect.X += offsetMargin + 2;
}
using (InterpolationModeGraphics ig =
new InterpolationModeGraphics(g))
{
ToolStripItemImageRenderEventArgs ne =
new ToolStripItemImageRenderEventArgs(
g, e.Item, e.Image, rect);
base.OnRenderItemImage(ne);
}
}
else
{
base.OnRenderItemImage(e);
}
}
protected override void OnRenderItemText(
ToolStripItemTextRenderEventArgs e)
{
ToolStrip toolStrip = e.ToolStrip;
e.TextColor = ColorTable.Fore;
if (toolStrip is ToolStripDropDown &&
e.Item is ToolStripMenuItem)
{
bool bDrawLogo = NeedDrawLogo(toolStrip);
int offsetMargin = bDrawLogo ? 18 : 0;
Rectangle rect = e.TextRectangle;
if (e.Item.RightToLeft == RightToLeft.Yes)
{
rect.X -= offsetMargin;
}
else
{
rect.X += offsetMargin;
}
rect.Height = e.Item.Height;
rect.Y = 0;
e.TextRectangle = rect;
}
e.Graphics.DrawString(e.Text, e.TextFont, new SolidBrush(e.TextColor), e.TextRectangle, new StringFormat() { LineAlignment= StringAlignment.Center });
//base.OnRenderItemText(e);
}
protected override void OnRenderItemCheck(
ToolStripItemImageRenderEventArgs e)
{
ToolStrip toolStrip = e.ToolStrip;
Graphics g = e.Graphics;
if (toolStrip is ToolStripDropDown &&
e.Item is ToolStripMenuItem)
{
bool bDrawLogo = NeedDrawLogo(toolStrip);
int offsetMargin = bDrawLogo ? OffsetMargin : 0;
Rectangle rect = e.ImageRectangle;
if (e.Item.RightToLeft == RightToLeft.Yes)
{
rect.X -= offsetMargin + 2;
}
else
{
rect.X += offsetMargin + 2;
}
rect.Width = 13;
rect.Y += 1;
rect.Height -= 3;
using (SmoothingModeGraphics sg = new SmoothingModeGraphics(g))
{
using (GraphicsPath path = new GraphicsPath())
{
path.AddRectangle(rect);
using (PathGradientBrush brush = new PathGradientBrush(path))
{
brush.CenterColor = Color.White;
brush.SurroundColors = new Color[] { ControlPaint.Light(ColorTable.BackNormal) };
Blend blend = new Blend();
blend.Positions = new float[] { 0f, 0.3f, 1f };
blend.Factors = new float[] { 0f, 0.5f, 1f };
brush.Blend = blend;
g.FillRectangle(brush, rect);
}
}
using (Pen pen = new Pen(ControlPaint.Light(ColorTable.BackNormal)))
{
g.DrawRectangle(pen, rect);
}
ControlPaintEx.DrawCheckedFlag(g, rect, ColorTable.Fore);
}
}
else
{
base.OnRenderItemCheck(e);
}
}
protected override void OnRenderArrow(
ToolStripArrowRenderEventArgs e)
{
if (e.Item.Enabled)
{
e.ArrowColor = ColorTable.Fore;
}
ToolStrip toolStrip = e.Item.Owner;
if (toolStrip is ToolStripDropDown &&
e.Item is ToolStripMenuItem)
{
bool bDrawLogo = NeedDrawLogo(toolStrip);
int offsetMargin = bDrawLogo ? 3 : 0;
Rectangle rect = e.ArrowRectangle;
if (e.Item.RightToLeft == RightToLeft.Yes)
{
rect.X -= offsetMargin;
}
else
{
rect.X += offsetMargin;
}
e.ArrowRectangle = rect;
}
base.OnRenderArrow(e);
}
protected override void OnRenderSeparator(
ToolStripSeparatorRenderEventArgs e)
{
ToolStrip toolStrip = e.ToolStrip;
Rectangle rect = e.Item.ContentRectangle;
Graphics g = e.Graphics;
if (toolStrip is ToolStripDropDown)
{
bool bDrawLogo = NeedDrawLogo(toolStrip);
int offsetMargin = bDrawLogo ?
OffsetMargin * 2 : OffsetMargin;
if (e.Item.RightToLeft != RightToLeft.Yes)
{
rect.X += offsetMargin + 2;
}
rect.Width -= offsetMargin + 4;
}
RenderSeparatorLine(
g,
rect,
ColorTable.DropDownImageSeparator,
ColorTable.BackNormal,
SystemColors.ControlLightLight,
e.Vertical);
}
internal void RenderSeparatorLine(
Graphics g,
Rectangle rect,
Color baseColor,
Color backColor,
Color shadowColor,
bool vertical)
{
float angle;
if (vertical)
{
angle = 90F;
}
else
{
angle = 180F;
}
using (LinearGradientBrush brush = new LinearGradientBrush(
rect,
baseColor,
backColor,
angle))
{
Blend blend = new Blend();
blend.Positions = new float[] { 0f, .2f, .5f, .8f, 1f };
blend.Factors = new float[] { 1f, .3f, 0f, .3f, 1f };
brush.Blend = blend;
using (Pen pen = new Pen(brush))
{
if (vertical)
{
g.DrawLine(pen, rect.X, rect.Y, rect.X, rect.Bottom);
}
else
{
g.DrawLine(pen, rect.X, rect.Y, rect.Right, rect.Y);
}
brush.LinearColors = new Color[] {
shadowColor, ColorTable.BackNormal };
pen.Brush = brush;
if (vertical)
{
g.DrawLine(pen, rect.X + 1, rect.Y, rect.X + 1, rect.Bottom);
}
else
{
g.DrawLine(pen, rect.X, rect.Y + 1, rect.Right, rect.Y + 1);
}
}
}
}
internal bool NeedDrawLogo(ToolStrip toolStrip)
{
ToolStripDropDown dropDown = toolStrip as ToolStripDropDown;
bool bDrawLogo =
(dropDown.OwnerItem != null &&
dropDown.OwnerItem.Owner is MenuStrip) ||
(toolStrip is ContextMenuStrip);
//return bDrawLogo;
return false;
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing.Drawing2D;
using System.Drawing;
using System.Windows.Forms;
namespace HZH_Controls.Controls
{
public static class RegionHelper
{
public static void CreateRegion(
Control control,
Rectangle bounds,
int radius,
RoundStyle roundStyle)
{
using (GraphicsPath path =
GraphicsPathHelper.CreatePath(
bounds, radius, roundStyle, true))
{
Region region = new Region(path);
path.Widen(Pens.White);
region.Union(path);
if (control.Region != null)
{
control.Region.Dispose();
}
control.Region = region;
}
}
public static void CreateRegion(
Control control,
Rectangle bounds,
int radius)
{
CreateRegion(control, bounds, radius, RoundStyle.All);
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;
namespace HZH_Controls.Controls
{
internal class RenderHelper
{
internal static void RenderBackgroundInternal(
Graphics g,
Rectangle rect,
Color baseColor,
Color borderColor,
RoundStyle style,
bool drawBorder,
bool drawGlass)
{
RenderBackgroundInternal(
g,
rect,
baseColor,
borderColor,
style,
8,
drawBorder,
drawGlass);
}
internal static void RenderBackgroundInternal(
Graphics g,
Rectangle rect,
Color baseColor,
Color borderColor,
RoundStyle style,
int roundWidth,
bool drawBorder,
bool drawGlass)
{
RenderBackgroundInternal(
g,
rect,
baseColor,
borderColor,
style,
roundWidth,
0.45f,
drawBorder,
drawGlass);
}
internal static void RenderBackgroundInternal(
Graphics g,
Rectangle rect,
Color baseColor,
Color borderColor,
RoundStyle style,
int roundWidth,
float basePosition,
bool drawBorder,
bool drawGlass)
{
if (drawBorder)
{
rect.Width--;
rect.Height--;
}
if (style != RoundStyle.None)
{
using (GraphicsPath path =
GraphicsPathHelper.CreatePath(rect, roundWidth, style, false))
{
g.FillPath(new SolidBrush(baseColor), path);
}
//if (baseColor.A > 80)
//{
// Rectangle rectTop = rect;
//
// using (GraphicsPath pathTop = GraphicsPathHelper.CreatePath(
// rectTop, roundWidth, RoundStyle.Top, false))
// {
// using (SolidBrush brushAlpha =
// new SolidBrush(Color.FromArgb(128, 255, 255, 255)))
// {
// g.FillPath(brushAlpha, pathTop);
// }
// }
//}
//if (drawGlass)
//{
// RectangleF glassRect = rect;
// if (mode == LinearGradientMode.Vertical)
// {
// glassRect.Y = rect.Y + rect.Height * basePosition;
// glassRect.Height = (rect.Height - rect.Height * basePosition) * 2;
// }
// else
// {
// glassRect.X = rect.X + rect.Width * basePosition;
// glassRect.Width = (rect.Width - rect.Width * basePosition) * 2;
// }
// ControlPaintEx.DrawGlass(g, glassRect, 170, 0);
//}
if (drawBorder)
{
using (GraphicsPath path =
GraphicsPathHelper.CreatePath(rect, roundWidth, style, false))
{
using (Pen pen = new Pen(borderColor))
{
g.DrawPath(pen, path);
}
}
rect.Inflate(-1, -1);
//using (GraphicsPath path =
// GraphicsPathHelper.CreatePath(rect, roundWidth, style, false))
//{
// using (Pen pen = new Pen(innerBorderColor))
// {
// g.DrawPath(pen, path);
// }
//}
}
}
else
{
g.FillRectangle(new SolidBrush(baseColor), rect);
//if (baseColor.A > 80)
//{
// Rectangle rectTop = rect;
// if (mode == LinearGradientMode.Vertical)
// {
// rectTop.Height = (int)(rectTop.Height * basePosition);
// }
// else
// {
// rectTop.Width = (int)(rect.Width * basePosition);
// }
// using (SolidBrush brushAlpha =
// new SolidBrush(Color.FromArgb(128, 255, 255, 255)))
// {
// g.FillRectangle(brushAlpha, rectTop);
// }
//}
//if (drawGlass)
//{
// RectangleF glassRect = rect;
// if (mode == LinearGradientMode.Vertical)
// {
// glassRect.Y = rect.Y + rect.Height * basePosition;
// glassRect.Height = (rect.Height - rect.Height * basePosition) * 2;
// }
// else
// {
// glassRect.X = rect.X + rect.Width * basePosition;
// glassRect.Width = (rect.Width - rect.Width * basePosition) * 2;
// }
// ControlPaintEx.DrawGlass(g, glassRect, 200, 0);
//}
if (drawBorder)
{
using (Pen pen = new Pen(borderColor))
{
g.DrawRectangle(pen, rect);
}
rect.Inflate(-1, -1);
//using (Pen pen = new Pen(innerBorderColor))
//{
// g.DrawRectangle(pen, rect);
//}
}
}
}
internal static Color GetColor(Color colorBase, int a, int r, int g, int b)
{
int a0 = colorBase.A;
int r0 = colorBase.R;
int g0 = colorBase.G;
int b0 = colorBase.B;
if (a + a0 > 255) { a = 255; } else { a = Math.Max(0, a + a0); }
if (r + r0 > 255) { r = 255; } else { r = Math.Max(0, r + r0); }
if (g + g0 > 255) { g = 255; } else { g = Math.Max(0, g + g0); }
if (b + b0 > 255) { b = 255; } else { b = Math.Max(0, b + b0); }
return Color.FromArgb(a, r, g, b);
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace HZH_Controls.Controls
{
/// <summary>
/// 建立圆角路径的样式。
/// </summary>
public enum RoundStyle
{
/// <summary>
/// 四个角都不是圆角。
/// </summary>
None = 0,
/// <summary>
/// 四个角都为圆角。
/// </summary>
All = 1,
/// <summary>
/// 左边两个角为圆角。
/// </summary>
Left = 2,
/// <summary>
/// 右边两个角为圆角。
/// </summary>
Right = 3,
/// <summary>
/// 上边两个角为圆角。
/// </summary>
Top = 4,
/// <summary>
/// 下边两个角为圆角。
/// </summary>
Bottom = 5,
/// <summary>
/// 左下角为圆角。
/// </summary>
BottomLeft = 6,
/// <summary>
/// 右下角为圆角。
/// </summary>
BottomRight = 7,
}
}
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;
namespace HZH_Controls.Controls
{
public class SmoothingModeGraphics : IDisposable
{
private SmoothingMode _oldMode;
private Graphics _graphics;
public SmoothingModeGraphics(Graphics graphics)
: this(graphics, SmoothingMode.AntiAlias)
{
}
public SmoothingModeGraphics(Graphics graphics, SmoothingMode newMode)
{
_graphics = graphics;
_oldMode = graphics.SmoothingMode;
graphics.SmoothingMode = newMode;
}
#region IDisposable 成员
public void Dispose()
{
_graphics.SmoothingMode = _oldMode;
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Text;
namespace HZH_Controls.Controls
{
internal class TextRenderingHintGraphics : IDisposable
{
private Graphics _graphics;
private TextRenderingHint _oldTextRenderingHint;
public TextRenderingHintGraphics(Graphics graphics)
: this(graphics, TextRenderingHint.AntiAlias)
{
}
public TextRenderingHintGraphics(
Graphics graphics,
TextRenderingHint newTextRenderingHint)
{
_graphics = graphics;
_oldTextRenderingHint = graphics.TextRenderingHint;
_graphics.TextRenderingHint = newTextRenderingHint;
}
#region IDisposable 成员
public void Dispose()
{
_graphics.TextRenderingHint = _oldTextRenderingHint;
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
namespace HZH_Controls.Controls
{
public class ToolStripColorTable
{
private static readonly Color _base = Color.FromArgb(49, 56, 82);
private static readonly Color _border = Color.FromArgb(49, 56, 82);
private static readonly Color _backNormal = Color.FromArgb(49, 56, 82);
private static readonly Color _backHover = Color.FromArgb(29, 33, 49);
private static readonly Color _backPressed = Color.FromArgb(29, 33, 49);
private static readonly Color _fore = Color.FromArgb(175, 193, 225);
private static readonly Color _dropDownImageBack = Color.FromArgb(49, 56, 82);
private static readonly Color _dropDownImageSeparator = Color.FromArgb(49, 56, 82);
public ToolStripColorTable() { }
public virtual Color Base
{
get { return _base; }
}
public virtual Color Border
{
get { return _border; }
}
public virtual Color BackNormal
{
get { return _backNormal; }
}
public virtual Color BackHover
{
get { return _backHover; }
}
public virtual Color BackPressed
{
get { return _backPressed; }
}
public virtual Color Fore
{
get { return _fore; }
}
public virtual Color DropDownImageBack
{
get { return _dropDownImageBack; }
}
public virtual Color DropDownImageSeparator
{
get { return _dropDownImageSeparator; }
}
}
}
...@@ -141,6 +141,16 @@ ...@@ -141,6 +141,16 @@
<Compile Include="Controls\TimeLine\UCTimeLine.Designer.cs"> <Compile Include="Controls\TimeLine\UCTimeLine.Designer.cs">
<DependentUpon>UCTimeLine.cs</DependentUpon> <DependentUpon>UCTimeLine.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Controls\ToolStripRendererEx\ControlPaintEx.cs" />
<Compile Include="Controls\ToolStripRendererEx\GraphicsPathHelper.cs" />
<Compile Include="Controls\ToolStripRendererEx\InterpolationModeGraphics.cs" />
<Compile Include="Controls\ToolStripRendererEx\ProfessionalToolStripRendererEx.cs" />
<Compile Include="Controls\ToolStripRendererEx\RegionHelper.cs" />
<Compile Include="Controls\ToolStripRendererEx\RenderHelper.cs" />
<Compile Include="Controls\ToolStripRendererEx\RoundStyle.cs" />
<Compile Include="Controls\ToolStripRendererEx\SmoothingModeGraphics.cs" />
<Compile Include="Controls\ToolStripRendererEx\TextRenderingHintGraphics.cs" />
<Compile Include="Controls\ToolStripRendererEx\ToolStripColorTable.cs" />
<Compile Include="Controls\Transfer\TransferEventArgs.cs" /> <Compile Include="Controls\Transfer\TransferEventArgs.cs" />
<Compile Include="Controls\Transfer\UCTransfer.cs"> <Compile Include="Controls\Transfer\UCTransfer.cs">
<SubType>UserControl</SubType> <SubType>UserControl</SubType>
......
...@@ -72,6 +72,7 @@ namespace Test ...@@ -72,6 +72,7 @@ namespace Test
tnControl.Nodes.Add("时间轴"); tnControl.Nodes.Add("时间轴");
tnControl.Nodes.Add("穿梭框"); tnControl.Nodes.Add("穿梭框");
tnControl.Nodes.Add("引用区块"); tnControl.Nodes.Add("引用区块");
tnControl.Nodes.Add("右键菜单");
this.tvMenu.Nodes.Add(tnControl); this.tvMenu.Nodes.Add(tnControl);
TreeNode tnCharts = new TreeNode(" 图表"); TreeNode tnCharts = new TreeNode(" 图表");
...@@ -296,6 +297,9 @@ namespace Test ...@@ -296,6 +297,9 @@ namespace Test
case "引用区块": case "引用区块":
AddControl(new UC.UCTestPanelQuote()); AddControl(new UC.UCTestPanelQuote());
break; break;
case "右键菜单":
AddControl(new UC.UCTestContextMenu());
break;
#endregion #endregion
#region 图表 English:Chart #region 图表 English:Chart
......
...@@ -127,6 +127,12 @@ ...@@ -127,6 +127,12 @@
<Compile Include="UC\UCTestConduit.Designer.cs"> <Compile Include="UC\UCTestConduit.Designer.cs">
<DependentUpon>UCTestConduit.cs</DependentUpon> <DependentUpon>UCTestConduit.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="UC\UCTestContextMenu.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="UC\UCTestContextMenu.Designer.cs">
<DependentUpon>UCTestContextMenu.cs</DependentUpon>
</Compile>
<Compile Include="UC\UCTestConveyor.cs"> <Compile Include="UC\UCTestConveyor.cs">
<SubType>UserControl</SubType> <SubType>UserControl</SubType>
</Compile> </Compile>
...@@ -695,6 +701,9 @@ ...@@ -695,6 +701,9 @@
<EmbeddedResource Include="UC\UCTestConduit.resx"> <EmbeddedResource Include="UC\UCTestConduit.resx">
<DependentUpon>UCTestConduit.cs</DependentUpon> <DependentUpon>UCTestConduit.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="UC\UCTestContextMenu.resx">
<DependentUpon>UCTestContextMenu.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UC\UCTestConveyor.resx"> <EmbeddedResource Include="UC\UCTestConveyor.resx">
<DependentUpon>UCTestConveyor.cs</DependentUpon> <DependentUpon>UCTestConveyor.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
......
namespace Test.UC
{
partial class UCTestContextMenu
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(UCTestContextMenu));
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.菜单1ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.菜单2ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.菜单1ToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.菜单1ToolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
this.菜单1ToolStripMenuItem3 = new System.Windows.Forms.ToolStripMenuItem();
this.菜单1ToolStripMenuItem4 = new System.Windows.Forms.ToolStripMenuItem();
this.菜单1ToolStripMenuItem5 = new System.Windows.Forms.ToolStripMenuItem();
this.菜单1ToolStripMenuItem6 = new System.Windows.Forms.ToolStripMenuItem();
this.菜单1ToolStripMenuItem7 = new System.Windows.Forms.ToolStripMenuItem();
this.菜单1ToolStripMenuItem8 = new System.Windows.Forms.ToolStripMenuItem();
this.菜单1ToolStripMenuItem9 = new System.Windows.Forms.ToolStripMenuItem();
this.菜单1ToolStripMenuItem10 = new System.Windows.Forms.ToolStripMenuItem();
this.label1 = new System.Windows.Forms.Label();
this.菜单1ToolStripMenuItem11 = new System.Windows.Forms.ToolStripMenuItem();
this.菜单1ToolStripMenuItem12 = new System.Windows.Forms.ToolStripMenuItem();
this.菜单1ToolStripMenuItem13 = new System.Windows.Forms.ToolStripMenuItem();
this.菜单1ToolStripMenuItem14 = new System.Windows.Forms.ToolStripMenuItem();
this.菜单1ToolStripMenuItem15 = new System.Windows.Forms.ToolStripMenuItem();
this.菜单1ToolStripMenuItem16 = new System.Windows.Forms.ToolStripMenuItem();
this.菜单1ToolStripMenuItem17 = new System.Windows.Forms.ToolStripMenuItem();
this.菜单1ToolStripMenuItem18 = new System.Windows.Forms.ToolStripMenuItem();
this.菜单1ToolStripMenuItem19 = new System.Windows.Forms.ToolStripMenuItem();
this.菜单1ToolStripMenuItem20 = new System.Windows.Forms.ToolStripMenuItem();
this.contextMenuStrip1.SuspendLayout();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
//
// contextMenuStrip1
//
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.菜单1ToolStripMenuItem11,
this.菜单1ToolStripMenuItem12,
this.菜单1ToolStripMenuItem13,
this.菜单1ToolStripMenuItem14,
this.菜单1ToolStripMenuItem15});
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(108, 204);
//
// menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.菜单1ToolStripMenuItem,
this.菜单2ToolStripMenuItem,
this.菜单1ToolStripMenuItem9,
this.菜单1ToolStripMenuItem10});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(572, 25);
this.menuStrip1.TabIndex = 1;
this.menuStrip1.Text = "menuStrip1";
//
// 菜单1ToolStripMenuItem
//
this.菜单1ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.菜单1ToolStripMenuItem1,
this.菜单1ToolStripMenuItem2,
this.菜单1ToolStripMenuItem5});
this.菜单1ToolStripMenuItem.Name = "菜单1ToolStripMenuItem";
this.菜单1ToolStripMenuItem.Size = new System.Drawing.Size(51, 21);
this.菜单1ToolStripMenuItem.Text = "菜单1";
//
// 菜单2ToolStripMenuItem
//
this.菜单2ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.菜单1ToolStripMenuItem6,
this.菜单1ToolStripMenuItem7});
this.菜单2ToolStripMenuItem.Name = "菜单2ToolStripMenuItem";
this.菜单2ToolStripMenuItem.Size = new System.Drawing.Size(51, 21);
this.菜单2ToolStripMenuItem.Text = "菜单2";
//
// 菜单1ToolStripMenuItem1
//
this.菜单1ToolStripMenuItem1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.菜单1ToolStripMenuItem3,
this.菜单1ToolStripMenuItem4});
this.菜单1ToolStripMenuItem1.Name = "菜单1ToolStripMenuItem1";
this.菜单1ToolStripMenuItem1.Size = new System.Drawing.Size(152, 22);
this.菜单1ToolStripMenuItem1.Text = "菜单1";
//
// 菜单1ToolStripMenuItem2
//
this.菜单1ToolStripMenuItem2.Name = "菜单1ToolStripMenuItem2";
this.菜单1ToolStripMenuItem2.Size = new System.Drawing.Size(152, 22);
this.菜单1ToolStripMenuItem2.Text = "菜单1";
//
// 菜单1ToolStripMenuItem3
//
this.菜单1ToolStripMenuItem3.Name = "菜单1ToolStripMenuItem3";
this.菜单1ToolStripMenuItem3.Size = new System.Drawing.Size(152, 22);
this.菜单1ToolStripMenuItem3.Text = "菜单1";
//
// 菜单1ToolStripMenuItem4
//
this.菜单1ToolStripMenuItem4.Name = "菜单1ToolStripMenuItem4";
this.菜单1ToolStripMenuItem4.Size = new System.Drawing.Size(152, 22);
this.菜单1ToolStripMenuItem4.Text = "菜单1";
//
// 菜单1ToolStripMenuItem5
//
this.菜单1ToolStripMenuItem5.Name = "菜单1ToolStripMenuItem5";
this.菜单1ToolStripMenuItem5.Size = new System.Drawing.Size(152, 22);
this.菜单1ToolStripMenuItem5.Text = "菜单1";
//
// 菜单1ToolStripMenuItem6
//
this.菜单1ToolStripMenuItem6.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.菜单1ToolStripMenuItem8});
this.菜单1ToolStripMenuItem6.Name = "菜单1ToolStripMenuItem6";
this.菜单1ToolStripMenuItem6.Size = new System.Drawing.Size(152, 22);
this.菜单1ToolStripMenuItem6.Text = "菜单1";
//
// 菜单1ToolStripMenuItem7
//
this.菜单1ToolStripMenuItem7.Name = "菜单1ToolStripMenuItem7";
this.菜单1ToolStripMenuItem7.Size = new System.Drawing.Size(152, 22);
this.菜单1ToolStripMenuItem7.Text = "菜单1";
//
// 菜单1ToolStripMenuItem8
//
this.菜单1ToolStripMenuItem8.Name = "菜单1ToolStripMenuItem8";
this.菜单1ToolStripMenuItem8.Size = new System.Drawing.Size(152, 22);
this.菜单1ToolStripMenuItem8.Text = "菜单1";
//
// 菜单1ToolStripMenuItem9
//
this.菜单1ToolStripMenuItem9.Name = "菜单1ToolStripMenuItem9";
this.菜单1ToolStripMenuItem9.Size = new System.Drawing.Size(51, 21);
this.菜单1ToolStripMenuItem9.Text = "菜单1";
//
// 菜单1ToolStripMenuItem10
//
this.菜单1ToolStripMenuItem10.Name = "菜单1ToolStripMenuItem10";
this.菜单1ToolStripMenuItem10.Size = new System.Drawing.Size(51, 21);
this.菜单1ToolStripMenuItem10.Text = "菜单1";
//
// label1
//
this.label1.BackColor = System.Drawing.Color.Silver;
this.label1.ContextMenuStrip = this.contextMenuStrip1;
this.label1.Location = new System.Drawing.Point(94, 112);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(357, 93);
this.label1.TabIndex = 2;
this.label1.Text = "看看我的右键菜单可好,骚年?\r\nHZH_Controls.Controls.ToolStripColorTable这里面有好多颜色 自己可以改 ";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// 菜单1ToolStripMenuItem11
//
this.菜单1ToolStripMenuItem11.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.菜单1ToolStripMenuItem16,
this.菜单1ToolStripMenuItem17});
this.菜单1ToolStripMenuItem11.Name = "菜单1ToolStripMenuItem11";
this.菜单1ToolStripMenuItem11.Padding = new System.Windows.Forms.Padding(0, 10, 0, 10);
this.菜单1ToolStripMenuItem11.Size = new System.Drawing.Size(152, 40);
this.菜单1ToolStripMenuItem11.Text = "菜单1";
//
// 菜单1ToolStripMenuItem12
//
this.菜单1ToolStripMenuItem12.Name = "菜单1ToolStripMenuItem12";
this.菜单1ToolStripMenuItem12.Padding = new System.Windows.Forms.Padding(0, 10, 0, 10);
this.菜单1ToolStripMenuItem12.Size = new System.Drawing.Size(152, 40);
this.菜单1ToolStripMenuItem12.Text = "菜单1";
//
// 菜单1ToolStripMenuItem13
//
this.菜单1ToolStripMenuItem13.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.菜单1ToolStripMenuItem18,
this.菜单1ToolStripMenuItem19});
this.菜单1ToolStripMenuItem13.Image = ((System.Drawing.Image)(resources.GetObject("菜单1ToolStripMenuItem13.Image")));
this.菜单1ToolStripMenuItem13.Name = "菜单1ToolStripMenuItem13";
this.菜单1ToolStripMenuItem13.Padding = new System.Windows.Forms.Padding(0, 10, 0, 10);
this.菜单1ToolStripMenuItem13.Size = new System.Drawing.Size(107, 40);
this.菜单1ToolStripMenuItem13.Text = "菜单1";
//
// 菜单1ToolStripMenuItem14
//
this.菜单1ToolStripMenuItem14.Name = "菜单1ToolStripMenuItem14";
this.菜单1ToolStripMenuItem14.Padding = new System.Windows.Forms.Padding(0, 10, 0, 10);
this.菜单1ToolStripMenuItem14.Size = new System.Drawing.Size(152, 40);
this.菜单1ToolStripMenuItem14.Text = "菜单1";
//
// 菜单1ToolStripMenuItem15
//
this.菜单1ToolStripMenuItem15.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.菜单1ToolStripMenuItem20});
this.菜单1ToolStripMenuItem15.Name = "菜单1ToolStripMenuItem15";
this.菜单1ToolStripMenuItem15.Padding = new System.Windows.Forms.Padding(0, 10, 0, 10);
this.菜单1ToolStripMenuItem15.Size = new System.Drawing.Size(152, 40);
this.菜单1ToolStripMenuItem15.Text = "菜单1";
//
// 菜单1ToolStripMenuItem16
//
this.菜单1ToolStripMenuItem16.Name = "菜单1ToolStripMenuItem16";
this.菜单1ToolStripMenuItem16.Padding = new System.Windows.Forms.Padding(0, 10, 0, 10);
this.菜单1ToolStripMenuItem16.Size = new System.Drawing.Size(152, 40);
this.菜单1ToolStripMenuItem16.Text = "菜单1";
//
// 菜单1ToolStripMenuItem17
//
this.菜单1ToolStripMenuItem17.Name = "菜单1ToolStripMenuItem17";
this.菜单1ToolStripMenuItem17.Padding = new System.Windows.Forms.Padding(0, 10, 0, 10);
this.菜单1ToolStripMenuItem17.Size = new System.Drawing.Size(152, 40);
this.菜单1ToolStripMenuItem17.Text = "菜单1";
//
// 菜单1ToolStripMenuItem18
//
this.菜单1ToolStripMenuItem18.Name = "菜单1ToolStripMenuItem18";
this.菜单1ToolStripMenuItem18.Padding = new System.Windows.Forms.Padding(0, 10, 0, 10);
this.菜单1ToolStripMenuItem18.Size = new System.Drawing.Size(152, 40);
this.菜单1ToolStripMenuItem18.Text = "菜单1";
//
// 菜单1ToolStripMenuItem19
//
this.菜单1ToolStripMenuItem19.Name = "菜单1ToolStripMenuItem19";
this.菜单1ToolStripMenuItem19.Padding = new System.Windows.Forms.Padding(0, 10, 0, 10);
this.菜单1ToolStripMenuItem19.Size = new System.Drawing.Size(152, 40);
this.菜单1ToolStripMenuItem19.Text = "菜单1";
//
// 菜单1ToolStripMenuItem20
//
this.菜单1ToolStripMenuItem20.Name = "菜单1ToolStripMenuItem20";
this.菜单1ToolStripMenuItem20.Padding = new System.Windows.Forms.Padding(0, 10, 0, 10);
this.菜单1ToolStripMenuItem20.Size = new System.Drawing.Size(152, 40);
this.菜单1ToolStripMenuItem20.Text = "菜单1";
//
// UCTestContextMenu
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.label1);
this.Controls.Add(this.menuStrip1);
this.Name = "UCTestContextMenu";
this.Size = new System.Drawing.Size(572, 332);
this.contextMenuStrip1.ResumeLayout(false);
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
private System.Windows.Forms.ToolStripMenuItem 菜单1ToolStripMenuItem11;
private System.Windows.Forms.ToolStripMenuItem 菜单1ToolStripMenuItem16;
private System.Windows.Forms.ToolStripMenuItem 菜单1ToolStripMenuItem17;
private System.Windows.Forms.ToolStripMenuItem 菜单1ToolStripMenuItem12;
private System.Windows.Forms.ToolStripMenuItem 菜单1ToolStripMenuItem13;
private System.Windows.Forms.ToolStripMenuItem 菜单1ToolStripMenuItem18;
private System.Windows.Forms.ToolStripMenuItem 菜单1ToolStripMenuItem19;
private System.Windows.Forms.ToolStripMenuItem 菜单1ToolStripMenuItem14;
private System.Windows.Forms.ToolStripMenuItem 菜单1ToolStripMenuItem15;
private System.Windows.Forms.ToolStripMenuItem 菜单1ToolStripMenuItem20;
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem 菜单1ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem 菜单1ToolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem 菜单1ToolStripMenuItem3;
private System.Windows.Forms.ToolStripMenuItem 菜单1ToolStripMenuItem4;
private System.Windows.Forms.ToolStripMenuItem 菜单1ToolStripMenuItem2;
private System.Windows.Forms.ToolStripMenuItem 菜单1ToolStripMenuItem5;
private System.Windows.Forms.ToolStripMenuItem 菜单2ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem 菜单1ToolStripMenuItem6;
private System.Windows.Forms.ToolStripMenuItem 菜单1ToolStripMenuItem8;
private System.Windows.Forms.ToolStripMenuItem 菜单1ToolStripMenuItem7;
private System.Windows.Forms.ToolStripMenuItem 菜单1ToolStripMenuItem9;
private System.Windows.Forms.ToolStripMenuItem 菜单1ToolStripMenuItem10;
private System.Windows.Forms.Label label1;
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Test.UC
{
public partial class UCTestContextMenu : UserControl
{
public UCTestContextMenu()
{
InitializeComponent();
//HZH_Controls.Controls.ToolStripColorTable这里面有好多颜色 自己可以改
ToolStripManager.Renderer = new HZH_Controls.Controls.ProfessionalToolStripRendererEx();
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>182, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="菜单1ToolStripMenuItem13.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAGQSURBVEhLzZS7SgQxGIXHQrSw8A209Al8Hx/AShZBEMUboqWgLigiWCkzGRC3WyaJqCAWVloo
bhLBBUEWOxFlPOP+ymySvcGCfvAXM+f8Z3KbBH9CWH4YYdIsMKHPULVY6lcmzGXE9dpx8jRGts5J07Qv
FGoRYW+o1FvSfOIjG3tJZZDa2hMJFXrDvKXOi8WrfmptTsjVrD+gRUmzSe1+WFIZZVx/2I2xMBeRVAUm
9SSey7b+XfJxnGJcYJi3G2JsFMm/YPpTjk/oLZJd0MDz5oirW5IcoMu8FzO9J8kFu2zy5kjobZIcIlGZ
znuxTC8kuUBUDWahdkhygD6X92IQLYKFOmkwc1Utle4GSG4A+o3lvSbJBWIhb6436KPD5HmILEH2IYxu
y/ZhjVfI4oLjNgxTzW7Kpok6QO1j96uurt6zo0oxfuJTM2E3tiv8VDPU3hqMbNUX4C+zS22dgemt+4Py
1WXoDwhf8gdm62qanvGOYFxl97EV2vzH6Qq67OvBXBfpdW/A7bbcs5H+Q4LgCy0wfhlJZv3aAAAAAElF
TkSuQmCC
</value>
</data>
</root>
\ No newline at end of file \ No newline at end of file
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!