/// <summary> /// Cache the screen bounds of the monitor in which the targetElement is rendered. /// </summary> /// <param name="itemsPresenter"></param> /// <returns></returns> public static Rect GetScreenBounds(FrameworkElement targetElement, Popup popup) { if (targetElement != null) { Rect targetBoundingBox = new Rect(targetElement.PointToScreen(new Point()), targetElement.PointToScreen(new Point(targetElement.RenderSize.Width, targetElement.RenderSize.Height))); NativeMethods.RECT rect = new NativeMethods.RECT() { top = 0, bottom = 0, left = 0, right = 0 }; NativeMethods.RECT nativeBounds = NativeMethods.FromRect(targetBoundingBox); IntPtr monitor = NativeMethods.MonitorFromRect(ref nativeBounds, NativeMethods.MONITOR_DEFAULTTONEAREST); if (monitor != IntPtr.Zero) { NativeMethods.MONITORINFOEX monitorInfo = new NativeMethods.MONITORINFOEX(); monitorInfo.cbSize = Marshal.SizeOf(typeof(NativeMethods.MONITORINFOEX)); NativeMethods.GetMonitorInfo(new HandleRef(null, monitor), monitorInfo); // WPF Popup special cases MenuItem to be restricted to work area // Hence Ribbon applies the same rules as well. if (popup.TemplatedParent is RibbonMenuItem) { rect = monitorInfo.rcWork; } else if (popup.TemplatedParent is RibbonMenuButton) { rect = monitorInfo.rcMonitor; } } return NativeMethods.ToRect(rect); } return Rect.Empty; }
public static bool IsItemMidpointInContainer(FrameworkElement container, FrameworkElement target) { var containerTopLeft = container.PointToScreen(new Point()); var itemTopLeft = target.PointToScreen(new Point()); double topBoundary = containerTopLeft.Y; double bottomBoundary = topBoundary + container.ActualHeight; double leftBoundary = containerTopLeft.X; double rightBoundary = leftBoundary + container.ActualWidth; //use midpoint of item (width or height divided by 2) double itemLeft = itemTopLeft.X + (target.ActualWidth / 2); double itemTop = itemTopLeft.Y + (target.ActualHeight / 2); if (itemTop < topBoundary || bottomBoundary < itemTop) { //Midpoint of target is outside of top or bottom return false; } if (itemLeft < leftBoundary || rightBoundary < itemLeft) { //Midpoint of target is outside of left or right return false; } return true; }
public void ShowErrorTooltip(FrameworkElement attachTo, UIElement errorElement) { if (attachTo == null) throw new ArgumentNullException("attachTo"); if (errorElement == null) throw new ArgumentNullException("errorElement"); AttachedErrorBalloon b = new AttachedErrorBalloon(attachTo, errorElement); Point pos = attachTo.PointToScreen(new Point(0, attachTo.ActualHeight)); b.Left = pos.X; b.Top = pos.Y - 8; b.Focusable = false; ITopLevelWindowService windowService = services.GetService<ITopLevelWindowService>(); ITopLevelWindow ownerWindow = (windowService != null) ? windowService.GetTopLevelWindow(attachTo) : null; if (ownerWindow != null) { ownerWindow.SetOwner(b); } b.Show(); if (ownerWindow != null) { ownerWindow.Activate(); } b.AttachEvents(); }
public EditTranslationDialog(TranslationItem translationItem, Action<TranslationItem> callback, FrameworkElement owinElement = null) { InitializeComponent(); if (translationItem == null || callback == null) { DialogResult = null; Close(); return; } _title = Title; if (owinElement != null) { try { var pointFromScreen = owinElement.PointToScreen(new Point(-5, 0)); WindowStartupLocation = WindowStartupLocation.Manual; var top = pointFromScreen.Y; var left = pointFromScreen.X; Top = top > 0 ? top : Top; Left = left > 0 ? left : Left; MaxHeight = SystemParameters.PrimaryScreenHeight - Top - 50; Width = owinElement.ActualWidth + 50; } catch (Exception e) { Console.WriteLine(e); } } _originalText = translationItem.TextWithOverflow; TranslationTextBox.Text = translationItem.TextWithOverflow; TranslationTextBox.TextChanged += (sender, args) => { var changed = string.Compare(_originalText, TranslationTextBox.Text, StringComparison.InvariantCulture) != 0; Title = changed ? _title + "*" : _title; }; TranslationTextBox.Focus(); var caretIndex = TranslationTextBox.Text.Length; if(caretIndex > -1) TranslationTextBox.CaretIndex = caretIndex; TranslationTextBox.ScrollToEnd(); CancelButton.Click += (sender, args) => { DialogResult = false; Close(); }; ReplaceButton.Click += (sender, args) => { var item = new TranslationItem(translationItem) {Text = TranslationTextBox.Text}; DialogResult = true; callback(item); Close(); }; }
/// <summary> /// ウィンドウ操作を実行します。 /// </summary> /// <param name="action">実行するウィンドウ操作。</param> /// <param name="source">操作を実行しようとしている UI 要素。この要素をホストするウィンドウに対し、<paramref name="action"/> 操作が実行されます。</param> public static void Invoke(this WindowAction action, FrameworkElement source) { var window = Window.GetWindow(source); if (window == null) return; switch (action) { case WindowAction.Active: window.Activate(); break; case WindowAction.Close: window.Close(); break; case WindowAction.Maximize: window.WindowState = WindowState.Maximized; break; case WindowAction.Minimize: window.WindowState = WindowState.Minimized; break; case WindowAction.Normalize: window.WindowState = WindowState.Normal; break; case WindowAction.OpenSystemMenu: var point = source.PointToScreen(new Point(0, source.ActualHeight)); SystemCommands.ShowSystemMenu(window, point); break; } }
/// <summary> /// ドラッグ中処理 /// </summary> /// <param name="owner"></param> public void QueryContinueDrag(FrameworkElement owner) { if (Ghost != null) { var p = CursorInfo.GetNowPosition(owner); var loc = owner.PointFromScreen(owner.PointToScreen(new Point(0, 0))); Point renderedLocation = owner.TranslatePoint(new Point(0, 0), Window.GetWindow(owner)); Ghost.LeftOffset = p.X - loc.X - renderedLocation.X; Ghost.TopOffset = p.Y - loc.Y - renderedLocation.Y; } }
public void FindValues(FrameworkElement container, FrameworkElement target) { var containerTopLeft = container.PointToScreen(new Point()); var itemTopLeft = target.PointToScreen(new Point()); _topBoundary = containerTopLeft.Y; _bottomBoundary = _topBoundary + container.ActualHeight; _leftBoundary = containerTopLeft.X; _rightBoundary = _leftBoundary + container.ActualWidth; _itemLeft = itemTopLeft.X + (target.ActualWidth / 2); _itemTop = itemTopLeft.Y + (target.ActualHeight / 2); }
private static void FindValues(FrameworkElement container, FrameworkElement target) { var containerTopLeft = container.PointToScreen(new Point()); var itemTopLeft = target.PointToScreen(new Point()); _topBoundary = containerTopLeft.Y; _bottomBoundary = _topBoundary + container.ActualHeight; _leftBoundary = containerTopLeft.X; _rightBoundary = _leftBoundary + container.ActualWidth; //use midpoint of item (width or height divided by 2) _itemLeft = itemTopLeft.X + (target.ActualWidth / 2); _itemTop = itemTopLeft.Y + (target.ActualHeight / 2); }
private void SetupPositionAndSize(double positionTargetX, FrameworkElement positionAndSizeBase) { Width = positionAndSizeBase.ActualWidth; Height = positionAndSizeBase.ActualHeight; Point mousePosition = Mouse.GetPosition(positionAndSizeBase); double windowOffsetX = positionTargetX - mousePosition.X; //TODO calculate value int windowHeaderCenterY = 7; Point targetPosition = positionAndSizeBase.PointToScreen(new Point(-windowOffsetX, mousePosition.Y - windowHeaderCenterY)); Left = targetPosition.X; Top = targetPosition.Y; }
private System.Windows.FrameworkElement FindElement(System.Windows.Media.Visual v, string name) { this.has_find_e = true; if (v == null) { return(null); } for (int i = 0; i < System.Windows.Media.VisualTreeHelper.GetChildrenCount(v); ++i) { System.Windows.Media.Visual child = System.Windows.Media.VisualTreeHelper.GetChild(v, i) as System.Windows.Media.Visual; if (child != null) { System.Windows.FrameworkElement e = child as System.Windows.FrameworkElement; //if (e != null && e.Name == name) // return e; if (e != null) { //Debug.WriteLine(e.Name); Point position = e.PointToScreen(new Point(0d, 0d)); if (eWithMinY == null) { eWithMinY = e; } if (position.Y < eWithMinY.PointToScreen(new Point(0d, 0d)).Y) { eWithMinY = e; } if (e.Name == name) { return(e); } } } System.Windows.FrameworkElement result = FindElement(child, name); if (result != null) { return(result); } } return(null); }
/// <summary> /// Constructor</summary> /// <param name="element">Source element to create window for</param> public DockIconsLayer(FrameworkElement element) { ShowInTaskbar = false; ShowActivated = false; WindowStyle = WindowStyle.None; AllowsTransparency = true; Background = Brushes.Transparent; Topmost = true; m_canvas = new Canvas(); Content = m_canvas; WindowStartupLocation = WindowStartupLocation.Manual; Point position = element.PointToScreen(new Point(0, 0)); Matrix m = PresentationSource.FromVisual(Window.GetWindow(element)).CompositionTarget.TransformToDevice; m.Invert(); position = m.Transform(position); Left = position.X; Top = position.Y; Width = element.ActualWidth; Height = element.ActualHeight; }
private static void OnSizeLocationChanged(System.Windows.FrameworkElement placementTarget, System.Windows.Window webHost) { //Here we set the location and size of the borderless Window hosting the WebBrowser control. // This is based on the location and size of the child grid of the NTWindow. When the grid changes, // the hosted WebBrowser changes to match. if (webHost.Visibility == Visibility.Visible) { webHost.Show(); } webHost.Owner = Window.GetWindow(placementTarget); Point locationFromScreen = placementTarget.PointToScreen(new System.Windows.Point(0, 0)); PresentationSource source = PresentationSource.FromVisual(webHost); if (source != null && source.CompositionTarget != null) { Point targetPoints = source.CompositionTarget.TransformFromDevice.Transform(locationFromScreen); webHost.Left = targetPoints.X; webHost.Top = targetPoints.Y; } webHost.Width = placementTarget.ActualWidth; webHost.Height = placementTarget.ActualHeight; }
private double CutRight(FrameworkElement placementTarget) { Point point = placementTarget.PointToScreen(new Point(0, placementTarget.ActualWidth)); point.X += placementTarget.ActualWidth; return Math.Min(0, SystemParameters.VirtualScreenWidth - (Math.Max(SystemParameters.VirtualScreenWidth, point.X))); }
private double CutTop(FrameworkElement placementTarget) { Point point = placementTarget.PointToScreen(new Point(placementTarget.ActualHeight, 0)); return Math.Min(0, point.Y); }
private double CutLeft(FrameworkElement placementTarget) { Point point = placementTarget.PointToScreen(new Point(0, placementTarget.ActualWidth)); return Math.Min(0, point.X); }
/// <summary> /// Returns screen workarea in witch control is placed /// </summary> /// <param name="control">Control</param> /// <returns>Workarea in witch control is placed</returns> public static Rect GetControlWorkArea(FrameworkElement control) { Point tabItemPos = control.PointToScreen(new Point(0, 0)); NativeMethods.Rect tabItemRect = new NativeMethods.Rect(); tabItemRect.Left = (int)tabItemPos.X; tabItemRect.Top = (int)tabItemPos.Y; tabItemRect.Right = (int)tabItemPos.X + (int)control.ActualWidth; tabItemRect.Bottom = (int)tabItemPos.Y + (int)control.ActualHeight; uint MONITOR_DEFAULTTONEAREST = 0x00000002; System.IntPtr monitor = NativeMethods.MonitorFromRect(ref tabItemRect, MONITOR_DEFAULTTONEAREST); if (monitor != System.IntPtr.Zero) { NativeMethods.MonitorInfo monitorInfo = new NativeMethods.MonitorInfo(); monitorInfo.Size = Marshal.SizeOf(monitorInfo); NativeMethods.GetMonitorInfo(monitor, monitorInfo); return new Rect(monitorInfo.Work.Left, monitorInfo.Work.Top, monitorInfo.Work.Right - monitorInfo.Work.Left, monitorInfo.Work.Bottom - monitorInfo.Work.Top); } return new Rect(); }
private static Rect GetElementBoundsInScreenCoordinates(FrameworkElement element) { var elementUpperLeft = element.PointToScreen(new Point(0, 0)); var elementBottomRight = element.PointToScreen(new Point(element.ActualWidth, element.ActualHeight)); return new Rect(elementUpperLeft, elementBottomRight); }
/// <summary> /// Returns monitor in witch control is placed /// </summary> /// <param name="control">Control</param> /// <returns>Workarea in witch control is placed</returns> public static Rect GetControlMonitor(FrameworkElement control) { var tabItemPos = control.PointToScreen(new Point(0, 0)); var tabItemRect = new RECT(); tabItemRect.left = (int)tabItemPos.X; tabItemRect.top = (int)tabItemPos.Y; tabItemRect.right = (int)tabItemPos.X + (int)control.ActualWidth; tabItemRect.bottom = (int)tabItemPos.Y + (int)control.ActualHeight; const uint MONITOR_DEFAULTTONEAREST = 0x00000002; var monitor = NativeMethods.MonitorFromRect(ref tabItemRect, MONITOR_DEFAULTTONEAREST); if (monitor != IntPtr.Zero) { var monitorInfo = new MONITORINFO(); monitorInfo.cbSize = Marshal.SizeOf(monitorInfo); NativeMethods.GetMonitorInfo(monitor, monitorInfo); return new Rect(monitorInfo.rcMonitor.left, monitorInfo.rcMonitor.top, monitorInfo.rcMonitor.right - monitorInfo.rcMonitor.left, monitorInfo.rcMonitor.bottom - monitorInfo.rcMonitor.top); } return new Rect(); }
public virtual Rect GetFrameworkElementWin32PixelRect(FrameworkElement fe) { var feLocation = fe.PointToScreen(new Point(0, 0)); return new Rect(feLocation.X, feLocation.Y, fe.ActualWidth, fe.ActualHeight); }
public HintRootWpf(FrameworkElement fe) { _fe = fe; var pt = fe.PointToScreen(new Point()); var pt2 = fe.PointToScreen(new Point(fe.ActualWidth, fe.ActualHeight)); ActiveRect = new Rect(pt.X, pt.Y, pt2.X - pt.X, pt2.Y - pt.Y); }
private bool IsCursorInButton(FrameworkElement cursor) { try { //Cursor midpoint location Point cursorTopLeft = cursor.PointToScreen(new Point()); double cursorCenterX = cursorTopLeft.X + (cursor.ActualWidth / 2); double cursorCenterY = cursorTopLeft.Y + (cursor.ActualHeight / 2); //Button location Point buttonTopLeft = this.PointToScreen(new Point()); double buttonLeft = buttonTopLeft.X; double buttonRight = buttonLeft + this.ActualWidth; double buttonTop = buttonTopLeft.Y; double buttonBottom = buttonTop + this.ActualHeight; if (cursorCenterX < buttonLeft || cursorCenterX > buttonRight) return false; if (cursorCenterY < buttonTop || cursorCenterY > buttonBottom) return false; return true; } catch { return false; } }
public void RenameService(FrameworkElement sb) { var input = new InputPopupViewModel { RelativePosition = sb.PointToScreen(new Point(0, 0)), TimeOut = new TimeSpan(0, 0, 2, 5), VerticalAlignment = VerticalAlignment.Bottom, Title = "Service Name", Width = 250.0, DefaultValue = service.Name }; input.Saved += (st, ea) => { var oldName = service.FileName; var old = service.Name; service.Name = ea.Result; if (oldName == service.FileName) return; if (File.Exists(oldName) && (!File.Exists(service.FileName))) { if (service.SaveXml()) { File.Delete(oldName); AppStateSettings.Instance.RenameStartPanelTabItem(old, service.Name); } else service.Name = old; } else service.Name = old; plugin.UpdateLayerTabs(service, this); }; AppStateSettings.Instance.Popups.Add(input); }
public async Task Start(string romLocation, FrameworkElement projectTo, double emulationSpeed = 1.0) { Window projectWindow = null; var parent = projectTo; while (parent.Parent != null) { parent = (FrameworkElement)parent.Parent; if (parent is Window) { projectWindow = (Window)parent; } } if (projectWindow == null) { throw new ArgumentException("The projection element must be a child of a window.", "projectTo"); } using (var myProcess = Process.GetCurrentProcess()) { foreach (var existingProcess in Process.GetProcessesByName(myProcess.ProcessName)) { using (existingProcess) { if (existingProcess.Id != myProcess.Id) { existingProcess.Kill(); await Task.Delay(1000); } } } } foreach (var existingProcess in Process.GetProcessesByName("bgb")) { using (existingProcess) { existingProcess.Kill(); await Task.Delay(1000); } } await Task.Delay(1000); var emulatorRoot = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "XPlaysGameboy", "Emulator"); if (!Directory.Exists(emulatorRoot)) { Directory.CreateDirectory(emulatorRoot); } var emulatorFilePath = Path.Combine(emulatorRoot, "bgb.exe"); if (!File.Exists(emulatorFilePath)) { File.WriteAllBytes(emulatorFilePath, Resources.bgbexe); File.WriteAllText(Path.Combine(emulatorRoot, "bgb.ini"), Resources.bgbini); } var information = new ProcessStartInfo(emulatorFilePath); information.Arguments = "\"" + romLocation + "\" " + "-setting Speed=" + emulationSpeed.ToString(new CultureInfo("en-US")) + " "; var process = Process.Start(information); Debug.Assert(process != null, "process != null"); while (process.MainWindowHandle == IntPtr.Zero) { await Task.Delay(1000); } await Task.Delay(1000); var gameboyWindowHandle = NativeMethods.FindWindowEx(IntPtr.Zero, IntPtr.Zero, "Tfgb", null); _gameboyWindowHandle = gameboyWindowHandle; NativeMethods.ShowWindow(gameboyWindowHandle, NativeMethods.WindowShowStyle.Hide); var style = (long)NativeMethods.GetWindowLong(process.MainWindowHandle, NativeMethods.WindowLongIndexFlags.GWL_STYLE); style &= ~((uint)NativeMethods.SetWindowLongFlags.WS_CAPTION | (uint)NativeMethods.SetWindowLongFlags.WS_THICKFRAME | (uint)NativeMethods.SetWindowLongFlags.WS_MINIMIZE | (uint)NativeMethods.SetWindowLongFlags.WS_MAXIMIZE | (uint)NativeMethods.SetWindowLongFlags.WS_SYSMENU | (uint)NativeMethods.SetWindowLongFlags.WS_EX_APPWINDOW | (uint)NativeMethods.SetWindowLongFlags.WS_EX_OVERLAPPEDWINDOW | (uint)NativeMethods.SetWindowLongFlags.WS_OVERLAPPED | (uint)NativeMethods.SetWindowLongFlags.WS_ICONIC | (uint)NativeMethods.SetWindowLongFlags.WS_BORDER | (uint)NativeMethods.SetWindowLongFlags.WS_DLGFRAME | (uint)NativeMethods.SetWindowLongFlags.WS_EX_CLIENTEDGE | (uint)NativeMethods.SetWindowLongFlags.WS_EX_COMPOSITED | (uint)NativeMethods.SetWindowLongFlags.WS_EX_DLGMODALFRAME | (uint)NativeMethods.SetWindowLongFlags.WS_MAXIMIZE | (uint)NativeMethods.SetWindowLongFlags.WS_MAXIMIZEBOX | (uint)NativeMethods.SetWindowLongFlags.WS_MINIMIZE | (uint)NativeMethods.SetWindowLongFlags.WS_MINIMIZEBOX | (uint)NativeMethods.SetWindowLongFlags.WS_POPUP | (uint)NativeMethods.SetWindowLongFlags.WS_SIZEBOX | (uint)NativeMethods.SetWindowLongFlags.WS_TILED); style |= (uint)NativeMethods.SetWindowLongFlags.WS_EX_TOPMOST; style |= (uint)NativeMethods.SetWindowLongFlags.WS_EX_TOOLWINDOW; NativeMethods.SetWindowLong(gameboyWindowHandle, NativeMethods.WindowLongIndexFlags.GWL_STYLE, (NativeMethods.SetWindowLongFlags)style); NativeMethods.ShowWindow(gameboyWindowHandle, NativeMethods.WindowShowStyle.Show); var resizeProjection = (Action)delegate() { var projectionLocation = projectTo.PointToScreen(new Point(0, 0)); var projectionSize = new Size(projectTo.ActualWidth, projectTo.ActualHeight); NativeMethods.SetWindowPos(gameboyWindowHandle, new IntPtr(-1), (int)projectionLocation.X, (int)projectionLocation.Y, (int)projectionSize.Width, (int)projectionSize.Height, NativeMethods.SetWindowPosFlags.SWP_NOACTIVATE); }; projectTo.SizeChanged += delegate { resizeProjection(); }; projectWindow.LocationChanged += delegate { resizeProjection(); }; projectWindow.SizeChanged += delegate { resizeProjection(); }; projectWindow.Closed += delegate { process.Kill(); }; projectWindow.StateChanged += delegate { if (projectWindow.WindowState == WindowState.Minimized) { NativeMethods.ShowWindow(_gameboyWindowHandle, NativeMethods.WindowShowStyle.Hide); } else { NativeMethods.ShowWindow(_gameboyWindowHandle, NativeMethods.WindowShowStyle.ShowNoActivate); } }; projectWindow.Activated += delegate { NativeMethods.ShowWindow(_gameboyWindowHandle, NativeMethods.WindowShowStyle.ShowNoActivate); }; resizeProjection(); }
private double CutBottom(FrameworkElement placementTarget) { Point point = placementTarget.PointToScreen(new Point(placementTarget.ActualHeight, 0)); point.Y += placementTarget.ActualHeight; return Math.Min(0, SystemParameters.VirtualScreenHeight - (Math.Max(SystemParameters.VirtualScreenHeight, point.Y))); }
private void Grip_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (e.ClickCount == 1) { frameworkElement = (FrameworkElement)sender; startDragPoint = frameworkElement.PointToScreen(Mouse.GetPosition(frameworkElement)); originalWidth = ActualWidth; originalHeight = ActualHeight; frameworkElement.CaptureMouse(); e.Handled = true; } }
private void SetPosition(PlacementMode preferedPlacement, FrameworkElement targetPlacement, System.Windows.Point mousePosition, bool secondSetPositionCall = false) { Screen screen = this.CurrentScreen(); this.relativeToTargetPoint = targetPlacement == null ? mousePosition : targetPlacement.PointToScreen(new System.Windows.Point(0.0, 0.0)); this.screenTop = (double) screen.WorkingArea.Top; this.screenLeft = (double) screen.WorkingArea.Left; InlinePopup inlinePopup1 = this; Rectangle workingArea = screen.WorkingArea; double num1 = (double) workingArea.Height; inlinePopup1.screenHeight = num1; InlinePopup inlinePopup2 = this; workingArea = screen.WorkingArea; double num2 = (double) workingArea.Width; inlinePopup2.screenWidth = num2; this.fitLeft = this.relativeToTargetPoint.X - this.ActualWidth * this.dpiXfactor > this.screenLeft; this.fitRight = this.ActualWidth * this.dpiXfactor + this.relativeToTargetPoint.X < this.screenLeft + this.screenWidth; this.fitTop = this.relativeToTargetPoint.Y - this.ActualHeight * this.dpiYfactor > this.screenTop; this.fitBottom = this.ActualHeight * this.dpiYfactor + this.relativeToTargetPoint.Y < this.screenTop + this.screenHeight; switch (preferedPlacement) { case PlacementMode.Bottom: if (this.fitBottom) { this.relativeToTargetPoint.Y += targetPlacement != null ? targetPlacement.ActualHeight * this.dpiYfactor : 0.0; this.PositionBottom(this.relativeToTargetPoint, secondSetPositionCall); } else { this.relativeToTargetPoint.Y = this.screenTop + this.screenHeight - this.ActualHeight * this.dpiYfactor; this.PositionBottom(this.relativeToTargetPoint, secondSetPositionCall); } if (secondSetPositionCall) break; this.SetPosition(PlacementMode.Right, targetPlacement, mousePosition, true); break; case PlacementMode.Right: if (this.fitRight) { this.PositionRight(this.relativeToTargetPoint, secondSetPositionCall); } else { this.relativeToTargetPoint.X = this.screenLeft + this.screenWidth - this.ActualWidth * this.dpiXfactor; this.PositionRight(this.relativeToTargetPoint, secondSetPositionCall); } if (secondSetPositionCall) break; this.SetPosition(PlacementMode.Bottom, targetPlacement, mousePosition, true); break; case PlacementMode.Left: if (this.fitLeft) { this.PositionLeft(this.relativeToTargetPoint, secondSetPositionCall); } else { this.relativeToTargetPoint.X = this.screenLeft + this.ActualWidth * this.dpiXfactor; this.PositionLeft(this.relativeToTargetPoint, secondSetPositionCall); } if (secondSetPositionCall) break; this.SetPosition(PlacementMode.Bottom, targetPlacement, mousePosition, true); break; case PlacementMode.Top: if (this.fitTop) { this.PositionTop(this.relativeToTargetPoint, secondSetPositionCall); } else { this.relativeToTargetPoint.Y = this.screenTop + this.ActualHeight * this.dpiYfactor; this.PositionTop(this.relativeToTargetPoint, secondSetPositionCall); } if (secondSetPositionCall) break; this.SetPosition(PlacementMode.Right, targetPlacement, mousePosition, true); break; } }