コード例 #1
0
ファイル: Shadow.cs プロジェクト: yunmiha/TizenFX
        /// <summary>
        /// Create a Shadow from a property map.
        /// </summary>
        internal Shadow(PropertyMap propertyMap) : base(propertyMap)
        {
            Color = noColor;
            PropertyValue pValue = propertyMap.Find(ColorVisualProperty.MixColor);

            pValue?.Get(Color);
            pValue?.Dispose();

            float blurRadius = 0;

            pValue = propertyMap.Find(ColorVisualProperty.BlurRadius);
            pValue?.Get(out blurRadius);
            pValue?.Dispose();
            BlurRadius = blurRadius;
        }
コード例 #2
0
ファイル: ShadowBase.cs プロジェクト: wonrst/TizenFX
        private void SetTransformMap(PropertyMap transformMap)
        {
            if (transformMap == null)
            {
                return;
            }

            PropertyValue temp = transformMap.Find((int)VisualTransformPropertyType.Offset);

            temp?.Get(Offset);
            temp?.Dispose();
            temp = transformMap.Find((int)VisualTransformPropertyType.ExtraSize);
            temp?.Get(Extents);
            temp?.Dispose();
        }
コード例 #3
0
        /// <summary>
        /// Create a Shadow from a propertyMap.
        /// </summary>
        internal ImageShadow(PropertyMap propertyMap) : base(propertyMap)
        {
            Border = noBorder;
            PropertyValue pValue = propertyMap.Find(ImageVisualProperty.Border);

            pValue?.Get(Border);
            pValue?.Dispose();

            string url = null;

            pValue = propertyMap.Find(ImageVisualProperty.URL);
            pValue?.Get(out url);
            pValue?.Dispose();
            Url = url;
        }
コード例 #4
0
ファイル: PropertyHelper.cs プロジェクト: yunmiha/TizenFX
        private static PropertyValue PropertyValueColorToAlpha(PropertyValue value)
        {
            var valueType = value.GetType();

            if (valueType != PropertyType.Vector4)
            {
                return(null);
            }

            using (var colorValue = new Vector4())
            {
                value.Get(colorValue);
                return(new PropertyValue(colorValue.A));
            }
        }
コード例 #5
0
ファイル: PropertyHelper.cs プロジェクト: yunmiha/TizenFX
        private static PropertyValue PropertyValueColorToVector3(PropertyValue value)
        {
            var valueType = value.GetType();

            if (valueType != PropertyType.Vector4)
            {
                return(null);
            }

            var colorValue = new Vector4();

            value.Get(colorValue);
            using (var v3 = new Vector3(colorValue.R, colorValue.G, colorValue.B))
            {
                colorValue.Dispose();
                return(new PropertyValue(v3));
            }
        }
コード例 #6
0
        /// <summary>
        /// Sets a property value on a view.
        /// </summary>
        private void SetPropertyValue(IntPtr refObjectPtr, string propertyName, IntPtr propertyValuePtr)
        {
            // Get the C# control that maps to the C++ control
            NUILog.Debug("SetPropertyValue   refObjectPtr = {0:X}" + refObjectPtr);

            PropertyValue propValue = new PropertyValue(propertyValuePtr, false);

            // Get the C# control that maps to the C++ control
            View view = Registry.GetManagedBaseHandleFromRefObject(refObjectPtr) as View;

            if (view != null)
            {
                System.Reflection.PropertyInfo propertyInfo = view.GetType().GetProperty(propertyName);
                // We know the property name, we know it's type, we just need to convert from a DALi property value to native C# type
                System.Type type = propertyInfo.PropertyType;
                bool        ok   = false;

                if (type.Equals(typeof(Int32)))
                {
                    int value = 0;
                    ok = propValue.Get(out value);
                    if (ok)
                    {
                        propertyInfo.SetValue(view, value);
                    }
                }
                else if (type.Equals(typeof(bool)))
                {
                    bool value = false;
                    ok = propValue.Get(out value);
                    if (ok)
                    {
                        propertyInfo.SetValue(view, value);
                    }
                }
                else if (type.Equals(typeof(float)))
                {
                    float value = 0;
                    ok = propValue.Get(out value);
                    if (ok)
                    {
                        propertyInfo.SetValue(view, value);
                    }
                }
                else if (type.Equals(typeof(string)))
                {
                    string value = "";
                    ok = propValue.Get(out value);
                    if (ok)
                    {
                        propertyInfo.SetValue(view, value);
                    }
                }
                else if (type.Equals(typeof(Vector2)))
                {
                    Vector2 value = new Vector2();
                    ok = propValue.Get(value);
                    if (ok)
                    {
                        propertyInfo.SetValue(view, value);
                    }
                }
                else if (type.Equals(typeof(Vector3)))
                {
                    Vector3 value = new Vector3();
                    ok = propValue.Get(value);
                    if (ok)
                    {
                        propertyInfo.SetValue(view, value);
                    }
                }
                else if (type.Equals(typeof(Vector4)))
                {
                    Vector4 value = new Vector4();
                    ok = propValue.Get(value);

                    if (ok)
                    {
                        propertyInfo.SetValue(view, value);
                    }
                }
                else if (type.Equals(typeof(Position)))
                {
                    Position value = new Position();
                    ok = propValue.Get(value);
                    if (ok)
                    {
                        propertyInfo.SetValue(view, value);
                    }
                }
                else if (type.Equals(typeof(Size)))
                {
                    Size value = new Size();
                    ok = propValue.Get(value);
                    if (ok)
                    {
                        propertyInfo.SetValue(view, new Size(value.Width, value.Height, value.Depth));
                    }
                    ;
                }
                else if (type.Equals(typeof(Color)))
                {
                    // Colors are stored as Vector4's in DALi
                    Color value = new Color();
                    ok = propValue.Get(value);
                    if (ok)
                    {
                        propertyInfo.SetValue(view, (Color)value);
                    }
                    ;
                }
                else if (type.Equals(typeof(PropertyMap)))
                {
                    PropertyMap map = new PropertyMap();
                    ok = propValue.Get(map);
                    if (ok)
                    {
                        propertyInfo.SetValue(view, map);
                    }
                }
                else if (type.Equals(typeof(PropertyArray)))
                {
                    PropertyArray array = new PropertyArray();
                    ok = propValue.Get(array);
                    if (ok)
                    {
                        propertyInfo.SetValue(view, array);
                    }
                }
                else
                {
                    throw new global::System.InvalidOperationException("SetPropertyValue Unimplemented type for Property Value for " + type.FullName);
                }
                if (!ok)
                {
                    throw new global::System.InvalidOperationException("SetPropertyValue propValue.Get failed");
                }
            }
            else
            {
                throw new global::System.InvalidOperationException("failed to find the control to write a property to: cptr = " + refObjectPtr);
            }
        }