Example #1
0
        static int add(int L)
        {
            if (!LuaCommon.CheckAndShowArgsError(L, LConst.UserData, LConst.UserData))
            {
                return(0);
            }

            object obj  = Lua.Lua_touserdata(L, 2);
            object view = Lua.Lua_touserdata(L, 3);

            if (obj == null || view == null)
            {
                return(0);
            }

            if (obj is FrameAnimationInfo)
            {
                var fe = LuaTransition.GetRYTControlView(view);
                (obj as FrameAnimationInfo).SetTargetControl(fe);
            }
            else if (obj != null && obj is Storyboard && view != null && view is FrameworkElement)
            {
                var sb = obj as Storyboard;
                var fe = view as FrameworkElement;
                foreach (var timeline in sb.Children)
                {
                    Storyboard.SetTarget(timeline, fe.RenderTransform);
                }
            }

            return(0);
        }
Example #2
0
        static int getStyleByName(int L)
        {
            if (!LuaCommon.CheckAndShowArgsError(L, LConst.String))
            {
                Lua.Lua_pushnil(L);
                return(1);
            }

            Object    tag      = (Object)Lua.Lua_touserdata(L, 1);
            String    arrtName = Lua.Lua_tostring(L, 2).ToString();
            Object    style    = null;
            FieldInfo tagCss   = tag.GetType().GetField("CurrentCSSStyle_");

            if (tagCss != null)
            {
                style = tagCss.GetValue(tag);
                if (style != null)
                {
                    MethodInfo methods = style.GetType().GetMethod("getStyleByName");
                    Object[]   pars    = new Object[] { arrtName };
                    var        obj     = methods.Invoke(style, pars);
                    if (obj != null)
                    {
                        Lua.Lua_pushstring(L, obj.ToString());
                        return(1);
                    }
                }
            }

            var fe  = LuaTransition.GetRYTControlView(tag);
            var str = GetDefaultStyle(fe, arrtName);

            Lua.Lua_pushstring(L, str);

            return(1);
        }
Example #3
0
        static int setMatrix(int L)
        {
            if (!LuaCommon.CheckAndShowArgsError(L, LConst.Table))
            {
                return(0);
            }

            Object tag     = (Object)Lua.Lua_touserdata(L, 1);
            bool   isTable = Lua.Lua_istable(L, -1);

            if (isTable && tag != null)
            {
                var fe = LuaTransition.GetRYTControlView(tag);
                CompositeTransform tranF = fe.RenderTransform as CompositeTransform;
                if (tranF == null)
                {
                    fe.RenderTransform = tranF = new CompositeTransform();
                }
                tranF.CenterX = fe.Width / 2;
                tranF.CenterY = fe.Height / 2;

                Matrix mValue = new Matrix();
                Dictionary <String, String> dic = new Dictionary <string, string>();
                Lua.Lua_pushnil(L);
                while (Lua.Lua_next(L, -2) != 0)
                {
                    String value = Lua.Lua_tostring(L, -1).ToString();
                    String key   = Lua.Lua_tostring(L, -2).ToString();
                    dic[key] = value;
                    Lua.Lua_pop(L, 1);

                    if (key.Equals("m11", StringComparison.CurrentCultureIgnoreCase))
                    {
                        mValue.M11   = double.Parse(value);
                        tranF.ScaleX = mValue.M11;
                    }
                    else if (key.Equals("m12", StringComparison.CurrentCultureIgnoreCase))
                    {
                        mValue.M12  = double.Parse(value);
                        tranF.SkewY = LuaManager.ConvertDegreesToRadians(Math.Atan(mValue.M12));
                    }
                    else if (key.Equals("m21", StringComparison.CurrentCultureIgnoreCase))
                    {
                        mValue.M21  = double.Parse(value);
                        tranF.SkewX = LuaManager.ConvertDegreesToRadians(Math.Atan(mValue.M21));
                    }
                    else if (key.Equals("m22", StringComparison.CurrentCultureIgnoreCase))
                    {
                        mValue.M22   = double.Parse(value);
                        tranF.ScaleY = mValue.M22;
                    }
                    else if (key.Equals("m31", StringComparison.CurrentCultureIgnoreCase))
                    {
                        mValue.OffsetX   = double.Parse(value);
                        tranF.TranslateX = mValue.OffsetX * LuaManager.WidthScale;
                    }
                    else if (key.Equals("m32", StringComparison.CurrentCultureIgnoreCase))
                    {
                        mValue.OffsetY   = double.Parse(value);
                        tranF.TranslateY = mValue.OffsetY * LuaManager.HeightScale;
                    }
                }

                MethodInfo methods = tag.GetType().GetMethod("SetMatrix");
                methods.Invoke(tag, new object[] { mValue });
            }

            return(0);
        }