Exemple #1
0
        public static int GetPropertyCount(this ID2D1Properties properties)
        {
            if (properties == null)
            {
                throw new ArgumentNullException(nameof(properties));
            }

            return(properties.GetPropertyCount());
        }
        public static IReadOnlyList <D2D1Property> GetProperties(this ID2D1Properties properties)
        {
            if (properties == null)
            {
                return(new D2D1Property[0]);
            }

            var list = new List <D2D1Property>();

            for (uint i = 0; i < properties.GetPropertyCount(); i++)
            {
                var len  = properties.GetPropertyNameLength(i);
                var name = new string('\0', (int)len);
                properties.GetPropertyName(i, name, len + 1).ThrowOnError();
                var property = new D2D1Property();
                property.Name = name;
                property.Type = properties.GetType(i);

                var size = properties.GetValueSize(i);
                if (size > 0)
                {
                    var data = new byte[size];
                    properties.GetValue(i, property.Type, data, data.Length).ThrowOnError();
                    property.ValueBytes = data;
                }

                properties.GetSubProperties(i, out var sub);
                property.SubProperties = GetProperties(sub);
                list.Add(property);
            }

            var prop = GetProperty(properties, unchecked ((uint)D2D1_PROPERTY.D2D1_PROPERTY_AUTHOR));

            if (prop != null)
            {
                list.Add(prop);
            }

            prop = GetProperty(properties, unchecked ((uint)D2D1_PROPERTY.D2D1_PROPERTY_CATEGORY));
            if (prop != null)
            {
                list.Add(prop);
            }

            prop = GetProperty(properties, unchecked ((uint)D2D1_PROPERTY.D2D1_PROPERTY_DESCRIPTION));
            if (prop != null)
            {
                list.Add(prop);
            }

            prop = GetProperty(properties, unchecked ((uint)D2D1_PROPERTY.D2D1_PROPERTY_DISPLAYNAME));
            if (prop != null)
            {
                list.Add(prop);
            }

            prop = GetProperty(properties, unchecked ((uint)D2D1_PROPERTY.D2D1_PROPERTY_CLSID));
            if (prop != null)
            {
                list.Add(prop);
            }

            prop = GetProperty(properties, unchecked ((uint)D2D1_PROPERTY.D2D1_PROPERTY_INPUTS));
            if (prop != null)
            {
                list.Add(prop);
            }

            prop = GetProperty(properties, unchecked ((uint)D2D1_PROPERTY.D2D1_PROPERTY_MIN_INPUTS));
            if (prop != null)
            {
                list.Add(prop);
            }

            prop = GetProperty(properties, unchecked ((uint)D2D1_PROPERTY.D2D1_PROPERTY_MAX_INPUTS));
            if (prop != null)
            {
                list.Add(prop);
            }

            prop = GetProperty(properties, unchecked ((uint)D2D1_PROPERTY.D2D1_PROPERTY_CACHED));
            if (prop != null)
            {
                list.Add(prop);
            }

            prop = GetProperty(properties, unchecked ((uint)D2D1_PROPERTY.D2D1_PROPERTY_PRECISION));
            if (prop != null)
            {
                list.Add(prop);
            }
            return(list);
        }