Download BitmapFontParser.zip, last updated 02/01/2012 (500.33 KB)

Download
  • md5: 9897dbfb0eb6346f09d88a50f9687e2e
using System;
using System.ComponentModel;

namespace BitmapFontViewer
{
  // Based on http://www.csharp-examples.net/readonly-propertygrid/

  internal class PropertyGrid : System.Windows.Forms.PropertyGrid
  {
    #region  Private Member Declarations

    private bool _readOnly;

    #endregion  Private Member Declarations

    #region  Protected Overridden Methods

    protected override void OnSelectedObjectsChanged(EventArgs e)
    {
      if (this.SelectedObject != null)
        this.SetObjectAsReadOnly(this.SelectedObject, this.ReadOnly);

      base.OnSelectedObjectsChanged(e);
    }

    #endregion  Protected Overridden Methods

    #region  Public Properties

    [Category("Behavior"), DefaultValue(false)]
    public bool ReadOnly
    {
      get { return _readOnly; }
      set
      {
        _readOnly = value;

        if (this.SelectedObject != null)
          this.SetObjectAsReadOnly(this.SelectedObject, _readOnly);
      }
    }

    #endregion  Public Properties

    #region  Protected Methods

    protected void SetObjectAsReadOnly(object selectedObject, bool readOnly)
    {
      TypeDescriptor.AddAttributes(selectedObject, new Attribute[] { new ReadOnlyAttribute(readOnly) });
    }

    #endregion  Protected Methods
  }
}

Donate

Donate