Ejemplo n.º 1
0
        public Window CreateTooltipWindow(TextEditor editor, int offset, Gdk.ModifierType modifierState, TooltipItem item)
        {
            //create a message string from all the results
            var results = item.Item as AbstractTooltipContent[];

            var win = new DToolTipWindow();

            // Set white background
            win.ModifyBg(StateType.Normal, new Gdk.Color(0xff, 0xff, 0xff));

            var pack = new Gtk.VBox();

            foreach (var r in results)
            {
                var titleLabel = new Label(r.Title);

                // Make left-bound
                titleLabel.SetAlignment(0, 0);

                // Set bold font
                titleLabel.ModifyFont(new Pango.FontDescription()
                {
                    Weight = Weight.Bold, AbsoluteSize = 12 * (int)Pango.Scale.PangoScale
                });

                pack.Add(titleLabel);

                if (!string.IsNullOrEmpty(r.Description))
                {
                    const int maximumDescriptionLength = 300;
                    var       descLabel = new Label(r.Description.Length > maximumDescriptionLength ? (r.Description.Substring(0, maximumDescriptionLength) + "...") : r.Description);

                    descLabel.ModifyFont(new Pango.FontDescription()
                    {
                        AbsoluteSize = 10 * (int)Pango.Scale.PangoScale
                    });
                    descLabel.SetAlignment(0, 0);

                    pack.Add(descLabel);
                }
            }

            win.Add(pack);

            return(win);
        }
Ejemplo n.º 2
0
        public Window CreateTooltipWindow(TextEditor editor, int offset, Gdk.ModifierType modifierState, TooltipItem item)
        {
            //create a message string from all the results
            var results = item.Item as AbstractTooltipContent[];

            var win = new DToolTipWindow();

            // Set white background
            win.ModifyBg(StateType.Normal,new Gdk.Color(0xff,0xff,0xff));

            var pack = new Gtk.VBox();

            foreach (var r in results)
            {
                var titleLabel = new Label(r.Title);

                // Make left-bound
                titleLabel.SetAlignment(0, 0);

                // Set bold font
                titleLabel.ModifyFont(new Pango.FontDescription() {Weight=Weight.Bold, AbsoluteSize=12*(int)Pango.Scale.PangoScale});

                pack.Add(titleLabel);

                if (!string.IsNullOrEmpty( r.Description))
                {
                    const int maximumDescriptionLength = 300;
                    var descLabel = new Label(r.Description.Length>maximumDescriptionLength ? (r.Description.Substring(0,maximumDescriptionLength)+"...") : r.Description);

                    descLabel.ModifyFont(new Pango.FontDescription() { AbsoluteSize = 10 * (int)Pango.Scale.PangoScale });
                    descLabel.SetAlignment(0, 0);

                    pack.Add(descLabel);
                }
            }

            win.Add(pack);

            return win;
        }