Exemplo n.º 1
0
        public GeneralPropertyDescriptor addOtherProperty(string name, string category, object value)
        {
            GeneralPropertyDescriptor p = new GeneralPropertyDescriptor(name);

            p.PropCategory = category;
            p.PropValue    = value;
            PropertyAdapter.OtherProperties.Add(p);
            return(p);
        }
        private UITypeEditor lookUpEditor(ITypeDescriptorContext context)
        {
            if (context != null && context.PropertyDescriptor is GeneralPropertyDescriptor)
            {
                GeneralPropertyDescriptor gpd = (GeneralPropertyDescriptor)context.PropertyDescriptor;

                if (gpd.PropValue != null && typeof(WhiskeyPropertyContainer).IsAssignableFrom(gpd.PropValue.GetType()))
                {
                    WhiskeyPropertyContainer wpc = (WhiskeyPropertyContainer)gpd.PropValue;
                    //if (editors.ContainsKey(wpc.TypeName))
                    //{
                    //    return editors[wpc.TypeName];
                    //}
                    return(WhiskeyTypeEditors.lookUp(wpc.TypeName));
                }
            }
            return(null);
        }
Exemplo n.º 3
0
 public RestrictedFloatPicker(GeneralPropertyDescriptor gpd, float min, float max, float inc)
     : this(min, max, inc)
 {
     Property = gpd;
 }
Exemplo n.º 4
0
 public RestrictedFloatPicker(GeneralPropertyDescriptor gpd)
     : this(gpd, 0, 1, .1f)
 {
 }
Exemplo n.º 5
0
        /// <summary>
        /// Getting a set of properties to give to the propertygrid
        /// </summary>
        /// <param name="attributes">?</param>
        /// <returns>a set of properties for the propertygrid</returns>
        public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
        {
            //clear previous property model set
            LastModelSet.Clear();
            List <PropertyDescriptor> properties = new List <PropertyDescriptor>();

            //for every property in our set...
            foreach (WhiskeyProperty prop in WhiskeyPropertys)
            {
                if (prop.Visible)
                {
                    //create a new property descriptor (for the property grid) for it....
                    GeneralPropertyDescriptor gpd = new GeneralPropertyDescriptor(prop.Name);

                    //create a model, that is either secure or unsecure depending on if the WhiskeyProp.Secure is true/false
                    WhiskeyPropertyContainer model;
                    if (prop.Secure)
                    {
                        model = new WhiskeyPropertyContainerSecured(prop);

                        gpd.PropCategory = "Base Properties";
                    }
                    else
                    {
                        model = new WhiskeyPropertyContainer(prop);

                        gpd.PropCategory = "Properties";
                    }

                    //set the value of the propertygrid property descriptor, to our model
                    gpd.PropValue    = model;
                    gpd.PropCategory = prop.Category;

                    //add a listener that will update the propertygrid when the model changes
                    model.Changed += (s, a) =>
                    {
                        gpd.PropDisplayName = a.WhiskeyProperty.Name;

                        if (PropertyGrid.IsHandleCreated)
                        {
                            //PropertyGrid.BeginInvoke(new NoArgFunction(() => {
                            PropertyGrid.Refresh();
                            //}));
                            PropertyValueChanged(this, new EventArgs());
                        }
                    };

                    //add the model to our set
                    LastModelSet.Add(model);
                    //add the propertygrid descriptor to the set to be returned
                    properties.Add(gpd);
                }
            }

            //converting the set of propertygrid descriptors to a returnable array
            //properties.Sort();

            //other
            foreach (GeneralPropertyDescriptor prop in OtherProperties)
            {
                //properties.Add(new WhiskeyPropertyContainer(new WhiskeyProperty(prop.DisplayName, new WhiskeyEditor.Backend.RealType(prop.ComponentType, prop.PropValue)));
                properties.Add(prop);
            }

            PropertyDescriptor[] props = (PropertyDescriptor[])properties.ToArray();

            return(new PropertyDescriptorCollection(props));
        }
Exemplo n.º 6
0
 public void removeOtherProperty(GeneralPropertyDescriptor p)
 {
     PropertyAdapter.OtherProperties.Remove(p);
 }