コード例 #1
0
        public void SetBuffer(IRichTextBuffer buffer)
        {
            var buf = buffer as RichTextBuffer;

            if (buf == null)
            {
                throw new ArgumentException("Passed buffer is of incorrect type", "buffer");
            }

            if (links != null)
            {
                foreach (var link in links)
                {
                    link.NavigateToUrl -= HandleNavigateToUrl;
                }
            }

            Widget.Buffer = buf;
            links         = new LinkLabel [buf.Links.Count];
            for (var i = 0; i < links.Length; i++)
            {
                var link  = buf.Links [i];
                var label = new LinkLabel(link.Text)
                {
                    Uri = link.Href
                };
                label.NavigateToUrl += HandleNavigateToUrl;
                Widget.AddChildAtAnchor((Gtk.Widget)WidgetRegistry.GetNativeWidget(label), link.Anchor);
                links [i] = label;
            }
        }