private void OpenControlGrid(UIElement sender) { ControlGrid.Visibility = Visibility.Visible; ControlGrid.UpdateLayout(); var element = sender.TransformToVisual(this).TransformBounds(new Rect(sender.RenderSize)); var content = ControlGrid.TransformToVisual(this).TransformBounds(new Rect(ControlGrid.RenderSize)); var maxX = this.RenderSize.Width - content.Width; var x = Convert.ToSingle(Math.Max(0, Math.Min(element.X, maxX))); Canvas.SetLeft(ControlGrid, x); Canvas.SetTop(ControlGrid, element.Bottom); UpdateArrow(element, new Rect(new Point(x, element.Bottom), ControlGrid.RenderSize)); }
private void MainWindow_OnMouseDown(object sender, MouseButtonEventArgs e) { if (e.ClickCount >= 2) { var point = Mouse.GetPosition(this); if (Controller.TransformToVisual(this).TransformBounds(new Rect(Controller.RenderSize)).Contains(point)) { return; } if (ControlGrid.TransformToVisual(this).TransformBounds(new Rect(ControlGrid.RenderSize)).Contains(point)) { return; } CopyToClipBoard(); this.Close(); } UpdateXY(); }