UIElement CreateDefaultToolTipUIElement(string description) { Debug.Assert(!string.IsNullOrEmpty(description)); if (string.IsNullOrEmpty(description)) return null; var screen = new Screen(wpfTextView?.VisualElement); var screenWidth = screen.IsValid ? screen.DisplayRect.Width : SystemParameters.WorkArea.Width; var maxWidth = screenWidth * 0.4; return new TextBlock { Text = description, MaxWidth = maxWidth, TextWrapping = TextWrapping.Wrap, }; }
public static Size GetMaxSize(WpfHexView wpfHexView) { var screen = new Screen(wpfHexView.VisualElement); var screenRect = screen.IsValid ? screen.DisplayRect : SystemParameters.WorkArea; var size = TransformFromDevice(wpfHexView, screenRect.Size); return new Size(size.Width * maxWidthMultiplier, size.Height * maxHeightMultiplier); }
public override Geometry PositionAndDisplay(Geometry reservedSpace) { var spanBoundsTmp = GetVisualSpanBounds(); if (spanBoundsTmp == null || spanBoundsTmp.Value.IsEmpty) return null; var spanBounds = WpfHexViewRectToScreenRect(spanBoundsTmp.Value); var desiredSize = ToScreenSize(PopupSize); var screen = new Screen(wpfHexView.VisualElement); var screenRect = screen.IsValid ? screen.DisplayRect : SystemParameters.WorkArea; Rect? popupRect = null; if ((style & VSTA.PopupStyles.PositionClosest) != 0) { foreach (var pos in GetValidPositions(screenRect, reservedSpace, desiredSize, spanBounds, style)) popupRect = GetClosest(spanBounds, popupRect, pos, style); } else { foreach (var pos in GetValidPositions(screenRect, reservedSpace, desiredSize, spanBounds, style)) { popupRect = pos; break; } } if (popupRect == null) return null; var viewRelativeRect = HexPopupHelper.TransformFromDevice(wpfHexView, popupRect.Value); bool isOpen = popup.IsOpen; if (!isOpen) AddEvents(); if (popupZoomLevel != wpfHexView.ZoomLevel) { // Must set IsOpen to false when setting a new scale transform popup.IsOpen = false; HexPopupHelper.SetScaleTransform(wpfHexView, popup); popupZoomLevel = wpfHexView.ZoomLevel; } if (!isOpen) { popup.Child = content; popup.Visibility = Visibility.Visible; } popup.VerticalOffset = viewRelativeRect.Top; popup.HorizontalOffset = viewRelativeRect.Left; popup.IsOpen = true; return new RectangleGeometry(popupRect.Value); }