本文整理汇总了C#中System.Windows.Point类的典型用法代码示例。如果您正苦于以下问题:C# Point类的具体用法?C# Point怎么用?C# Point使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Point类属于System.Windows命名空间,在下文中一共展示了Point类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ContainsPoint
/// <summary>
/// Returns a value indicating whether a point is inside the bounding box of the element.
/// </summary>
/// <param name="element"></param>
/// <param name="pointRelativeToElement"></param>
/// <returns></returns>
public static bool ContainsPoint(this FrameworkElement element, Point pointRelativeToElement)
{
//TODO: Silverlight allows more complex geometries than Rectangle.
Rect rect = new Rect { X = 0, Y = 0, Width = element.ActualWidth, Height=element.ActualHeight };
return rect.Contains(pointRelativeToElement);
}
示例2: Setup
public void Setup()
{
m_StartSegment = Substitute.For <ITurnCircleArcSegment>();
m_MiddleSegment = Substitute.For <ITurnCircleArcSegment>();
m_EndSegment = Substitute.For <ITurnCircleArcSegment>();
m_Path = Substitute.For <IPath>();
var segments = new List <IPolylineSegment>
{
m_StartSegment,
m_MiddleSegment,
m_EndSegment
};
m_Path.Segments.Returns(segments);
m_ArcSegmentOne = new ArcSegment(new Point(10.0,
10.0),
new Size(10.0,
10.0),
45.0,
false,
SweepDirection.Clockwise,
false);
m_LineSegment = new LineSegment(new Point(20.0,
20.0),
false);
m_ArcSegmentTwo = new ArcSegment(new Point(30.0,
30.0),
new Size(30.0,
30.0),
90.0,
false,
SweepDirection.Counterclockwise,
false);
m_ArcSegmentThree = new ArcSegment(new Point(40.0,
40.0),
new Size(40.0,
40.0),
135.0,
false,
SweepDirection.Counterclockwise,
false);
m_Point = new Point(10.0,
10.0);
m_Helper = Substitute.For <IPathSegmentHelper>();
m_Helper.SegmentToLineSegment(Line.Unknown).ReturnsForAnyArgs(m_LineSegment);
m_Helper.SegmentToArcSegment(TurnCircleArcSegment.Unknown).ReturnsForAnyArgs(m_ArcSegmentOne,
m_ArcSegmentTwo,
m_ArcSegmentThree);
m_Helper.PointRelativeToOrigin(null).ReturnsForAnyArgs(m_Point);
m_Converter = new RacetrackPathUTurnToFiguresConverter(m_Helper);
}
示例3: Point
public void It_sets_the_new_position_to_24_24_when_the_initial_position_is_10_10_and_the_speed_is_20_and_the_direction_is_45_degrees_and_the_timeElapsed_is_1000()
{
var result = Calculator.CalculateNewPosition(new Point(10, 10), 45D.ToRadians(), 20, 1000);
var expectedResult = new Point(24, -4);
Assert.IsTrue(expectedResult.IsEqualTo(result), string.Format("{0} is not equal to {1}", expectedResult, result));
}
示例4: InfoLinkDecal
public InfoLinkDecal()
{
MetaData = new InfoLinkMetaData() { Source = "http://" };
Stretch = System.Windows.Media.Stretch.Uniform;
Size = 1;
CanResize = false;
Stretch = System.Windows.Media.Stretch.None;
Center = new System.Windows.Point(1, 1);
PinPoint = new System.Windows.Point(1, 1);
CanMove = false;
OpenUrl = new DelegateCommand(() =>
{
if (!MetaData.Source.StartsWith("http://"))
{
MetaData.Source = "http://" + MetaData.Source;
}
#if WINDOWS_PHONE
Microsoft.Phone.Controls.PhoneApplicationFrame frame = Application.Current.RootVisual as Microsoft.Phone.Controls.PhoneApplicationFrame;
frame.Navigate(new Uri(MetaData.Source));
#elif SILVERLIGHT
HtmlPage.Window.Navigate(new Uri(MetaData.Source), "_blank");
#else
Process.Start(MetaData.Source);
#endif
}, CanOpenUrl);
}
示例5: PerpendicularLine
public static WPFMEDIA.LineGeometry PerpendicularLine(WPF.Point StartPoint, WPF.Point EndPoint, double Length)
{
//Get Current Angle Don't need the actual angle, radians is fine.
double angle = CurrentAngle(StartPoint, EndPoint);
double radians = Math.Atan2(StartPoint.Y - EndPoint.Y, StartPoint.X - EndPoint.X);
//Take 90 deg
double newAngle = angle + 90;
double newRadians = radians + Math.PI / 2;
//need to determine the shift.
double shiftX = Length * Math.Cos(newRadians);
//double shiftX2 = Length * Math.Cos(newAngle * Math.PI / 180);
double shiftY = Length * Math.Sin(newRadians);
double newStartPointX = StartPoint.X - shiftX;
double newStartPointY = StartPoint.Y - shiftY;
double newEndPointX = StartPoint.X + shiftX;
double newEndPointY = StartPoint.Y + shiftY;
WPF.Point newStartPoint = new WPF.Point(newStartPointX, newStartPointY);
WPF.Point newEndPoint = new WPF.Point(newEndPointX, newEndPointY);
//get the second point
//draw line from center of the point.
WPFMEDIA.LineGeometry newLine = new System.Windows.Media.LineGeometry(newStartPoint, newEndPoint);
return newLine;
}
示例6: OnPlacementCallback
private static CustomPopupPlacement[] OnPlacementCallback(Size popupSize, Size targetSize, Point offset) {
return new[] {
new CustomPopupPlacement {
Point = new Point(0, targetSize.Height)
}
};
}
示例7: Arc
public void Arc(object backend, double xc, double yc, double radius, double angle1, double angle2, bool inverse)
{
var c = (DrawingContext)backend;
if (angle1 == angle2)
return;
if (angle1 > angle2)
angle2 += (Math.Truncate (angle1 / 360) + 1) * 360;
double nextAngle;
do {
nextAngle = angle2 - angle1 < 360 ? angle2 : angle1 + 359;
var p1 = new SW.Point (xc + radius * Math.Cos (angle1 * Math.PI / 180.0), yc + radius * Math.Sin (angle1 * Math.PI / 180.0));
var p2 = new SW.Point (xc + radius * Math.Cos (nextAngle * Math.PI / 180.0), yc + radius * Math.Sin (nextAngle * Math.PI / 180.0));
c.ConnectToLastFigure (p1, true);
var largeArc = inverse ? nextAngle - angle1 < 180 : nextAngle - angle1 > 180;
var direction = inverse ? SweepDirection.Counterclockwise : SweepDirection.Clockwise;
c.Path.Segments.Add (new ArcSegment (p2, new SW.Size (radius, radius), 0, largeArc, direction, true));
angle1 = nextAngle;
c.EndPoint = p2;
}
while (nextAngle < angle2);
}
示例8: Character
/// <summary>
/// Initializes a new character instance.
/// </summary>
/// <param name="p0">Lower left character position.</param>
/// <param name="size">Size of the character.</param>
/// <param name="uiTaskSchedule">Scheduler associated with the UI thread.</param>
public Character(Point p0, Vector size, TaskScheduler uiTaskSchedule)
: base(uiTaskSchedule)
{
this.Position = new Quadrilateral(p0, size);
this.Gravity = CharacterGravityState.Down;
this.Animation = CharacterAnimationState.Down;
}
示例9: EllipseGeometry
public EllipseGeometry (Point center, double radiusX, double radiusY, Transform transform)
{
Transform = transform;
Center = center;
RadiusX = radiusX;
RadiusY = radiusY;
}
示例10: CustomPopupPlacementCallbackImpl
public static CustomPopupPlacement[] CustomPopupPlacementCallbackImpl(Size popupSize, Size targetSize, Point offset)
{
return new []
{
new CustomPopupPlacement(new Point(targetSize.Width/2 - popupSize.Width/2, targetSize.Height + 14), PopupPrimaryAxis.Horizontal)
};
}
示例11: ImageJigsawRectPiece
public ImageJigsawRectPiece(BitmapImage imageSource, int col, int row, double pieceSize)
: base(imageSource, col, row, pieceSize)
{
this._origin = new Point((col * pieceSize), (double)(row * pieceSize));
this.Position = new Point((col * pieceSize), (double)(row * pieceSize));
base.InitShapeProperties();
}
示例12: ArrangeOverride
protected override Size ArrangeOverride(Size finalSize)
{
Size inflate = new Size();
if (finalSize.Width < totChildWidth)
inflate.Width = (totChildWidth - finalSize.Width) / InternalChildren.Count;
Point offset = new Point();
if (finalSize.Width > totChildWidth)
offset.X = -(finalSize.Width - totChildWidth)/2;
double totalFinalWidth = 0.0;
foreach (UIElement child in InternalChildren)
{
Size childFinalSize = child.DesiredSize;
childFinalSize.Width -= inflate.Width;
childFinalSize.Height = finalSize.Height;
child.Arrange(new Rect(offset, childFinalSize));
offset.Offset(childFinalSize.Width, 0);
totalFinalWidth += childFinalSize.Width;
}
return new Size(totalFinalWidth, finalSize.Height);
}
示例13: CalculateStartAndEndPoint
private void CalculateStartAndEndPoint(out Point startPoint, out Point endPoint)
{
startPoint = new Point();
endPoint = new Point();
double width = this.AdornedElement.RenderSize.Width;
double height = this.AdornedElement.RenderSize.Height;
if (this.isSeparatorHorizontal)
{
endPoint.X = width;
if (!this.IsInFirstHalf)
{
startPoint.Y = height;
endPoint.Y = height;
}
}
else
{
endPoint.Y = height;
if (!this.IsInFirstHalf)
{
startPoint.X = width;
endPoint.X = width;
}
}
}
示例14: Equals
public void Equals ()
{
Point p = new Point (4, 5);
Assert.IsTrue (p.Equals (new Point (4, 5)));
Assert.IsFalse (p.Equals (new Point (5, 4)));
Assert.IsFalse (p.Equals (new object()));
}
示例15: Arrange
/// <summary>
/// Arranges the adorner element on the specified adorner panel.
/// </summary>
public override void Arrange(AdornerPanel panel, UIElement adorner, Size adornedElementSize)
{
Point p = new Point(0, 0);
if (shape is Line)
{
var s = shape as Line;
double x, y;
if (alignment == PlacementAlignment.BottomRight)
{
x = s.X2;
y = s.Y2;
}
else
{
x = s.X1;
y = s.Y1;
}
p = new Point(x, y);
} else if (shape is Polygon) {
var pg = shape as Polygon;
p = pg.Points[Index];
} else if (shape is Polyline) {
var pg = shape as Polyline;
p = pg.Points[Index];
}
var transform = shape.RenderedGeometry.Transform;
p = transform.Transform(p);
adorner.Arrange(new Rect(p.X - 3.5, p.Y - 3.5, 7, 7));
}