public class DrawImageEventArgs : EventArgs
Public Class DrawImageEventArgs
Inherits EventArgs
public ref class DrawImageEventArgs : public EventArgs
type DrawImageEventArgs =
class
inherit EventArgs
end
public ImageMapEventsForm()
{
InitializeComponent();
// Hook up the event handlers. Since they are not accessible in the
// designer, we must do it manually.
ImageAreaBase a = (ImageAreaBase)imMap.Areas[4];
a.DrawImage += Button_DrawImage;
a = (ImageAreaBase)imMap.Areas[5];
a.DrawImage += Button_DrawImage;
a = (ImageAreaBase)imMap.Areas[6];
a.DrawImage += Button_DrawImage;
.
.
.
}
/// <summary>
/// Draw the "button" image areas
/// </summary>
/// <param name="sender">The sender of the event (the image area)</param>
/// <param name="e">The event arguments</param>
private void Button_DrawImage(object sender, DrawImageEventArgs e)
{
ImageAttributes ia;
Graphics g = e.Graphics;
// All are ellipse image areas
ImageAreaEllipse a = (ImageAreaEllipse)sender;
Rectangle r = a.Ellipse;
// Offset the area rectangle by the draw event offset
r.Offset(e.ImageOffset.X, e.ImageOffset.Y);
if(!a.Enabled)
ia = iaDisabled;
else
ia = iaNormal;
using(TextureBrush tb = new TextureBrush(imgFiller,
new Rectangle(0, 0, imgFiller.Width, imgFiller.Height), ia))
{
tb.WrapMode = WrapMode.Tile;
// Translate the brush coordinates to account for the offset
using(Matrix m = new Matrix())
{
m.Translate(r.X, r.Y);
tb.Transform = m;
// If the area is focused or hot lighted, give it a glow effect
if(e.DrawState == DrawState.Focus || e.DrawState == DrawState.HotLight)
{
using(GraphicsPath pth = new GraphicsPath())
{
pth.AddEllipse(r);
using(PathGradientBrush pgb = new PathGradientBrush(pth))
{
pgb.CenterColor = Color.LightSteelBlue;
if(e.DrawState == DrawState.Focus)
pgb.SurroundColors = new Color[] { Color.Yellow };
else
pgb.SurroundColors = new Color[] { Color.Blue };
pgb.FocusScales = new PointF(0.8f, 0.8f);
g.FillEllipse(pgb, r);
}
}
}
// Draw the filler
g.FillEllipse(tb, r);
g.DrawString((string)a.Tag, buttonFont, Brushes.Black, r, sfFormat);
}
}
}
Public Sub New()
MyBase.New()
InitializeComponent()
' Hook up the event handlers. Since they are not accessible in the
' designer, we must do it manually.
Dim a As ImageAreaBase = DirectCast(imMap.Areas(4), ImageAreaBase)
AddHandler a.DrawImage, AddressOf Button_DrawImage
a = DirectCast(imMap.Areas(5), ImageAreaBase)
AddHandler a.DrawImage, AddressOf Button_DrawImage
a = DirectCast(imMap.Areas(6), ImageAreaBase)
AddHandler a.DrawImage, AddressOf Button_DrawImage
.
.
.
End Sub
''' <summary>
''' Draw the "button" image areas
''' </summary>
''' <param name="sender">The sender of the event (the image area)</param>
''' <param name="e">The event arguments</param>
Private Sub Button_DrawImage(sender As Object, e As DrawImageEventArgs)
Dim ia As ImageAttributes
Dim g As Graphics = e.Graphics
' All are ellipse image areas
Dim a As ImageAreaEllipse = DirectCast(sender, ImageAreaEllipse)
Dim r As Rectangle = a.Ellipse
' Offset the area rectangle by the draw event offset
r.Offset(e.ImageOffset.X, e.ImageOffset.Y)
If Not a.Enabled Then
ia = iaDisabled
Else
ia = iaNormal
End If
Using tb As New TextureBrush(imgFiller, _
New Rectangle(0, 0, imgFiller.Width, imgFiller.Height), ia)
tb.WrapMode = WrapMode.Tile
' Translate the brush coordinates to account for the offset
Using m As New Matrix()
m.Translate(CType(r.X, Single), CType(r.Y, Single))
tb.Transform = m
' If the area is focused or hot lighted, give it a glow effect
If e.DrawState = DrawState.Focus Or e.DrawState = DrawState.HotLight Then
Using pth As New GraphicsPath()
pth.AddEllipse(r)
Using pgb As New PathGradientBrush(pth)
pgb.CenterColor = Color.LightSteelBlue
If e.DrawState = DrawState.Focus Then
pgb.SurroundColors = New Color() { Color.Yellow }
Else
pgb.SurroundColors = New Color() { Color.Blue }
End If
pgb.FocusScales = New PointF(0.8!, 0.8!)
g.FillEllipse(pgb, r)
End Using
End Using
End If
' Draw the filler
g.FillEllipse(tb, r)
g.DrawString(DirectCast(a.Tag, String), buttonFont, Brushes.Black, _
New RectangleF(CType(r.X, Single), CType(r.Y, Single), _
CType(r.Width, Single), CType(r.Height, Single)), sfFormat)
End Using
End Using
End Sub
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
DrawImageEventArgs | Constructor |
DrawFocus | This property is used to get or set whether the image map should draw the default focus frame around the active image area. |
DrawState | This property is used to get or set the state of the item to draw |
Graphics | This read-only property is used to get the graphics context for drawing |
ImageOffset | This read-only property is used to get the image offset |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object) |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object) |
GetHashCode | Serves as the default hash function. (Inherited from Object) |
GetType | Gets the Type of the current instance. (Inherited from Object) |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object) |
ToString | Returns a string that represents the current object. (Inherited from Object) |