本文整理汇总了C#中System.Line.Begin方法的典型用法代码示例。如果您正苦于以下问题:C# Line.Begin方法的具体用法?C# Line.Begin怎么用?C# Line.Begin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Line
的用法示例。
在下文中一共展示了Line.Begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FillRectangle
/// <summary>
/// Fills a Rectangle.
/// </summary>
/// <param name="color">The Color.</param>
/// <param name="rectangle">The Rectangle.</param>
public void FillRectangle(Color color, Rectangle rectangle)
{
var line = new Line(_direct3D9Device) {Antialias = true, Width = rectangle.Height};
line.Begin();
line.Draw(
DirectXHelper.ConvertToVertex(new Vector2(rectangle.X, rectangle.Center.Y),
new Vector2(rectangle.X + rectangle.Width, rectangle.Center.Y)),
DirectXHelper.ConvertColor(color));
line.End();
}
示例2: EndSceneHook
//.........这里部分代码省略.........
new SlimDX.Vector2(_renderTarget.Description.Width - 1, _renderTarget.Description.Height - 1),
new SlimDX.Vector2(0, _renderTarget.Description.Height - 1),
new SlimDX.Vector2(_renderTarget.Description.Width - 1, 0),
new SlimDX.Vector2(0, 0),
new SlimDX.Vector2(0, _renderTarget.Description.Height - 1),
new SlimDX.Vector2(_renderTarget.Description.Width - 1, _renderTarget.Description.Height - 1),
new SlimDX.Vector2(_renderTarget.Description.Width - 1, 0),
};
}
else
{
_lineVectors = new SlimDX.Vector2[] {
new SlimDX.Vector2(this.Request.RegionToCapture.X, this.Request.RegionToCapture.Y),
new SlimDX.Vector2(this.Request.RegionToCapture.Right, this.Request.RegionToCapture.Bottom),
new SlimDX.Vector2(this.Request.RegionToCapture.X, this.Request.RegionToCapture.Bottom),
new SlimDX.Vector2(this.Request.RegionToCapture.Right, this.Request.RegionToCapture.Y),
new SlimDX.Vector2(this.Request.RegionToCapture.X, this.Request.RegionToCapture.Y),
new SlimDX.Vector2(this.Request.RegionToCapture.X, this.Request.RegionToCapture.Bottom),
new SlimDX.Vector2(this.Request.RegionToCapture.Right, this.Request.RegionToCapture.Bottom),
new SlimDX.Vector2(this.Request.RegionToCapture.Right, this.Request.RegionToCapture.Y),
};
}
#endregion
using (Surface backBuffer = device.GetBackBuffer(0, 0))
{
// Create a super fast copy of the back buffer on our Surface
device.GetRenderTargetData(backBuffer, _renderTarget);
// We have the back buffer data and can now work on copying it to a bitmap
ProcessRequest();
}
}
finally
{
// We have completed the request - mark it as null so we do not continue to try to capture the same request
// Note: If you are after high frame rates, consider implementing buffers here to capture more frequently
// and send back to the host application as needed. The IPC overhead significantly slows down
// the whole process if sending frame by frame.
Request = null;
}
DateTime end = DateTime.Now;
this.DebugMessage("EndSceneHook: Capture time: " + (end - start).ToString());
_lastScreenshotTime = (end - start);
}
}
#endregion
#region Example: Draw Overlay (after screenshot so we don't capture overlay as well)
if (this.ShowOverlay)
{
#region Draw fading lines based on last screencapture request
if (_lastRequestTime != null && _lineVectors != null)
{
TimeSpan timeSinceRequest = DateTime.Now - _lastRequestTime.Value;
if (timeSinceRequest.TotalMilliseconds < 1000.0)
{
using (Line line = new Line(device))
{
_lineAlpha = (float)((1000.0 - timeSinceRequest.TotalMilliseconds) / 1000.0); // This is our fade out
line.Antialias = true;
line.Width = 1.0f;
line.Begin();
line.Draw(_lineVectors, new SlimDX.Color4(_lineAlpha, 0.5f, 0.5f, 1.0f));
line.End();
}
}
else
{
_lineVectors = null;
}
}
#endregion
#region Draw frame rate
using (SlimDX.Direct3D9.Font font = new SlimDX.Direct3D9.Font(device, new System.Drawing.Font("Times New Roman", 16.0f)))
{
if (_lastFrame != null)
{
font.DrawString(null, String.Format("{0:N1} fps", (1000.0 / (DateTime.Now - _lastFrame.Value).TotalMilliseconds)), 100, 100, System.Drawing.Color.Red);
}
_lastFrame = DateTime.Now;
}
#endregion
}
#endregion
}
catch(Exception e)
{
// If there is an error we do not want to crash the hooked application, so swallow the exception
this.DebugMessage("EndSceneHook: Exeception: " + e.GetType().FullName + ": " + e.Message);
}
// EasyHook has already repatched the original EndScene - so calling EndScene against the SlimDX device will call the original
// EndScene and bypass this hook. EasyHook will automatically reinstall the hook after this hook function exits.
return device.EndScene().Code;
}
}
示例3: DrawRectangle
/// <summary>
/// Draws a Rectangle.
/// </summary>
/// <param name="pen">The Pen.</param>
/// <param name="rectangle">The Rectangle.</param>
public void DrawRectangle(Pen pen, Rectangle rectangle)
{
var dxPen = pen.Instance as DirectXPen;
if (dxPen == null) throw new ArgumentException("DirectX9 expects a DirectXPen as resource.");
var line = new Line(_direct3D9Device) {Antialias = true, Width = dxPen.Width};
line.Begin();
line.Draw(
DirectXHelper.ConvertToVertex(
new Vector2(rectangle.X, rectangle.Y),
new Vector2(rectangle.X + rectangle.Width, rectangle.Y),
new Vector2(rectangle.X, rectangle.Y + rectangle.Height),
new Vector2(rectangle.X + rectangle.Width, rectangle.Y + rectangle.Height),
new Vector2(rectangle.X, rectangle.Y),
new Vector2(rectangle.X, rectangle.Y + rectangle.Height),
new Vector2(rectangle.X + rectangle.Width, rectangle.Y),
new Vector2(rectangle.X + rectangle.Width, rectangle.Y + rectangle.Height)),
DirectXHelper.ConvertColor(dxPen.Color));
line.End();
}
示例4: FillEllipse
/// <summary>
/// Fills a Ellipse.
/// </summary>
/// <param name="color">The Color.</param>
/// <param name="ellipse">The Ellipse.</param>
public void FillEllipse(Color color, Ellipse ellipse)
{
var line = new Line(_direct3D9Device) {Antialias = false, Width = 2};
line.Begin();
line.Draw(DirectXHelper.ConvertToVertex(ellipse.Points), DirectXHelper.ConvertColor(color));
line.End();
}
示例5: DrawFacialView
private void DrawFacialView(ToothGraphic toothGraphic,Matrix defOrient) {
Matrix toothTrans=Matrix.Identity;
toothTrans.Translate(GetTransX(toothGraphic.ToothID),
GetTransYfacial(toothGraphic.ToothID),
0);
Matrix rotAndTranUser=ToothRotationAndTranslationMatrix(toothGraphic);
device.Transform.World=rotAndTranUser*toothTrans*defOrient;
if(toothGraphic.Visible
||(toothGraphic.IsCrown && toothGraphic.IsImplant)
||toothGraphic.IsPontic)
{
DrawTooth(toothGraphic);
}
device.RenderState.ZBufferEnable=false;
device.RenderState.Lighting=false;
Matrix lineMatrix=ScreenSpaceMatrix();
Line line=new Line(device);
line.GlLines=true;
if(toothGraphic.DrawBigX) {
//Thickness of line depends on size of window.
//The line size needs to be slightly larger than in OpenGL because
//lines are drawn with polygons in DirectX and they are anti-aliased,
//even when the line.Antialias flag is set.
line.Width=2.2f*TcData.PixelScaleRatio;
line.Begin();
if(ToothGraphic.IsMaxillary(toothGraphic.ToothID)) {
line.DrawTransform(new Vector3[] {
new Vector3(-2f,12f,0f),
new Vector3(2f,-6f,0f),},
lineMatrix,
toothGraphic.colorX);
line.DrawTransform(new Vector3[] {
new Vector3(2f,12f,0f),
new Vector3(-2f,-6f,0f),},
lineMatrix,
toothGraphic.colorX);
}
else {
line.DrawTransform(new Vector3[] {
new Vector3(-2f,6f,0f),
new Vector3(2f,-12f,0f),},
lineMatrix,
toothGraphic.colorX);
line.DrawTransform(new Vector3[] {
new Vector3(2f,6f,0f),
new Vector3(-2f,-12f,0f),},
lineMatrix,
toothGraphic.colorX);
}
line.End();
}
if(toothGraphic.Visible && toothGraphic.IsRCT) {//draw RCT
//Thickness of lines depend on size of window.
//The line size needs to be slightly larger than in OpenGL because
//lines are drawn with polygons in DirectX and they are anti-aliased,
//even when the line.Antialias flag is set.
line.Width=2.5f*TcData.PixelScaleRatio;
line.Begin();
List<LineSimple> linesSimple=toothGraphic.GetRctLines();
for(int i=0;i<linesSimple.Count;i++) {
if(linesSimple[i].Vertices.Count<2){
continue;//Just to avoid internal errors, even though not likely.
}
//Convert each line strip into very simple two point lines so that line extensions can be calculated more easily below.
//Items in the array are tuples of (2D point,bool indicating end point).
List <object> twoPointLines=new List<object> ();
for(int j=0;j<linesSimple[i].Vertices.Count-1;j++){
twoPointLines.Add(new Vector3(
linesSimple[i].Vertices[j ].X,
linesSimple[i].Vertices[j ].Y,
linesSimple[i].Vertices[j ].Z));
twoPointLines.Add(j==0);
twoPointLines.Add(new Vector3(
linesSimple[i].Vertices[j+1].X,
linesSimple[i].Vertices[j+1].Y,
linesSimple[i].Vertices[j+1].Z));
twoPointLines.Add(j==linesSimple[i].Vertices.Count-2);
}
//Draw each individual two point line. The lines must be broken down from line strips so that when individual two point
//line locations are modified they do not affect any other two point lines within the same line strip.
for(int j=0;j<twoPointLines.Count;j+=4){
Vector3 p1=(Vector3)twoPointLines[j];
bool p1IsEndPoint=(bool)twoPointLines[j+1];
Vector3 p2=(Vector3)twoPointLines[j+2];
bool p2IsEndPoint=(bool)twoPointLines[j+3];
Vector3 lineDir=p2-p1;
lineDir.Normalize();//Gives the line direction a single unit length.
float extSize=0.25f;//The number of units to extend each end of the two point line.
if(!p1IsEndPoint){//Do not extend the endpoints for the ends of the line strips.
p1=p1-extSize*lineDir;
}
if(!p2IsEndPoint){//Do not extend the endpoints for the ends of the line strips.
p2=p2+extSize*lineDir;
}
Vector3[] lineVerts=new Vector3[] {p1,p2};
line.DrawTransform(lineVerts,lineMatrix,toothGraphic.colorRCT);
}
}
line.End();
}
//.........这里部分代码省略.........
示例6: DrawPolygon
/// <summary>
/// Draws a Polygon.
/// </summary>
/// <param name="pen">The Pen.</param>
/// <param name="polygon">The Polygon.</param>
public void DrawPolygon(Pen pen, Polygon polygon)
{
var dxPen = pen.Instance as DirectXPen;
if (dxPen == null) throw new ArgumentException("DirectX9 expects a DirectXPen as resource.");
var line = new Line(_direct3D9Device) {Antialias = true, Width = dxPen.Width};
line.Begin();
line.Draw(DirectXHelper.ConvertToVertex(polygon.Points), DirectXHelper.ConvertColor(dxPen.Color));
line.End();
}
示例7: DrawDrawingSegments
private void DrawDrawingSegments() {
device.RenderState.Lighting=false;
device.RenderState.ZBufferEnable=false;
device.Transform.World=Matrix.Identity;
Matrix lineMatrix=ScreenSpaceMatrix();
Line line=new Line(device);
line.Width=2.2f*TcData.PixelScaleRatio;
line.Begin();
for(int s=0;s<TcData.DrawingSegmentList.Count;s++) {
string[] pointStr=TcData.DrawingSegmentList[s].DrawingSegment.Split(';');
List<Vector3> points=new List<Vector3>();
for(int p=0;p<pointStr.Length;p++) {
string[] xy=pointStr[p].Split(',');
if(xy.Length==2) {
Point point=new Point((int)(float.Parse(xy[0])),(int)(float.Parse(xy[1])));
//if we set 0,0 to center, then this is where we would convert it back.
PointF pointMm=TcData.PointDrawingPixToMm(point);
points.Add(new Vector3(pointMm.X,pointMm.Y,0f));
}
}
//Convert each line strip into very simple two point lines so that line extensions can be calculated more easily below.
List<Vector3> twoPointLines=new List<Vector3>();
for(int j=0;j<points.Count-1;j++) {
twoPointLines.Add(new Vector3(
points[j].X,
points[j].Y,
points[j].Z));
twoPointLines.Add(new Vector3(
points[j+1].X,
points[j+1].Y,
points[j+1].Z));
}
//Draw each individual two point line. The lines must be broken down from line strips so that when individual two point
//line locations are modified they do not affect any other two point lines within the same line strip.
//All lines are expanded on both sides here, because the drawing could end with a loop and the loop must be closed.
for(int j=0;j<twoPointLines.Count;j+=2){
Vector3 p1=(Vector3)twoPointLines[j];
Vector3 p2=(Vector3)twoPointLines[j+1];
Vector3 lineDir=p2-p1;
lineDir.Normalize();//Gives the line direction a single unit length.
float extSize=0.25f;//The number of units to extend each end of the two point line.
p1=p1-extSize*lineDir;
p2=p2+extSize*lineDir;
Vector3[] lineVerts=new Vector3[] {p1,p2};
line.DrawTransform(lineVerts,lineMatrix,TcData.DrawingSegmentList[s].ColorDraw);
}
//no filled circle at intersections
}
//Draw the points that make up the segment which is currently being drawn
//but which has not yet been sent to the database.
for(int p=1;p<TcData.PointList.Count;p++){
PointF pMm1=TcData.PointPixToMm(TcData.PointList[p]);
PointF pMm2=TcData.PointPixToMm(TcData.PointList[p-1]);
line.DrawTransform(new Vector3[] {
new Vector3(pMm1.X,pMm1.Y,0f),
new Vector3(pMm2.X,pMm2.Y,0f)},
lineMatrix,
TcData.ColorDrawing);
}
line.End();
line.Dispose();
}
示例8: DrawRectangle
void DrawRectangle(float x, float y, float w, int h, Line MenuLine, SlimDX.Direct3D9.Font MenuFont, Color4 MenuLineColor)
{
try
{
SlimDX.Vector2[] vLine1 = new SlimDX.Vector2[2];
SlimDX.Vector2[] vLine2 = new SlimDX.Vector2[2];
SlimDX.Vector2[] vLine3 = new SlimDX.Vector2[2];
SlimDX.Vector2[] vLine4 = new SlimDX.Vector2[2];
vLine1[0] = new Vector2();
vLine1[1] = new Vector2();
vLine2[0] = new Vector2();
vLine2[1] = new Vector2();
vLine3[0] = new Vector2();
vLine3[1] = new Vector2();
vLine4[0] = new Vector2();
vLine4[1] = new Vector2();
vLine1[0].X = x;
vLine1[0].Y = y;
vLine1[1].X = x;
vLine1[1].Y = y + h;
vLine2[0].X = x + w;
vLine2[0].Y = y;
vLine2[1].X = x + w;
vLine2[1].Y = y + h;
vLine3[0].X = x;
vLine3[0].Y = y;
vLine3[1].X = x + w;
vLine3[1].Y = y;
vLine4[0].X = x;
vLine4[0].Y = y + h;
vLine4[1].X = x + w;
vLine4[1].Y = y + h;
if (MenuLine != null)
{
MenuLine.Width = 2;
MenuLine.Antialias = false;
MenuLine.GLLines = false;
MenuLine.Begin();
MenuLine.Draw(vLine1, MenuLineColor);
MenuLine.Draw(vLine2, MenuLineColor);
MenuLine.Draw(vLine3, MenuLineColor);
MenuLine.Draw(vLine4, MenuLineColor);
MenuLine.End();
}
}
catch (Exception ExtInfo)
{
Interface.ReportException(ExtInfo);
return;
}
}
示例9: DrawNumbersAndLines
private void DrawNumbersAndLines() {
//Draw the center line.
Line centerLine=new Line(device);
centerLine.Width=1f*TcData.PixelScaleRatio;
centerLine.Antialias=false;
centerLine.Begin();//Must call Line.Begin() in order for Antialias=false to take effect.
centerLine.Draw(new Vector2[] {
new Vector2(-1,this.Height/2),
new Vector2(this.Width,this.Height/2)},
Color.White);
centerLine.End();
//Draw the tooth numbers.
string tooth_id;
for(int i=1;i<=52;i++) {
tooth_id=Tooth.FromOrdinal(i);
if(TcData.SelectedTeeth.Contains(tooth_id)) {
DrawNumber(tooth_id,true,0);
}
else {
DrawNumber(tooth_id,false,0);
}
}
//TimeSpan displayTime=(frameEndTime-frameBeginTime);
//float fps=1000f/displayTime.Milliseconds;
//this.PrintString(fps.ToString(),0,0,0,Color.Blue,xfont);
}
示例10: DrawNumbersAndLinesPerio
private void DrawNumbersAndLinesPerio(float baseY) {
device.RenderState.Lighting=false;
device.RenderState.ZBufferEnable=false;
//Draw the center line.
device.Transform.World=Matrix.Identity;
Matrix lineMatrix=ScreenSpaceMatrix();
Line centerLine=new Line(device);
centerLine.Width=2.5f;
centerLine.Antialias=false;
centerLine.Begin();//Must call Line.Begin() in order for Antialias=false to take effect.
centerLine.DrawTransform(new Vector3[] {
new Vector3(-65f,baseY,0),
new Vector3(65f,baseY,0)},
lineMatrix,
Color.Black);
centerLine.End();
//Draw the tooth numbers.
string tooth_id;
for(int i=1;i<=32;i++) {
tooth_id=Tooth.FromOrdinal(i);
//bool isSelected=TcData.SelectedTeeth.Contains(tooth_id);
float yOffset=ToothGraphic.IsMaxillary(tooth_id)?30:-29;
DrawNumber(tooth_id,false,baseY+yOffset);
}
}
示例11: DrawRectangle
public static void DrawRectangle(System.Drawing.Rectangle rect, long color, bool fill)
{
if (fill)
{
System.Drawing.Rectangle[] regions = new System.Drawing.Rectangle[1]
{
rect
};
GUIGraphicsContext.DX9Device.Clear(ClearFlags.Target, (int)color, 1f, 0, regions);
}
else
{
Vector2[] vertexList = new Vector2[2];
vertexList[0].X = (float)rect.Left;
vertexList[0].Y = (float)rect.Top;
vertexList[1].X = (float)(rect.Left + rect.Width);
vertexList[1].Y = (float)rect.Top;
using (Line line = new Line(GUIGraphicsContext.DX9Device))
{
line.Begin();
line.Draw(vertexList, (int)color);
vertexList[0].X = (float)(rect.Left + rect.Width);
vertexList[0].Y = (float)rect.Top;
vertexList[1].X = (float)(rect.Left + rect.Width);
vertexList[1].Y = (float)(rect.Top + rect.Height);
line.Draw(vertexList, (int)color);
vertexList[0].X = (float)(rect.Left + rect.Width);
vertexList[0].Y = (float)(rect.Top + rect.Width);
vertexList[1].X = (float)rect.Left;
vertexList[1].Y = (float)(rect.Top + rect.Height);
line.Draw(vertexList, (int)color);
vertexList[0].X = (float)rect.Left;
vertexList[0].Y = (float)(rect.Top + rect.Height);
vertexList[1].X = (float)rect.Left;
vertexList[1].Y = (float)rect.Top;
line.Draw(vertexList, (int)color);
line.End();
}
}
}
示例12: DrawLine
public static void DrawLine(int x1, int y1, int x2, int y2, long color)
{
Vector2[] vertexList = new Vector2[2];
vertexList[0].X = (float)x1;
vertexList[0].Y = (float)y1;
vertexList[1].X = (float)x2;
vertexList[1].Y = (float)y2;
using (Line line = new Line(GUIGraphicsContext.DX9Device))
{
line.Begin();
line.Draw(vertexList, (int)color);
line.End();
}
}
示例13: DrawOrigin
/// <summary>
///
/// </summary>
private void DrawOrigin()
{
this.dxDevice.Transform.World = Matrix.Translation(0, 0, 0);
Matrix lineMatrix = this.dxDevice.Transform.World * this.dxDevice.Transform.View * this.dxDevice.Transform.Projection;
using (Line myLine = new Line(this.dxDevice))
{
// Set the width
myLine.Width = 1;
// Should they be antialiased?
myLine.Antialias = true;
// Draw the line
myLine.Begin();
myLine.DrawTransform(this.vtrOrigin, lineMatrix, Color.WhiteSmoke);
myLine.End();
} // End of using block
}
示例14: DrawLine
public static void DrawLine(int x1, int y1, int x2, int y2, long color)
{
Vector2[] vec = new Vector2[2];
vec[0].X = x1;
vec[0].Y = y1;
vec[1].X = x2;
vec[1].Y = y2;
using (Line line = new Line(GUIGraphicsContext.DX9Device))
{
line.Begin();
line.Draw(vec, (int)color);
line.End();
}
}
示例15: DrawExtended3dLine
///<summary>Draws a line strip extending the two point lines which to not include endpoints.
///Set extendEndPoints to true to extend the endpoints of the line.</summary>
private void DrawExtended3dLine(Vector3[] points,float extendDist,bool extendEndPoints,Color color,float lineWidth,Matrix transform){
//Convert each line strip into very simple two point lines so that line extensions can be calculated more easily below.
//Items in the array are tuples of (2D point,bool indicating end point).
List<object> twoPointLines=new List<object>();
for(int p=0;p<points.Length-1;p++) {
twoPointLines.Add(points[p]);
twoPointLines.Add(p==0);
twoPointLines.Add(points[p+1]);
twoPointLines.Add(p==points.Length-2);
}
Line line=new Line(device);
line.Antialias=false;
line.Width=lineWidth;
line.Begin();
//Draw each individual two point line. The lines must be broken down from line strips so that when individual two point
//line locations are modified they do not affect any other two point lines within the same line strip.
for(int j=0;j<twoPointLines.Count;j+=4) {
Vector3 p1=(Vector3)twoPointLines[j];
bool p1IsEndPoint=(bool)twoPointLines[j+1];
Vector3 p2=(Vector3)twoPointLines[j+2];
bool p2IsEndPoint=(bool)twoPointLines[j+3];
Vector3 lineDir=p2-p1;
lineDir.Normalize();//Gives the line direction a single unit length.
//Do not extend the endpoints for the ends of the line strips unless extendEndPoints=true.
if(!p1IsEndPoint || extendEndPoints) {
p1=p1-extendDist*lineDir;
}
//Do not extend the endpoints for the ends of the line strips unless extendEndPoints=true.
if(!p2IsEndPoint || extendEndPoints) {
p2=p2+extendDist*lineDir;
}
Vector3[] lineVerts=new Vector3[] { p1,p2 };
line.DrawTransform(lineVerts,transform,color);
}
line.End();
line.Dispose();
}