示例#1
0
        void SetImagePosition(bool removeImage = true)
        {
            uint left, top;
            bool shouldHideLabel = false;

            switch (ImagePosition)
            {
            case ButtonImagePosition.Above:
                left            = 1;
                top             = 0;
                shouldHideLabel = true;
                break;

            case ButtonImagePosition.Below:
                left            = 1;
                top             = 2;
                shouldHideLabel = true;
                break;

            case ButtonImagePosition.Left:
                left = 0;
                top  = 1;
                break;

            case ButtonImagePosition.Right:
                left = 2;
                top  = 1;
                break;

            case ButtonImagePosition.Overlay:
                left = 1;
                top  = 1;
                break;

            default:
                throw new NotSupportedException();
            }
            shouldHideLabel &= string.IsNullOrEmpty(label.Text);
            if (shouldHideLabel)
            {
                label.Hide();
            }
            else
            {
                label.Show();
            }

            var right   = left + 1;
            var bottom  = top + 1;
            var options = shouldHideLabel ? Gtk.AttachOptions.Expand : Gtk.AttachOptions.Shrink;

            if (removeImage)
            {
                table.Remove(gtkimage);
            }
            table.Attach(gtkimage, left, right, top, bottom, options, options, 0, 0);
            Control.QueueResize();
        }
示例#2
0
 public ButtonHandler()
 {
     label           = new Gtk.AccelLabel(string.Empty);
     label.Ellipsize = Pango.EllipsizeMode.End;
     label.Show();
 }