本文整理汇总了C#中System.Windows.Point.Offset方法的典型用法代码示例。如果您正苦于以下问题:C# Point.Offset方法的具体用法?C# Point.Offset怎么用?C# Point.Offset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Point
的用法示例。
在下文中一共展示了Point.Offset方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnRender
/// <summary>
/// When overridden in a derived class, participates in rendering operations that are directed by the layout system. The rendering instructions for this element are not used directly when this method is invoked, and are instead preserved for later asynchronous use by layout and drawing.
/// </summary>
/// <param name="drawingContext">The drawing instructions for a specific element. This context is provided to the layout system.</param>
protected override void OnRender(DrawingContext drawingContext)
{
// When no interfaces have been defined, there is nothing to draw.
if (this.interfaceNames.Count == 0)
{
return;
}
base.OnRender(drawingContext);
Pen pen = new Pen(Brushes.Gray, 0.5);
Point origin = new Point(30, 3);
double length = Constants.StartHeight + (this.interfaceNames.Count * Constants.LineHeight);
// draw path at top left
drawingContext.DrawLine(pen, origin, new Point(origin.X, origin.Y - length));
drawingContext.DrawEllipse(Brushes.Transparent, pen, new Point(origin.X, origin.Y - length - Constants.Radius), Constants.Radius, Constants.Radius);
// draw interface names
origin.Offset(5.0D, -length - Constants.Radius);
foreach (string name in this.interfaceNames)
{
drawingContext.DrawText(new FormattedText(name, CultureInfo.InvariantCulture, FlowDirection.LeftToRight, new Typeface("Segoe UI"), 7, pen.Brush), origin);
origin.Offset(0, 7.0D);
}
}
示例2: GetOffsetPoint
private static Point GetOffsetPoint(Point point, ConnectorOrientation orientation, int offset)
{
switch (orientation)
{
case ConnectorOrientation.Left:
point.Offset(-offset, 0);
return point;
case ConnectorOrientation.Right:
point.Offset(offset, 0);
return point;
default:
throw new ArgumentOutOfRangeException("orientation");
}
}
示例3: 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);
}
示例4: GetPosition
protected Point GetPosition(UIElement relativeTo, FrameworkElement element, bool centered)
{
Point point = new Point(Canvas.GetLeft(element), Canvas.GetTop(element));
if(centered)
point.Offset(element.Width / 2, element.Height / 2);
return relativeTo.TranslatePoint(point, window);
}
示例5: Start
public void Start()
{
pt = getpos();
pt.Offset(-win.Left, -win.Top);
bool b = win.CaptureMouse();
win.PreviewMouseLeftButtonUp += win_PreviewMouseLeftButtonUp;
win.PreviewMouseMove += win_PreviewMouseMove;
}
示例6: DrawSlot
public static void DrawSlot(DrawingContext drawingContext, Point p1)
{
//@TODO(Joy)DONE magic number 10?
p1.X = (int)p1.X;
p1.Y = (int)p1.Y;
Point p2 = p1;
p2.Y = p1.Y + Configurations.SlotSize;
p1.Offset(0.5, 0);
p2.Offset(0.5, 0);
drawingContext.DrawLine(Configurations.BorderPen, p1, p2);
p1.Offset(-Configurations.OutputHittestPixels, -Configurations.SlotStripeSize / 2 + Configurations.SlotSize / 2);
//draw hit test rectangle
Size hitTestSize = new Size(Configurations.OutputHittestPixels, Configurations.SlotStripeSize);
Rect hitTestRect = new Rect(p1, hitTestSize);
drawingContext.DrawRectangle(Configurations.SlotHitTestColor, Configurations.NoBorderPen, hitTestRect);
}
示例7: MovableChartLabelPoint_MouseLeftButtonDown
void MovableChartLabelPoint_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
isMoving = true;
e.Handled = true;
CaptureMouse();
startPt = e.GetPosition(null);
if (!double.IsNaN(Offset.X) && !double.IsNaN(Offset.Y))
startPt.Offset(-Offset.X, -Offset.Y);
}
示例8: DrawingArea_MouseDown
private void DrawingArea_MouseDown(object sender, MouseButtonEventArgs e)
{
if (DrawingArea.IsMouseDirectlyOver)
{
_backDragStartPt = e.GetPosition(this);
_backDragStartPt.Offset(-DrawingArea.Margin.Left, -DrawingArea.Margin.Top);
DrawingArea.CaptureMouse();
}
}
示例9: Hittest
internal bool Hittest(Point mousePosition)
{
Point pt = new Point(this.x, this.y);
pt.Offset(this.width, 0);
if (mousePosition.X > pt.X - Configurations.HittestPixels && mousePosition.X < pt.X)
if (mousePosition.Y > pt.Y && mousePosition.Y < pt.Y + Configurations.HittestPixels)
return true;
return false;
}
示例10: OnMouseDragHandler
private void OnMouseDragHandler(object sender, Point dragPoint)
{
var rect = (Rectangle) sender;
dragPoint.Offset(MouseOffset, MouseOffset);
_sourceLine.X2 = dragPoint.X;
_sourceLine.Y2 = dragPoint.Y;
_targetLine.X1 = dragPoint.X;
_targetLine.Y1 = dragPoint.Y;
Canvas.SetLeft(rect, dragPoint.X - Width / 2);
Canvas.SetTop(rect, dragPoint.Y - Height / 2);
}
示例11: Convert
public override object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
var conn = (Connection)value;
var endpoint1 = new Point(conn.Source.Location.X, (conn.Source.Region.Size.Height - conn.Source.Location.Y));
var endpoint2 = new Point(conn.Target.Location.X, (conn.Target.Region.Size.Height - conn.Target.Location.Y));
endpoint1.Offset(-conn.Source.Region.MiniMapOffset.X, -conn.Source.Region.MiniMapOffset.Y);
endpoint2.Offset(-conn.Target.Region.MiniMapOffset.X, -conn.Target.Region.MiniMapOffset.Y);
return new LineGeometry(endpoint1, endpoint2);
}
示例12: OnRender
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
// Introduce clipping
drawingContext.PushClip(new RectangleGeometry(new Rect(_adornedElement.RenderSize)));
foreach (ChartMarkerSet set in MarkerSets)
{
// ChartPrimitive parent = set.ParentPrimitive;
var setBrush = new SolidColorBrush(set.Fill);
var setPen = new Pen(new SolidColorBrush(set.Stroke), set.StrokeWidth);
foreach (ChartPoint p in set.Points)
{
// Snap the marker's Y-position onto the parent primitive
var snappedToParentPos = p.Point;
// snappedToParentPos.Y = parent.GetValueY(p.Point.X);
// Then render it to the adorner layer (which is on top of the plot canvas)
Point pixelPos = _parentChart.ToPixel(snappedToParentPos);
drawingContext.DrawEllipse(setBrush, setPen, pixelPos, set.Size/2, set.Size/2);
const double labelOffsetY = 10;
Point labelPixelOffset = new Point(0, +5);
if (snappedToParentPos.Y >= 0)
labelPixelOffset.Offset(0, labelOffsetY);
else
labelPixelOffset.Offset(0, -labelOffsetY);
// ChartHelper.RenderTextToChartPosition(drawingContext, _parentChart.TextCanvasInfo, p.Label, set.Color, snappedToParentPos, labelPixelOffset, FlipYAxis, true);
}
}
// End clipping
drawingContext.Pop();
}
示例13: ArrangeOverride
protected override Size ArrangeOverride(Size finalSize)
{
Point currentPosition = new Point();
foreach (UIElement child in Children)
{
Rect childRect = new Rect(currentPosition, child.DesiredSize);
//Rect childRect = new Rect(currentPosition, new Size(100,100));
child.Arrange(childRect);
currentPosition.Offset(childRect.Width, childRect.Height);
}
return new Size(currentPosition.X, currentPosition.Y);
}
示例14: Convert
/// <summary>
/// 1 - Content presenter render size,
/// 2 - Clipping border padding (main control padding)
/// </summary>
/// <param name="values"></param>
/// <param name="targetType"></param>
/// <param name="parameter"></param>
/// <param name="culture"></param>
/// <returns></returns>
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
if (values.Length != 2 || !(values[0] is Size) || !(values[1] is Thickness))
return Binding.DoNothing;
var size = (Size)values[0];
var farPoint = new Point(
Math.Max(0, size.Width),
Math.Max(0, size.Height));
var padding = (Thickness)values[1];
farPoint.Offset(padding.Left + padding.Right, padding.Top + padding.Bottom);
return new Rect(
new Point(),
new Point(farPoint.X, farPoint.Y));
}
示例15: CanConstructUsing2Points
public void CanConstructUsing2Points()
{
double topX = 12.43, topY = 56.89;
double bottomX = 45.89, bottomY = 45.87;
var topPoint = new Point(topX, topY);
var bottomPoint = new Point(bottomX, bottomY);
var subject = new Area(topPoint, bottomPoint);
// Ensure it doesnt change after creation, ie cloned.
topPoint.Offset(1, 1);
bottomPoint.Offset(2, 2);
Assert.AreEqual(topX, subject.TopLeft.X);
Assert.AreEqual(topY, subject.TopLeft.Y);
Assert.AreEqual(bottomX, subject.BottomRight.X);
Assert.AreEqual(bottomY, subject.BottomRight.Y);
}