本文整理汇总了C#中System.Windows.Forms.ToolStripItemImageRenderEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# ToolStripItemImageRenderEventArgs类的具体用法?C# ToolStripItemImageRenderEventArgs怎么用?C# ToolStripItemImageRenderEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ToolStripItemImageRenderEventArgs类属于System.Windows.Forms命名空间,在下文中一共展示了ToolStripItemImageRenderEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnRenderItemImage
/// <summary>
/// 将图标居中绘制
/// </summary>
/// <param name="e"></param>
protected override void OnRenderItemImage(ToolStripItemImageRenderEventArgs e)
{
//base.OnRenderItemImage(e);
int offset = 28;
Image icon = e.Image;
Rectangle iconRect = e.ImageRectangle;
Graphics g = e.Graphics;
if (e.ToolStrip is ContextMenuStrip)
{
ContextMenuStrip contextMenuStrip = e.ToolStrip as ContextMenuStrip;
iconRect.X = (offset - icon.Width) / 2;
if (icon.Width < contextMenuStrip.ImageScalingSize.Width ||
icon.Height < contextMenuStrip.ImageScalingSize.Height)
{
g.DrawImage(icon, iconRect);
}
else
{
Rectangle iconPoint = new Rectangle(
iconRect.X,
2,
contextMenuStrip.ImageScalingSize.Width + 3,
contextMenuStrip.ImageScalingSize.Height + 2);
Rectangle imgRect = new Rectangle(0, 0, icon.Width, icon.Height);
g.DrawImage(icon, iconPoint, imgRect, GraphicsUnit.Pixel);
}
}
}
示例2: OnRenderItemImage
protected override void OnRenderItemImage(ToolStripItemImageRenderEventArgs e)
{
Rectangle destRect = e.ImageRectangle;
destRect.X++;
destRect.Width -= 2;
destRect.Y++;
destRect.Height -= 2;
Image normalImage = e.Image;
if ((destRect != Rectangle.Empty) && (normalImage != null))
{
if (e.Item.Enabled)
{
e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
e.Graphics.DrawImage(normalImage, destRect);
}
else
{
Image disabledImage = new Bitmap(destRect.Width, destRect.Height);
Graphics g = Graphics.FromImage(disabledImage);
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.DrawImage(e.Image, 0, 0, destRect.Width, destRect.Height);
g.Dispose();
ControlPaint.DrawImageDisabled(e.Graphics, disabledImage, destRect.X, destRect.Y, Color.Transparent);
}
}
}
示例3: OnRenderItemCheck
protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e)
{
base.OnRenderItemCheck(e);
/*
if (e.Item is ToolStripMenuItem )
{
if (((ToolStripMenuItem) e.Item).Checked)
{
Rectangle rect = new Rectangle(3, 3, 12, 12);
e.Graphics.DrawRectangle(Pens.Black, rect);
e.Graphics.DrawLine(Pens.Black, new Point(5,12), new Point( 8,12 ) );
e.Graphics.DrawLine(Pens.Black, new Point(8, 12), new Point(11, 4));
}
else
{
Rectangle rect = new Rectangle(3, 3, 12, 12);
e.Graphics.DrawRectangle(Pens.Black, rect);
}
}
else
{
base.OnRenderItemCheck(e);
}
* */
}
示例4: OnRenderItemImage
protected override void OnRenderItemImage(ToolStripItemImageRenderEventArgs e)
{
Rectangle imageRectangle = e.ImageRectangle;
Image normalImage = e.Image;
if (!imageRectangle.IsEmpty && (normalImage != null))
{
bool flag = false;
if (!e.Item.Enabled)
{
normalImage = ToolStripRenderer.CreateDisabledImage(normalImage);
flag = true;
}
if (e.Item.ImageScaling == ToolStripItemImageScaling.None)
{
e.Graphics.DrawImage(normalImage, imageRectangle.Location);
}
else
{
e.Graphics.DrawImage(normalImage, imageRectangle);
}
if (flag)
{
normalImage.Dispose();
}
}
}
示例5: OnRenderItemCheck
protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e)
{
Rectangle rect = Rectangle.Inflate(e.ImageRectangle, 3, 2);
e.Graphics.FillRectangle(new LinearGradientBrush(
new Point(0, 0),
new Point(0, e.Item.ContentRectangle.Height),
backFillColorTop,
backFillColorBottom), rect);
e.Graphics.DrawLines(new Pen(outlineColor), GraphicsHelper.getRoundedLines(rect));
rect = Rectangle.Inflate(rect, -1, -1);
e.Graphics.DrawLines(new Pen(insetOutlineColor), GraphicsHelper.getRoundedLines(rect));
rect = Rectangle.Inflate(rect, -2, -1);
try
{
if (e.Item.Image == null)
e.Graphics.DrawImageUnscaled(Properties.Resources.bullet_black, rect);
}
catch
{
base.OnRenderItemCheck(e);
}
}
示例6: OnRenderItemImage
protected override void OnRenderItemImage(ToolStripItemImageRenderEventArgs e)
{
Rectangle rect = new Rectangle(25,1,16,16);
if (e.Item is ToolStripMenuItem && ((ToolStripMenuItem)e.Item).Checked)
e.Graphics.DrawImage(e.Image, rect);
else
base.OnRenderItemImage(e);
}
示例7: OnRenderItemImage
protected override void OnRenderItemImage(ToolStripItemImageRenderEventArgs e)
{
Rectangle rect = e.ImageRectangle;
rect.X += 4;
ToolStripItemImageRenderEventArgs ne = new ToolStripItemImageRenderEventArgs(e.Graphics, e.Item, e.Image, rect);
base.OnRenderItemImage(ne);
}
示例8: OnRenderItemImage
protected override void OnRenderItemImage(ToolStripItemImageRenderEventArgs e)
{
if (e.Item is ToolStripMenuItem)
{
Rectangle imageRectangle = new Rectangle(e.ImageRectangle.Left + 2, e.ImageRectangle.Top, e.ImageRectangle.Width, e.ImageRectangle.Height);
e = new ToolStripItemImageRenderEventArgs(e.Graphics, e.Item, e.Image, imageRectangle);
}
base.OnRenderItemImage(e);
}
示例9: OnRenderItemCheck
protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e)
{
Rectangle backRect = new Rectangle(5, 4, 13, 13);
LinearGradientBrush bgBrush = new LinearGradientBrush(backRect, Color.FromArgb(255, 220, 120), Color.FromArgb(240, 160, 40), LinearGradientMode.Vertical);
e.Graphics.DrawRectangle(new Pen(new SolidBrush(Color.FromArgb(150, 50, 0)), 1), new Rectangle(4, 3, 14, 14));
e.Graphics.FillRectangle(bgBrush, backRect);
e.Graphics.DrawImage(e.Image, new Point(3, 3));
}
示例10: OnRenderItemImage
protected override void OnRenderItemImage(ToolStripItemImageRenderEventArgs e)
{
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
if (e.Image != null)
{
imageheight = e.Item.Height - offsety * 2;
imagewidth = (int)((Convert.ToDouble(imageheight) / e.Image.Height) * e.Image.Width);
}
e.Graphics.DrawImage(e.Image, new Rectangle(offsetx, offsety, imagewidth, imageheight));
}
示例11: OnRenderItemCheck
protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e)
{
base.OnRenderItemCheck(e);
Rectangle bounds = new Rectangle(e.ImageRectangle.Left - 2, 1, e.ImageRectangle.Width + 4, e.Item.Height - 2);
Graphics g = e.Graphics;
using (Pen p = new Pen(ThemeColorTable.HighlightColor, 1))
{
g.DrawRectangle(p, bounds.X, bounds.Y, bounds.Width - 1, bounds.Height - 1);
}
}
示例12: OnRenderItemImage
protected override void OnRenderItemImage(ToolStripItemImageRenderEventArgs e)
{
ToolStripSplitButton item = e.Item as ToolStripSplitButton;
if (!((e.Item is ToolStripMenuItem) || !((item != null) ? item.ButtonPressed : e.Item.Pressed)))
{
Rectangle imageRectangle = e.ImageRectangle;
imageRectangle.Offset(1, 1);
e = new ToolStripItemImageRenderEventArgs(e.Graphics, e.Item, e.Image, imageRectangle);
}
base.OnRenderItemImage(e);
}
示例13: OnRenderItemCheck
protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e) {
if (scaledCheckbox == null || scaledCheckbox.Size != coreConfiguration.IconSize) {
if (scaledCheckbox != null) {
scaledCheckbox.Dispose();
}
scaledCheckbox = ImageHelper.ResizeImage(e.Image, true, coreConfiguration.IconSize.Width, coreConfiguration.IconSize.Height, null);
}
Rectangle old = e.ImageRectangle;
ToolStripItemImageRenderEventArgs clone = new ToolStripItemImageRenderEventArgs(e.Graphics, e.Item, scaledCheckbox, new Rectangle(old.X, 0, old.Width, old.Height));
base.OnRenderItemCheck(clone);
}
示例14: OnRenderItemImage
/// <summary>
/// Render an item
/// </summary>
/// <param name="e"></param>
protected override void OnRenderItemImage(ToolStripItemImageRenderEventArgs e)
{
// automatic adjust the color of attached images...
if (e.Item.Selected && e.Item.Pressed == false)
e.Graphics.DrawImageUnscaled(e.Item.Image.AdjustRGBGamma(1f, 1f, 1f, 0.01f), e.ImageRectangle);
else
{
if (MetroUI.Style.DarkStyle)
e.Graphics.DrawImageUnscaled(e.Item.Image.AdjustRGBGamma(1f, 1f, 1f, 0.01f), e.ImageRectangle);
else
base.OnRenderItemImage(e);
}
}
示例15: OnRenderItemImage
protected override void OnRenderItemImage(ToolStripItemImageRenderEventArgs e) {
QMenuItem item = e.Item as QMenuItem;
if(((item != null) && item.IsCut) && ((e.ImageRectangle != Rectangle.Empty) && (e.Image != null))) {
ColorMatrix newColorMatrix = new ColorMatrix();
using(ImageAttributes attributes = new ImageAttributes()) {
newColorMatrix.Matrix33 = 0.5f;
attributes.SetColorMatrix(newColorMatrix);
Size size = e.Image.Size;
e.Graphics.DrawImage(e.Image, e.ImageRectangle, 0, 0, size.Width, size.Height, GraphicsUnit.Pixel, attributes);
return;
}
}
base.OnRenderItemImage(e);
}