本文整理汇总了C#中Line类的典型用法代码示例。如果您正苦于以下问题:C# Line类的具体用法?C# Line怎么用?C# Line使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Line类属于命名空间,在下文中一共展示了Line类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: boardCanvas_MouseDown
public void boardCanvas_MouseDown(object sender, MouseButtonEventArgs e)
{
boardCanvas.CaptureMouse();
sP = e.GetPosition(boardCanvas);
newAtr.Color = (Color)colorStroke.SelectedColor;
newAtr.Height = newAtr.Width = slider.Value;
boardCanvas.DefaultDrawingAttributes = newAtr;
if (tempTool == pencilImage.Name || tempTool == eraserImage.Name || tempTool == circleImage.Name || tempTool == rectangleImage.Name)
{
if (tempTool == circleImage.Name)
{
ellipse = new Ellipse();
}
else if (tempTool == rectangleImage.Name)
{
rect = new Rectangle();
}
}
else if (tempTool == lineImage.Name)
{
line_C = new Line();
}
else if (tempTool == textBoxImage.Name) {
tB = new TextBox();
}
//eP = new Point(0, 0);
}
示例2: MainWindow
public MainWindow()
{
InitializeComponent();
//int highestPrice = 65;
//List<int> vals = new List<int>() { 10, 20, 30, 40, 50 };
//int min = vals.Min();
//int max = vals.Max();
//max = highestPrice > max ? highestPrice : max;
//double range = max - min;
Color d = new Color() { ScA = 1, ScR = .5F, ScG = .5F, ScB = .5F };
var line = new Line() { X1 = 0, Y1 = 0, X2 = canvas.Width, Y2 = 0, Stroke = new SolidColorBrush(d), StrokeThickness = 2.0 };
line = new Line() { X1 = 0, Y1 = 0, X2 = canvas.Width, Y2 = 10, Stroke = new SolidColorBrush(d), StrokeThickness = 1.0 };
canvas.Children.Add(line);
line = new Line() { X1 = canvas.Width, Y1 = 10, X2 = 0, Y2 = 20, Stroke = new SolidColorBrush(d), StrokeThickness = 1.0 };
canvas.Children.Add(line);
//foreach (int val in vals)
//{
// double percent = 1.0 - ((val - min) / range); // 0 is at the top, so invert it by doing 1.0 - xxx
// double y = percent * canvas.Height;
// // Draw line in a shade of blue/green
// c = new Color() { ScA = 1, ScR = 0, ScG = 0.5f, ScB = (float)percent };
// line = new Line() { X1 = 0, Y1 = y, X2 = canvas.Width, Y2 = y, Stroke = new SolidColorBrush(c), StrokeThickness = 2.0 };
// canvas.Children.Add(line);
//}
}
示例3: DrawLineBetween
/// <summary>
/// Draw a line between two joints in a canvas
/// </summary>
/// <param name="canvas">the canvas</param>
/// <param name="jstart">the joint where to start the line</param>
/// <param name="jend">the joint where to end the line</param>
/// <param name="vskeleton">the visual skeleton</param>
private static void DrawLineBetween(Canvas canvas, Joint jstart, Joint jend, VisualSkeleton vskeleton)
{
if (vskeleton.positionMap.ContainsKey(jstart) && vskeleton.positionMap.ContainsKey(jend))
{
Line l = new Line();
l.X1 = vskeleton.positionMap[jstart].X;
l.Y1 = vskeleton.positionMap[jstart].Y;
l.X2 = vskeleton.positionMap[jend].X;
l.Y2 = vskeleton.positionMap[jend].Y;
if (jstart.TrackingState == JointTrackingState.Inferred &&
jend.TrackingState == JointTrackingState.Inferred)
{
l.Stroke = Brushes.Yellow;
l.StrokeThickness = 3;
}
else if (jstart.TrackingState == JointTrackingState.Tracked &&
jend.TrackingState == JointTrackingState.Tracked)
{
l.Stroke = Brushes.Green;
l.StrokeThickness = 3;
}
else if (jstart.TrackingState == JointTrackingState.NotTracked ||
jend.TrackingState == JointTrackingState.NotTracked)
{
l.Stroke = Brushes.Transparent;
l.StrokeThickness = 0;
}
canvas.Children.Add(l);
}
}
示例4: Log
/// <summary>
/// Add line to Log
/// </summary>
/// <param name="text"></param>
/// <param name="file"></param>
/// <param name="member"></param>
/// <param name="lineNumber"></param>
public static void Log(string text, LogLineType type = LogLineType.Notification, [CallerFilePath] string filename = "", [CallerMemberName] string member = "", [CallerLineNumber] int lineNumber = 0)
{
try
{
string[] lines = text.Split(new string[] { "\r\n", "\n", Environment.NewLine }, StringSplitOptions.None);
foreach (var line in lines)
{
var queueLine = new Line();
queueLine.Text = line;
queueLine.Type = type;
queueLine.Timestamp = DateTime.Now;
var assembly = Assembly.GetCallingAssembly();
queueLine.Assembly = assembly.FullName;
queueLine.Filename = filename;
queueLine.Member = member;
queueLine.LineNumber = lineNumber;
logQueue.AddLineToQueue(queueLine);
Console.WriteLine(line);
}
}
catch (Exception ex) { }
}
示例5: Setup
public void Setup()
{
m_StartPoint = new Point(-10.0,
-10.0);
m_EndPoint = new Point(10.0,
10.0);
m_LineDirection = Constants.LineDirection.Forward;
m_Line = new Line(m_StartPoint,
m_EndPoint);
m_WindowsStartPoint = new System.Windows.Point(100.0,
200.0);
m_WindowsEndPoint = new System.Windows.Point(300.0,
400.0);
m_GeometryPointToWindowsPointConverter = Substitute.For <IGeometryPointToWindowsPointConverter>();
m_GeometryPointToWindowsPointConverter.Point.Returns(m_WindowsStartPoint,
m_WindowsEndPoint);
m_Sut = new LineToWindowPointsConverter(m_GeometryPointToWindowsPointConverter)
{
Line = m_Line
};
m_Sut.Line = m_Line;
m_Sut.LineDirection = m_LineDirection;
m_Sut.Convert();
}
示例6: OnPart
public void OnPart(Line line)
{
line.GetChannel().Users.Remove(line.Prefix.Nickname);
if (line.PrefixIsSelf())
Channels.Remove(line.Target);
}
示例7: SqlCommandWithValues
internal static SqlCommand SqlCommandWithValues(SqlCommand sqlCommand, Line line) {
var values = line.Values.ToArray();
for (var i = 0; i < values.Length; i++) {
sqlCommand.Parameters[i].Value = values[i];
}
return sqlCommand;
}
示例8: Setup
public void Setup()
{
m_FromStartPoint = new Point(10.0,
10.0);
m_FromEndPoint = new Point(60.0,
60.0);
m_ToStartPoint = new Point(-10.0,
-10.0);
m_ToEndPoint = new Point(-60.0,
-60.0);
m_From = new Line(0,
m_FromStartPoint,
m_FromEndPoint);
m_FromDirection = Constants.LineDirection.Forward;
m_To = new Line(1,
m_ToStartPoint,
m_ToEndPoint);
m_ToDirection = Constants.LineDirection.Forward;
m_Sut = new LinesToTransferPointsConverter(m_From,
m_FromDirection,
m_To,
m_ToDirection);
m_Sut.Convert();
}
示例9: Intersect
// Static function to find the intersection of two planes
// If they are parallel, returns false and outputs an invalid line struct
// Otherwise, returns true and outputs the line of intersection
public static bool Intersect(Plane a, Plane b, out Line result)
{
Vec3 cross = Vec3.Cross(a.normal, b.normal);
double magsq = cross.ComputeMagnitudeSquared();
if (magsq == 0)
{
// failure! planes did not intersect, or planes were equal
result = new Line { direction = Vec3.Zero, origin = Vec3.Zero }; // not a valid line!
return false;
}
double invmag = 1.0 / Math.Sqrt(magsq);
Vec3 line_direction = cross * invmag;
// using plane a to find intersection (also could try b?)
Vec3 in_a_toward_edge = Vec3.Normalize(Vec3.Cross(a.normal, line_direction));
Vec3 point_in_a = a.normal * a.offset;
double dist = b.PointDistance(point_in_a);
// seems this number could be either the positive or negative of what we want...
double unsigned_r = dist * invmag;
Vec3 positive = point_in_a + in_a_toward_edge * unsigned_r;
Vec3 negative = point_in_a - in_a_toward_edge * unsigned_r;
// figure out which one is actually at the intersection (or closest to it)
double positive_check = new Vec2 { x = a.PointDistance(positive), y = b.PointDistance(positive) }.ComputeMagnitudeSquared();
double negative_check = new Vec2 { x = a.PointDistance(negative), y = b.PointDistance(negative) }.ComputeMagnitudeSquared();
// and use that one as a point on the line (for the out value)
Vec3 point_on_line;
if (positive_check < negative_check)
point_on_line = positive;
else
point_on_line = negative;
// success! planes intersectedx
result = new Line { origin = point_on_line, direction = line_direction };
return true;
}
示例10: Cross
internal static Vector Cross(Line line1, Line line2)
{
if (line2.K - line1.K == 0) return new Vector(0, line1.B);
var x = (line1.B - line2.B) / (line2.K - line1.K);
var y = line1.K * x + line1.B;
return new Vector(x, y);
}
示例11: Normal
internal static Line Normal(Line line, Vector point)
{
if (line.K == 0) return new Line(0, 0);
var kn = Math.Round(-1f / line.K, 1);
var bn = Math.Round(point.Y - kn * point.X, 1);
return new Line(kn, bn);
}
示例12: Setup
public void Setup()
{
m_Line1 = new Line(0, 10.0, 10.0, 20.0, 10.0);
m_Line2 = new Line(1, 10.0, 20.0, 20.0, 20.0);
m_Lines1 = new[] {m_Line1, m_Line2};
m_Lines2 = new[] {m_Line2, m_Line1};
m_ForwardForwardPaths = CreateForwardForwardPaths();
m_ForwardReversePaths = CreateForwardReversePaths();
m_ReverseForwardPaths = CreateReverseForwardPaths();
m_ReverseReversePaths = CreateReverseReversePaths();
m_Racetracks = Substitute.For<IRacetracks>();
m_Racetracks.ForwardToForward.Returns(m_ForwardForwardPaths);
m_Racetracks.ForwardToReverse.Returns(m_ForwardReversePaths);
m_Racetracks.ReverseToForward.Returns(m_ReverseForwardPaths);
m_Racetracks.ReverseToReverse.Returns(m_ReverseReversePaths);
m_Converter = new LineToLinesConverter(new CostStartToStartCalculator(),
new CostStartToEndCalculator(),
new CostEndToStartCalculator(),
new CostEndToEndCalculator())
{
Racetracks = m_Racetracks,
Line = m_Line1,
Lines = m_Lines1
};
m_Converter.Convert();
}
示例13: Move
public override void Move()
{
if (x + 2 < Console.WindowHeight && isGoingDown)
{
Console.SetCursorPosition(0, x);
foreach (var dot in LineTypes.AllLines[x].Dots)
{
dot.Content = Dot.ContentToString(Strings.emptyString);
}
LineTypes.AllLines[x].Draw();
x++;
this.ruler = LineTypes.AllLines[x];
}
else
{
isGoingDown = false;
}
if (x > 0 && !isGoingDown)
{
Console.SetCursorPosition(0, x);
foreach (var dot in LineTypes.AllLines[x].Dots)
{
dot.Content = Dot.ContentToString(Strings.emptyString);
}
LineTypes.AllLines[x].Draw();
x--;
this.ruler = LineTypes.AllLines[x];
}
else
{
isGoingDown = true;
}
}
示例14: Exec
async Task Exec(string cmd, double param)
{
var px = x; var py = y;
switch(cmd)
{
case "forw":
x += param * Math.Sin(Conv(angle));
y += param * Math.Cos(Conv(angle));
await Speak("Going forward");
break;
case "back":
x -= param * Math.Sin(Conv(angle));
y -= param * Math.Cos(Conv(angle));
await Speak("Going Back");
break;
case "left":
angle += param;
await Speak("Turning left");
break;
case "right":
angle -= param;
await Speak("Turning right");
break;
}
if (px!=x || py!=y)
{
var P = new Line();
P.X1 = px; P.Y1 = py;
P.X2 = x; P.Y2 = y;
P.Stroke = new SolidColorBrush(Colors.Black);
P.StrokeThickness = 1;
main.Children.Add(P);
}
SetTurtle();
}
示例15: GetGraphics
public override GraphicsResult GetGraphics(IWpfTextView view, Geometry geometry)
{
Initialize(view);
// We clip off a bit off the start of the line to prevent a half-square being
// drawn.
var clipRectangle = geometry.Bounds;
clipRectangle.Offset(2, 0);
var line = new Line
{
X1 = geometry.Bounds.Left,
Y1 = geometry.Bounds.Bottom - _graphicsTagPen.Thickness,
X2 = geometry.Bounds.Right,
Y2 = geometry.Bounds.Bottom - _graphicsTagPen.Thickness,
Clip = new RectangleGeometry { Rect = clipRectangle }
};
// RenderOptions.SetEdgeMode(line, EdgeMode.Aliased);
ApplyPen(line, _graphicsTagPen);
// Shift the line over to offset the clipping we did.
line.RenderTransform = new TranslateTransform(-_graphicsTagPen.Thickness, 0);
return new GraphicsResult(line, null);
}