/// <summary> /// Position the tool tip (Vertically) /// </summary> /// <param name="element">The Thumb that the tooltip will be possitioned next to.</param> private void PositionToolTipVertically(Thumb element) { // Turn the tool tip to the side for a better appearance ElementValueTipPopupRoot.RenderTransform = new RotateTransform { Angle = -90 }; double popupWidth = ElementValueTipPopupRoot.ActualWidth; double thumbHeight = element.ActualHeight; System.Windows.Media.GeneralTransform gt = element.TransformToVisual(this as UIElement); //// Check if the popup will display too far up or down double top = gt.Transform(new Point(0, (-(popupWidth / 2) + (thumbHeight / 2)))).Y; double offset = Math.Abs(Math.Min(top, 0)); if (offset == 0) { // Check if the popup will display too far right and adjust double bottom = gt.Transform(new Point(0, (-(popupWidth / 2) + (thumbHeight / 2)) + popupWidth)).Y; offset = Math.Min(ActualHeight - bottom, 0); } Point tipOffset = new Point(); if (IsRangeEnabled) { tipOffset = gt.Transform(new Point(-(ElementValueTipPopupRoot.ActualHeight + (ElementHorizontalLowerThumb.Height / 2)), ((popupWidth / 2) + (thumbHeight / 2)) + offset)); } else { tipOffset = gt.Transform(new Point(-ElementValueTipPopupRoot.ActualHeight, ((popupWidth / 2) + (thumbHeight / 2)) + offset)); } ElementValueTipPopup.HorizontalOffset = tipOffset.X; ElementValueTipPopup.VerticalOffset = tipOffset.Y; }
/// <summary> /// Position the tool tip (Horizontally) /// </summary> /// <param name="element">The Thumb that the tooltip will be possitioned above.</param> private void PositionToolTipHorizontally(Thumb element) { double popupWidth = ElementValueTipPopupRoot.ActualWidth; double thumbWidth = element.ActualWidth; System.Windows.Media.GeneralTransform gt = element.TransformToVisual(this as UIElement); // Check if the popup will display too far left and adjust double farLeft = gt.Transform(new Point((-popupWidth / 2) + (thumbWidth / 2), 0)).X; double offset = Math.Abs(Math.Min(0 + farLeft, 0)); //TODO: MAKE SURE '0' WORKS IF SLIDER IS NOT AGAINST THE SIDE if (offset == 0) { // Check if the popup will display too far right and adjust double farRight = gt.Transform(new Point(((-popupWidth / 2) + (thumbWidth / 2)) + popupWidth, 0)).X; offset = Math.Min(ActualWidth - farRight, 0); } Point tipOffset = new Point(); if (IsRangeEnabled) { tipOffset = gt.Transform(new Point(((-popupWidth / 2) + (thumbWidth / 2)) + offset, -(ElementValueTipPopupRoot.ActualHeight + (ElementHorizontalLowerThumb.ActualHeight / 2)))); ; } else { tipOffset = gt.Transform(new Point(((-popupWidth / 2) + (thumbWidth / 2)) + offset, -ElementValueTipPopupRoot.ActualHeight)); ; } ElementValueTipPopup.HorizontalOffset = tipOffset.X; ElementValueTipPopup.VerticalOffset = tipOffset.Y; }