Exemple #1
0
        LabelLink FindLink(double px, double py)
        {
            if (links == null)
            {
                return(null);
            }

            var alloc = Label.Allocation;

            int offsetX, offsetY;

            Label.GetLayoutOffsets(out offsetX, out offsetY);

            var x = (px - offsetX + alloc.X) * Pango.Scale.PangoScale;
            var y = (py - offsetY + alloc.Y) * Pango.Scale.PangoScale;

            int byteIndex, trailing;

            if (!Label.Layout.XyToIndex((int)x, (int)y, out byteIndex, out trailing))
            {
                return(null);
            }

            foreach (var li in links)
            {
                if (byteIndex >= li.StartIndex && byteIndex <= li.EndIndex)
                {
                    return(li);
                }
            }

            return(null);
        }