AspNetEdit.UI.PropertyEditors.ColorEditor.GetDisplayWidget C# (CSharp) Method

GetDisplayWidget() public method

public GetDisplayWidget ( ) : Gtk.Widget
return Gtk.Widget
        public override Gtk.Widget GetDisplayWidget()
        {
            DrawingArea colorPreview = new DrawingArea ();

            colorPreview.ModifyBg(StateType.Normal, GetColor ());
            colorPreview.WidthRequest = 15;

            Alignment colorPreviewAlign = new Alignment (0, 0, 0, 1);
            colorPreviewAlign.SetPadding (2, 2, 2, 2);
            colorPreviewAlign.Add (colorPreview);

            string labelText;

            System.Drawing.Color color = (System.Drawing.Color) parentRow.PropertyValue;
            //TODO: dropdown known color selector so this does something
            if (color.IsKnownColor)
                labelText = color.Name;
            else if (color.IsEmpty)
                labelText = "[empty]";
            else
                labelText = String.Format("#{0:x2}{1:x2}{2:x2}", color.R, color.G, color.B);

            //we use StringValue as it auto-bolds the text for non-default values
            Label theLabel = (Label) base.StringValue (labelText);
            theLabel.Xalign = 0;
            theLabel.Xpad = 3;

            HBox hbox = new HBox ();
            hbox.PackStart (colorPreviewAlign, false, false, 0);
            hbox.PackStart (theLabel, true, true, 0);

            return hbox;
        }