本文整理汇总了C#中ScreenPoint类的典型用法代码示例。如果您正苦于以下问题:C# ScreenPoint类的具体用法?C# ScreenPoint怎么用?C# ScreenPoint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ScreenPoint类属于命名空间,在下文中一共展示了ScreenPoint类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: HitTestResult
/// <summary>
/// Initializes a new instance of the <see cref="HitTestResult" /> class.
/// </summary>
/// <param name="element">The element that was hit.</param>
/// <param name="nearestHitPoint">The nearest hit point.</param>
/// <param name="item">The item.</param>
/// <param name="index">The index.</param>
public HitTestResult(UIElement element, ScreenPoint nearestHitPoint, object item = null, double index = 0)
{
this.Element = element;
this.NearestHitPoint = nearestHitPoint;
this.Item = item;
this.Index = index;
}
开发者ID:benjaminrupp,项目名称:oxyplot,代码行数:14,代码来源:HitTestResult.cs
示例2: ColorPicker
/// <summary>
/// Erzeugt eine neue Instanz eines ColorPicker-Objekts und initialisiert diese
/// mit der Farbe, auf welche der Farbwähler beim Aufruf aus Sicht des Spielers zeigt.
/// </summary>
public ColorPicker(IScreen screen, DisplayLayer drawOrder, Color def)
: base(screen, drawOrder)
{
tileSize = new ScreenPoint (screen, 0.032f, 0.032f);
// Widget-Attribute
BackgroundColorFunc = (s) => Design.WidgetBackground;
ForegroundColorFunc = (s) => Design.WidgetForeground;
AlignX = HorizontalAlignment.Left;
AlignY = VerticalAlignment.Top;
// die Farb-Tiles
colors = new List<Color> (CreateColors (64));
colors.Sort (ColorHelper.SortColorsByLuminance);
tiles = new List<ScreenPoint> (CreateTiles (colors));
// einen Spritebatch
spriteBatch = new SpriteBatch (screen.GraphicsDevice);
// Position und Größe
Bounds.Position = ScreenPoint.Centered (screen, Bounds);
Bounds.Size.RelativeFunc = () => {
float sqrt = (float)Math.Ceiling (Math.Sqrt (colors.Count));
return tileSize * sqrt;
};
// Die Callback-Funktion zur Selektion setzt das SelectedColor-Attribut
ColorSelected += (color, time) => {
SelectedColor = color;
};
}
开发者ID:knot3,项目名称:knot3-code,代码行数:35,代码来源:ColorPicker.cs
示例3: GetNearestPoint
private static DataPoint? GetNearestPoint(ISeries s, ScreenPoint point, bool snap, bool pointsOnly)
{
if (s == null)
return null;
if (snap || pointsOnly)
{
ScreenPoint spn;
DataPoint dpn;
if (s.GetNearestPoint(point, out dpn, out spn) && snap)
{
if (spn.DistanceTo(point) < 20)
return dpn;
}
}
ScreenPoint sp;
DataPoint dp;
if (!pointsOnly)
if (s.GetNearestInterpolatedPoint(point, out dp, out sp))
return dp;
return null;
}
开发者ID:AndrewTPohlmann,项目名称:open-hardware-monitor,代码行数:25,代码来源:SliderAction.cs
示例4: OxyTouchEventArgs
/// <summary>
/// Initializes a new instance of the <see cref="OxyTouchEventArgs" /> class.
/// </summary>
/// <param name="currentTouches">The current touches.</param>
/// <param name="previousTouches">The previous touches.</param>
public OxyTouchEventArgs(ScreenPoint[] currentTouches, ScreenPoint[] previousTouches)
{
this.Position = currentTouches[0];
if (currentTouches.Length == previousTouches.Length)
{
this.DeltaTranslation = currentTouches[0] - previousTouches[0];
}
double scale = 1;
if (currentTouches.Length > 1 && currentTouches.Length == previousTouches.Length)
{
var currentDistance = (currentTouches[1] - currentTouches[0]).Length;
var previousDistance = (previousTouches[1] - previousTouches[0]).Length;
scale = currentDistance / previousDistance;
if (scale < 0.5)
{
scale = 0.5;
}
if (scale > 2)
{
scale = 2;
}
}
this.DeltaScale = new ScreenVector(scale, scale);
}
开发者ID:Celderon,项目名称:oxyplot,代码行数:34,代码来源:OxyTouchEventArgs.cs
示例5: TweenEffect
public TweenEffect(ScreenPoint startpoint, ScreenPoint endpoint, int time)
{
this.StartLocation = startpoint;
this.EndLocation = endpoint;
this.CurrentLocation = new ScreenPoint(this.StartLocation.X, this.StartLocation.Y);
this.Time = time;
this.Finished = (endpoint.X == startpoint.X && endpoint.Y == startpoint.Y);
}
开发者ID:NullSoldier,项目名称:Valkyrie,代码行数:9,代码来源:TweenEffect.cs
示例6: EmptyArray
public void EmptyArray()
{
var points = new ScreenPoint[0];
var clippingRectangle = new OxyRect(0.3, -0.5, 0.5, 1);
var rc = Substitute.For<IRenderContext>();
var received = new List<ScreenPoint>();
rc.DrawClippedLine(clippingRectangle, points, 1, OxyColors.Black, 1, null, LineJoin.Miter, false, null, received.AddRange);
Assert.AreEqual(0, received.Count);
}
开发者ID:benjaminrupp,项目名称:oxyplot,代码行数:9,代码来源:RenderingExtensionsTests.cs
示例7: EndpointsOutsideArea
public void EndpointsOutsideArea()
{
var clipping = new CohenSutherlandClipping(new OxyRect(0, 0, 1, 1));
var p0 = new ScreenPoint(0.3, -0.2);
var p1 = new ScreenPoint(0.6, 1.3);
Assert.IsTrue(clipping.ClipLine(ref p0, ref p1));
Assert.AreEqual(0, p0.Y);
Assert.AreEqual(1, p1.Y);
}
开发者ID:benjaminrupp,项目名称:oxyplot,代码行数:9,代码来源:CohenSutherlandClippingTests.cs
示例8: OnMouseMove
public override void OnMouseMove(ScreenPoint pt, bool control, bool shift)
{
if (currentSeries == null)
return;
var current = GetNearestPoint(currentSeries, pt, !control, shift);
if (current != null)
pc.ShowSlider(currentSeries, current.Value);
}
开发者ID:AndrewTPohlmann,项目名称:open-hardware-monitor,代码行数:9,代码来源:SliderAction.cs
示例9: EndpointsOutsideArea2
public void EndpointsOutsideArea2()
{
var clipping = new CohenSutherlandClipping(new OxyRect(0.3, -0.5, 0.5, 1));
var p0 = new ScreenPoint(0, 0);
var p1 = new ScreenPoint(1, 0);
Assert.IsTrue(clipping.ClipLine(ref p0, ref p1));
Assert.AreEqual(new ScreenPoint(0.3, 0), p0);
Assert.AreEqual(new ScreenPoint(0.8, 0), p1);
}
开发者ID:benjaminrupp,项目名称:oxyplot,代码行数:9,代码来源:CohenSutherlandClippingTests.cs
示例10: ClipLine_LineOutsideArea
public void ClipLine_LineOutsideArea()
{
var clipping = new CohenSutherlandClipping(0, 1, 0, 1);
var p0 = new ScreenPoint(0.3, -0.2);
var p1 = new ScreenPoint(0.6, -0.2);
Assert.IsFalse(clipping.ClipLine(ref p0, ref p1));
Assert.AreEqual(-0.2, p0.Y);
Assert.AreEqual(-0.2, p1.Y);
}
开发者ID:aleksanderkobylak,项目名称:oxyplot,代码行数:9,代码来源:CohenSutherlandClippingTests.cs
示例11: ClipLine_EndpointsInsideArea
public void ClipLine_EndpointsInsideArea()
{
var clipping = new CohenSutherlandClipping(0, 1, 0, 1);
var p0 = new ScreenPoint(0.3, 0.2);
var p1 = new ScreenPoint(0.6, 0.8);
Assert.IsTrue(clipping.ClipLine(ref p0, ref p1));
Assert.AreEqual(0.2, p0.Y);
Assert.AreEqual(0.8, p1.Y);
}
开发者ID:aleksanderkobylak,项目名称:oxyplot,代码行数:9,代码来源:CohenSutherlandClippingTests.cs
示例12: GetTouchPoints
/// <summary>
/// Gets the touch points from the specified <see cref="MotionEvent" /> argument.
/// </summary>
/// <param name="e">The event arguments.</param>
/// <param name = "scale">The resolution scale factor.</param>
/// <returns>The touch points.</returns>
public static ScreenPoint[] GetTouchPoints(this MotionEvent e, double scale)
{
var result = new ScreenPoint[e.PointerCount];
for (int i = 0; i < e.PointerCount; i++)
{
result[i] = new ScreenPoint(e.GetX(i) / scale, e.GetY(i) / scale);
}
return result;
}
开发者ID:Cheesebaron,项目名称:oxyplot,代码行数:16,代码来源:ExtensionMethods.cs
示例13: BaseCamera
public BaseCamera(int x, int y, int width, int height)
{
this.screen = new Rectangle(x, y, width, height);
this.halfscreen = new ScreenPoint(screen.Width / 2, screen.Height / 2);
this.Viewport = new Viewport()
{
X = x,
Y = y,
Width = width,
Height = height
};
}
开发者ID:NullSoldier,项目名称:Valkyrie,代码行数:13,代码来源:BaseCamera.cs
示例14: ImageAnnotation
/// <summary>
/// Initializes a new instance of the <see cref="ImageAnnotation"/> class.
/// </summary>
/// <param name="image">
/// The image.
/// </param>
/// <param name="position">
/// The position in screen coordinates.
/// </param>
/// <param name="horizontalAlignment">
/// The horizontal alignment.
/// </param>
/// <param name="verticalAlignment">
/// The vertical alignment.
/// </param>
public ImageAnnotation(
OxyImage image,
ScreenPoint position,
HorizontalAlignment horizontalAlignment = OxyPlot.HorizontalAlignment.Center,
VerticalAlignment verticalAlignment = OxyPlot.VerticalAlignment.Middle)
: this()
{
this.ImageSource = image;
this.X = new PlotLength(position.X, PlotLengthUnit.ScreenUnits);
this.Y = new PlotLength(position.Y, PlotLengthUnit.ScreenUnits);
this.HorizontalAlignment = horizontalAlignment;
this.VerticalAlignment = verticalAlignment;
}
开发者ID:AndrewTPohlmann,项目名称:open-hardware-monitor,代码行数:28,代码来源:ImageAnnotation.cs
示例15: GetNearestPoint
/// <summary>
/// Gets the point on the series that is nearest the specified point.
/// </summary>
/// <param name="point">The point.</param>
/// <param name="interpolate">Interpolate the series if this flag is set to <c>true</c>.</param>
/// <returns>A TrackerHitResult for the current hit.</returns>
public override TrackerHitResult GetNearestPoint(ScreenPoint point, bool interpolate)
{
if (this.XAxis == null || this.YAxis == null)
{
return null;
}
if (interpolate)
{
return null;
}
TrackerHitResult result = null;
// http://paulbourke.net/geometry/pointlineplane/
double minimumDistance = double.MaxValue;
var points = this.ActualPoints;
for (int i = 0; i < points.Count; i++)
{
var p1 = points[i];
var basePoint = new DataPoint(p1.X, this.Base);
var sp1 = this.Transform(p1);
var sp2 = this.Transform(basePoint);
var u = ScreenPointHelper.FindPositionOnLine(point, sp1, sp2);
if (double.IsNaN(u))
{
continue;
}
if (u < 0 || u > 1)
{
continue; // outside line
}
var sp = sp1 + ((sp2 - sp1) * u);
double distance = (point - sp).LengthSquared;
if (distance < minimumDistance)
{
result = new TrackerHitResult(
this, new DataPoint(p1.X, p1.Y), new ScreenPoint(sp1.x, sp1.y), this.GetItem(i));
minimumDistance = distance;
}
}
return result;
}
开发者ID:Cheesebaron,项目名称:oxyplot,代码行数:55,代码来源:StemSeries.cs
示例16: DrawLines
public void DrawLines(IEnumerable<ScreenPoint> points, OxyColor stroke, double thickness, double[] dashArray,
OxyPenLineJoin lineJoin, bool aliased)
{
var startPoint = new ScreenPoint();
bool first = true;
foreach (var p in points)
{
if (!first)
{
Add(new Line { X1 = startPoint.X, Y1 = startPoint.Y, X2 = p.X, Y2 = p.Y });
}
else
{
startPoint = p;
}
first = !first;
}
}
开发者ID:aleksanderkobylak,项目名称:oxyplot,代码行数:18,代码来源:GeometryRenderContext.cs
示例17: OnMouseDown
public override void OnMouseDown(ScreenPoint pt, OxyMouseButton button, int clickCount, bool control, bool shift)
{
base.OnMouseDown(pt, button, clickCount, control, shift);
if (button != OxyMouseButton.Left)
return;
// Middle button double click adds an annotation
if (clickCount == 2)
{
// pc.Annotations.
pc.Refresh();
}
currentSeries = pc.GetSeriesFromPoint(pt) as DataSeries;
OnMouseMove(pt, control, shift);
//pc.CaptureMouse();
// pc.Cursor = Cursors.Cross;
}
开发者ID:AndrewTPohlmann,项目名称:open-hardware-monitor,代码行数:21,代码来源:SliderAction.cs
示例18: ToPoint
private static Point ToPoint(ScreenPoint point)
{
return new Point(point.X, point.Y);
}
开发者ID:aleksanderkobylak,项目名称:oxyplot,代码行数:4,代码来源:GeometryRenderContext.cs
示例19: DrawText
public void DrawText(ScreenPoint p, string text, OxyColor fill, string fontFamily, double fontSize,
double fontWeight, double rotate, HorizontalAlignment halign, VerticalTextAlign valign)
{
var tb = new TextBlock
{
Text = text,
Foreground = new SolidColorBrush(fill.ToColor())
};
if (fontFamily != null)
tb.FontFamily = new FontFamily(fontFamily);
if (fontSize > 0)
tb.FontSize = fontSize;
if (fontWeight > 0)
tb.FontWeight = FontWeight.FromOpenTypeWeight((int)fontWeight);
tb.Measure(new Size(1000, 1000));
double dx = 0;
if (halign == HorizontalAlignment.Center)
dx = -tb.DesiredSize.Width / 2;
if (halign == HorizontalAlignment.Right)
dx = -tb.DesiredSize.Width;
double dy = 0;
if (valign == VerticalTextAlign.Middle)
dy = -tb.DesiredSize.Height / 2;
if (valign == VerticalTextAlign.Bottom)
dy = -tb.DesiredSize.Height;
var transform = new TransformGroup();
transform.Children.Add(new TranslateTransform(dx, dy));
if (rotate != 0)
transform.Children.Add(new RotateTransform(rotate));
transform.Children.Add(new TranslateTransform(p.X, p.Y));
tb.RenderTransform = transform;
tb.SetValue(RenderOptions.ClearTypeHintProperty, ClearTypeHint.Enabled);
Add(tb);
}
开发者ID:aleksanderkobylak,项目名称:oxyplot,代码行数:40,代码来源:GeometryRenderContext.cs
示例20: Render
/// <summary>
/// Renders the Series on the specified rendering context.
/// </summary>
/// <param name="rc">The rendering context.</param>
/// <param name="model">The model.</param>
public override void Render(IRenderContext rc, PlotModel model)
{
this.ActualBarRectangles = new List<OxyRect>();
if (this.ValidItems.Count == 0)
{
return;
}
var clippingRect = this.GetClippingRect();
var categoryAxis = this.GetCategoryAxis();
var actualBarWidth = this.GetActualBarWidth();
var stackIndex = categoryAxis.GetStackIndex(this.StackGroup);
for (var i = 0; i < this.ValidItems.Count; i++)
{
var item = this.ValidItems[i];
var categoryIndex = item.GetCategoryIndex(i);
double categoryValue = categoryAxis.GetCategoryValue(categoryIndex, stackIndex, actualBarWidth);
var p0 = this.Transform(item.Start, categoryValue);
var p1 = this.Transform(item.End, categoryValue + actualBarWidth);
var rectangle = OxyRect.Create(p0.X, p0.Y, p1.X, p1.Y);
this.ActualBarRectangles.Add(rectangle);
rc.DrawClippedRectangleAsPolygon(
clippingRect,
rectangle,
this.GetSelectableFillColor(item.Color.GetActualColor(this.ActualFillColor)),
this.StrokeColor,
this.StrokeThickness);
if (this.LabelFormatString != null)
{
var s = this.Format(this.LabelFormatString, this.GetItem(i), item.Start, item.End, item.Title);
var pt = new ScreenPoint(
(rectangle.Left + rectangle.Right) / 2, (rectangle.Top + rectangle.Bottom) / 2);
rc.DrawClippedText(
clippingRect,
pt,
s,
this.ActualTextColor,
this.ActualFont,
this.ActualFontSize,
this.ActualFontWeight,
0,
HorizontalAlignment.Center,
VerticalAlignment.Middle);
}
}
}
开发者ID:Cheesebaron,项目名称:oxyplot,代码行数:62,代码来源:IntervalBarSeries.cs
注:本文中的ScreenPoint类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论