System.Windows.Point.Offset C# (CSharp) Method

Offset() public method

public Offset ( double offsetX, double offsetY ) : void
offsetX double
offsetY double
return void
        public void Offset(double offsetX, double offsetY)
        {
            this._x += offsetX;
            this._y += offsetY;
        }

Usage Example

示例#1
0
    /// <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);
      }
    }
All Usage Examples Of System.Windows.Point::Offset