本文整理汇总了C#中System.Drawing.Drawing2D.GraphicsPath.AddPath方法的典型用法代码示例。如果您正苦于以下问题:C# GraphicsPath.AddPath方法的具体用法?C# GraphicsPath.AddPath怎么用?C# GraphicsPath.AddPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Drawing2D.GraphicsPath
的用法示例。
在下文中一共展示了GraphicsPath.AddPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CombinePaths
/// <summary>
///
/// </summary>
/// <param name="region"></param>
/// <param name="element"></param>
private void CombinePaths(GraphicsPath path, SvgElement element)
{
var graphicsElement = element as SvgVisualElement;
if (graphicsElement != null && graphicsElement.Path != null)
{
path.FillMode = (graphicsElement.ClipRule == SvgClipRule.NonZero) ? FillMode.Winding : FillMode.Alternate;
GraphicsPath childPath = graphicsElement.Path;
if (graphicsElement.Transforms != null)
{
foreach (SvgTransform transform in graphicsElement.Transforms)
{
childPath.Transform(transform.Matrix);
}
}
path.AddPath(childPath, false);
}
foreach (SvgElement child in element.Children)
{
this.CombinePaths(path, child);
}
}
示例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: DrawShape
protected override void DrawShape(GraphicsPath g)
{
g.AddPath(Settings.Screen.ShapeUnit, true);
//g.AddClosedCurve(new[]
// {
// new Point(0, TOTAL_HEIGHT/2 - 1), new Point(TOTAL_WIDTH/2, TOTAL_HEIGHT),
// new Point(TOTAL_WIDTH, TOTAL_HEIGHT/2 - 1)
// });
}
示例4: DrawHighlight
protected virtual void DrawHighlight(GraphicsPath graphicsPath, Graphics graphics)
{
if (!Tracked) return;
using (var hi = new GraphicsPath())
{
hi.AddEllipse(0, 0, TOTAL_WIDTH, TOTAL_HEIGHT);
graphicsPath.AddPath(hi, true);
}
}
示例5: AddStringToPath
public void AddStringToPath(ISvgRenderer renderer, GraphicsPath path, string text, PointF location)
{
var textPath = GetPath(renderer, text, null, false);
if (textPath.PointCount > 0)
{
using (var translate = new Matrix())
{
translate.Translate(location.X, location.Y);
textPath.Transform(translate);
path.AddPath(textPath, false);
}
}
}
示例6: CombinePaths
/// <summary>
///
/// </summary>
/// <param name="region"></param>
/// <param name="element"></param>
private void CombinePaths(GraphicsPath path, SvgElement element)
{
var graphicsElement = element as SvgVisualElement;
if (graphicsElement != null && graphicsElement.Path != null)
{
path.FillMode = (graphicsElement.ClipRule == SvgClipRule.NonZero) ? FillMode.Winding : FillMode.Alternate;
path.AddPath(graphicsElement.Path, false);
}
foreach (SvgElement child in element.Children)
{
this.CombinePaths(path, child);
}
}
示例7: Export2GDIPlus
/// <summary>
/// Exports a figure, created by Potrace from a Bitmap to a svg-formatted string
///It should be SVG-formattted
/// </summary>
/// <param name="Fig">Arraylist, which contains vectorinformations about the Curves</param>
/// <param name="Width">Width of the Bitmap</param>
/// <param name="Height">Height of the Bitmap</param>
/// <returns></returns>
public static Bitmap Export2GDIPlus(ArrayList Fig, int Width,int Height )
{
Image I= new Bitmap(Width,Height);
Graphics g = Graphics.FromImage(I);
g.FillRectangle(new SolidBrush(Color.White),0,0,Width,Height);
GraphicsPath gp = new GraphicsPath();
for (int i = 0; i < Fig.Count; i++)
{
ArrayList CurveArray = (ArrayList)Fig[i];
GraphicsPath Contour = null;
GraphicsPath Hole = null;
GraphicsPath Current = null;
for (int j = 0; j < CurveArray.Count; j++)
{
if (j == 0)
{
Contour = new GraphicsPath();
Current = Contour;
}
else
{
Hole = new GraphicsPath();
Current = Hole;
}
Potrace.Curve[] Curves = (Potrace.Curve[])CurveArray[j];
float factor = 1;
for (int k = 0; k < Curves.Length; k++)
{
if (Curves[k].Kind == Potrace.CurveKind.Bezier)
Current.AddBezier((float)Curves[k].A.x * factor, (float)Curves[k].A.y * factor, (float)Curves[k].ControlPointA.x * factor, (float)Curves[k].ControlPointA.y * factor,
(float)Curves[k].ControlPointB.x * factor, (float)Curves[k].ControlPointB.y * factor, (float)Curves[k].B.x * factor, (float)Curves[k].B.y * factor);
else
Current.AddLine((float)Curves[k].A.x * factor, (float)Curves[k].A.y * factor, (float)Curves[k].B.x * factor, (float)Curves[k].B.y * factor);
}
if (j > 0) Contour.AddPath(Hole, false);
}
gp.AddPath(Contour, false);
}
g.FillPath(Brushes.Black, gp);
return (Bitmap)I;
}
示例8: GetOutline_ToolWindow
private GraphicsPath GetOutline_ToolWindow(int index)
{
Rectangle rectTab = GetTabRectangle(index);
rectTab.Intersect(TabsRectangle);
rectTab = RectangleToScreen(DrawHelper.RtlTransform(this, rectTab));
Rectangle rectPaneClient = DockPane.RectangleToScreen(DockPane.ClientRectangle);
GraphicsPath path = new GraphicsPath();
GraphicsPath pathTab = GetTabOutline(Tabs[index], true, true);
path.AddPath(pathTab, true);
path.AddLine(rectTab.Left, rectTab.Top, rectPaneClient.Left, rectTab.Top);
path.AddLine(rectPaneClient.Left, rectTab.Top, rectPaneClient.Left, rectPaneClient.Top);
path.AddLine(rectPaneClient.Left, rectPaneClient.Top, rectPaneClient.Right, rectPaneClient.Top);
path.AddLine(rectPaneClient.Right, rectPaneClient.Top, rectPaneClient.Right, rectTab.Top);
path.AddLine(rectPaneClient.Right, rectTab.Top, rectTab.Right, rectTab.Top);
return path;
}
示例9: GetObjectOutlineForArrangements
/// <summary>
/// Get the object outline for arrangements in object world coordinates.
/// </summary>
/// <returns>Object outline for arrangements in object world coordinates</returns>
public override GraphicsPath GetObjectOutlineForArrangements()
{
GraphicsPath result = new GraphicsPath();
foreach (var ele in _groupedObjects)
result.AddPath(ele.GetObjectOutlineForArrangements(), false);
return result;
}
示例10: OnLoad
public void OnLoad(EventArgs e)
{
Bitmap bmp = new Bitmap(this.Height*0x06, this.Height*0x02);
Graphics g = Graphics.FromImage(bmp);
g.CompositingQuality = CompositingQuality.HighQuality;
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
g.SmoothingMode = SmoothingMode.HighQuality;
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
float w = 6.0f*this.Height;
int hInt = this.Height;
float h = (float)hInt;
float margin = h/48.0f;
float m2 = 2.0f*margin;
float r = h/36.0f;///36.0f
float r2 = 2.0f*r;
float h_2 = 0.5f*h;
float Ro = h_2-margin;
float alpha = (float)(180.0d/Math.PI*Math.Acos(1.0d-0.5d*r/Ro));
float beta = (float)(180.0d/Math.PI*Math.Acos(1.0d-r/Ro));
float betaY = (float)Math.Sqrt(Ro*Ro-(Ro-r)*(Ro-r));
float sqrtR2 = (float)(Math.Sqrt(0.5d)*(h-m2-r2));
float __R2 = h_2-margin-r;
__R2 *= __R2;
for(int l = 0x00; l < 0x02; l++) {
using(GraphicsPath gpNocturne = new GraphicsPath()) {
//left wing
gpNocturne.AddArc(0.5f*w-h+m2, margin, h-m2, h-m2, 180.0f+alpha, 360.0f-2.0f*alpha);
gpNocturne.AddArc(0.5f*w+2.0f*(m2-h)+r, margin, h-m2, h-m2, alpha, 90.0f-alpha);
gpNocturne.AddLine(0.5f*w+1.5f*m2+r-1.5f*h, h-margin, h_2, h-margin);
gpNocturne.AddArc(margin, margin, h-m2, h-m2, 90.0f, 90.0f-beta);
gpNocturne.AddLine(margin+r, h_2+betaY, margin+r, h-margin);
gpNocturne.AddLine(margin+r, h-margin, margin, h-margin);
gpNocturne.AddLine(margin, h-margin, margin, margin);
gpNocturne.AddLine(margin, margin, margin+r, margin);
gpNocturne.AddLine(margin+r, margin, margin+r, h_2-betaY);
gpNocturne.AddArc(margin, margin, h-m2, h-m2, 180.0f+beta, 90.0f-beta);
gpNocturne.AddLine(h_2, margin, 0.5f*w+1.5f*m2+r-1.5f*h, margin);
gpNocturne.AddArc(0.5f*w+2.0f*(m2-h)+r, margin, h-m2, h-m2, 270.0f, 90.0f-alpha);
gpNocturne.CloseFigure();
//right wing
gpNocturne.AddArc(0.5f*w, margin, h-m2, h-m2, 360.0f-alpha, 2.0f*alpha-360.0f);
gpNocturne.AddArc(0.5f*w+h-m2-r, margin, h-m2, h-m2, 180.0f-alpha, alpha-90.0f);
gpNocturne.AddLine(0.5f*w+2.0f*(h-m2)-r, h-margin, w-h_2, h-margin);
gpNocturne.AddArc(w-h+margin, margin, h-m2, h-m2, 90.0f, beta-90.0f);
gpNocturne.AddLine(w-margin-r, h_2+betaY, w-margin-r, h-margin);
gpNocturne.AddLine(w-margin-r, h-margin, w-margin, h-margin);
gpNocturne.AddLine(w-margin, h-margin, w-margin, margin);
gpNocturne.AddLine(w-margin, margin, w-margin-r, margin);
gpNocturne.AddLine(w-margin-r, margin, w-margin-r, h_2-betaY);
gpNocturne.AddArc(w-h+margin, margin, h-m2, h-m2, -beta, beta-90.0f);
gpNocturne.AddLine(w-h_2, margin, 0.5f*w+2.0f*(h-m2)-r, margin);
gpNocturne.AddArc(0.5f*w+h-m2-r, margin, h-m2, h-m2, 270.0f, alpha-90.0f);
gpNocturne.CloseFigure();
if(l == 0x00)
g.FillPath(EgyptInformation.Brushes.EgyptNocturne, gpNocturne);
else
g.FillPath(EgyptInformation.Brushes.EgyptPaintBlue, gpNocturne);
//g.FillPath(new SolidBrush(Color.FromArgb(0x4c,0x41,0x0b)),gpNocturne);
using(GraphicsPath gpGold = new GraphicsPath()) {
gpGold.AddPath(gpNocturne, false);
//left inner
gpGold.AddArc(margin+r, margin+r, h-m2-r2, h-m2-r2, 90.0f, 180.0f);
gpGold.AddArc(0.5f*w+2.0f*(m2-h)+r2, margin+r, h-m2-r2, h-m2-r2, 270.0f, 180.0f);
gpGold.CloseFigure();
//left ellipse
gpGold.AddEllipse(0.5f*w-h+m2+r, margin+r, h-m2-r2, h-m2-r2);
gpGold.CloseFigure();
//right inner
gpGold.AddArc(w-h+margin+r, margin+r, h-m2-r2, h-m2-r2, 90.0f, -180.0f);
gpGold.AddArc(0.5f*w+h-m2, margin+r, h-m2-r2, h-m2-r2, 270.0f, -180.0f);
gpGold.CloseFigure();
//right ellipse
gpGold.AddEllipse(0.5f*w+r, margin+r, h-m2-r2, h-m2-r2);
gpGold.CloseFigure();
g.FillPath(EgyptInformation.Brushes.EgyptGold, gpGold);
GraphicsUtils.DrawGlass(g, gpGold);
}
Matrix M = new Matrix();
M.Scale(sqrtR2, sqrtR2);
RectangleF bounds;
Matrix Mtrans = new Matrix();
GraphicsPath gpHedjet = EgyptInformation.GraphicsPaths.Hedjet();
gpHedjet.Transform(M);
bounds = gpHedjet.GetBounds();
Mtrans.Translate(-0.5f*bounds.Width, 0.0f);
Mtrans.Scale(-1.0f, 1.0f, MatrixOrder.Append);
Mtrans.Translate(0.5f*(w-h+m2), h_2-0.5f*bounds.Height, MatrixOrder.Append);
gpHedjet.Transform(Mtrans);
g.FillPath(EgyptInformation.Brushes.EgyptPaintWhite, gpHedjet);
GraphicsUtils.DrawGlass(g, gpHedjet);
GraphicsPath gpDeshret = EgyptInformation.GraphicsPaths.Deshret();
gpDeshret.Transform(M);
bounds = gpDeshret.GetBounds();
Mtrans.Reset();
Mtrans.Translate(0.5f*(w+h-m2-bounds.Width), h_2-0.5f*bounds.Height);
gpDeshret.Transform(Mtrans);
g.FillPath(EgyptInformation.Brushes.EgyptPaintRed, gpDeshret);
GraphicsUtils.DrawGlass(g, gpDeshret);
}
//.........这里部分代码省略.........
示例11: GetLineCap
//
internal static GraphicsPath GetLineCap(LineAnchor lineCap, int capsize, out float capinset)
{
//WE DO NOT SUPPORT ARROWCAPS FOR ANGULAR CONNECTORS FOR NOW
capinset = 0.0f;
capinset = (float)capsize / 2;
Size capSize = new Size(capsize, capsize);
GraphicsPath lineCapPath = new GraphicsPath();
switch (lineCap)
{
case LineAnchor.Arrow:
case LineAnchor.ArrowAnchor:
int arcRadius = capSize.Height / 3;
lineCapPath.AddLine(capSize.Width / 2, -capSize.Height, 0, 0);
lineCapPath.AddLine(0, 0, -capSize.Width / 2, -capSize.Height);
lineCapPath.AddLine(-capSize.Width / 2, -capSize.Height, 0, -capSize.Height + arcRadius);
lineCapPath.AddLine(0, -capSize.Height + arcRadius, capSize.Width / 2, -capSize.Height);
capinset = capSize.Height - arcRadius;
break;
case LineAnchor.Diamond:
case LineAnchor.DiamondAnchor:
lineCapPath.AddLine(0, -capSize.Height, capSize.Width / 2, -capSize.Height / 2);
lineCapPath.AddLine(capSize.Width / 2, -capSize.Height / 2, 0, 0);
lineCapPath.AddLine(0, 0, -capSize.Width / 2, -capSize.Height / 2);
lineCapPath.AddLine(-capSize.Width / 2, -capSize.Height / 2, 0, -capSize.Height);
break;
case LineAnchor.Round:
case LineAnchor.RoundAnchor:
lineCapPath.AddEllipse(new Rectangle(-capSize.Width / 2, -capSize.Height, capSize.Width, capSize.Height));
break;
case LineAnchor.Rectangle:
case LineAnchor.RectangleAnchor:
lineCapPath.AddRectangle(new Rectangle(-capSize.Width / 2, -capSize.Height, capSize.Width, capSize.Height));
break;
case LineAnchor.RoundedRectangle:
case LineAnchor.RoundedRectangleAnchor:
arcRadius = capSize.Height / 4;
lineCapPath.AddPath(ActivityDesignerPaint.GetRoundedRectanglePath(new Rectangle(-capSize.Width / 2, -capSize.Height, capSize.Width, capSize.Height), arcRadius), true);
break;
}
lineCapPath.CloseFigure();
return lineCapPath;
}
示例12: CreatePath
public static GraphicsPath CreatePath(SvgPathElement element)
{
GraphicsPath gp = new GraphicsPath();
SvgPointF initPoint = new SvgPointF(0, 0);
SvgPointF lastPoint = new SvgPointF(0, 0);
ISvgPathSeg segment = null;
SvgPathSegMoveto pathMoveTo = null;
SvgPathSegLineto pathLineTo = null;
SvgPathSegCurveto pathCurveTo = null;
SvgPathSegArc pathArc = null;
ISvgPathSegList segments = element.PathSegList;
int nElems = segments.NumberOfItems;
for (int i = 0; i < nElems; i++)
{
segment = segments.GetItem(i);
if (DynamicCast.Cast(segment, out pathMoveTo))
{
//SvgPathSegMoveto seg = (SvgPathSegMoveto)segment;
gp.StartFigure();
lastPoint = initPoint = pathMoveTo.AbsXY;
}
else if (DynamicCast.Cast(segment, out pathLineTo))
{
//SvgPathSegLineto seg = (SvgPathSegLineto)segment;
SvgPointF p = pathLineTo.AbsXY;
gp.AddLine(lastPoint.X, lastPoint.Y, p.X, p.Y);
lastPoint = p;
}
else if (DynamicCast.Cast(segment, out pathCurveTo))
{
// SvgPathSegCurveto seg = (SvgPathSegCurveto)segment;
SvgPointF xy = pathCurveTo.AbsXY;
SvgPointF x1y1 = pathCurveTo.CubicX1Y1;
SvgPointF x2y2 = pathCurveTo.CubicX2Y2;
gp.AddBezier(lastPoint.X, lastPoint.Y, x1y1.X, x1y1.Y, x2y2.X, x2y2.Y, xy.X, xy.Y);
lastPoint = xy;
}
else if (DynamicCast.Cast(segment, out pathArc))
{
//SvgPathSegArc seg = (SvgPathSegArc)segment;
SvgPointF p = pathArc.AbsXY;
if (lastPoint.Equals(p))
{
// If the endpoints (x, y) and (x0, y0) are identical, then this
// is equivalent to omitting the elliptical arc segment entirely.
}
else if (pathArc.R1 == 0 || pathArc.R2 == 0)
{
// Ensure radii are valid
gp.AddLine(lastPoint.X, lastPoint.Y, p.X, p.Y);
}
else
{
CalculatedArcValues calcValues = pathArc.GetCalculatedArcValues();
GraphicsPath gp2 = new GraphicsPath();
gp2.StartFigure();
gp2.AddArc((float)(calcValues.Cx - calcValues.CorrRx),
(float)(calcValues.Cy - calcValues.CorrRy),
(float)calcValues.CorrRx * 2, (float)calcValues.CorrRy * 2,
(float)calcValues.AngleStart, (float)calcValues.AngleExtent);
Matrix matrix = new Matrix();
matrix.Translate(-(float)calcValues.Cx, -(float)calcValues.Cy);
gp2.Transform(matrix);
matrix = new Matrix();
matrix.Rotate((float)pathArc.Angle);
gp2.Transform(matrix);
matrix = new Matrix();
matrix.Translate((float)calcValues.Cx, (float)calcValues.Cy);
gp2.Transform(matrix);
gp.AddPath(gp2, true);
}
lastPoint = p;
}
else if (segment is SvgPathSegClosePath)
{
gp.CloseFigure();
lastPoint = initPoint;
}
}
string fillRule = element.GetPropertyValue("fill-rule");
if (fillRule == "evenodd")
gp.FillMode = FillMode.Alternate;
else
gp.FillMode = FillMode.Winding;
return gp;
//.........这里部分代码省略.........
示例13: GetLineCap
internal static GraphicsPath GetLineCap(LineAnchor lineCap, int capsize, out float capinset)
{
int num;
capinset = 0f;
capinset = capsize;
Size size = new Size(capsize, capsize);
GraphicsPath path = new GraphicsPath();
switch (lineCap)
{
case LineAnchor.Arrow:
case LineAnchor.ArrowAnchor:
num = size.Height / 3;
path.AddLine(size.Width / 2, -size.Height, 0, 0);
path.AddLine(0, 0, -size.Width / 2, -size.Height);
path.AddLine(-size.Width / 2, -size.Height, 0, -size.Height + num);
path.AddLine(0, -size.Height + num, size.Width / 2, -size.Height);
capinset = size.Height - num;
break;
case LineAnchor.Diamond:
case LineAnchor.DiamondAnchor:
path.AddLine(0, -size.Height, size.Width / 2, -size.Height / 2);
path.AddLine(size.Width / 2, -size.Height / 2, 0, 0);
path.AddLine(0, 0, -size.Width / 2, -size.Height / 2);
path.AddLine(-size.Width / 2, -size.Height / 2, 0, -size.Height);
break;
case LineAnchor.Round:
case LineAnchor.RoundAnchor:
path.AddEllipse(new Rectangle(-size.Width / 2, -size.Height, size.Width, size.Height));
break;
case LineAnchor.Rectangle:
case LineAnchor.RectangleAnchor:
path.AddRectangle(new Rectangle(-size.Width / 2, -size.Height, size.Width, size.Height));
break;
case LineAnchor.RoundedRectangle:
case LineAnchor.RoundedRectangleAnchor:
num = size.Height / 4;
path.AddPath(GetRoundedRectanglePath(new Rectangle(-size.Width / 2, -size.Height, size.Width, size.Height), num), true);
break;
}
path.CloseFigure();
return path;
}
示例14: GetDesignerPath
internal static GraphicsPath GetDesignerPath(ActivityDesigner designer, Point offset, Size inflate, DesignerEdges edgeToInflate, bool enableRoundedCorners)
{
GraphicsPath path = new GraphicsPath();
Rectangle bounds = designer.Bounds;
bounds.Offset(offset);
if ((edgeToInflate & DesignerEdges.Left) > DesignerEdges.None)
{
bounds.X -= inflate.Width;
bounds.Width += inflate.Width;
}
if ((edgeToInflate & DesignerEdges.Right) > DesignerEdges.None)
{
bounds.Width += inflate.Width;
}
if ((edgeToInflate & DesignerEdges.Top) > DesignerEdges.None)
{
bounds.Y -= inflate.Height;
bounds.Height += inflate.Height;
}
if ((edgeToInflate & DesignerEdges.Bottom) > DesignerEdges.None)
{
bounds.Height += inflate.Height;
}
if ((designer == ActivityDesigner.GetSafeRootDesigner(designer.Activity.Site)) && (((IWorkflowRootDesigner) designer).InvokingDesigner == null))
{
path.AddRectangle(bounds);
return path;
}
ActivityDesignerTheme designerTheme = designer.DesignerTheme;
if ((enableRoundedCorners && (designerTheme != null)) && (designerTheme.DesignerGeometry == DesignerGeometry.RoundedRectangle))
{
path.AddPath(GetRoundedRectanglePath(bounds, 8), true);
return path;
}
path.AddRectangle(bounds);
return path;
}
示例15: ReDrawLines
/// <summary>Draws visual code connecting lines that connect the Cuda code to PTX code. These are a visual aid that help in understanding PTX.</summary>
private void ReDrawLines()
{
if (!LinesEnabled)
return;
txtSrc.Refresh();
txtDst.Refresh();
if (linesInfo.Count > 0)
{
GraphicsPath path = new GraphicsPath(FillMode.Winding);
byte[] types = { (byte)PathPointType.Start, 3, 3, 3, 1, 3, 3, 3, 1 };
int txtSrcRowHeight = txtSrc.Lines.FirstVisible.Height;
int txtSrcfirstVisible = txtSrc.Lines.FirstVisible.Number;
int txtSrcVisibleLineCt = txtSrc.Lines.VisibleCount;
int txtSrcOverExtendPixels = 4;
float txtSrcFontSz = (txtSrc.Font.Size + (float)txtSrc.ZoomFactor) * 0.75f ;
int txtDstRowHeight = txtDst.Lines.FirstVisible.Height;
int txtDstfirstVisible = txtDst.Lines.FirstVisible.Number;
int txtDstVisibleLineCt = txtDst.Lines.VisibleCount;
int txtDstOverExtendPixels = 4;
foreach (LineInfo arrowInfo in linesInfo)
if (arrowInfo.srcLineNo > 0)
{
const int width = 1;
int s_x = (int)(txtSrc.Lines[arrowInfo.srcLineNo - 1].Length * (txtSrcFontSz+1)); // get source-x width
s_x = Math.Min(s_x, txtSrc.Width-15); // make sure it does not start past the end of the screen
int s_y = (int)((arrowInfo.srcLineNo - txtSrcfirstVisible) * txtSrcRowHeight) - (txtSrcRowHeight / 2);
int d_x = txtSrc.Width + 30;
int d_y = (int)((arrowInfo.lineNo - txtDstfirstVisible) * txtDstRowHeight) - (txtDstRowHeight / 2);
if (s_y < (0 - txtSrcOverExtendPixels) * txtSrcRowHeight)
continue;
if (s_y > (0 + txtSrcVisibleLineCt + txtSrcOverExtendPixels) * txtSrcRowHeight)
continue;
if (d_y < (0 - txtDstOverExtendPixels) * txtDstRowHeight)
continue;
if (d_y > (0 + txtDstVisibleLineCt + txtDstOverExtendPixels) * txtDstRowHeight)
continue;
Point[] pts2 = { new Point(s_x, s_y), new Point(s_x + 60, s_y), new Point(d_x - 60, d_y), new Point(d_x, d_y), new Point(d_x, d_y + width), new Point(d_x - 60, d_y + width), new Point(s_x + 60, s_y + width), new Point(s_x, s_y + width), new Point(s_x, s_y) };
GraphicsPath subpath = new GraphicsPath(pts2, types);
path.AddPath(subpath, false);
}
linesDrawPanel.Region = new Region(path);
path.Dispose();
}
linesDrawPanel.Visible = true; // added 1-1-2015
}