本文整理汇总了C#中System.Drawing.Drawing2D.GraphicsPath.Widen方法的典型用法代码示例。如果您正苦于以下问题:C# GraphicsPath.Widen方法的具体用法?C# GraphicsPath.Widen怎么用?C# GraphicsPath.Widen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Drawing2D.GraphicsPath
的用法示例。
在下文中一共展示了GraphicsPath.Widen方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Form2_Paint
private void Form2_Paint(object sender, PaintEventArgs e)
{
//패스 그래디언트
Point[] pts = { new Point(100, 0), new Point(0, 100), new Point(200, 100) };
PathGradientBrush B = new PathGradientBrush(pts, WrapMode.Tile);
e.Graphics.FillRectangle(B, ClientRectangle);
//패스 그래디언트 끝
//패스변형
GraphicsPath Path = new GraphicsPath();
Path.AddString("한글", new FontFamily("궁서"), 0, 100, new Point(10, 30), new StringFormat());
//확장 후 외곽선 그리기
Path.Widen(new Pen(Color.Black, 3));
e.Graphics.DrawPath(Pens.Black, Path);
//확장 후 채우기
Path.Widen(new Pen(Color.Blue, 3));
e.Graphics.DrawPath(Pens.Black, Path);
//곡선 펴기
Path.Flatten(new Matrix(), 12f);
e.Graphics.DrawPath(Pens.Black, Path);
//회전
Matrix M = new Matrix();
M.Rotate(-10);
Path.Transform(M);
e.Graphics.FillPath(Brushes.Blue, Path);
//휘기
RectangleF R = Path.GetBounds();
PointF[] arPoint = new PointF[4];
arPoint[0] = new PointF(R.Left, R.Top + 30);
arPoint[1] = new PointF(R.Right, R.Top - 10);
arPoint[2] = new PointF(R.Left + 10, R.Bottom - 10);
arPoint[3] = new PointF(R.Right + 30, R.Bottom + 30);
Path.Warp(arPoint, R);
e.Graphics.FillPath(Brushes.Blue, Path);
//클리핑
//graphicspath path= new graphicspath();
//path.fillmode = fillmode.winding;
//path.addellipse(50, 10, 100, 80);
//path.addellipse(20, 45, 160, 120);
//e.graphics.fillpath(brushes.white, path);
//e.graphics.setclip(path);
//for (int y = 0; y < bottom; y+= 20)
//{
// string str = "눈사람의 모양의클리핑 영역에 글자를 쓴것입니다";
// e.graphics.drawstring(str, font, brushes.blue, 0, y);
//}
//클리핑 끝
}
示例2: ContainsPoint
/// <summary>
/// Проверяет попадание точки в фигуру
/// </summary>
/// <param name="p"></param>
/// <returns>-1 - нет попадания, 0 - есть попадание, 1 и более - номер опорной точки в которую попал курсор</returns>
public override int ContainsPoint(Point p)
{
if (this.IsSelected)
{
for (int i = 1; i <= KeyPoints.Length; i++)
{
if (PaintHelper.GetKeyPointWhiteRect(KeyPoints[i - 1]).Contains(p))
return i;
}
}
var path = new GraphicsPath();
Pen pen = new Pen(DrawSettings.Color, DrawSettings.Thickness);
Rectangle rect = NormalRectToSquare(PaintHelper.NormalizeRect(StartPoint, EndPoint));
path.AddEllipse(rect);
path.Widen(pen);
Region region = new Region(path);
pen.Dispose();
if(region.IsVisible(p))
return 0;
Point center = new Point(rect.X + rect.Width / 2, rect.Y + rect.Height / 2);
double radius = rect.Width / 2;
float dx = p.X - center.X;
float dy = p.Y - center.Y;
if (Math.Sqrt(dx * dx + dy * dy) <= radius)
return 0;
return -1;
}
示例3: Draw
public new void Draw(Graphics g, PointF pntDrawOffset, Point pntMouseLocation, MouseButtons mbButtons) {
GraphicsPath gpSeekPosition = new GraphicsPath();
gpSeekPosition.AddLine(new PointF(6.0F, 2), new PointF(this.SeekerBounds.Width - this.SeekerPosition * (this.SeekerBounds.Width - 15) - 5, 2));
gpSeekPosition.Widen(this.m_pOneWidth);
this.DrawBwShape(g, gpSeekPosition, this.ButtonOpacity, 4.0F, Color.Black, ControlPaint.LightLight(Color.LightSeaGreen));
if (this.m_isMouseDown == true) {
if (pntMouseLocation.X < pntDrawOffset.X) {
this.SeekerPosition = 0.0F;
}
else if (pntMouseLocation.X > pntDrawOffset.X + this.SeekerBounds.Width - 15) {
this.SeekerPosition = 1.0F;
}
else {
this.SeekerPosition = (pntMouseLocation.X - pntDrawOffset.X - 6) / (this.SeekerBounds.Width - 15);
}
}
float xBeginningOffset = pntDrawOffset.X;
pntDrawOffset.X += this.SeekerPosition * (this.SeekerBounds.Width - 15);
this.HotSpot = new RectangleF(-pntDrawOffset.X + xBeginningOffset, -15, this.SeekerBounds.Width, 20);
base.Draw(g, pntDrawOffset, pntMouseLocation, mbButtons);
gpSeekPosition.Dispose();
}
示例4: ContainsInShape
//檢查座標是否圖形內
public override bool ContainsInShape(int x, int y)
{
GraphicsPath path = new GraphicsPath();
path.FillMode = FillMode.Winding;
path.AddLine(_locationOfPaintFirstPoint.X + _moveingXOffset, _locationOfPaintFirstPoint.Y + _moveingYOffset,_locationOfPaintEndPoint.X + _moveingXOffset, _locationOfPaintEndPoint.Y + _moveingYOffset);
path.Widen(_pen);
return path.IsVisible(x, y);
}
示例5: DrawHighlight
protected override void DrawHighlight(GraphicsPath graphicsPath, Graphics graphics)
{
if (Target)
{
using (var p = new Pen(Color.Black, 2))
{
graphicsPath.Widen(p);
}
return;
}
base.DrawHighlight(graphicsPath, graphics);
}
示例6: ContainsPoint
/// <summary>
/// Проверяет попадание точки в фигуру
/// </summary>
/// <param name="p"></param>
/// <returns>-1 - нет попадания, 0 - есть попадание, 1 и более - номер опорной точки в которую попал курсор</returns>
public int ContainsPoint(Point p)
{
if (this.IsSelected)
{
for (int i = 1; i <= KeyPoints.Length; i++)
{
if (PaintHelper.GetKeyPointWhiteRect(KeyPoints[i - 1]).Contains(p))
return i;
}
}
var path = new GraphicsPath();
Pen pen = new Pen(DrawSettings.Color, DrawSettings.Thickness);
path.AddCurve(points.ToArray());
path.Widen(pen);
Region region = new Region(path);
pen.Dispose();
if (region.IsVisible(p))
return 0;
return -1;
}
示例7: Widen_Pen_Matrix_NonInvertible
public void Widen_Pen_Matrix_NonInvertible ()
{
Matrix matrix = new Matrix (123, 24, 82, 16, 47, 30);
Assert.IsFalse (matrix.IsInvertible, "!IsInvertible");
GraphicsPath path = new GraphicsPath ();
path.Widen (new Pen (Color.Blue), matrix);
Assert.AreEqual (0, path.PointCount, "Points");
}
示例8: Widen_Pen_Matrix_Empty
public void Widen_Pen_Matrix_Empty ()
{
Pen pen = new Pen (Color.Blue);
GraphicsPath path = new GraphicsPath ();
path.AddPolygon (new Point[3] { new Point (5, 5), new Point (15, 5), new Point (10, 15) });
path.Widen (pen, new Matrix ());
Assert.AreEqual (9, path.PointCount, "Count");
CheckWiden3 (path);
}
示例9: GetBounds
public void GetBounds(Graphics g)
{
// Create path number 1 and a Pen for drawing.
GraphicsPath myPath = new GraphicsPath();
Pen pathPen = new Pen(Color.Black, 1);
// Add an Ellipse to the path and Draw it (circle in start
// position).
myPath.AddEllipse(20, 20, 100, 100);
g.DrawPath(pathPen, myPath);
// Get the path bounds for Path number 1 and draw them.
RectangleF boundRect = myPath.GetBounds();
g.DrawRectangle(new Pen(Color.Red, 1),
boundRect.X,
boundRect.Y,
boundRect.Height,
boundRect.Width);
// Create a second graphics path and a wider Pen.
GraphicsPath myPath2 = new GraphicsPath();
Pen pathPen2 = new Pen(Color.Black, 10);
// Create a new ellipse with a width of 10.
myPath2.AddEllipse(150, 20, 100, 100);
myPath2.Widen(pathPen2);
g.FillPath(Brushes.Black, myPath2);
// Get the second path bounds.
RectangleF boundRect2 = myPath2.GetBounds();
// Draw the bounding rectangle.
g.DrawRectangle(new Pen(Color.Red, 1),
boundRect2.X,
boundRect2.Y,
boundRect2.Height,
boundRect2.Width);
}
示例10: Draw
public void Draw(Graphics g, PointF pntDrawOffset, Point pntMouseLocation, MouseButtons mbButtons, Dictionary<Kill, KillDisplayDetails> dicKills, List<BattlemapRoundChange> lstRounds, KillDisplayColours colours, Dictionary<int, Color> teamColours)
{
GraphicsPath gpTimelineOutline = new GraphicsPath();
gpTimelineOutline.AddLines(new Point[] { new Point(5, 0), new Point(0, 5), new Point(0, 15), new Point((int)g.ClipBounds.Width - 280, 15), new Point((int)g.ClipBounds.Width - 280, 5), new Point((int)g.ClipBounds.Width - 275, 0) });
//gpTimelineOutline.AddLine(new Point(this.m_mtsSeek.SeekerPosition, 15), new Point((int)g.ClipBounds.Width - 280, 15));
//gpTimelineOutline.AddLines(new Point[] { new Point(235, (int)g.ClipBounds.Height - 55), new Point(230, (int)g.ClipBounds.Height - 50), new Point(230, (int)g.ClipBounds.Height - 40), new Point((int)g.ClipBounds.Width - 50, (int)g.ClipBounds.Height - 40), new Point((int)g.ClipBounds.Width - 50, (int)g.ClipBounds.Height - 50), new Point((int)g.ClipBounds.Width - 45, (int)g.ClipBounds.Height - 55) });
gpTimelineOutline.Widen(this.m_pOneWidth);
this.ObjectPath = gpTimelineOutline;
RectangleF recBounds = gpTimelineOutline.GetBounds();
recBounds.Height += 50.0F;
this.HotSpot = recBounds;
//string strMouseOverKillList = String.Empty;
float flMouseOffsetX = 0.0F;
bool blRoundChanged = false;
MapTextBlock timeList = new MapTextBlock();
foreach (BattlemapRoundChange RoundChange in new List<BattlemapRoundChange>(lstRounds)) {
float flOffsetXs = (this.HotSpot.Width - 5.0F) - ((float)((DateTime.Now.Ticks - RoundChange.ChangeTime.Ticks) / TimeSpan.TicksPerSecond) / 3600.0F) * (this.HotSpot.Width - 5.0F);
RectangleF recChangePosition = new RectangleF(flOffsetXs + this.m_pntDrawOffset.X - 2.0F, this.m_pntDrawOffset.Y, 4.0F, 20.0F);
if (flOffsetXs >= 0.0F) {
GraphicsPath gpChangeTime = new GraphicsPath();
gpChangeTime.AddLine(new PointF(flOffsetXs, 5), new PointF(flOffsetXs, 12));
gpChangeTime.Widen(this.m_pOneWidth);
this.DrawBwShape(g, gpChangeTime, this.TimelineOpacity, 4.0F, Color.Black, Color.RoyalBlue);
gpChangeTime.Dispose();
if (recChangePosition.Contains(new PointF(pntMouseLocation.X, pntMouseLocation.Y)) == true) {
//strMouseOverKillList += String.Format("Round change {0}\r\n", RoundChange.Map.PublicLevelName);
timeList.Strings.Add(new MapTextBlockString(String.Format("Round change {0}", RoundChange.Map.PublicLevelName), Color.Pink, true));
blRoundChanged = true;
flMouseOffsetX = flOffsetXs;
//flMouseOffsetX = flOffsetXs;
}
}
}
foreach (KeyValuePair<Kill, KillDisplayDetails> kvpKill in new Dictionary<Kill, KillDisplayDetails>(dicKills)) {
float flOffsetXs = (this.HotSpot.Width - 5.0F) - ((float)((DateTime.Now.Ticks - kvpKill.Key.TimeOfDeath.Ticks) / TimeSpan.TicksPerSecond) / 3600.0F) * (this.HotSpot.Width - 5.0F);
RectangleF recKillPosition = new RectangleF(flOffsetXs + this.m_pntDrawOffset.X - 2.0F, this.m_pntDrawOffset.Y, 4.0F, 20.0F);
if (recKillPosition.Contains(new PointF(pntMouseLocation.X + 5.0F, pntMouseLocation.Y)) == true) {
GraphicsPath gpKillTime = new GraphicsPath();
gpKillTime.AddLine(new PointF(flOffsetXs, 10), new PointF(flOffsetXs, 12));
gpKillTime.Widen(this.m_pOneWidth);
this.DrawBwShape(g, gpKillTime, this.TimelineOpacity, 4.0F, Color.Black, Color.RoyalBlue);
gpKillTime.Dispose();
Color killerColour = Color.White;
Color victimColour = Color.White;
if (colours == KillDisplayColours.EnemyColours) {
killerColour = ControlPaint.Light(Color.SeaGreen);
victimColour = ControlPaint.LightLight(Color.Black);
}
else if (colours == KillDisplayColours.TeamColours) {
if (teamColours.ContainsKey(kvpKill.Key.Killer.TeamID) == true && teamColours.ContainsKey(kvpKill.Key.Victim.TeamID) == true) {
killerColour = ControlPaint.Light(teamColours[kvpKill.Key.Killer.TeamID]);
victimColour = ControlPaint.Light(teamColours[kvpKill.Key.Victim.TeamID]);
}
}
if (kvpKill.Key.Killer.ClanTag.Length > 0) {
timeList.Strings.Add(new MapTextBlockString(String.Format("[{0}] ", kvpKill.Key.Killer.ClanTag), killerColour, false));
}
timeList.Strings.Add(new MapTextBlockString(kvpKill.Key.Killer.SoldierName, killerColour, false));
timeList.Strings.Add(new MapTextBlockString(String.Format("[{0}] ", kvpKill.Key.DamageType), Color.WhiteSmoke, false));
if (kvpKill.Key.Victim.ClanTag.Length > 0) {
timeList.Strings.Add(new MapTextBlockString(String.Format("[{0}] ", kvpKill.Key.Victim.ClanTag), victimColour, false));
}
timeList.Strings.Add(new MapTextBlockString(kvpKill.Key.Victim.SoldierName, victimColour, true));
flMouseOffsetX = flOffsetXs;
}
}
if (timeList.Strings.Count > 0) {
RectangleF recText = timeList.GetBounds();
PointF timeListOffset = new PointF(pntDrawOffset.X + flMouseOffsetX - recText.Width / 2.0F, pntDrawOffset.Y - recText.Height);
if (timeListOffset.X + recText.Width > g.ClipBounds.Width) {
timeListOffset.X = g.ClipBounds.Width - recText.Width;
}
timeList.Draw(g, timeListOffset, pntMouseLocation, mbButtons);
//.........这里部分代码省略.........
示例11: GetPath
/// <summary>
/// Gives the path where the hit test is successfull.
/// </summary>
/// <param name="layer"></param>
/// <param name="withTicks">If true, the selection path is not only drawn around the axis, but around the axis and the ticks.</param>
/// <returns>The graphics path of the selection rectangle.</returns>
protected GraphicsPath GetPath(XYPlotLayer layer, bool withTicks, float inflateby)
{
Logical3D r0 = _cachedAxisStyleInfo.Identifier.Begin;
Logical3D r1 = _cachedAxisStyleInfo.Identifier.End;
GraphicsPath gp = new GraphicsPath();
layer.CoordinateSystem.GetIsoline(gp, r0, r1);
if(withTicks)
{
if(this._showFirstDownMajorTicks || this._showFirstUpMajorTicks)
inflateby = Math.Max(inflateby,this._majorTickLength);
if(this._showFirstDownMinorTicks || this._showFirstUpMinorTicks)
inflateby = Math.Max(inflateby,this._minorTickLength);
}
Pen widenPen = new Pen(Color.Black, 2*inflateby);
gp.Widen(widenPen);
return gp;
}
示例12: GetGrips
public override IGripManipulationHandle[] GetGrips(double pageScale, int gripLevel)
{
if (gripLevel <= 1)
{
LineShape ls = (LineShape)_hitobject;
PointF[] pts = new PointF[] { new PointF(0, 0), new PointF((float)ls.Width, (float)ls.Height) };
for (int i = 0; i < pts.Length; i++)
{
var pt = ls._transformation.TransformPoint(pts[i]);
pt = this.Transformation.TransformPoint(pt);
pts[i] = pt;
}
IGripManipulationHandle[] grips = new IGripManipulationHandle[gripLevel == 0 ? 1 : 3];
// Translation grips
GraphicsPath path = new GraphicsPath();
path.AddLine(pts[0], pts[1]);
path.Widen(new Pen(Color.Black, (float)(6 / pageScale)));
grips[0] = new MovementGripHandle(this, path, null);
// PathNode grips
if (gripLevel == 1)
{
grips[2] = grips[0]; // put the movement grip to the background, the two NodeGrips need more priority
float gripRadius = (float)(3 / pageScale);
grips[0] = new PathNodeGripHandle(this, new PointF(0, 0), pts[0], gripRadius);
grips[1] = new PathNodeGripHandle(this, new PointF(1, 1), pts[1], gripRadius);
}
return grips;
}
else
{
return base.GetGrips(pageScale, gripLevel);
}
}
示例13: PointInLine
bool PointInLine(Point[] line, Point pt)
{
Pen p = new Pen(Color.Black, 4);
GraphicsPath gp = new GraphicsPath();
gp.AddLine(line[0], line[1]);
gp.Widen(p);
p.Dispose();
return gp.IsVisible(pt);
}
示例14: DrawScale
private void DrawScale(Graphics g) {
if (this.LoadedMapImagePack != null) {
// Move to class so they are not declared every paint.
/* FontFamily family = new FontFamily("Arial");
int fontStyle = (int)FontStyle.Regular;
int emSize = 12;
StringFormat format = StringFormat.GenericDefault;
*/
GraphicsPath gpScale = new GraphicsPath();
GraphicsPath gpScaleUnits = new GraphicsPath();
gpScale.AddLine(new Point(10, (int)g.ClipBounds.Height - 50), new Point(10, (int)g.ClipBounds.Height - 30));
gpScale.AddLine(new Point(10, (int)g.ClipBounds.Height - 40), new Point(200, (int)g.ClipBounds.Height - 40));
gpScale.Widen(this.m_pOneWidth);
gpScaleUnits.AddString("m", this.family, this.fontStyle, this.emSize, new Point(4, (int)g.ClipBounds.Height - 65), this.format);
gpScaleUnits.AddString("yd", this.family, this.fontStyle, this.emSize, new Point(1, (int)g.ClipBounds.Height - 30), this.format);
// Only interested in horizontal
double dblMetrePixels = this.LoadedMapImagePack.MapScale.X * this.ZoomFactor;
for (double i = 0.0D; i < 16.0D; i++) {
double dblMetres = Math.Pow(2, i);
// Metres
int iOffset = (int)Math.Round(dblMetres * dblMetrePixels);
if (iOffset >= 15 && 10 + iOffset <= 200) {
GraphicsPath gpScaleMarkerLine = new GraphicsPath();
GraphicsPath gpScaleMarker = new GraphicsPath();
gpScaleMarker.AddString(String.Format("{0:0}", dblMetres), this.family, this.fontStyle, this.emSize, new Point(4 + iOffset, (int)g.ClipBounds.Height - 60), this.format);
gpScaleMarkerLine.AddLine(new Point(10 + iOffset, (int)g.ClipBounds.Height - 45), new Point(10 + iOffset, (int)g.ClipBounds.Height - 40));
gpScaleMarkerLine.Widen(this.m_pOneWidth);
this.DrawBwShape(g, gpScaleMarkerLine, 1.0F);
this.DrawBwShape(g, gpScaleMarker, 1.0F);
gpScaleMarkerLine.Dispose();
gpScaleMarker.Dispose();
}
// Yards
iOffset = (int)Math.Round(dblMetres * (dblMetrePixels / 1.0936133D));
if (iOffset >= 15 && 10 + iOffset <= 200) {
GraphicsPath gpScaleMarkerLine = new GraphicsPath();
GraphicsPath gpScaleMarker = new GraphicsPath();
gpScaleMarker.AddString(String.Format("{0:0}", dblMetres), this.family, this.fontStyle, this.emSize, new Point(4 + iOffset, (int)g.ClipBounds.Height - 32), this.format);
gpScaleMarkerLine.AddLine(new Point(10 + iOffset, (int)g.ClipBounds.Height - 35), new Point(10 + iOffset, (int)g.ClipBounds.Height - 40));
gpScaleMarkerLine.Widen(this.m_pOneWidth);
this.DrawBwShape(g, gpScaleMarkerLine, 1.0F);
this.DrawBwShape(g, gpScaleMarker, 1.0F);
gpScaleMarkerLine.Dispose();
gpScaleMarker.Dispose();
}
}
//gpScale.AddLine(new Point(10, (int)g.ClipBounds.Height - 20), new Point(10, (int)g.ClipBounds.Height - 10));
//gpScale.AddLine(new Point(10, (int)g.ClipBounds.Height - 10), new Point(60, (int)g.ClipBounds.Height - 10));
//gpScale.AddLine(new Point(10, (int)g.ClipBounds.Height - 20), new Point(60, (int)g.ClipBounds.Height - 20));
this.DrawBwShape(g, gpScale, 1.0F);
this.DrawBwShape(g, gpScaleUnits, 1.0F);
gpScale.Dispose();
gpScaleUnits.Dispose();
//g.DrawLine(Pens.White, new Point(10, (int)g.ClipBounds.Height - 10), new Point(60, (int)g.ClipBounds.Height - 10));
}
}
示例15: DrawMeasuringResults
private void DrawMeasuringResults(Graphics g) {
if (this.LoadedMapImagePack != null) {
// Move to class so they are not declared every paint.
/* FontFamily family = new FontFamily("Arial");
int fontStyle = (int)FontStyle.Regular;
int emSize = 12;
StringFormat format = StringFormat.GenericDefault;
*/
//double dblMetrePixels = this.ZoomFactor;
if (this.LoadedMapImagePack.MapScale.X != 0.0F && this.LoadedMapImagePack.MapScale.Y != 0.0F && this.ZoomFactor != 0.0F && (this.m_pntStart.X != this.m_pntEnd.X || this.m_pntStart.Y != this.m_pntEnd.Y)) {
double dx = (this.m_pntStart.X - this.m_pntEnd.X) / (this.LoadedMapImagePack.MapScale.X * this.ZoomFactor);
double dy = (this.m_pntStart.Y - this.m_pntEnd.Y) / (this.LoadedMapImagePack.MapScale.Y * this.ZoomFactor);
double dblMetresDistance = Math.Sqrt(dx * dx + dy * dy);
//double dblMetresDistance = dblPixelDistance / dblMetrePixels;
GraphicsPath gpMeasuringResultsLine = new GraphicsPath();
gpMeasuringResultsLine.AddLine(this.m_pntStart, this.m_pntEnd);
gpMeasuringResultsLine.Widen(this.m_pOneWidth);
this.DrawBwShape(g, gpMeasuringResultsLine, 1.0F);
gpMeasuringResultsLine.Dispose();
GraphicsPath gpMeasuringResults = new GraphicsPath();
gpMeasuringResults.AddString(String.Format("{0:0.0} m\n{1:0.0} yd", dblMetresDistance, dblMetresDistance * 1.0936133D), this.family, this.fontStyle, this.emSize, new PointF(this.m_pntEnd.X, this.m_pntEnd.Y - 25), this.format);
this.DrawBwShape(g, gpMeasuringResults, 1.0F);
gpMeasuringResults.Dispose();
}
//family.Dispose();
}
}