static FontImage() { RegisterFont("Segoe UI Symbol", new FontFamily("Segoe UI Symbol")); var dpi = ScreenHelper.GetDpi().Width; RenderingEmSize = dpi / 96d; }
private void OnOpened(object sender, EventArgs e) { if (_parentElement is null) { return; } var window = AssociatedObject.FindLogicalOrVisualAncestorByType <Window>(); var screenBounds = ScreenHelper.GetScreenBounds(window); var currentScreenWidth = screenBounds.Width + screenBounds.X; var rightCornerPointOnScreen = _parentElement.PointToScreen(new Point(_parentElement.ActualWidth, 0)).X; var dpi = ScreenHelper.GetDpi().Width / 96d; var width = _parentElement.ActualWidth; if (currentScreenWidth > rightCornerPointOnScreen) { var leftCornerPointOnScreen = _parentElement.PointToScreen(new Point(0, 0)).X; if (leftCornerPointOnScreen < screenBounds.X) { width = (rightCornerPointOnScreen - screenBounds.X) / dpi; } } else { width = (_parentElement.ActualWidth * dpi - (rightCornerPointOnScreen - currentScreenWidth)) / dpi; } if (width < 0) { width = _parentElement.ActualWidth; } AssociatedObject.SetCurrentValue(FrameworkElement.WidthProperty, width); }