本文整理汇总了C#中System.Drawing.Pen.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# Pen.Clone方法的具体用法?C# Pen.Clone怎么用?C# Pen.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Pen
的用法示例。
在下文中一共展示了Pen.Clone方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawArrow
public static void DrawArrow(this FakeGraphics.FakeGraphics g, Pen pen, int x1, int y1, int x2, int y2)
{
Pen p = (Pen)pen.Clone();
p.StartCap = LineCap.Round;
p.EndCap = LineCap.Flat;
g.DrawLine(pen, x1, y1, x2, y2);
p.Width = 5;
p.EndCap = LineCap.ArrowAnchor;
int xx=x2, yy=y2;
if (x1 == x2)
{
if (y1 > y2)
yy += 5;
else
yy -= 5;
}
else
{
if (x1 > x2)
xx += 5;
else
xx -= 5;
}
g.DrawLine(p, xx, yy, x2, y2);
}
示例2: ColorizationStyle
/// <summary>
/// Initializes a new instance of the ColorizationStyle class.
/// </summary>
/// <param name="newFixationPen">The new fixation pen to set.</param>
/// <param name="newConnectionPen">The new fixation connection pen to set.</param>
/// <param name="newFont">The new font to set.</param>
/// <param name="newFontColor">The new font color to set.</param>
public ColorizationStyle(Pen newFixationPen, Pen newConnectionPen, Font newFont, Color newFontColor)
{
this.fixationPen = (Pen)newFixationPen.Clone();
this.connectionPen = (Pen)newConnectionPen.Clone();
this.font = (Font)newFont.Clone();
this.fontColor = newFontColor;
}
示例3: GestureThumbnail
public GestureThumbnail(PointF[] Points, Size Size, bool WithArrow)
{
_Points = Points;
_Size = Size;
_DrawingPen = new Pen(Properties.Settings.Default.MiniViewColor, 3);
_DrawingPen.StartCap = _DrawingPen.EndCap = LineCap.Round;
_ArrowPen = _DrawingPen.Clone() as Pen;
// Create new large arrow cap
AdjustableArrowCap arrowCap = new AdjustableArrowCap(3, 3, true);
arrowCap.BaseCap = LineCap.Square;
_ArrowPen.CustomEndCap = arrowCap;
_WithArrow = WithArrow;
}
示例4: VGElement
/// <summary>
/// Initializes a new instance of the VGElement class.
/// </summary>
/// <param name="newShapeDrawAction">Drawing action: Edge, Fill, Both</param>
/// <param name="newPen">Pen for edges</param>
/// <param name="newFont">Font for text</param>
/// <param name="newFontColor">Color for text</param>
/// <param name="newBounds">Bounds of element</param>
/// <param name="newStyleGroup">Group Enumeration, <see cref="VGStyleGroup"/></param>
/// <param name="newName">Name of Element</param>
/// <param name="newElementGroup">Element group description</param>
public VGElement(
ShapeDrawAction newShapeDrawAction,
Pen newPen,
Font newFont,
Color newFontColor,
RectangleF newBounds,
VGStyleGroup newStyleGroup,
string newName,
string newElementGroup)
{
this.InitStandards();
this.styleGroup = newStyleGroup;
this.name = newName;
this.elementGroup = newElementGroup;
this.shapeDrawAction = newShapeDrawAction;
this.pen = newPen == null ? null : (Pen)newPen.Clone();
this.Font = newFont == null ? null : (Font)newFont.Clone();
this.FontColor = newFontColor;
this.Bounds = newBounds;
}
示例5: RenderThread
/// <summary>
/// The constructor for the RenderThread. Sets up the private members
/// of the class, but DOES NOT start the rendering process.
/// </summary>
/// @param metrics The MapMetrics object for this Map
/// @param features The VectorFeature array
/// @param type The type of shapefile we're going to draw
/// @param beginning The array index of the VectorFeature to begin drawing with
/// @param ending The array index of the VectorFeature to end drawing with
/// @param pen The pen to draw the features with
/// @param brush The brush to fill the features with
public RenderThread( MapMetrics metrics,
VectorFeature[] features,
ShapeType type,
int beginning,
int ending,
Pen pen,
Brush brush )
{
_mapMetrics = metrics;
_features = features;
_shapeType = type;
_beginningFeature = beginning;
_endingFeature = ending;
_pen = (Pen) pen.Clone();
_brush = (Brush) brush.Clone();
_gr = Graphics.FromImage( _mapMetrics.Canvas );
}
示例6: Clone
public void Clone ()
{
using (Pen p = new Pen (Brushes.Red)) {
using (Pen clone = (Pen) p.Clone ()) {
Check (clone);
}
}
}
示例7: DrawLineShadowed
private void DrawLineShadowed(Graphics g, Pen pen, float x1, float y1, float x2, float y2, bool flipShadow)
{
var shadowPen = (Pen)pen.Clone();
shadowPen.Color = Settings.ShadowsColor;
if (!flipShadow)
{
g.DrawLine(shadowPen, x1 + 1, y1 + 1, x2 + 1, y2 + 1);
g.DrawLine(shadowPen, x1 + 1, y1 + 2, x2 + 1, y2 + 2);
g.DrawLine(shadowPen, x1 + 1, y1 + 3, x2 + 1, y2 + 3);
g.DrawLine(pen, x1, y1, x2, y2);
}
else
{
g.DrawLine(shadowPen, x1 + 1, y1 - 1, x2 + 1, y2 - 1);
g.DrawLine(shadowPen, x1 + 1, y1 - 2, x2 + 1, y2 - 2);
g.DrawLine(shadowPen, x1 + 1, y1 - 3, x2 + 1, y2 - 3);
g.DrawLine(pen, x1, y1, x2, y2);
}
}
示例8: DrawVectorReal
public void DrawVectorReal(Graphics gdi, Pen pen, int x1, int y1, double vx, double vy, double lenscale)
{
Vector3 uv = new Vector3(vx, vy, 0);
double len = uv.Length();
uv.Normalize();
uv = uv * lenscale;
Pen myPen = (Pen)pen.Clone();
myPen.Width = (float)(len/4);
if (myPen.Width > 6)
myPen.Width = 6;
DrawLine(gdi, myPen, x1, y1, x1 + (int)(uv.x / 1.8), y1 + (int)(uv.y/ 1.8));
// DrawLine(gdi, myPen, x1, y1, x1 + (int)(uv.x), y1 + (int)(uv.y ));
if (Math.Abs(vy) < 0.0000001)
vy = 0.001;
{
double x2 = 1;
double y2 = -(vx * x2) / vy;
Vector3 p = new Vector3(x2, y2, 0);
p.Normalize();
p = p * (lenscale / 2);
Vector3 av = uv / 1.8;
int ax = x1 + (int)av.x;
int ay = y1 + (int)av.y;
Vector3 p1 = p / 1.5;
Vector3 p2 = -p1;
// gdi.DrawLine(pen, ax, ay, ax + (int)p1.x, ay + (int)p1.y);
// gdi.DrawLine(pen, ax, ay, ax + (int)p2.x, ay + (int)p2.y);
int sx1 = ax + (int)p1.x;
int sy1 = ay + (int)p1.y;
int sx2 = ax + (int)p2.x;
int sy2 = ay + (int)p2.y;
//gdi.DrawLine(pen, sx1, sy1, x1 + (int)uv.x, y1 + (int)uv.y);
//gdi.DrawLine(pen, sx2, sy2, x1 + (int)uv.x, y1 + (int)uv.y);
//gdi.DrawLine(pen, sx1, sy1, sx2, sy2);
GraphicsPath path = new GraphicsPath();
path.AddLines(new Point[] { new Point(startx + sx1, starty - sy1), new Point(startx + sx2, starty - sy2), new Point(startx + x1 + (int)uv.x, starty - (y1 + (int)uv.y)), });
path.CloseFigure();
// gdi.DrawPath(Brushes.Red, path);
gdi.DrawPath(Pens.Red, path);
}
}
示例9: InitializePen
private void InitializePen()
{
_drawingPen = new Pen(AppConfig.VisualFeedbackColor, AppConfig.VisualFeedbackWidth * _screenDpi);
_drawingPen.StartCap = _drawingPen.EndCap = LineCap.Round;
_drawingPen.LineJoin = LineJoin.Round;
_shadowPen = new Pen(Color.FromArgb(30, 0, 0, 0), (_drawingPen.Width + 4f)) { EndCap = LineCap.Round, StartCap = LineCap.Round };
_dirtyMarkerPen = (Pen)_shadowPen.Clone();
_dirtyMarkerPen.Width *= 1.5f;
}
示例10: DrawCoordinates
/// <summary>
/// Рисует линии координатных осей с насечками.
/// А также внешнюю окантовку графика (с насечками +))
/// </summary>
private void DrawCoordinates(Graphics G, Pen Pe, PointF Zero, PointF Left, PointF Right, PointF Up, PointF Down, double kx, double ky)
{
G.DrawLine(Pe, Left, Right); // Рисуем ось X
G.DrawLine(Pe, Down, Up); // Рисуем ось Y
PointF DownLeft = new PointF(Left.X, Down.Y);
PointF DownRight = new PointF(Right.X, Down.Y);
PointF UpLeft = new PointF(Left.X, Up.Y);
PointF UpRight = new PointF(Right.X, Up.Y);
// --- Рисуем контур
Pen temp = (Pen)Pe.Clone();
temp.Color = Color.FromArgb(100, Pe.Color);
temp.Width = 2;
G.DrawLine(temp, DownLeft, UpLeft);
G.DrawLine(temp, UpLeft, UpRight);
G.DrawLine(temp, UpRight, DownRight);
G.DrawLine(temp, DownRight, DownLeft);
decimal i;
decimal leftX = (decimal)Left.X;
decimal rightX = (decimal)Right.X;
decimal downY = (decimal)Down.Y;
decimal upY = (decimal)Up.Y;
// ---- насечки
for (i = leftX; i <= rightX + 1; i += (decimal)(Step1 * kx))
{
G.DrawLine(Pe, new PointF((float)i, Zero.Y - 3), new PointF((float)i, Zero.Y + 3)); // насечка на оси
G.DrawLine(Pe, new PointF((float)i, DownLeft.Y - 6), new PointF((float)i, DownLeft.Y)); // насечка на границе
}
for (i = downY; i >= upY - 1; i -= (decimal)(Step2 * ky))
{
G.DrawLine(Pe, new PointF(Zero.X - 3, (float)i), new PointF(Zero.X + 3, (float)i));
G.DrawLine(Pe, new PointF(DownLeft.X, (float)i), new PointF(DownLeft.X + 6, (float)i)); // насечка на границе
}
}
示例11: DrawCanvas
private void DrawCanvas(Graphics g, SizeF windowSize, float scale)
{
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.SmoothingMode = SmoothingMode.HighQuality;
g.TextRenderingHint = TextRenderingHint.AntiAlias;
windowSize = ClipSize(windowSize);
var mat = new Matrix();
//mat.Scale(0.5f, 0.5f);
mat.Translate(windowSize.Width, windowSize.Height);
g.Transform = mat;
_canvasMatrix = mat.Clone();
_canvasMatrix.Invert();
_drawRectangle = new RectangleF(-(float)windowSize.Width, -(float)windowSize.Height, (float)windowSize.Width * 2, (float)windowSize.Height * 2);
g.DrawRectangle(Pens.Black, _drawRectangle.X, _drawRectangle.Y, _drawRectangle.Width, _drawRectangle.Height);
if (_geometry == null) return;
foreach (var geo in _geometry)
{
try
{
foreach (var point in geo.PointsToDraw)
{
var pos = point.ToPointF();
Brush brush = new SolidBrush(geo.Color.ToColor());
PointF posWindow = pos.Scale(windowSize);
var size = (float)geo.Size * scale;
g.FillEllipse(brush, (posWindow.X - size / 2), (posWindow.Y - size / 2), size, size);
}
foreach (var spline in geo.LinesToDraw)
{
var size = (float)geo.Size * scale;
Pen pen = new Pen(geo.Color.ToColor(), (float)size / 2);
Pen penDashed = pen.Clone() as Pen;
penDashed.DashPattern = new float[] { 0.5f, 0.5f };
penDashed.DashStyle = DashStyle.Dash;
Brush brush = new SolidBrush(geo.Color.ToColor());
g.DrawBezier(pen,
spline.PosA.ToPointF().Scale(windowSize),
spline.PosB.ToPointF().Scale(windowSize),
spline.PosC.ToPointF().Scale(windowSize),
spline.PosD.ToPointF().Scale(windowSize));
}
foreach (var text in geo.TextToDraw)
{
var size = (float)geo.Size * scale;
Brush brush = Brushes.Black;
Font font = new Font(FontFamily.GenericMonospace, (float)size);
var posWindow = (text.Position.ToPointF().Scale(windowSize));
g.DrawString(text.Text, font, brush, posWindow);
}
//var renderer = RendererStorage.GetRenderer(geo);
//if (renderer == null)
// continue;
//renderer.Draw(geo,g, windowSize, scale);
}
catch (Exception ex)
{
InterAppComunication.ReportError("Problem drawing " + geo.ToString(), ex);
}
}
}
示例12: InitDefaultProperties
private void InitDefaultProperties()
{
//defaults
ShowCommandName = true;
ShowPath = true;
ViewFadeOut = true;
_pathMaxPointCount = (int)(256 * _dpiFactor);
const float widthBase = 2f;
#region init pens
_mainPen = new Pen(Color.FromArgb(255, 50, 200, 100), widthBase * _dpiFactor) { EndCap = LineCap.Round, StartCap = LineCap.Round };
_middleBtnPen = new Pen(Color.FromArgb(255, 20, 150, 200), widthBase * _dpiFactor) { EndCap = LineCap.Round, StartCap = LineCap.Round };
_borderPen = new Pen(Color.FromArgb(220, 255, 255, 255), (widthBase + 2.5f) * _dpiFactor) { EndCap = LineCap.Round, StartCap = LineCap.Round };
_alternativePen = new Pen(Color.FromArgb(255, 255, 120, 20), widthBase * _dpiFactor) { EndCap = LineCap.Round, StartCap = LineCap.Round };
_shadowPen = new Pen(Color.FromArgb(30, 0, 0, 0), (widthBase + 4f) * _dpiFactor) { EndCap = LineCap.Round, StartCap = LineCap.Round };
_shadowPenWidth = _shadowPen.Width;
_dirtyMarkerPen = (Pen) _shadowPen.Clone();
_dirtyMarkerPen.Width *= 1.5f;
#endregion
}
示例13: SelectPen
// Select a pen into the toolkit graphics object.
private void SelectPen(Pen pen)
{
if(pen == null)
{
throw new ArgumentNullException("pen");
}
if(graphics == null)
{
throw new ObjectDisposedException("graphics");
}
Pen penNew = pen;
if( transform != null ) {
// calculation new pen size, if a transformation is set
// using the workaround for Font scaling
float penWidth = pen.Width;
float newWidth = transform.TransformFontSize(penWidth);
if( penWidth != newWidth ) {
penNew = (Pen) pen.Clone();
penNew.Width = newWidth;
}
}
IToolkitPen tpen = penNew.GetPen(graphics.Toolkit);
if(penNew.PenType == PenType.SolidColor)
{
tpen.Select(graphics);
}
else
{
IToolkitBrush tbrush = penNew.Brush.GetBrush(graphics.Toolkit);
tpen.Select(graphics, tbrush);
}
}
示例14: PieSlice
/// <summary>
/// Initializes a new instance of <c>PieSlice</c> class with given
/// bounds and visual style.
/// </summary>
/// <param name="boundingRectX">
/// x-coordinate of the upper-left corner of the rectangle that is
/// used to draw the top surface of the pie slice.
/// </param>
/// <param name="boundingRectY">
/// y-coordinate of the upper-left corner of the rectangle that is
/// used to draw the top surface of the pie slice.
/// </param>
/// <param name="boundingRectWidth">
/// Width of the rectangle that is used to draw the top surface of
/// the pie slice.
/// </param>
/// <param name="boundingRectHeight">
/// Height of the rectangle that is used to draw the top surface of
/// the pie slice.
/// </param>
/// <param name="sliceHeight">
/// Height of the pie slice.
/// </param>
/// <param name="startAngle">
/// Starting angle (in degrees) of the pie slice.
/// </param>
/// <param name="sweepAngle">
/// Sweep angle (in degrees) of the pie slice.
/// </param>
/// <param name="surfaceColor">
/// Color used to paint the pie slice.
/// </param>
/// <param name="shadowStyle">
/// Shadow style used for slice rendering.
/// </param>
/// <param name="edgeColorType">
/// Edge color style used for slice rendering.
/// </param>
public PieSlice(float boundingRectX, float boundingRectY, float boundingRectWidth, float boundingRectHeight,
float sliceHeight, float startAngle, float sweepAngle, Color surfaceColor, ShadowStyle shadowStyle,
EdgeColorType edgeColorType)
: this()
{
// set some persistent values
m_actualStartAngle = startAngle;
m_actualSweepAngle = sweepAngle;
m_surfaceColor = surfaceColor;
m_shadowStyle = shadowStyle;
m_edgeColorType = edgeColorType;
// create pens for rendering
Color edgeLineColor = EdgeColor.GetRenderingColor(edgeColorType, surfaceColor);
using (Pen pen = new Pen(edgeLineColor))
{
pen.LineJoin = LineJoin.Round;
m_pen = (Pen)pen.Clone();
}
InitializePieSlice(boundingRectX, boundingRectY, boundingRectWidth, boundingRectHeight, sliceHeight);
}
示例15: DrawColorTheme
//.........这里部分代码省略.........
g.DrawPath(PnLegend, gpShp);
}
PnLegend.Dispose();
}
else if (((Lyr.LayerType == ShapeType.PolyLineFeature & BaseLyrVisibility == true) | (Lyr.LayerType == ShapeType.PolyLineCustom & Lyr.Visible == true)) & _Theme.Type == ThemeType.Color)
{
gpShp.Reset();
while (dicEnumerator.MoveNext())
{
//*** Traverse Shapes
_Shape = (Shape)dicEnumerator.Value;
for (j = 0; j <= _Shape.Parts.Count - 1; j++)
{
gpShp.StartFigure();
gpShp.AddLines((PointF[])_Shape.Parts[j]);
}
}
Pen PnLayer = new Pen(Lyr.BorderColor, Lyr.BorderSize);
PnLayer.DashStyle = Lyr.BorderStyle;
gpShp.Transform(mTransMatrix);
g.DrawPath(PnLayer, gpShp);
PnLayer.Dispose();
}
else if (Lyr.LayerType == ShapeType.Point & BaseLyrVisibility == true)
{
g.SmoothingMode = SmoothingMode.AntiAlias;
{
PointF[] Pt = new PointF[1];
int LegendItemIndex;
int[] MarkerSize = new int[_Theme.Legends.Count];
//PtSize based on Legend item
char[] MarkerChar = new char[_Theme.Legends.Count];
Font[] MarkerFont = new Font[_Theme.Legends.Count];
Pen PnCross = (Pen)PnTheme.Clone();
for (i = 0; i <= _Theme.Legends.Count - 1; i++)
{
_Legend = _Theme.Legends[i];
MarkerSize[i] = _Legend.MarkerSize;
MarkerChar[i] = _Legend.MarkerChar;
MarkerFont[i] = _Legend.MarkerFont;
if (_Legend.MarkerType == MarkerStyle.Cross)
PnCross.Color = _Legend.Color;
}
while (dicEnumerator.MoveNext())
{
//*** Traverse Shapes
_Shape = (Shape)dicEnumerator.Value;
//*** BugFix 04 July 2006 Base point layer missing data rendered with 1st legend information
if (_Theme.AreaIndexes.ContainsKey(_Shape.AreaId))
{
LegendItemIndex = (int)((AreaInfo)_Theme.AreaIndexes[_Shape.AreaId]).RenderingInfo;
}
else
{
LegendItemIndex = _Theme.Legends.Count - 1;
}
Pt[0] = (PointF)_Shape.Parts[0];
mTransMatrix.TransformPoints(Pt);
switch (_Theme.Legends[LegendItemIndex].MarkerType)
{
case MarkerStyle.Circle:
g.FillEllipse(BrLegend[LegendItemIndex], (int)Pt[0].X - MarkerSize[LegendItemIndex] / 2, (int)Pt[0].Y - MarkerSize[LegendItemIndex] / 2, MarkerSize[LegendItemIndex], MarkerSize[LegendItemIndex]);
g.DrawEllipse(PnTheme, (int)Pt[0].X - MarkerSize[LegendItemIndex] / 2, (int)Pt[0].Y - MarkerSize[LegendItemIndex] / 2, MarkerSize[LegendItemIndex], MarkerSize[LegendItemIndex]);
if (Lyr.SelectedArea.Contains(_Shape.AreaId))
g.FillEllipse(BrSelection, (int)Pt[0].X - MarkerSize[LegendItemIndex] / 2, (int)Pt[0].Y - MarkerSize[LegendItemIndex] / 2, MarkerSize[LegendItemIndex], MarkerSize[LegendItemIndex]);