public PolarCoordinate(float r, double theta, Azimuth origin, PolarCoordinateOrientation orientation) { _R = r; _Theta = new Angle(theta); _Origin = origin; _Orientation = orientation; }
internal PolarGraphics(Graphics g, Angle rotation, Azimuth origin, PolarCoordinateOrientation orientation, float centerR, float maximumR) #endif { this.g = g; pRotation = rotation; pOrigin = origin; pOrientation = orientation; pCenterR = centerR; pMaximumR = maximumR; #if PocketPC HalfWidth = (visibleClipBounds.Width * 0.5); HalfHeight = (visibleClipBounds.Height * 0.5); // // Create smoother graphics // gx = new DotSpatial.Positioning.Drawing.GraphicsX(visibleClipBounds.Width, visibleClipBounds.Height); // gx.Clear(Color.White); // gx.ResetTransform(); #else HalfWidth = g.VisibleClipBounds.Width * 0.5; HalfHeight = g.VisibleClipBounds.Height * 0.5; #endif SpanSize = Math.Abs(pMaximumR - pCenterR); HorizontalScale = HalfWidth / SpanSize; VerticalScale = HalfHeight / SpanSize; #if !PocketPC // Set up the string format pStringFormat.LineAlignment = StringAlignment.Center; pStringFormat.Alignment = StringAlignment.Center; #endif }
/// <summary>Occurs when the control's orientation has changed.</summary> protected virtual void OnOrientationChanged(PolarCoordinateOrientation orientation) { if (OrientationChanged != null) { OrientationChanged(this, new PolarCoordinateOrientationEventArgs(orientation)); } }
/// <summary> /// Creates a new instance by converting the specified string. /// </summary> /// <param name="value">A <strong>String</strong> describing a polar coordinate in any culture.</param> /// <param name="culture">A <strong>CultureInfo</strong> object describing how to parse the specified string.</param> public PolarCoordinate(string value, CultureInfo culture) { // Split the two values based on the list separator string[] Values = value.Split(culture.TextInfo.ListSeparator.ToCharArray()); // The first value is R, the second is Theta _R = float.Parse(Values[0], culture); _Theta = Angle.Parse(Values[1], culture); _Origin = Azimuth.North; _Orientation = PolarCoordinateOrientation.Clockwise; }
/// <summary> /// Returns the current instance adjusted to the specified orientation and /// origin. /// </summary> public PolarCoordinate ToOrientation(Azimuth origin, PolarCoordinateOrientation orientation) { if (_Orientation.Equals(orientation) && _Origin.Equals(origin)) { return(this); } // Make a copy of the angle double NewAngle = Theta.DecimalDegrees; // Has the CW/CCW orientation changed? if (Orientation != orientation) { // Yes. Subtract the angle from 360 NewAngle = 360 - NewAngle; } if (Origin != origin) { // Add the offset to the angle and normalize NewAngle -= 360 - origin.DecimalDegrees - Origin.DecimalDegrees; } // And return the new coordinate return(new PolarCoordinate(_R, new Angle(NewAngle), origin, orientation)); }
/// <summary>Occurs when the control's orientation has changed.</summary> protected virtual void OnOrientationChanged(PolarCoordinateOrientation orientation) { if (OrientationChanged != null) OrientationChanged(this, new PolarCoordinateOrientationEventArgs(orientation)); }
internal PolarGraphics(Graphics g, Rectangle visibleClipBounds, Angle rotation, Azimuth origin, PolarCoordinateOrientation orientation, float centerR, float maximumR)
/// <summary> /// Creates a new instance using the specified radius, angle, origin and winding direction. /// </summary> /// <param name="r">A <strong>Double</strong> indicating a radius. Increasing values represent a distance further away from the center of a circle.</param> /// <param name="theta">An <strong>Angle</strong> representing a direction from the center of a circle.</param> /// <param name="origin">An <strong>Azimuth</strong> indicating which compass direction is associated with zero degrees. (Typically North.)</param> /// <param name="orientation">A <strong>PolarCoordinateOrientation</strong> value indicating whether increasing Theta values wind clockwise or counter-clockwise.</param> /// <remarks>The radius "r," when combined with an angle "theta" will create a coordinate relative to /// the center of a circle. The BearingOrigin will associate a compass direction with zero degrees (0°), but this value is typically "North".</remarks> public PolarCoordinate(float r, Angle theta, Azimuth origin, PolarCoordinateOrientation orientation) : this(r, theta.DecimalDegrees, origin, orientation) { }
public PolarCoordinateOrientationEventArgs(PolarCoordinateOrientation orientation) { pOrientation = orientation; }
/// <summary> /// Returns the current instance adjusted to the specified orientation and /// origin. /// </summary> public PolarCoordinate ToOrientation(Azimuth origin, PolarCoordinateOrientation orientation) { if (_Orientation.Equals(orientation) && _Origin.Equals(origin)) return this; // Make a copy of the angle double NewAngle = Theta.DecimalDegrees; // Has the CW/CCW orientation changed? if (Orientation != orientation) // Yes. Subtract the angle from 360 NewAngle = 360 - NewAngle; if (Origin != origin) { // Add the offset to the angle and normalize NewAngle -= 360 - origin.DecimalDegrees - Origin.DecimalDegrees; } // And return the new coordinate return new PolarCoordinate(_R, new Angle(NewAngle), origin, orientation); }