public void SetFrame(RYTFrame value) { if (SB != null) { /* 奇怪的逻辑,被注销。by hu.pengtao * if (StopFunctionId != 0) * { * LuaManager.Instance.ExecuteCallBackFunctionWithParam(StopFunctionId,this);// * StopFunctionId = 0; * } */ SB.Stop(); SB.Children.Clear(); } Dispose(); Frame = value; img = new Image() { Height = value.Height, Width = value.Width }; img.VerticalAlignment = VerticalAlignment.Top; img.HorizontalAlignment = HorizontalAlignment.Left; img.Stretch = Stretch.Fill; img.Margin = new Thickness(value.Left, value.Top, 0, 0); }
/// <summary> /// 设置动画显示区域 /// animation:setFrame(object,frame) object:动画对象frame:为table类型,{x, y, width, height} /// </summary> /// <param name="lua"></param> /// <returns></returns> static int setFrame(int L) { if (!LuaCommon.CheckAndShowArgsError(L, LConst.UserData, LConst.Table)) { return(0); } RYTFrame frame = new RYTFrame(); Lua.Lua_pushnil(L); //int index = 0; while (Lua.Lua_next(L, -2) != 0) { var key = Lua.Lua_tostring(L, -2).ToString(); var value = Lua.Lua_tonumber(L, -1); Lua.Lua_pop(L, 1); if (key.Equals("x", StringComparison.CurrentCultureIgnoreCase)) { frame.Left = value * LuaManager.WidthScale; } else if (key.Equals("y", StringComparison.CurrentCultureIgnoreCase)) { frame.Top = value * LuaManager.HeightScale; } else if (key.Equals("width", StringComparison.CurrentCultureIgnoreCase)) { frame.Width = value * LuaManager.WidthScale; } else if (key.Equals("height", StringComparison.CurrentCultureIgnoreCase)) { frame.Height = value * LuaManager.HeightScale; } } object obj = Lua.Lua_touserdata(L, 2); if (obj is FrameAnimationInfo) { (obj as FrameAnimationInfo).SetFrame(frame); } else { } return(0); }
static int play(int L) { #region table Frame Size RYTFrame frame = null; // 特殊的参数判断 if (!LuaCommon.CheckAndShowArgsError(L, LConst.UserData, LConst.NFuction, LConst.NTable)) { return(0); } if (Lua.Lua_gettop(L) > 3 && Lua.Lua_istable(L, 4)) { frame = new RYTFrame(); Lua.Lua_pushnil(L); while (Lua.Lua_next(L, 4) != 0) { var key = Lua.Lua_tostring(L, -2).ToString(); var value = Lua.Lua_tonumber(L, -1); if (key.Equals("x", StringComparison.CurrentCultureIgnoreCase)) { frame.Left = value * LuaManager.WidthScale; } else if (key.Equals("y", StringComparison.CurrentCultureIgnoreCase)) { frame.Top = value * LuaManager.HeightScale; } else if (key.Equals("width", StringComparison.CurrentCultureIgnoreCase)) { frame.Width = value * LuaManager.WidthScale; } else if (key.Equals("height", StringComparison.CurrentCultureIgnoreCase)) { frame.Height = value * LuaManager.HeightScale; } Lua.Lua_pop(L, 1); } } #endregion var callbackId = -1; RYTVideoInfo info = null; int count = Lua.Lua_gettop(L); if (count == 2) { info = Lua.Lua_touserdata(L, 0) as RYTVideoInfo; } else { info = Lua.Lua_touserdata(L, 2) as RYTVideoInfo; callbackId = LuaManager.GetFunctionIDIndex(L); } // no loop now //int loop = Lua.Lua_tointeger(L, 3); bool bLoop = false; // = loop == 1 ? true : false; if (info != null) { Action action = () => { if (callbackId != -1) { LuaManager.GetLuaManager(L).ExecuteCallBackFunction(callbackId, false); } }; RYTVideo.Play(info, string.Empty, frame, bLoop, action); } return(0); }