MonoHotDraw.Figures.SimpleTextFigure.SetAttribute C# (CSharp) Method

SetAttribute() public method

public SetAttribute ( FigureAttribute attribute, object value ) : void
attribute FigureAttribute
value object
return void
        public override void SetAttribute(FigureAttribute attribute, object value)
        {
            //FIXME: Improve this logic, because doesn't make any sense
            //invalidating when isn't needed (current value = new value)
            WillChange ();
            switch (attribute) {
                case FigureAttribute.FillColor:
                    FillColor = (Cairo.Color) value;
                    break;
                case FigureAttribute.FontAlignment:
                    FontAlignment = (Pango.Alignment) value;
                    break;
                case FigureAttribute.FontColor:
                    FontColor = (Cairo.Color) value;
                    break;
                case FigureAttribute.FontSize:
                    FontSize = (int) value;
                    break;
                case FigureAttribute.FontStyle:
                    FontStyle = (Pango.Style) value;
                    break;
                case FigureAttribute.LineColor:
                    LineColor = (Cairo.Color) value;
                    break;
                default:
                    base.SetAttribute (attribute, value);
                    break;
            }
            GenerateDummyContext ();
            Changed ();
        }

Usage Example

        private void populateTable()
        {
            //Create Labels
            _tableName = new PlainSimpleTextFigure (_tableModel.Name);
            _tableName.SetAttribute (FigureAttribute.FontSize, 7);
            _tableName.SetAttribute (FigureAttribute.FontColor, new Cairo.Color (0, 0, 0.501961));
            //TODO: don't change name at each letter changed
            _tableName.TextChanged += delegate { Model.Name = _tableName.Text; };

            _indexLabel = new PlainSimpleTextFigure ("Indexes");
            _indexLabel.SetAttribute (FigureAttribute.FontColor, new Cairo.Color (0, 0, 0.501961));
            _indexLabel.SetAttribute (FigureAttribute.FontSize, 6);

            _triggerLabel = new PlainSimpleTextFigure ("Triggers");
            _triggerLabel.SetAttribute (FigureAttribute.FontColor, new Cairo.Color (0, 0, 0.501961));
            _triggerLabel.SetAttribute (FigureAttribute.FontSize, 6);
            //Add Table Columns & Name
            this.Add (_tableName);
            _tableName.MoveTo (DisplayBox.X + 2, DisplayBox.Y + 2);
            foreach (AbstractColumnFigure col in _tableModel.columns) {
                this.Add (col);
            }

            //TODO: Add/Detect Foreign Keys that table model have

            //Add Table Indexes Label (items added at ButtonHandle)
            this.Add (_indexLabel);
            //Add Table Triggers Label (items added at ButtonHandle)
            this.Add (_triggerLabel);

            OnFigureChanged (new FigureEventArgs (this, DisplayBox));
        }