Skip to content

Commit

Permalink
Merge pull request #116 from YuuukiA/Issue115-fix-BorderForMouseOver-…
Browse files Browse the repository at this point in the history
…for-line-control

Fix so that BorderForMouseOver of Line control is displayed at correct position
  • Loading branch information
jogibear9988 authored Oct 15, 2024
2 parents 38e9db5 + 4c3aecf commit 88127f7
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions WpfDesign.Designer/Project/Extensions/BorderForMouseOver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

using System.Windows.Shapes;
using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Extensions;

Expand All @@ -31,18 +31,33 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
public class BorderForMouseOver : AdornerProvider
{
readonly AdornerPanel adornerPanel;
readonly Border border = new Border();

public BorderForMouseOver()
{
adornerPanel = new AdornerPanel();
adornerPanel.Order = AdornerOrder.Background;
this.Adorners.Add(adornerPanel);
var border = new Border();
border.BorderThickness = new Thickness(1);
border.BorderBrush = Brushes.DodgerBlue;
border.Margin = new Thickness(-2);
AdornerPanel.SetPlacement(border, AdornerPlacement.FillContent);
adornerPanel.Children.Add(border);
}

protected override void OnInitialized()
{
base.OnInitialized();

if (ExtendedItem.Component is Line line)
{
// To display border of Line in correct position.
border.Margin = new Thickness
{
Left = line.X2 < 0 ? line.X2 : 0,
Top = line.Y2 < 0 ? line.Y2 : 0
};
}
}
}
}

0 comments on commit 88127f7

Please sign in to comment.