Esempio n. 1
0
            public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
            {
                PropertiesContainer obj = (value as PropertiesContainer);

                if (obj == null)
                {
                    return(new PropertyDescriptorCollection(new PropertyDescriptor[] {}));
                }

                List <Property> propertyList = obj.PropertyList;

                PropertyDescriptor[] props = new PropertyDescriptor[propertyList.Count];

                // Create the list of property descriptors.
                for (int i = 0; i < propertyList.Count; i++)
                {
                    Property              property      = propertyList[i];
                    string                name          = property.Name;
                    UITypeEditor          editor        = null;
                    PropertyDocumentation documentation = property.GetDocumentation();

                    // Find the editor.
                    if (documentation != null)
                    {
                        editor = obj.PropertyGrid.GetUITypeEditor(documentation.EditorType);
                    }

                    // Create the property descriptor.
                    props[i] = new CustomPropertyDescriptor(
                        documentation, editor, property.Name, obj.Properties);
                }

                return(new PropertyDescriptorCollection(props));
            }
        //-----------------------------------------------------------------------------
        // Constructor
        //-----------------------------------------------------------------------------
        public PropertyGridControl(EditorControl editorControl, PropertyGrid propertyGrid)
        {
            this.editorControl	= editorControl;
            this.propertyGrid	= propertyGrid;

            propertiesContainer = new PropertiesContainer(null);
            propertyGrid.SelectedObject = propertiesContainer;

            // Create property editor types.
            typeEditors = new Dictionary<string, CustomPropertyEditor>();
            typeEditors["sprite"]			= new ResourcePropertyEditor<Sprite>();
            typeEditors["animation"]		= new ResourcePropertyEditor<Animation>();
            typeEditors["collision_model"]	= new ResourcePropertyEditor<CollisionModel>();
            typeEditors["song"]				= new ResourcePropertyEditor<Song>();
            typeEditors["sound"]			= new ResourcePropertyEditor<Sound>();
            typeEditors["zone"]				= new ResourcePropertyEditor<Zone>();
            typeEditors["reward"]			= new RewardPropertyEditor(editorControl.RewardManager);
            typeEditors["text_message"]		= new TextMessagePropertyEditor();
            typeEditors["script"]			= new ScriptPropertyEditor();
            typeEditors["sprite_index"]		= new SpriteIndexComboBox();
            typeEditors["direction"]		= new DirectionPropertyEditor();
            typeEditors["angle"]			= null;
            typeEditors["enum"]				= new EnumComboBox();
            typeEditors["enum_flags"]		= null;
            typeEditors["dungeon"]			= new DungeonPropertyEditor();
            typeEditors["level"]			= new LevelPropertyEditor();
            /*
            // Initialize property type editors.
            foreach (KeyValuePair<string, CustomPropertyEditor> entry in typeEditors) {
                if (entry.Value != null)
                    entry.Value.Initialize(this);
            }*/
        }
Esempio n. 3
0
        //-----------------------------------------------------------------------------
        // Constructor
        //-----------------------------------------------------------------------------

        public ZeldaPropertyGrid()
        {
            editorControl       = null;
            propertyObject      = null;
            propertiesContainer = new PropertiesContainer(this);
            typeEditors         = new Dictionary <string, CustomPropertyEditor>();

            this.SelectedObject        = propertiesContainer;
            this.PropertyValueChanged += OnPropertyChange;
        }
        //-----------------------------------------------------------------------------
        // Constructor
        //-----------------------------------------------------------------------------
        public ZeldaPropertyGrid()
        {
            editorControl		= null;
            propertyObject		= null;
            propertiesContainer	= new PropertiesContainer(this);
            typeEditors			= new Dictionary<string, CustomPropertyEditor>();

            this.SelectedObject			= propertiesContainer;
            this.PropertyValueChanged	+= OnPropertyChange;
        }
        //-----------------------------------------------------------------------------
        // Constructor
        //-----------------------------------------------------------------------------
        public PropertyGridControl(EditorControl editorControl, PropertyGrid propertyGrid)
        {
            this.editorControl	= editorControl;
            this.propertyGrid	= propertyGrid;

            propertiesContainer = new PropertiesContainer(this);
            propertyGrid.SelectedObject = propertiesContainer;

            // Setup property editor types.
            typeEditors = new Dictionary<string,UITypeEditor>();
            typeEditors["sprite"]			= new ResourcePropertyEditor<Sprite>();
            typeEditors["animation"]		= new ResourcePropertyEditor<Animation>();
            typeEditors["collision_model"]	= new ResourcePropertyEditor<CollisionModel>();
            typeEditors["song"]				= new ResourcePropertyEditor<Song>();
            typeEditors["sound"]			= new ResourcePropertyEditor<Sound>();
            typeEditors["zone"]				= new ResourcePropertyEditor<Zone>();
            typeEditors["reward"]			= new RewardPropertyEditor(editorControl.RewardManager);
            typeEditors["text_message"]		= new TextMessagePropertyEditor();
            typeEditors["script"]			= null;
            typeEditors["sprite_index"]		= new SpriteIndexComboBox(this);
        }