/// <summary> /// Dynamically compute the desired angle of an element along a segment of the route. /// </summary> /// <param name="elt">the <c>UIElement</c> being rotated</param> /// <param name="orient">the <see cref="LabelOrientation"/> declared for the element</param> /// <param name="angle">the angle of the segment of the route where the element is attached</param> /// <returns>the intended angle for the element</returns> /// <remarks> /// This method is not called unless the <see cref="GetOrientation"/> attached property value is /// not <see cref="LabelOrientation.None"/>. /// </remarks> protected virtual double ComputeAngle(UIElement elt, LabelOrientation orient, double angle) { double a; switch (orient) { default: case LabelOrientation.None: a = 0; break; case LabelOrientation.Along: a = angle; break; case LabelOrientation.Plus90: a = angle + 90; break; case LabelOrientation.Minus90: a = angle - 90; break; case LabelOrientation.Opposite: a = angle + 180; break; case LabelOrientation.Upright: // like Along a = Geo.NormalizeAngle(angle); if (a > 90 && a < 270) { a -= 180; // make sure never upside-down } break; case LabelOrientation.Plus90Upright: // like Plus90 a = Geo.NormalizeAngle(angle + 90); if (a > 90 && a < 270) { a -= 180; // make sure never upside-down } break; case LabelOrientation.Minus90Upright: // like Minus90 a = Geo.NormalizeAngle(angle - 90); if (a > 90 && a < 270) { a -= 180; // make sure never upside-down } break; case LabelOrientation.Upright45: // like Along a = Geo.NormalizeAngle(angle); if (a > 45 && a < 135) { return(0); // make sure never angled too much } if (a > 225 && a < 315) { return(0); } if (a > 90 && a < 270) { a -= 180; // make sure never upside-down } break; } return(Geo.NormalizeAngle(a)); }