Skip to content

Commit

Permalink
Fix so that BorderForMouseOver of Line control is displayed at correc…
Browse files Browse the repository at this point in the history
…t position
  • Loading branch information
YuuukiA committed Oct 15, 2024
1 parent 38e9db5 commit d625e43
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions WpfDesign.Designer/Project/Extensions/BorderForMouseOver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.

using System.Reflection;
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 +32,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 d625e43

Please sign in to comment.