本文整理汇总了C#中System.Drawing.Drawing2D.GraphicsPath类的典型用法代码示例。如果您正苦于以下问题:C# System.Drawing.Drawing2D.GraphicsPath类的具体用法?C# System.Drawing.Drawing2D.GraphicsPath怎么用?C# System.Drawing.Drawing2D.GraphicsPath使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
System.Drawing.Drawing2D.GraphicsPath类属于命名空间,在下文中一共展示了System.Drawing.Drawing2D.GraphicsPath类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Round
// 圆角代码
public void Round(System.Drawing.Region region)
{
// -----------------------------------------------------------------------------------------------
// 已经是.net提供给我们的最容易的改窗体的属性了(以前要自己调API)
System.Drawing.Drawing2D.GraphicsPath oPath = new System.Drawing.Drawing2D.GraphicsPath();
int x = 0;
int y = 0;
int thisWidth = this.Width;
int thisHeight = this.Height;
int angle = _Radius;
if (angle > 0)
{
System.Drawing.Graphics g = CreateGraphics();
oPath.AddArc(x, y, angle, angle, 180, 90); // 左上角
oPath.AddArc(thisWidth - angle, y, angle, angle, 270, 90); // 右上角
oPath.AddArc(thisWidth - angle, thisHeight - angle, angle, angle, 0, 90); // 右下角
oPath.AddArc(x, thisHeight - angle, angle, angle, 90, 90); // 左下角
oPath.CloseAllFigures();
Region = new System.Drawing.Region(oPath);
}
// -----------------------------------------------------------------------------------------------
else
{
oPath.AddLine(x + angle, y, thisWidth - angle, y); // 顶端
oPath.AddLine(thisWidth, y + angle, thisWidth, thisHeight - angle); // 右边
oPath.AddLine(thisWidth - angle, thisHeight, x + angle, thisHeight); // 底边
oPath.AddLine(x, y + angle, x, thisHeight - angle); // 左边
oPath.CloseAllFigures();
Region = new System.Drawing.Region(oPath);
}
}
示例2: BBControl
public BBControl(int X, int Y, int dx, int dy)
{
InitializeComponent();
this.Location = new Point(X, Y);
Random rannd = new Random();
this.dx = dx;
this.dy = dy;
while (dy == 0)
{
this.dy = rannd.Next(-50, 50);
}
while (dx == 0)
{
this.dx = rannd.Next(-50, 50);
}
Color color = Color.FromArgb(rannd.Next(255), rannd.Next(255), rannd.Next(255));
while (color == Color.White)
{
color = Color.FromArgb(rannd.Next(255), rannd.Next(255), rannd.Next(255));
}
this.BackColor = color;
this.Width = 2 * rannd.Next(2, 25);
this.Height = this.Width;
System.Drawing.Drawing2D.GraphicsPath Button_Path = new System.Drawing.Drawing2D.GraphicsPath();
Button_Path.AddEllipse(0, 0, this.Width, this.Height);
Region Button_Region = new Region(Button_Path);
this.Region = Button_Region;
thread = new Thread(DoWork);
thread.Start();
}
示例3: DrawFilledPath
private void DrawFilledPath(SeriesBase series, System.Drawing.Pen pen,System.Drawing.Brush brush)
{
var path = new System.Drawing.Drawing2D.GraphicsPath();
if (series is AreaSeries)
{
path.StartFigure();
AreaSeries areaSeries = series as AreaSeries;
var points = areaSeries.AreaPoints;
var pointCount = areaSeries.AreaPoints.Count;
for (int i = 0; i < pointCount - 1; i++)
{
System.Drawing.PointF startPoint = points[i].AsDrawingPointF();
System.Drawing.PointF endPoint = points[i + 1].AsDrawingPointF();
path.AddLine(startPoint, endPoint);
}
path.CloseAllFigures();
switch (RenderingMode)
{
case RenderingMode.GDIRendering:
GDIGraphics.FillPath(brush, path);
break;
case RenderingMode.Default:
break;
case RenderingMode.WritableBitmap:
WritableBitmapGraphics.FillPath(brush, path);
break;
default:
break;
}
}
}
示例4: DrawLabel
/// <summary>
/// Renders a label to the map.
/// </summary>
/// <param name="g">Graphics reference</param>
/// <param name="LabelPoint">Label placement</param>
/// <param name="Offset">Offset of label in screen coordinates</param>
/// <param name="font">Font used for rendering</param>
/// <param name="forecolor">Font forecolor</param>
/// <param name="backcolor">Background color</param>
/// <param name="halo">Color of halo</param>
/// <param name="rotation">Text rotation in degrees</param>
/// <param name="text">Text to render</param>
/// <param name="map">Map reference</param>
public static void DrawLabel(System.Drawing.Graphics g, System.Drawing.PointF LabelPoint, System.Drawing.PointF Offset, System.Drawing.Font font, System.Drawing.Color forecolor, System.Drawing.Brush backcolor, System.Drawing.Pen halo, float rotation, string text, SharpMap.Map map)
{
System.Drawing.SizeF fontSize = g.MeasureString(text, font); //Calculate the size of the text
LabelPoint.X += Offset.X; LabelPoint.Y += Offset.Y; //add label offset
if (rotation != 0 && rotation != float.NaN)
{
g.TranslateTransform(LabelPoint.X, LabelPoint.Y);
g.RotateTransform(rotation);
g.TranslateTransform(-fontSize.Width / 2, -fontSize.Height / 2);
if (backcolor != null && backcolor != System.Drawing.Brushes.Transparent)
g.FillRectangle(backcolor, 0, 0, fontSize.Width * 0.74f + 1f, fontSize.Height * 0.74f);
System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
path.AddString(text, font.FontFamily, (int)font.Style, font.Size, new System.Drawing.Point(0, 0), null);
if (halo != null)
g.DrawPath(halo, path);
g.FillPath(new System.Drawing.SolidBrush(forecolor), path);
//g.DrawString(text, font, new System.Drawing.SolidBrush(forecolor), 0, 0);
g.Transform = map.MapTransform;
}
else
{
if (backcolor != null && backcolor != System.Drawing.Brushes.Transparent)
g.FillRectangle(backcolor, LabelPoint.X, LabelPoint.Y, fontSize.Width * 0.74f + 1, fontSize.Height * 0.74f);
System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
path.AddString(text, font.FontFamily, (int)font.Style, font.Size, LabelPoint, null);
if (halo != null)
g.DrawPath(halo, path);
g.FillPath(new System.Drawing.SolidBrush(forecolor), path);
//g.DrawString(text, font, new System.Drawing.SolidBrush(forecolor), LabelPoint.X, LabelPoint.Y);
}
}
示例5: btnCFD_Paint
//Chnage Facing Direction CFD
private void btnCFD_Paint(object sender, PaintEventArgs e)
{
System.Drawing.Drawing2D.GraphicsPath myGraphicsPath = new System.Drawing.Drawing2D.GraphicsPath();
myGraphicsPath.AddEllipse(new Rectangle(0, 0, 100, 100));
btnCFD.Size = new System.Drawing.Size(100, 100);
btnCFD.Region = new Region(myGraphicsPath);
}
示例6: Form1
public Form1(String ime, PocetnaForma pf)
{
InitializeComponent();
igracIme = ime;
this.igraci = pf.igraci;
fruits = new List<Fruit>();
toolStripStatusLabel1.Text = "";
this.DoubleBuffered = true;
selected = false;
pf = new PocetnaForma();
this.pf = pf;
i1 = new Igrac(igracIme);
timer1.Start();
timer2.Start();
//za kopceto da bide okruglo i bez border
System.Drawing.Drawing2D.GraphicsPath ag = new System.Drawing.Drawing2D.GraphicsPath();
ag.AddArc(0, 0, button1.Width, button1.Height, 0, 360);
button1.Region = new Region(ag);
button1.TabStop = false;
button1.FlatStyle = FlatStyle.Flat;
button1.FlatAppearance.BorderSize = 0;
//za play kopceto
System.Drawing.Drawing2D.GraphicsPath ag1 = new System.Drawing.Drawing2D.GraphicsPath();
ag1.AddArc(0, 0, button2.Width, button2.Height, 0, 360);
button2.Region = new Region(ag1);
button2.TabStop = false;
button2.FlatStyle = FlatStyle.Flat;
button2.FlatAppearance.BorderSize = 0;
}
示例7: WndProc
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
switch (m.Msg)
{
case 0xf:
Graphics g = this.CreateGraphics();
g.FillRectangle(BorderBrush, this.ClientRectangle);
//Create the path for the arrow
System.Drawing.Drawing2D.GraphicsPath pth = new System.Drawing.Drawing2D.GraphicsPath();
PointF TopLeft = new PointF(this.Width - 13, (this.Height - 5) / 2);
PointF TopRight = new PointF(this.Width - 6, (this.Height - 5) / 2);
PointF Bottom = new PointF(this.Width - 9, (this.Height + 2) / 2);
pth.AddLine(TopLeft, TopRight);
pth.AddLine(TopRight, Bottom);
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
//Draw the arrow
g.FillPath(new SolidBrush(Color.White), pth);
break;
default:
break;
}
}
示例8: DrawRoundRect
/// <summary>
/// 绘制圆角
/// </summary>
/// <param name="g"></param>
/// <param name="p"></param>
/// <param name="X"></param>
/// <param name="Y"></param>
/// <param name="width"></param>
/// <param name="height"></param>
/// <param name="radius"></param>
public static void DrawRoundRect(Graphics g, Pen p, Brush brush,float X, float Y, float width, float height, float radius)
{
System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
gp.AddLine(X + radius, Y, X + width - (radius * 2), Y);
gp.AddArc(X + width - (radius * 2), Y, radius * 2, radius * 2, 270, 90);
gp.AddLine(X + width, Y + radius, X + width, Y + height - (radius * 2));
gp.AddArc(X + width - (radius * 2), Y + height - (radius * 2), radius * 2, radius * 2, 0, 90);
gp.AddLine(X + width - (radius * 2), Y + height, X + radius, Y + height);
gp.AddArc(X, Y + height - (radius * 2), radius * 2, radius * 2, 90, 90);
gp.AddLine(X, Y + height - (radius * 2), X, Y + radius);
gp.AddArc(X, Y, radius * 2, radius * 2, 180, 90);
gp.CloseFigure();
g.DrawPath(p, gp);
g.FillPath(brush, gp);
gp.Dispose();
}
示例9: DrawCurves
/// <summary>
/// Draw curves on graphics with transform and given pen
/// </summary>
static void DrawCurves(
Graphics graphics,
List<PointF[]> curves,
System.Drawing.Drawing2D.Matrix transform,
Pen pen)
{
foreach( PointF[] curve in curves )
{
System.Drawing.Drawing2D.GraphicsPath gPath = new System.Drawing.Drawing2D.GraphicsPath();
if( curve.Length == 0 )
{
break;
}
if( curve.Length == 1 )
{
gPath.AddArc( new RectangleF( curve[0], new SizeF( 0.5f, 0.5f ) ), 0.0f, (float) Math.PI );
}
else
{
gPath.AddLines( curve );
}
if( transform != null )
gPath.Transform( transform );
graphics.DrawPath( pen, gPath );
}
}
示例10: frmLogin
public frmLogin()
{
InitializeComponent();
foreach (Button btn in this.Controls.OfType<Button>())
{//this will controll all button inside form
btn.FlatStyle = FlatStyle.Standard;
btn.ForeColor = Color.Black;
btn.BackColor = Color.White;
}
foreach (TextBox txtbox in this.Controls.OfType<TextBox>())
{//this will controll all textbox inside form
txtbox.BorderStyle = BorderStyle.None;
}
//background
this.BackgroundImage = Properties.Resources.bg;
this.BackgroundImageLayout = ImageLayout.Stretch;
System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
gp.AddEllipse(0, 0, pictureBox1.Width - 3, pictureBox1.Height - 3);
Region rg = new Region(gp);
pictureBox1.Region = rg;
}
示例11: Paint
/// <summary>
/// Repaints the form with cool background and stuff
/// </summary>
/// <param name="graph">The graphics object to paint to, the element will be drawn to 0,0</param>
override public void Paint(Graphics graph)
{
//Draws Rectangular Shapes
if (Shape == ModelShapes.Arrow)
{
_arrowPath = new System.Drawing.Drawing2D.GraphicsPath();
//Draws the basic shape
Pen arrowPen;
if (Highlight < 1)
arrowPen = new Pen(Color.Cyan, 3F);
else
arrowPen = new Pen(Color.Black, 3F);
//Draws the curved arrow
Point[] lineArray = new Point[4];
lineArray[0] = new Point(_startPoint.X, _startPoint.Y);
lineArray[1] = new Point(_startPoint.X - ((_startPoint.X - _stopPoint.X) / 3), _startPoint.Y);
lineArray[2] = new Point(_stopPoint.X - ((_stopPoint.X - _startPoint.X) / 3), _stopPoint.Y);
lineArray[3] = new Point(_stopPoint.X, _stopPoint.Y);
graph.DrawBeziers(arrowPen, lineArray);
_arrowPath.AddBeziers(lineArray);
_arrowPath.Flatten();
//Draws the arrow head
Point[] arrowArray = new Point[3];
arrowArray[0] = _stopPoint;
arrowArray[1] = new Point(_stopPoint.X - (5 * Math.Sign(_stopPoint.X - _startPoint.X)),_stopPoint.Y - 2);
arrowArray[2] = new Point(_stopPoint.X - (5 * Math.Sign(_stopPoint.X - _startPoint.X)), _stopPoint.Y + 2);
graph.DrawPolygon(arrowPen,arrowArray);
//Garbage collection
arrowPen.Dispose();
}
}
示例12: Form1_Load
private void Form1_Load(object sender, EventArgs e)
{
// Cut the form
System.Drawing.Drawing2D.GraphicsPath myPath = new System.Drawing.Drawing2D.GraphicsPath();
myPath.AddPolygon(new Point[] { new Point(0, 0), new Point(0, this.Height), new Point(this.Width, 0) });
Region myRegion = new Region(myPath); this.Region = myRegion;
}
示例13: Form1
public Form1()
{
InitializeComponent();
saveLogs("InitializeComponent");
cookies = ReadCookiesFromDisk("cookies.dat");
if ((!check()) && (Properties.Settings.Default.email != "") && (Properties.Settings.Default.password != ""))
{
if (!auth())
resultLabel.Text = "Error authentication";
}
Microsoft.Win32.RegistryKey readKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\ETS2MP");
if (readKey != null)
{
regInstallLocation = (string)readKey.GetValue("InstallLocation");
regInstallDir = (string)readKey.GetValue("InstallDir");
}
else
{
saveLogs("Game not found!");
}
System.Drawing.Drawing2D.GraphicsPath Button_Path = new System.Drawing.Drawing2D.GraphicsPath();
Button_Path.AddEllipse(0, 0, btnPlay.Width, btnPlay.Height);
System.Drawing.Region Button_Region = new System.Drawing.Region(Button_Path);
this.btnPlay.Region = Button_Region;
}
示例14: GetPath
private System.Drawing.Drawing2D.GraphicsPath GetPath(int index)
{
System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
path.Reset();
Rectangle rect = this.GetTabRect(index);
if (index == 0)
{
path.AddLine(rect.Left + 1, rect.Bottom + 1, rect.Left + rect.Height, rect.Top + 2);
path.AddLine(rect.Left + rect.Height + 4, rect.Top, rect.Right - 3, rect.Top);
path.AddLine(rect.Right - 1, rect.Top + 2, rect.Right - 1, rect.Bottom + 1);
}
else
{
if (index == this.SelectedIndex)
{
path.AddLine(rect.Left + 5 - rect.Height, rect.Bottom + 1, rect.Left + 4, rect.Top + 2);
path.AddLine(rect.Left + 8, rect.Top, rect.Right - 3, rect.Top);
path.AddLine(rect.Right - 1, rect.Top + 2, rect.Right - 1, rect.Bottom + 1);
path.AddLine(rect.Right - 1, rect.Bottom + 1, rect.Left + 5 - rect.Height, rect.Bottom + 1);
}
else
{
path.AddLine(rect.Left, rect.Top + 6, rect.Left + 4, rect.Top + 2);
path.AddLine(rect.Left + 8, rect.Top, rect.Right - 3, rect.Top);
path.AddLine(rect.Right - 1, rect.Top + 2, rect.Right - 1, rect.Bottom + 1);
path.AddLine(rect.Right - 1, rect.Bottom + 1, rect.Left, rect.Bottom + 1);
}
}
return path;
}
示例15: TestPathPointSymbolizer
public void TestPathPointSymbolizer()
{
var fdt = CreatingData.CreatePointFeatureDataTableFromArrays(
CreatingData.GetRandomOrdinates(50, -180, 180), CreatingData.GetRandomOrdinates(50, -90, 90), null);
var geometryFeatureProvider = new SharpMap.Data.Providers.FeatureProvider(fdt);
var layer = new SharpMap.Layers.VectorLayer("randompoints", geometryFeatureProvider);
var pps =
SharpMap.Rendering.Symbolizer.PathPointSymbolizer.CreateSquare(new System.Drawing.Pen(System.Drawing.Color.Red, 2),
new System.Drawing.SolidBrush(
System.Drawing.Color.DodgerBlue), 20);
layer.Style.PointSymbolizer = pps;
var map = new SharpMap.Map(new System.Drawing.Size(720, 360));
map.Layers.Add(layer);
map.ZoomToExtents();
map.GetMap().Save("PathPointSymbolizer1.bmp");
pps.Rotation = -30;
map.GetMap().Save("PathPointSymbolizer2.bmp");
pps.Rotation = 0f;
pps.Offset = new System.Drawing.PointF(4, 4);
map.GetMap().Save("PathPointSymbolizer3.bmp");
var gpTriangle1 = new System.Drawing.Drawing2D.GraphicsPath();
gpTriangle1.AddPolygon(new [] { new System.Drawing.Point(0, 0), new System.Drawing.Point(5, 10), new System.Drawing.Point(10, 0), new System.Drawing.Point(0, 0), });
var gpTriangle2 = new System.Drawing.Drawing2D.GraphicsPath();
gpTriangle2.AddPolygon(new[] { new System.Drawing.Point(0, 0), new System.Drawing.Point(-5, -10), new System.Drawing.Point(-10, 0), new System.Drawing.Point(0, 0), });
pps = new
SharpMap.Rendering.Symbolizer.PathPointSymbolizer(new[]
{
new SharpMap.Rendering.Symbolizer.PathPointSymbolizer.PathDefinition
{
Path = gpTriangle1,
Line =
new System.Drawing.Pen(
System.Drawing.Color.Red, 2),
Fill =
new System.Drawing.SolidBrush(
System.Drawing.Color.DodgerBlue)
},
new SharpMap.Rendering.Symbolizer.PathPointSymbolizer.PathDefinition
{
Path = gpTriangle2,
Line =
new System.Drawing.Pen(
System.Drawing.Color.DodgerBlue, 2),
Fill =
new System.Drawing.SolidBrush(
System.Drawing.Color.Red)
}
}){ Rotation = 45 };
layer.Style.PointSymbolizer = pps;
map.GetMap().Save("PathPointSymbolizer4.bmp");
pps.Rotation = 180;
map.GetMap().Save("PathPointSymbolizer5.bmp");
}