<commit_before>﻿using Mapsui.Widgets;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Media;

namespace Mapsui.Rendering.Xaml
{
    public static class HyperlinkWidgetRenderer
    {
        public static void Draw(Canvas canvas, Hyperlink hyperlink)
        {
            if (string.IsNullOrEmpty(hyperlink.Text)) return;
            var border = CreateBorder(hyperlink);

            canvas.Children.Add(border);
            border.UpdateLayout(); // to calculate the boundingbox

            // Get position in x direction
            double posX = 0;
            switch(hyperlink.HorizontalAlignment)
            {
                case Widgets.HorizontalAlignment.Left:
                    posX = hyperlink.MarginX;
                    break;
                case Widgets.HorizontalAlignment.Center:
                    posX = (canvas.Width - border.ActualWidth) * 0.5;
                    break;
                case Widgets.HorizontalAlignment.Right:
                    posX = (canvas.Width - border.ActualWidth - hyperlink.MarginX);
                    break;
                case Widgets.HorizontalAlignment.Position:
                    posX = hyperlink.PositionX;
                    break;
            }

            // Get position in x direction
            double posY = 0;
            switch (hyperlink.VerticalAlignment)
            {
                case Widgets.VerticalAlignment.Top:
                    posY = hyperlink.MarginY;
                    break;
                case Widgets.VerticalAlignment.Center:
                    posY = (canvas.Height - border.ActualHeight) * 0.5;
                    break;
                case Widgets.VerticalAlignment.Bottom:
                    posY = (canvas.Height - border.ActualHeight - hyperlink.MarginY);
                    break;
                case Widgets.VerticalAlignment.Position:
                    posY = hyperlink.PositionY;
                    break;
            }

            Canvas.SetLeft(border, posX);
            Canvas.SetTop(border, posY);

            hyperlink.Envelope = BoundsRelativeTo(border, canvas).ToMapsui();<commit_msg>Added offset to Envelop, so that the Envelop has the correct screen position<commit_after>﻿using Mapsui.Widgets;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Media;

namespace Mapsui.Rendering.Xaml
{
    public static class HyperlinkWidgetRenderer
    {
        public static void Draw(Canvas canvas, Hyperlink hyperlink)
        {
            if (string.IsNullOrEmpty(hyperlink.Text)) return;
            var border = CreateBorder(hyperlink);

            canvas.Children.Add(border);
            border.UpdateLayout(); // to calculate the boundingbox

            // Get position in x direction
            double posX = 0;
            switch(hyperlink.HorizontalAlignment)
            {
                case Widgets.HorizontalAlignment.Left:
                    posX = hyperlink.MarginX;
                    break;
                case Widgets.HorizontalAlignment.Center:
                    posX = (canvas.Width - border.ActualWidth) * 0.5;
                    break;
                case Widgets.HorizontalAlignment.Right:
                    posX = (canvas.Width - border.ActualWidth - hyperlink.MarginX);
                    break;
                case Widgets.HorizontalAlignment.Position:
                    posX = hyperlink.PositionX;
                    break;
            }

            // Get position in x direction
            double posY = 0;
            switch (hyperlink.VerticalAlignment)
            {
                case Widgets.VerticalAlignment.Top:
                    posY = hyperlink.MarginY;
                    break;
                case Widgets.VerticalAlignment.Center:
                    posY = (canvas.Height - border.ActualHeight) * 0.5;
                    break;
                case Widgets.VerticalAlignment.Bottom:
                    posY = (canvas.Height - border.ActualHeight - hyperlink.MarginY);
                    break;
                case Widgets.VerticalAlignment.Position:
                    posY = hyperlink.PositionY;
                    break;
            }

            Canvas.SetLeft(border, posX);
            Canvas.SetTop(border, posY);

            hyperlink.Envelope = BoundsRelativeTo(border, canvas).ToMapsui();
            hyperlink.Envelope.Offset(posX, posY);
{'fraction_non_alphanumeric': 0.0751226036558181, 'fraction_numerical': 0.0026749888542131075, 'mean_word_length': 1.4913936701832315, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6194812', 'n_tokens_mistral': 1118, 'n_tokens_neox': 1063, 'n_words': 231}