本文整理汇总了C#中System.Drawing.Drawing2D.GraphicsPath.Reset方法的典型用法代码示例。如果您正苦于以下问题:C# GraphicsPath.Reset方法的具体用法?C# GraphicsPath.Reset怎么用?C# GraphicsPath.Reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Drawing2D.GraphicsPath
的用法示例。
在下文中一共展示了GraphicsPath.Reset方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Analyzer
public Analyzer(double meanX, double meanY, GraphicsPath path)
{
Counters = new RunningCount[Enum.GetValues(typeof(AnalysisMetric)).Length];
foreach(AnalysisMetric metric in Enum.GetValues(typeof(AnalysisMetric)))
Counters[(int)metric] = new RunningCount(metric);
MeanX = meanX;
MeanY = meanY;
path.Flatten();
using(GraphicsPathIterator PathIterator = new GraphicsPathIterator(path))
{
using(GraphicsPath Subpath = new GraphicsPath())
{
Paths = new List<PointF[]>();
bool Closed;
while(PathIterator.NextSubpath(Subpath, out Closed) > 0)
{
Paths.Add(Subpath.PathPoints);
Subpath.Reset();
}
}
}
}
示例2: WarpPath
public static void WarpPath(GraphicsPath path, PointF[] destPoints, RectangleF srcRect, Matrix matrix = null, WarpMode warpMode = WarpMode.Perspective, float flatness = 0.25f)
{
if (path.PointCount == 0)
return;
path.Flatten(matrix, flatness);
var pathData = path.PathData;
var pnts = path.PathPoints;
var srcPoints = new PointF[] { new PointF(srcRect.Left, srcRect.Top),
new PointF(srcRect.Right, srcRect.Top),
new PointF(srcRect.Left, srcRect.Bottom),
new PointF(srcRect.Right, srcRect.Bottom) };
var count = pnts.Length;
float x1, y1;
int i;
if (warpMode == WarpMode.Perspective)
{
CalcProjectiveXformCoeffs(srcPoints, destPoints, out coeffs);
for (i = 0; i < count; i++)
{
x1 = pnts[i].X;
y1 = pnts[i].Y;
var factor = 1.0f / (coeffs[6] * x1 + coeffs[7] * y1 + 1.0f);
pnts[i].X = (float)(factor * (coeffs[0] * x1 + coeffs[1] * y1 + coeffs[2]));
pnts[i].Y = (float)(factor * (coeffs[3] * x1 + coeffs[4] * y1 + coeffs[5]));
}
}
else
{
CalcBilinearXformCoeffs(srcPoints, destPoints, out coeffs);
for (i = 0; i < count; i++)
{
x1 = pnts[i].X;
y1 = pnts[i].Y;
pnts[i].X = (float)(coeffs[0] * x1 + coeffs[1] * y1 + coeffs[2] * x1 * y1 + coeffs[3]);
pnts[i].Y = (float)(coeffs[4] * x1 + coeffs[5] * y1 + coeffs[6] * x1 * y1 + coeffs[7]);
}
}
GraphicsPath warpedPath = new GraphicsPath(pnts, pathData.Types);
if (warpedPath != null)
{
FillMode fm = path.FillMode;
path.Reset();
path.FillMode = fm;
path.AddPath(warpedPath, true);
warpedPath.Dispose();
}
}
示例3: Form1_Paint
private void Form1_Paint(object sender, PaintEventArgs e)
{
//if (scythians.Count <= 2) return;
GraphicsPath path = new GraphicsPath();
Pen pen = new Pen(Color.Black, 3F);
foreach(KeyValuePair<int, List<PointF>> list in scythians)
{
path.AddLines(list.Value.ToArray());
path.CloseFigure();
e.Graphics.DrawPath(pen, path);
e.Graphics.DrawString(list.Key.ToString() + " год", Font, Brushes.Maroon, list.Value[0].X+50, list.Value[0].Y);
path.Reset();
pen.Color = Color.FromArgb(pen.Color.R + 10, pen.Color.G + 10, pen.Color.G + 10);
}
path.Reset();
pen.Color = Color.Red;
pen.Width = 5;
path.AddLines(scythians[trackBar1.Value].ToArray());
path.CloseFigure();
e.Graphics.DrawPath(pen, path);
}
示例4: RenderArcScaleNumbers
public static void RenderArcScaleNumbers(
this Graphics graphics,
Rectangle ClientRectangle,
Font Font,
Color ForeColor,
FontBound.BoundDef FontBound,
Point Center,
Int32 Radius,
Single MinimumValue,
Single MaximumValue,
String Format,
Int32 StartScaleLine,
Single MajorStepValue,
Int32 ArcStart,
Int32 ArcSweep,
ArcOriantationTypeEnum Orientation
)
{
using (var graphicsPath = new GraphicsPath()) {
graphics.SetClip(ClientRectangle);
Single countValue = 0;
Int32 counter1 = 0;
while (countValue <= (MaximumValue - MinimumValue)) {
graphics.ResetTransform();
graphicsPath.Reset();
var valueText = (MinimumValue + countValue).ToString(Format);
var boundingBox = graphics.MeasureString(valueText, Font, -1, StringFormat.GenericTypographic);
if (Orientation != ArcOriantationTypeEnum.Horizontal) {
graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
graphics.RotateTransform(90.0F + ArcStart + countValue * ArcSweep / (MaximumValue - MinimumValue));
}
graphics.TranslateTransform(
(Single)(Center.X + Radius * Math.Cos((ArcStart + countValue * ArcSweep / (MaximumValue - MinimumValue)) * Math.PI / 180.0f)),
(Single)(Center.Y + Radius * Math.Sin((ArcStart + countValue * ArcSweep / (MaximumValue - MinimumValue)) * Math.PI / 180.0f)),
System.Drawing.Drawing2D.MatrixOrder.Append
);
if (counter1 >= StartScaleLine - 1)
graphics.DrawString(valueText, Font, new SolidBrush(ForeColor), -boundingBox.Width / 2, -FontBound.Y1 - (FontBound.Y2 - FontBound.Y1 + 1) / 2, StringFormat.GenericTypographic);
countValue += MajorStepValue;
counter1++;
graphics.ResetTransform();
}
}
}
示例5: DrawGraphics
public override void DrawGraphics(Graphics destination)
{
DrawGraphics();
using (var gfxPath = new GraphicsPath())
using (var brush = Style.CreateBrush())
using (var pen = Style.CreatePen())
{
gfxPath.Reset();
gfxPath.AddLine(Edges[0].Points[0], Edges[0].Points[1]);
gfxPath.AddLine(Edges[1].Points[0], Edges[1].Points[1]);
gfxPath.AddLine(Edges[2].Points[0], Edges[2].Points[1]);
gfxPath.AddLine(Edges[3].Points[0], Edges[3].Points[1]);
destination.FillPath(brush, gfxPath);
//destination.DrawPath(pen, gfxPath);
}
EditablegeometryCue.DrawGeometry(destination);
}
示例6: ArcRenderRange
private static void ArcRenderRange(this Graphics Graphics, Rectangle ClientRectangle, Point Center, Int32 ArcStart, Int32 ArcSweep, Single MinimumValue, Single MaximumValue, ArcRangeDef Range)
{
Graphics.SetClip(ClientRectangle);
Graphics.SmoothingMode = SmoothingMode.HighQuality;
Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
using (var graphicsPath = new GraphicsPath()) {
if (Range.EndValue > Range.StartValue && Range.Enabled) {
var rangeStartAngle = ArcStart + (Range.StartValue - MinimumValue) * ArcSweep / (MaximumValue - MinimumValue);
var rangeSweepAngle = (Range.EndValue - Range.StartValue) * ArcSweep / (MaximumValue - MinimumValue);
graphicsPath.Reset();
graphicsPath.AddPie(new Rectangle(Center.X - Range.OuterRadius, Center.Y - Range.OuterRadius, 2 * Range.OuterRadius, 2 * Range.OuterRadius), rangeStartAngle, rangeSweepAngle);
graphicsPath.Reverse();
graphicsPath.AddPie(new Rectangle(Center.X - Range.InnerRadius, Center.Y - Range.InnerRadius, 2 * Range.InnerRadius, 2 * Range.InnerRadius), rangeStartAngle, rangeSweepAngle);
graphicsPath.Reverse();
Graphics.SetClip(graphicsPath);
using (var solidBrush = new SolidBrush(Range.ForeColor)) {
Graphics.FillPie(solidBrush, new Rectangle(Center.X - Range.OuterRadius, Center.Y - Range.OuterRadius, 2 * Range.OuterRadius, 2 * Range.OuterRadius), rangeStartAngle, rangeSweepAngle);
}
}
}
}
示例7: DrawBitmap
//---------------------------------------------------------------------------
private void DrawBitmap(bool justClip = false)
{
if (!justClip)
{
if (rbTest2.Checked)
GenerateAustPlusRandomEllipses((int)nudCount.Value);
else
GenerateRandomPolygon((int)nudCount.Value);
}
Cursor.Current = Cursors.WaitCursor;
Graphics newgraphic;
newgraphic = Graphics.FromImage(mybitmap);
newgraphic.SmoothingMode = SmoothingMode.AntiAlias;
newgraphic.Clear(Color.White);
GraphicsPath path = new GraphicsPath();
if (rbNonZero.Checked) path.FillMode = FillMode.Winding;
//draw subjects ...
foreach (Polygon pg in subjects)
{
PointF[] pts = PolygonToPointFArray(pg, scale);
path.AddPolygon(pts);
pts = null;
}
Pen myPen = new Pen(Color.FromArgb(196, 0xC3, 0xC9, 0xCF), (float)0.6);
SolidBrush myBrush = new SolidBrush(Color.FromArgb(127, 0xDD, 0xDD, 0xF0));
newgraphic.FillPath(myBrush, path);
newgraphic.DrawPath(myPen, path);
path.Reset();
//draw clips ...
if (rbNonZero.Checked) path.FillMode = FillMode.Winding;
foreach (Polygon pg in clips)
{
PointF[] pts = PolygonToPointFArray(pg, scale);
path.AddPolygon(pts);
pts = null;
}
myPen.Color = Color.FromArgb(196, 0xF9, 0xBE, 0xA6);
myBrush.Color = Color.FromArgb(127, 0xFF, 0xE0, 0xE0);
newgraphic.FillPath(myBrush, path);
newgraphic.DrawPath(myPen, path);
//do the clipping ...
if ((clips.Count > 0 || subjects.Count > 0) && !rbNone.Checked)
{
Polygons solution2 = new Polygons();
Clipper c = new Clipper();
c.AddPolygons(subjects, PolyType.ptSubject);
c.AddPolygons(clips, PolyType.ptClip);
exSolution.Clear();
solution.Clear();
bool succeeded = c.Execute(GetClipType(), solution, GetPolyFillType(), GetPolyFillType());
if (succeeded)
{
myBrush.Color = Color.Black;
path.Reset();
//It really shouldn't matter what FillMode is used for solution
//polygons because none of the solution polygons overlap.
//However, FillMode.Winding will show any orientation errors where
//holes will be stroked (outlined) correctly but filled incorrectly ...
path.FillMode = FillMode.Winding;
//or for something fancy ...
if (nudOffset.Value != 0)
solution2 = Clipper.OffsetPolygons(solution, (double)nudOffset.Value * scale, JoinType.jtMiter);
else
solution2 = new Polygons(solution);
foreach (Polygon pg in solution2)
{
PointF[] pts = PolygonToPointFArray(pg, scale);
if (pts.Count() > 2)
path.AddPolygon(pts);
pts = null;
}
myBrush.Color = Color.FromArgb(127, 0x66, 0xEF, 0x7F);
myPen.Color = Color.FromArgb(255, 0, 0x33, 0);
myPen.Width = 1.0f;
newgraphic.FillPath(myBrush, path);
newgraphic.DrawPath(myPen, path);
//now do some fancy testing ...
Font f = new Font("Arial", 8);
SolidBrush b = new SolidBrush(Color.Navy);
double subj_area = 0, clip_area = 0, int_area = 0, union_area = 0;
c.Clear();
c.AddPolygons(subjects, PolyType.ptSubject);
c.Execute(ClipType.ctUnion, solution2, GetPolyFillType(), GetPolyFillType());
foreach (Polygon pg in solution2) subj_area += Clipper.Area(pg);
c.Clear();
c.AddPolygons(clips, PolyType.ptClip);
c.Execute(ClipType.ctUnion, solution2, GetPolyFillType(), GetPolyFillType());
foreach (Polygon pg in solution2) clip_area += Clipper.Area(pg);
c.AddPolygons(subjects, PolyType.ptSubject);
c.Execute(ClipType.ctIntersection, solution2, GetPolyFillType(), GetPolyFillType());
foreach (Polygon pg in solution2) int_area += Clipper.Area(pg);
//.........这里部分代码省略.........
示例8: CreateVerifyCodeImage
/// <summary>创建验证码图片</summary>
/// <param name="verifyCodeImageInfo">验证码图片信息</param>
public void CreateVerifyCodeImage(VerifyCodeImageInfo verifyCodeImageInfo)
{
int textLength = verifyCodeImageInfo.Text.Length;
if(textLength == 0 || verifyCodeImageInfo.ImageWidth == 0 || verifyCodeImageInfo.ImageHeight == 0) return;
using(Bitmap img = new Bitmap(verifyCodeImageInfo.ImageWidth, verifyCodeImageInfo.ImageHeight, PixelFormat.Format32bppArgb))
{
using(GraphicsPath p = new GraphicsPath())
{
using(Graphics g = Graphics.FromImage(img))
{
g.SmoothingMode = SmoothingMode.AntiAlias;
g.Clear(verifyCodeImageInfo.BackgroundColor);
int charSize = (int)(Math.Min(verifyCodeImageInfo.ImageHeight, (int)(verifyCodeImageInfo.ImageWidth / textLength)) * 0.8);
PointF charPoint = new PointF();
int halfCharSize = (int)(charSize * 0.5f);
int paddingHeight = (int)(verifyCodeImageInfo.ImageHeight * 0.8) - charSize;
using(Matrix matrix = new Matrix())
{
using(Pen pen = new Pen(Color.Empty))
{
using(StringFormat format = new StringFormat())
{
format.Alignment = StringAlignment.Near;
format.LineAlignment = StringAlignment.Near;
FontFamily f;
for(int i = 0; i < textLength; i++)
{
charPoint.X = (float)(i * charSize + Utils.Rand((int)(charSize * 0.2f), (int)(charSize * 0.8f)));
charPoint.Y = (float)Utils.Rand(2, paddingHeight);
p.Reset();
float fs = charSize * Utils.Rand(80, 120) * 0.01f;
f = GetFontFamily(verifyCodeImageInfo.Fonts);
p.AddString(verifyCodeImageInfo.Text[i].ToString(), f, 0, fs, new Point(0, 0), format);
matrix.Reset();
matrix.RotateAt((float)Utils.Rand(-60, 60), new PointF(charPoint.X + halfCharSize, charPoint.Y + halfCharSize));
matrix.Translate(charPoint.X, charPoint.Y);
p.Transform(matrix);
pen.Color = GetTextColor(verifyCodeImageInfo.RandomTextColor, verifyCodeImageInfo.TextColor);
pen.Width = Utils.Rand(1, 2);
g.DrawPath(pen, p);
g.DrawBezier(pen,
Utils.Rand(verifyCodeImageInfo.ImageWidth),
Utils.Rand(verifyCodeImageInfo.ImageHeight),
Utils.Rand(verifyCodeImageInfo.ImageWidth),
Utils.Rand(verifyCodeImageInfo.ImageHeight),
Utils.Rand(verifyCodeImageInfo.ImageWidth),
Utils.Rand(verifyCodeImageInfo.ImageHeight),
Utils.Rand(verifyCodeImageInfo.ImageWidth),
Utils.Rand(verifyCodeImageInfo.ImageHeight));
}
}
pen.Color = GetTextColor(verifyCodeImageInfo.RandomTextColor, verifyCodeImageInfo.TextColor);
pen.Width = Utils.Rand(1, 2);
g.DrawBezier(pen,
Utils.Rand(verifyCodeImageInfo.ImageWidth),
0,
Utils.Rand(verifyCodeImageInfo.ImageWidth),
Utils.Rand(verifyCodeImageInfo.ImageHeight),
Utils.Rand(verifyCodeImageInfo.ImageWidth),
Utils.Rand(verifyCodeImageInfo.ImageHeight),
Utils.Rand(verifyCodeImageInfo.ImageWidth),
verifyCodeImageInfo.ImageHeight);
pen.Width = Utils.Rand(1, 2);
pen.Color = GetTextColor(verifyCodeImageInfo.RandomTextColor, verifyCodeImageInfo.TextColor);
g.DrawBezier(pen,
0,
Utils.Rand(verifyCodeImageInfo.ImageHeight),
Utils.Rand(verifyCodeImageInfo.ImageWidth),
Utils.Rand(verifyCodeImageInfo.ImageHeight),
Utils.Rand(verifyCodeImageInfo.ImageWidth),
Utils.Rand(verifyCodeImageInfo.ImageHeight),
verifyCodeImageInfo.ImageWidth,
Utils.Rand(verifyCodeImageInfo.ImageHeight));
}
}
}
}
verifyCodeImageInfo.ImageData = img.Clone() as Image;
}
}
示例9: Draw
public override void Draw(Graphics g, RectangleD worldRect, Rectangle canvasRect)
{
if (Hidden) return;
base.Draw(g, worldRect, canvasRect);
var pen = new Pen(LineColor ?? ForeColor, LineWidth);
var brush = new SolidBrush(BackColor);
var path = new GraphicsPath();
var path2 = new GraphicsPath();
pen.Alignment = PenAlignment.Center;
if (LineDashStyle.HasValue)
pen.DashStyle = LineDashStyle.Value;
else
pen.DashStyle = (DashStyle)Enum.Parse(typeof(DashStyle), LineStyle.ToString());
if (pen.DashStyle == DashStyle.Custom)
pen.DashPattern = dashPattern;
var markerPen = new Pen(ColorMarker);
// измерить расстояние между маркерами в пикселях
var markerSpanPointsView = MarkerSpanPoints;
if (MinPixelsBetweenMarkers > 0)
{
for (var i = 0; i < 10; i++)
{
var sizeUnit = Conversion.WorldToScreen(new SizeD(markerSpanPointsView, 0), worldRect, canvasRect);
if (sizeUnit.Width >= MinPixelsBetweenMarkers) break;
markerSpanPointsView *= markerSpanPointsMultiplier;
}
}
using (pen)
{
using (brush)
{
using (path)
{
using (path2)
{
using (markerPen)
{
PointF tf;
PointF tf2;
if (Data.BarCount > 0)
{
tf =
(PointF)
Conversion.WorldToScreen(
new PointD(Data.StartIndex,
Data[Data.StartIndex]), worldRect, canvasRect);
path2.AddLine(tf.X, canvasRect.Bottom, tf.X, tf.Y);
}
// разлиновать
if (Data.StartIndex < Data.LastIndex && markerSpanPointsView > 0)
{
for (var i = Data.StartIndex; i <= Data.LastIndex; i += markerSpanPointsView)
{
var pointTop = (PointF) Conversion.WorldToScreen(
new PointD(
i + ShiftX,
0),
worldRect, canvasRect);
pointTop.Y = canvasRect.Top;
var pointBottom = new PointF(pointTop.X, canvasRect.Bottom);
g.DrawLine(markerPen, pointTop, pointBottom);
}
}
// построить график
var startIndex = Math.Max(Data.StartIndex, (int)Chart.StockPane.WorldRect.Left);
var endIndex = Math.Min(Data.LastIndex, (int) Chart.StockPane.WorldRect.Right);
for (var i = startIndex + 1; i <= endIndex; i++)
{
if (double.IsNaN(Data[i - 1]) || double.IsNaN(Data[i]))
{
g.DrawPath(pen, path);
path.Reset();
continue;
}
tf =
(PointF)
Conversion.WorldToScreen(
new PointD((i - 1 - 1) + ShiftX,
Data[i - 1]),
worldRect,
canvasRect);
tf2 =
(PointF)
Conversion.WorldToScreen(new PointD(i - 1 + ShiftX,
Data[i]), worldRect, canvasRect);
path2.AddLine(tf, tf2);
path.AddLine(tf, tf2);
}
if (Data.BarCount > 0)
{
if (Data[Data.LastIndex] != double.NaN)
{
tf2 =
//.........这里部分代码省略.........
示例10: DrawCursor
//.........这里部分代码省略.........
bandpassWidth = cursorWidth - bandpassOffset;
_lower = xCarrier - bandpassOffset - bandpassWidth;
break;
case BandType.Center:
_lower = xCarrier - cursorWidth / 2;
bandpassWidth = cursorWidth;
break;
}
_upper = _lower + bandpassWidth;
using (var transparentBackground = new SolidBrush(Color.FromArgb(80, Color.DarkGray)))
using (var redPen = new Pen(Color.Red))
using (var graphics = Graphics.FromImage(_buffer))
using (var fontFamily = new FontFamily("Arial"))
using (var path = new GraphicsPath())
using (var outlinePen = new Pen(Color.Black))
{
if (_enableFilter && cursorWidth < ClientRectangle.Width)
{
var carrierPen = redPen;
carrierPen.Width = CarrierPenWidth;
graphics.FillRectangle(transparentBackground, (int) _lower + 1, 0, (int) bandpassWidth, ClientRectangle.Height);
if (xCarrier >= AxisMargin && xCarrier <= ClientRectangle.Width - AxisMargin)
{
graphics.DrawLine(carrierPen, xCarrier, 0f, xCarrier, ClientRectangle.Height);
}
}
if (_markPeaks && _spectrumWidth > 0)
{
var windowSize = (int) bandpassWidth;
windowSize = Math.Max(windowSize, 10);
windowSize = Math.Min(windowSize, _scaledSpectrum.Length);
PeakDetector.GetPeaks(_scaledSpectrum, _peaks, windowSize);
var yIncrement = (ClientRectangle.Height - 2 * AxisMargin) / (float) byte.MaxValue;
for (var i = 0; i < _peaks.Length; i++)
{
if (_peaks[i])
{
var y = (int) (ClientRectangle.Height - AxisMargin - _scaledSpectrum[i] * yIncrement);
var x = i + AxisMargin;
graphics.DrawEllipse(Pens.Yellow, x - 5, y - 5, 10, 10);
}
}
}
if (_hotTrackNeeded && _trackingX >= AxisMargin && _trackingX <= ClientRectangle.Width - AxisMargin &&
_trackingY >= AxisMargin && _trackingY <= ClientRectangle.Height - AxisMargin)
{
if (_scaledSpectrum != null && !_changingFrequency && !_changingCenterFrequency && !_changingBandwidth)
{
var index = _trackingX - AxisMargin;
if (_useSnap)
{
// Todo: snap the index
}
if (index > 0 && index < _scaledSpectrum.Length)
{
graphics.DrawLine(redPen, _trackingX, 0, _trackingX, ClientRectangle.Height);
}
}
string fstring;
if (_changingFrequency)
{
fstring = "VFO = " + GetFrequencyDisplay(_frequency);
}
else if (_changingBandwidth)
{
fstring = "BW = " + GetFrequencyDisplay(_filterBandwidth);
}
else if (_changingCenterFrequency)
{
fstring = "Center Freq. = " + GetFrequencyDisplay(_centerFrequency);
}
else
{
fstring = string.Format("{0}\r\n{1:0.##}dB", GetFrequencyDisplay(_trackingFrequency), _trackingPower);
}
path.AddString(fstring, fontFamily, (int)FontStyle.Regular, TrackingFontSize, Point.Empty, StringFormat.GenericTypographic);
var stringSize = path.GetBounds();
var currentCursor = Cursor.Current;
var xOffset = _trackingX + 15.0f;
var yOffset = _trackingY + (currentCursor == null ? DefaultCursorHeight : currentCursor.Size.Height) - 8.0f;
xOffset = Math.Min(xOffset, ClientRectangle.Width - stringSize.Width - 5);
yOffset = Math.Min(yOffset, ClientRectangle.Height - stringSize.Height - 5);
path.Reset();
path.AddString(fstring, fontFamily, (int)FontStyle.Regular, TrackingFontSize, new Point((int)xOffset, (int)yOffset), StringFormat.GenericTypographic);
var smoothingMode = graphics.SmoothingMode;
var interpolationMode = graphics.InterpolationMode;
graphics.SmoothingMode = SmoothingMode.AntiAlias;
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
outlinePen.Width = 2;
graphics.DrawPath(outlinePen, path);
graphics.FillPath(Brushes.White, path);
graphics.SmoothingMode = smoothingMode;
graphics.InterpolationMode = interpolationMode;
}
}
}
示例11: GenerateImageFromTextWithStyleInner
//.........这里部分代码省略.........
if (sb.Length > 0)
{
lastText.Append(sb);
TextDraw.DrawText(font, sf, path, sb, isItalic, parameter.SubtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint);
}
if (path.PointCount > 0)
{
var list = (PointF[])path.PathPoints.Clone(); // avoid using very slow path.PathPoints indexer!!!
for (int k = oldPathPointIndex; k < list.Length; k++)
{
if (list[k].X > addLeft)
{
addLeft = list[k].X;
}
}
}
if (path.PointCount == 0)
{
addLeft = left;
}
else if (addLeft < 0.01)
{
addLeft = left + 2;
}
left = addLeft;
DrawShadowAndPath(parameter, g, path);
var p2 = new SolidBrush(c);
g.FillPath(p2, path);
p2.Dispose();
path.Reset();
path = new GraphicsPath();
sb = new StringBuilder();
int endIndex = text.Substring(i).IndexOf('>');
if (endIndex < 0)
{
i += 9999;
}
else
{
string fontContent = text.Substring(i, endIndex);
if (fontContent.Contains(" color="))
{
string[] arr = fontContent.Substring(fontContent.IndexOf(" color=", StringComparison.Ordinal) + 7).Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
if (arr.Length > 0)
{
string fontColor = arr[0].Trim('\'').Trim('"').Trim('\'');
try
{
colorStack.Push(c); // save old color
if (fontColor.StartsWith("rgb(", StringComparison.Ordinal))
{
arr = fontColor.Remove(0, 4).TrimEnd(')').Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
c = Color.FromArgb(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2]));
}
else
{
c = ColorTranslator.FromHtml(fontColor);
}
}
catch
{
示例12: GenerateImageFromTextWithStyle
//.........这里部分代码省略.........
int newLinePathPoint = -1;
Color c = _subtitleColor;
var colorStack = new Stack<Color>();
var lastText = new StringBuilder();
while (i < text.Length)
{
if (text.Substring(i).StartsWith("<font ", StringComparison.OrdinalIgnoreCase))
{
float addLeft = 0;
int oldPathPointIndex = path.PointCount;
if (oldPathPointIndex < 0)
oldPathPointIndex = 0;
if (sb.Length > 0)
{
TextDraw.DrawText(font, sf, path, sb, isItalic, subtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint);
}
if (path.PointCount > 0)
{
PointF[] list = (PointF[])path.PathPoints.Clone(); // avoid using very slow path.PathPoints indexer!!!
for (int k = oldPathPointIndex; k < list.Length; k++)
{
if (list[k].X > addLeft)
addLeft = list[k].X;
}
}
if (addLeft == 0)
addLeft = left + 2;
left = addLeft;
if (_borderWidth > 0)
g.DrawPath(new Pen(_borderColor, _borderWidth), path);
g.FillPath(new SolidBrush(c), path);
path.Reset();
path = new GraphicsPath();
sb = new StringBuilder();
int endIndex = text.Substring(i).IndexOf('>');
if (endIndex < 0)
{
i += 9999;
}
else
{
string fontContent = text.Substring(i, endIndex);
if (fontContent.Contains(" color="))
{
var arr = fontContent.Substring(fontContent.IndexOf(" color=", StringComparison.Ordinal) + 7).Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
if (arr.Length > 0)
{
string fontColor = arr[0].Trim('\'').Trim('"').Trim('\'');
try
{
colorStack.Push(c); // save old color
if (fontColor.StartsWith("rgb("))
{
arr = fontColor.Remove(0, 4).TrimEnd(')').Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
c = Color.FromArgb(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2]));
}
else
{
c = ColorTranslator.FromHtml(fontColor);
}
}
catch
{
示例13: draw_me
private void draw_me()
{
using (GraphicsPath winShape = new GraphicsPath())
{
//get the (resized) rectangle to draw our Yin-Yang
rc = this.ClientRectangle;
shape = new Region(winShape);
//Add ellipse
winShape.AddEllipse(this.ClientRectangle);
//start with making the outer circle region
shape.Union(winShape);
//rectangle for the inner circle
rc = new Rectangle(rc.X + border, rc.Y + border,
rc.Size.Width - 2 * border, rc.Size.Height - 2 * border);
//remove old stuff
winShape.Reset();
//add inner circle
winShape.AddEllipse(rc);
//exclude inner circle
shape.Exclude(winShape);
//add Yang to the region
int yang_x = rc.Width / 4 + border;
int yang_y = border;
int yang_height = rc.Height / 2;
int yang_width = rc.Width / 2;
Rectangle yang = new Rectangle(yang_x, yang_y, yang_width, yang_height);
winShape.Reset();
winShape.AddEllipse(yang);
shape.Union(winShape);
//add left side
rc = this.ClientRectangle;
winShape.Reset();
winShape.AddArc(rc, 90, 180);
shape.Union(winShape);
//add the small top circle
int dot_height = yang.Height * 1 / 6;
int dot_width = yang.Width * 1 / 6;
int top_dot_x = yang.X + yang_width / 2 - dot_width / 2;
int top_dot_y = yang.Y + yang_height / 2 - dot_height / 2;
Rectangle top_dot = new Rectangle(top_dot_x, top_dot_y, dot_width, dot_height);
winShape.Reset();
winShape.AddEllipse(top_dot);
shape.Exclude(winShape);
//exclude/remove Yin(lower circle)
rc = new Rectangle(rc.X + border, rc.Y + border,
rc.Size.Width - 2 * border, rc.Size.Height - 2 * border);
int yin_x = rc.Width / 4 + border;
int yin_y = rc.Height / 2+ border;
int yin_height = rc.Height / 2;
int yin_width = rc.Width / 2;
yang = new Rectangle(yin_x, yin_y, yin_width, yin_height);
winShape.Reset();
winShape.AddEllipse(yang);
shape.Exclude(winShape);
//add/union bottom dot
int bot_dot_x = yang.X + yang.Width / 2 - dot_width / 2;
int bot_dot_y = yang.Y + yang.Height / 2 - dot_height / 2;
Rectangle bot_dot = new Rectangle(bot_dot_x, bot_dot_y, dot_width, dot_height);
winShape.Reset();
winShape.AddEllipse(bot_dot);
shape.Union(winShape);
//UPDATE NEW SHAPE !
if (isYin)
{
RotateRegion(shape, 180);
this.Region = shape;
}
else
this.Region = shape;
}
}
示例14: OnMouseMove
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
if ((!this.picturePanel.firstload && (this.SVGDocument != null)))
{
SizeF ef1 = this.picturePanel.GridSize;
float single1 = ef1.Height;
float single2 = ef1.Width;
Point point1 = this.picturePanel.PointToView(new Point(e.X, e.Y));
this.picturePanel.ToolTip(point1.X.ToString() + "," + point1.Y.ToString(), 0);
this.picturePanel.InvadatePosLine();
if (((this.picturePanel.ShowGuides && !this.picturePanel.lockGuides) && (e.Button == MouseButtons.None)) && (OperationFunc.IsSelectOperation(this.currentOperation) || OperationFunc.IsTransformOperation(this.currentOperation)))
{
this.oldindex = 0;
foreach (RefLine line1 in this.picturePanel.RefLines)
{
if ((line1.Hori && (Math.Abs(point1.Y - line1.Pos) < 2)) || (!line1.Hori && (Math.Abs(point1.X - line1.Pos) < 2)))
{
this.hori = line1.Hori;
this.oldPoint = base.PointToClient(Control.MousePosition);
this.Cursor = SpecialCursors.DragInfoCursor;
this.picturePanel.ToolTip("�ƶ�������϶������ߣ��ϳ�������ɾ��������", 1);
return;
}
this.oldindex++;
}
this.oldindex = -1;
}
if (((this.picturePanel.ShowGuides && !this.picturePanel.lockGuides) && ((e.Button == MouseButtons.Left) && this.mousedown)) && (((this.oldindex >= 0) && (this.oldindex < this.picturePanel.RefLines.Count)) && (OperationFunc.IsSelectOperation(this.currentOperation) || OperationFunc.IsTransformOperation(this.currentOperation))))
{
if (this.hori)
{
this.win32.hdc = this.win32.W32GetDC(base.Handle);
this.win32.W32SetROP2(7);
GraphicsPath path1 = new GraphicsPath();
path1.AddLine(new PointF(0f, (float) this.oldPoint.Y), new PointF((float) base.Width, (float) this.oldPoint.Y));
this.win32.W32PolyDraw(path1);
this.oldPoint = this.picturePanel.PointToView(base.PointToClient(Control.MousePosition));
if (this.picturePanel.SnapToGrid)
{
int num1 = (int) ((this.oldPoint.X + (single2/2f))/single2);
int num2 = (int) ((this.oldPoint.Y + (single1/2f))/single1);
this.oldPoint = new Point((int) (num1*single2), (int) (num2*single1));
}
this.oldPoint = Point.Round(this.picturePanel.PointToSystem(new PointF((float) this.oldPoint.X, (float) this.oldPoint.Y)));
path1.Reset();
path1.AddLine(new PointF(0f, (float) this.oldPoint.Y), new PointF((float) base.Width, (float) this.oldPoint.Y));
this.win32.W32PolyDraw(path1);
this.win32.ReleaseDC();
path1.Dispose();
}
else
{
this.win32.hdc = this.win32.W32GetDC(base.Handle);
this.win32.W32SetROP2(7);
GraphicsPath path2 = new GraphicsPath();
path2.AddLine(new PointF((float) this.oldPoint.X, 0f), new PointF((float) this.oldPoint.X, (float) base.Height));
this.win32.W32PolyDraw(path2);
this.oldPoint = this.picturePanel.PointToView(base.PointToClient(Control.MousePosition));
if (this.picturePanel.SnapToGrid)
{
int num3 = (int) ((this.oldPoint.X + (single2/2f))/single2);
int num4 = (int) ((this.oldPoint.Y + (single1/2f))/single1);
this.oldPoint = new Point((int) (num3*single2), (int) (num4*single1));
}
this.oldPoint = Point.Round(this.picturePanel.PointToSystem(new PointF((float) this.oldPoint.X, (float) this.oldPoint.Y)));
path2.Reset();
path2.AddLine(new PointF((float) this.oldPoint.X, 0f), new PointF((float) this.oldPoint.X, (float) base.Height));
this.win32.W32PolyDraw(path2);
this.win32.ReleaseDC();
path2.Dispose();
}
}
else if (this.editingOperation != null)
{
if(moving)return;
DateTime time1 =DateTime.Now;
moving =true;
this.editingOperation.OnMouseMove(e);
moving =false;
DateTime time2 =DateTime.Now;
TimeSpan ts=time2-time1;
this.picturePanel.ToolTip(ts.ToString(), 1);
}
}
}
示例15: GenerateAustPlusRandomEllipses
//---------------------------------------------------------------------
private void GenerateAustPlusRandomEllipses(int count)
{
subjects.Clear();
//load map of Australia from resource ...
Assembly _assembly = Assembly.GetExecutingAssembly();
using (BinaryReader polyStream = new BinaryReader(_assembly.GetManifestResourceStream("GuiDemo.aust.bin")))
{
int polyCnt = polyStream.ReadInt32();
for (int i = 0; i < polyCnt; ++i)
{
int vertCnt = polyStream.ReadInt32();
Polygon pg = new Polygon(vertCnt);
for (int j = 0; j < vertCnt; ++j)
{
float x = polyStream.ReadSingle() * scale;
float y = polyStream.ReadSingle() * scale;
pg.Add(new IntPoint((int)x, (int)y));
}
subjects.Add(pg);
}
}
clips.Clear();
Random rand = new Random();
using (GraphicsPath path = new GraphicsPath())
{
const int ellipse_size = 100, margin = 10;
for (int i = 0; i < count; ++i)
{
int w = pictureBox1.ClientRectangle.Width - ellipse_size - margin * 2;
int h = pictureBox1.ClientRectangle.Height - ellipse_size - margin * 2 - statusStrip1.Height;
int x = rand.Next(w) + margin;
int y = rand.Next(h) + margin;
int size = rand.Next(ellipse_size - 20) + 20;
path.Reset();
path.AddEllipse(x, y, size, size);
path.Flatten();
Polygon clip = new Polygon(path.PathPoints.Count());
foreach (PointF p in path.PathPoints)
clip.Add(new IntPoint((int)(p.X * scale), (int)(p.Y * scale)));
clips.Add(clip);
}
}
}