Beispiel #1
0
        /// <summary>
        /// offline:downfile(src, callback)
        /// 表示当前资源的地址(EWP返回给客户端的描述信息中的“path”字段)
        /// </summary>
        /// <param name="lua">callback(optional) Function. 监听方法。此监听方法在定义时必须有一个参数,类型为Boolean, 表示当前离线资源是否下载成功。</param>
        /// <returns></returns>
        static int downfile(int L)
        {
            if (!LuaCommon.CheckAndShowArgsError(L, LConst.String, LConst.String, LConst.Function))
            {
                return(0);
            }

            var fileName    = Lua.Lua_tostring(L, 2);
            var relatedPath = Lua.Lua_tostring(L, 3);
            int callbackF   = Lua.LuaL_ref(L, Lua._LUA_REGISTRYINDEX);

            Action <bool> action = null;

            if (callbackF != -1)
            {
                action = (result) =>
                {
                    LuaManager.GetLuaManager(L).ExecuteCallBackFunctionWithParam(callbackF, result);
                };
            }

            MethodInfo mi = LuaManager.GetLuaManager(L).DetailV_.GetType().GetMethod("OfflineDownloadFile", new Type[] { typeof(string), typeof(string), typeof(Action <bool>) });

            if (mi != null)
            {
                mi.Invoke(LuaManager.GetLuaManager(L).DetailV_, new object[] { fileName, relatedPath, action });
            }

            return(0);
        }
Beispiel #2
0
        static int stop(int L)
        {
            if (!LuaCommon.CheckAndShowArgsError(L, LConst.UserData))
            {
                return(0);
            }

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

            if (obj != null)
            {
                if (obj is Storyboard)
                {
                    var sb = obj as Storyboard;
                    sb.Stop();
                }
                else if (obj is FrameAnimationInfo)
                {
                    var fInfo = obj as FrameAnimationInfo;
                    fInfo.Stop(L);
                }
            }

            return(0);
        }
        static int setListener(int L)
        {
            if (!LuaCommon.CheckAndShowArgsError(L, LConst.Function))
            {
                return(0);
            }

            int callbackF = Lua.LuaL_ref(L, Lua._LUA_REGISTRYINDEX);

            //if (RYTAccelerometer == null)
            //{
            //    RYTAccelerometer = new RYTAccelerometer();
            //}

            Action <Vector3> action = (vector) =>
            {
                Dictionary <String, object> dict = new Dictionary <string, object>();
                dict.Add("accelerometerX", vector.X);
                dict.Add("accelerometerY", vector.Y);
                dict.Add("accelerometerZ", vector.Z);

                LuaManager.GetLuaManager(L).ExecuteCallBackFunctionWithTableParam(callbackF, dict);
            };

            RYTAccelerometer.SetLisenter(action);

            return(0);
        }
Beispiel #4
0
        private static int getElementById(int L)
        {
            if (!LuaCommon.CheckAndShowArgsError(L, LConst.String))
            {
                return(0);
            }
            String id = Lua.Lua_tostring(L, 2).ToString();

            Lua.Lua_pop(L, 2);
            object page = LuaManager.GetLuaManager(L).DetailV_;

            if (string.IsNullOrEmpty(id) || page == null)
            {
                Lua.Lua_pushnil(L);
            }
            else
            {
                MethodInfo methods      = page.GetType().GetMethod("getElementById");
                Object[]   pars         = new Object[] { id };
                var        invokeResult = methods.Invoke(page, pars);
                if (invokeResult != null)
                {
                    Lua.Lua_pushlightuserdata(L, invokeResult);
                    Lua.LuaL_getmetatable(L, "elementFunction");
                    Lua.Lua_setmetatable(L, -2);
                }
                else
                {
                    return(0);
                }
            }
            return(1);
        }
Beispiel #5
0
        static int setDuration(int L)
        {
            if (!LuaCommon.CheckAndShowArgsError(L, LConst.UserData, LConst.Number))
            {
                return(0);
            }

            object obj     = Lua.Lua_touserdata(L, 2);
            var    seconds = Lua.Lua_tonumber(L, 3);

            if (obj is FrameAnimationInfo)
            {
                (obj as FrameAnimationInfo).SetDuration(seconds);
            }
            else if (obj != null && obj is Storyboard)
            {
                var sb = obj as Storyboard;
                //sb.Duration = TimeSpan.FromSeconds(seconds);
                foreach (var timeline in sb.Children)
                {
                    (timeline as DoubleAnimation).Duration = TimeSpan.FromSeconds(seconds);
                }
            }

            //Lua.Lua_pushlightuserdata(L, obj);

            return(0);
        }
Beispiel #6
0
        static int open(int L)
        {
            if (!LuaCommon.CheckAndShowArgsError(L, LConst.Function))
            {
                return(0);
            }

            int callbackF = Lua.LuaL_ref(L, Lua._LUA_REGISTRYINDEX);

            if (callbackF == -1)
            {
                return(0);
            }

            Action <string> succeedAction = (result) =>
            {
                LuaManager.GetLuaManager(L).ExecuteCallBackFunctionWithParam(callbackF, result);
            };
            Action <string> failedAction = (result) =>
            {
                LuaManager.GetLuaManager(L).ExecuteCallBackFunctionWithParam(callbackF, null);
            };

            FunctionLib.RYTCamera.Open(succeedAction, failedAction);

            return(0);
        }
Beispiel #7
0
        static int setListener(int L)
        {
            if (!LuaCommon.CheckAndShowArgsError(L, LConst.UserData, LConst.Function))
            {
                return(1);
            }

            Geolocator watcher = (Geolocator)Lua.Lua_touserdata(L, 2);

            if (watcher != null)
            {
                try
                {
                    if (_GeoChangedRegistry == null)
                    {
                        _GeoChangedRegistry = new List <KeyValuePair <Geolocator, int> >();
                    }

                    int callbackF = Lua.LuaL_ref(L, Lua._LUA_REGISTRYINDEX);
                    if (!_GeoChangedRegistry.Any(k => k.Key.Equals(watcher)))
                    {
                        watcher.PositionChanged += GeoChangedCallback4Lua;
                    }
                    _GeoChangedRegistry.Add(new KeyValuePair <Geolocator, int>(watcher, callbackF));

                    //watcher.Start();
                }
                catch
                {
                    LuaCommon.ShowError(null, "setListener failed @gps", "GPS");
                }
            }

            return(1);
        }
Beispiel #8
0
        /// <summary>
        ///  history:clear(N); 是指删除最后第N个添加到history的页面(N>0)
        /// </summary>
        /// <param name="lua"></param>
        /// <returns></returns>
        static int clear(int L)
        {
            if (!LuaCommon.CheckAndShowArgsError(L, LConst.NNumber))
            {
                return(0);
            }
            List <string> historyHtml = LuaManager.GetLuaManager(L).HistoryHtml;
            int           index       = -1;
            var           count       = Lua.Lua_gettop(L);

            if (count == 2 && !Lua.Lua_isnil(L, 2))
            {
                index = (int)Lua.Lua_tonumber(L, 2);
            }
            if (index > 0 && historyHtml.Count >= index)
            {
                historyHtml.RemoveRange(historyHtml.Count - index, index);
            }
            else
            {
                historyHtml.Clear();
            }
            //var mi = LuaManager.GetLuaManager(L).DetailV_.GetType().GetMethod("Clear");
            //if (mi != null)
            //{
            //    mi.Invoke(LuaManager.GetLuaManager(L).DetailV_, new object[] { index });
            //}
            return(0);
        }
Beispiel #9
0
        static int setSwipeListener(int L)
        {
            if (!LuaCommon.CheckAndShowArgsError(L, LConst.UserData, LConst.Function))
            {
                return(0);
            }

            Object control   = Lua.Lua_touserdata(L, 2);
            int    callbackF = Lua.LuaL_ref(L, Lua._LUA_REGISTRYINDEX);

            if (control != null && callbackF != 0)
            {
                var pi = control.GetType().GetProperty("View_");
                var fe = pi.GetValue(control, null);

                if (EventsList.Any(c => (c.FE == fe as FrameworkElement) && c.EventsName.Equals("setSwipeListener")))
                {
                    ClearLastUselessEvents(fe as FrameworkElement, "setSwipeListener");
                }

                var lisenter = GestureService.GetGestureListener(fe as FrameworkElement);
                EventHandler <Microsoft.Phone.Controls.FlickGestureEventArgs> FlickGestureHandler = null;
                lisenter.Flick += FlickGestureHandler = (s, e) =>
                {
                    Dictionary <string, object> dict = new Dictionary <string, object>();
                    string value = string.Empty;
                    if (e.Direction == Orientation.Horizontal)
                    {
                        if (e.HorizontalVelocity > 0)
                        {
                            value = "right";
                        }
                        else
                        {
                            value = "left";
                        }
                    }
                    else if (e.Direction == Orientation.Vertical)
                    {
                        if (e.VerticalVelocity > 0)
                        {
                            value = "down";
                        }
                        else
                        {
                            value = "up";
                        }
                    }
                    dict.Add("direction", value);

                    LuaManager.GetLuaManager(L).ExecuteCallBackFunctionWithAnyParams(callbackF, dict, control);
                };

                EventsList.Add(new GestureEventRegisterInfo()
                {
                    FE = fe as FrameworkElement, EventsName = "setSwipeListener", FlickGestureEventHandler = FlickGestureHandler
                });
            }
            return(0);
        }
Beispiel #10
0
        static int base64Decode(int L)
        {
            if (!LuaCommon.CheckAndShowArgsError(L, LConst.String))
            {
                Lua.Lua_pushnil(L);
                return(1);
            }

            string str = Lua.Lua_tostring(L, 2);

            if (!string.IsNullOrEmpty(str))
            {
                try
                {
                    var bytes = Convert.FromBase64String(str);
                    var r     = System.Text.UTF8Encoding.UTF8.GetString(bytes, 0, bytes.Length);

                    Lua.Lua_pushstring(L, r);
                }
                catch
                {
                    Debug.WriteLine("base64Decode error.");
                    Lua.Lua_pushstring(L, string.Empty);
                }
            }
            else
            {
                Lua.Lua_pushstring(L, string.Empty);
            }

            return(1);
        }
Beispiel #11
0
        static int stopTimer(int L)
        {
            if (!LuaCommon.CheckAndShowArgsError(L, LConst.UserData))
            {
                Lua.Lua_pushnil(L);
                return(1);
            }
            try
            {
                if (Lua.Lua_islightuserdata(L, 2))
                {
                    DispatcherTimer timer = (DispatcherTimer)Lua.Lua_touserdata(L, 2);
                    if (timer != null)
                    {
                        timer.Stop();
                    }
                }
            }
            catch
            {
                Debug.WriteLine("stopTimer error ..");
            }

            return(1);
        }
Beispiel #12
0
        /// <summary>
        ///	发起离线资源的升级、下载、删除功能。
        /// </summary>
        static int download(int L)
        {
            if (!LuaCommon.CheckAndShowArgsError(L, LConst.Function))
            {
                return(0);
            }

            int callbackF = Lua.LuaL_ref(L, Lua._LUA_REGISTRYINDEX);

            Action <string, string> action = null;

            if (callbackF != -1)
            {
                action = (result, mustUpdate) =>
                {
                    LuaManager.GetLuaManager(L).ExecuteCallBackFunctionWithAnyParams(callbackF, result, mustUpdate);
                };
            }

            MethodInfo mi = LuaManager.GetLuaManager(L).DetailV_.GetType().GetMethod("OfflineDownload", new Type[] { typeof(Action <string, string>) });

            if (mi != null)
            {
                mi.Invoke(LuaManager.GetLuaManager(L).DetailV_, new object[] { action });
            }

            return(0);
        }
Beispiel #13
0
        private static int commentOfFile(int L)
        {
            if (!LuaCommon.CheckAndShowArgsError(L, LConst.String, LConst.NString))
            {
                Lua.Lua_pushnil(L);
                return(1);
            }

            var    fileName = Lua.Lua_tostring(L, 2);
            string appName  = "";

            if (Lua.Lua_gettop(L) == 3)
            {
                appName = Lua.Lua_tostring(L, 3);
            }
            MethodInfo mi = LuaManager.GetLuaManager(L).DetailV_.GetType().GetMethod("GetCommentOfFile", new Type[] { typeof(string), typeof(string) });

            if (mi != null)
            {
                string result = (string)mi.Invoke(LuaManager.GetLuaManager(L).DetailV_, new object[] { fileName, appName });
                if (!string.IsNullOrEmpty(result))
                {
                    Lua.Lua_pushstring(L, result);
                }
                else
                {
                    Lua.Lua_pushnil(L);
                }
            }
            else
            {
                Lua.Lua_pushnil(L);
            }
            return(1);
        }
Beispiel #14
0
        private static int getOptInfoInLocal(int L)
        {
            if (!LuaCommon.CheckAndShowArgsError(L, LConst.NString))
            {
                return(0);
            }

            string appName = "";

            if (Lua.Lua_gettop(L) == 2)
            {
                appName = Lua.Lua_tostring(L, -1);
            }
            Dictionary <string, string> result_Dictionary = new Dictionary <string, string>();
            MethodInfo mi = LuaManager.GetLuaManager(L).DetailV_.GetType().GetMethod("GetOptInfoInLocal", new Type[] { typeof(string) });

            if (mi != null)
            {
                result_Dictionary = (Dictionary <string, string>)mi.Invoke(LuaManager.GetLuaManager(L).DetailV_, new object[] { appName });
            }

            Lua.Lua_newtable(L);
            foreach (var item in result_Dictionary)
            {
                Lua.Lua_pushstring(L, item.Key);
                Lua.Lua_pushstring(L, item.Value);
                Lua.Lua_rawset(L, -3);
            }
            return(1);
        }
Beispiel #15
0
        static int logError(int L)
        {
            if (!LuaCommon.CheckAndShowArgsError(L, LConst.String, LConst.String, LConst.Integer))
            {
                return(0);
            }

            string name       = Lua.Lua_tostring(L, 2).ToString();
            string message    = string.Empty;
            int    lineNumber = 0;

            if (Lua.Lua_gettop(L) > 2)
            {
                message = Lua.Lua_tostring(L, 3).ToString();
            }
            if (Lua.Lua_gettop(L) > 3)
            {
                lineNumber = Lua.Lua_tointeger(L, 4);
            }
            //RYTTrackInstanse.AddTask(() => { RYTTrackInstanse.LogError(name, message, lineNumber); });
            System.Reflection.MethodInfo AddTask_MethodInfo = TrackType.GetMethod("AddTask");
            Action LogError_Action = delegate() { TrackType.GetMethod("LogError").Invoke(RYTTrackInstanse, new object[] { name, message, lineNumber }); };

            AddTask_MethodInfo.Invoke(RYTTrackInstanse, new object[] { LogError_Action });
            return(0);
        }
Beispiel #16
0
        static int setStyleByName(int L)
        {
            if (!LuaCommon.CheckAndShowArgsError(L, LConst.String, LConst.String))
            {
                return(0);
            }

            Object    tag       = (Object)Lua.Lua_touserdata(L, 1);
            String    attriName = Lua.Lua_tostring(L, 2).ToString();
            String    value     = Lua.Lua_tostring(L, 3).ToString();
            Object    style     = null;
            FieldInfo fi        = tag.GetType().GetField("CurrentCSSStyle_");

            if (fi != null)
            {
                style = fi.GetValue(tag);
                if (style != null)
                {
                    MethodInfo methods = style.GetType().GetMethod("setStyleByName");
                    Object[]   pars    = new Object[] { attriName, value };
                    methods.Invoke(style, pars);
                }
                else
                {
                    MessageBox.Show("setStyleByName: 当前控件没有应用样式,无法设置样式");
                }
            }

            return(0);
        }
Beispiel #17
0
        static int logPurchase(int L)
        {
            if (!LuaCommon.CheckAndShowArgsError(L, LConst.String, LConst.Number, LConst.NString, LConst.NTable))
            {
                return(0);
            }

            string name     = Lua.Lua_tostring(L, 2).ToString();
            double cost     = Lua.Lua_tonumber(L, 3);
            string currency = string.Empty;
            List <KeyValuePair <string, string> > parameters = null;

            if (Lua.Lua_gettop(L) > 3)
            {
                currency = Lua.Lua_tostring(L, 4).ToString();
            }
            if (Lua.Lua_gettop(L) > 4)
            {
                parameters = ParseTableToList(L, 5);
            }
            //RYTTrackInstanse.AddTask(() => { RYTTrackInstanse.LogPurchase(name, cost, currency, parameters); });
            System.Reflection.MethodInfo AddTask_MethodInfo = TrackType.GetMethod("AddTask");
            Action LogPurchase_Action = delegate() { TrackType.GetMethod("LogPurchase").Invoke(RYTTrackInstanse, new object[] { name, cost, currency, parameters }); };

            AddTask_MethodInfo.Invoke(RYTTrackInstanse, new object[] { LogPurchase_Action });
            return(0);
        }
Beispiel #18
0
        static int appendChild(int L)
        {
            if (!LuaCommon.CheckAndShowArgsError(L, LConst.UserData))
            {
                return(0);
            }

            Object control = Lua.Lua_touserdata(L, 1);
            Object child   = Lua.Lua_touserdata(L, 2);

            bool bSucceed = false;

            if (child != null)
            {
                MethodInfo method = control.GetType().GetMethod("appendChild");
                if (method != null)
                {
                    var result = method.Invoke(control, new object[] { child });
                    bSucceed = (bool)result;
                }
            }

            Lua.Lua_pushboolean(L, bSucceed ? 1 : 0);
            return(1);
        }
Beispiel #19
0
        static int objectFromJSON(int L)
        {
            if (!LuaCommon.CheckAndShowArgsError(L, LConst.String))
            {
                Lua.Lua_pushnil(L);
                return(1);
            }

            String jsonStr = Lua.Lua_tostring(L, 2);

            try
            {
                JObject jo = JObject.Parse(jsonStr);
                parseJsonToTable(L, jo);

                return(1);
            }
            catch (Exception e)
            {
                if (LuaManager.ExceptionHandleAction != null)
                {
                    string message = string.Format("{0}\n↘\n{1}", e.Message, jsonStr);
                    LuaManager.ExceptionHandleAction(null, message, LogLib.RYTLog.Const.JsonError);
                }
                Lua.Lua_pushnil(L);
                return(1);
            }
        }
Beispiel #20
0
        static int insertBefore(int L)
        {
            if (!LuaCommon.CheckAndShowArgsError(L, LConst.UserData, LConst.NUserData))
            {
                return(0);
            }

            object control     = Lua.Lua_touserdata(L, 1);
            object child       = Lua.Lua_touserdata(L, 2);
            object flagControl = null;

            if (Lua.Lua_isuserdata(L, 3))
            {
                flagControl = Lua.Lua_touserdata(L, 3);
            }

            bool bSucceed = false;

            if (control != null && child != null)
            {
                MethodInfo method = control.GetType().GetMethod("insertBefore");
                if (method != null)
                {
                    var r = method.Invoke(control, new object[] { child, flagControl });
                    bSucceed = (bool)r;
                }
            }

            Lua.Lua_pushboolean(L, bSucceed ? 1 : 0);
            return(1);
        }
Beispiel #21
0
        static int getElementsByClassName(int L)
        {
            if (!LuaCommon.CheckAndShowArgsError(L, LConst.String))
            {
                return(0);
            }
            String name = Lua.Lua_tostring(L, 2).ToString();

            Lua.Lua_pop(L, 2);
            object page = LuaManager.GetLuaManager(L).DetailV_;

            if (string.IsNullOrEmpty(name) || page == null)
            {
                Lua.Lua_newtable(L);
            }
            else
            {
                MethodInfo methods      = page.GetType().GetMethod("getElementsByClassName");
                Object[]   pars         = new Object[] { name };
                var        invokeResult = methods.Invoke(page, pars);
                var        list         = invokeResult as IList;
                Lua.Lua_newtable(L);
                for (int i = 0; i < list.Count; i++)
                {
                    Lua.Lua_pushnumber(L, i + 1);
                    Lua.Lua_pushlightuserdata(L, list[i]);
                    Lua.LuaL_getmetatable(L, "elementFunction");
                    Lua.Lua_setmetatable(L, -2);
                    Lua.Lua_rawset(L, -3);
                }
            }
            return(1);
        }
Beispiel #22
0
        static int setOnChangeListener(int L)
        {
            if (!LuaCommon.CheckAndShowArgsError(L, LConst.Function))
            {
                return(0);
            }

            Object tag = (Object)Lua.Lua_touserdata(L, 1);
            Action <object, string, string> callbackAction = null;
            int callbackF = Lua.LuaL_ref(L, Lua._LUA_REGISTRYINDEX);

            if (callbackF == 0)
            {
                return(0);
            }
            callbackAction = (control, name, value) =>
            {
                LuaManager.GetLuaManager(L).ExecuteCallBackFunctionWithAnyParamsSync(callbackF, control, name, value);
            };
            if (tag != null)
            {
                MethodInfo method = tag.GetType().GetMethod("setOnChangeListener");
                if (method != null)
                {
                    method.Invoke(tag, new object[] { callbackAction, tag });
                }
            }
            return(0);
        }
Beispiel #23
0
        static int getEventElementsByListener(int L)
        {
            if (!LuaCommon.CheckAndShowArgsError(L, LConst.String))
            {
                return(0);
            }
            String listener = Lua.Lua_tostring(L, 2);

            Lua.Lua_pop(L, 2);
            object page = LuaManager.GetLuaManager(L).DetailV_;

            if (string.IsNullOrEmpty(listener) || page == null)
            {
                return(0);
            }
            MethodInfo methods      = page.GetType().GetMethod("getEventElementsByListener");
            var        invokeResult = methods.Invoke(page, new object[] { listener });
            var        list         = invokeResult as IList;

            Lua.Lua_newtable(L);
            for (int i = 0; i < list.Count; i++)
            {
                Lua.Lua_pushnumber(L, i);
                Lua.Lua_pushlightuserdata(L, list[i]);
                Lua.LuaL_getmetatable(L, "elementFunction");
                Lua.Lua_setmetatable(L, -2);
                Lua.Lua_rawset(L, -3);
            }
            return(1);
        }
Beispiel #24
0
        static int getAttribute(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();

            var value = RYTKeyMapping.Instance.DoReflection(arrtName, tag, null, ReflectionType.Get);

            if (value != null)
            {
                Lua.Lua_pushstring(L, value.ToString());
                return(1);
            }
            else
            {
                Lua.Lua_pushstring(L, string.Empty);
                //MessageBox.Show(string.Format("未在Control:[{0}]上取到属性为:[{1}]的值", tag.ToString(), arrtName),"LuaElement:getAttribute()", MessageBoxButton.OK);
            }


            return(1);
        }
Beispiel #25
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);
        }
Beispiel #26
0
        static int setLocation(int L)
        {
            if (!LuaCommon.CheckAndShowArgsError(L, LConst.NNumber, LConst.NNumber, LConst.NNumber))
            {
                return(0);
            }

            double latitude  = double.NaN;
            double longitude = double.NaN;
            double accuracy  = double.NaN;

            if (Lua.Lua_gettop(L) > 2)
            {
                latitude  = Lua.Lua_tonumber(L, 2);
                longitude = Lua.Lua_tonumber(L, 3);
            }
            if (Lua.Lua_gettop(L) > 3)
            {
                Lua.Lua_tonumber(L, 4);
            }

            //RYTTrackInstanse.AddTask(() => { RYTTrackInstanse.SetLocation(latitude, longitude, accuracy); });
            System.Reflection.MethodInfo AddTask_MethodInfo = TrackType.GetMethod("AddTask");
            Action SetLocation_Action = delegate() { TrackType.GetMethod("SetLocation").Invoke(RYTTrackInstanse, new object[] { latitude, longitude, accuracy }); };

            AddTask_MethodInfo.Invoke(RYTTrackInstanse, new object[] { SetLocation_Action });
            return(0);
        }
Beispiel #27
0
        static int setStopListener(int L)
        {
            if (!LuaCommon.CheckAndShowArgsError(L, LConst.UserData, LConst.Function))
            {
                return(0);
            }

            object obj       = Lua.Lua_touserdata(L, 2);
            int    callbackF = Lua.LuaL_ref(L, Lua._LUA_REGISTRYINDEX);

            if (callbackF != 0)
            {
                if (obj is FrameAnimationInfo)
                {
                    (obj as FrameAnimationInfo).StopFunctionId = callbackF;
                }
                else if (obj is AnimationNewInfo)
                {
                    (obj as AnimationNewInfo).EndFunctionId = callbackF;
                }
                else
                {
                }
            }

            return(0);
        }
Beispiel #28
0
        static int logEvent(int L)
        {
            if (!LuaCommon.CheckAndShowArgsError(L, LConst.String, LConst.NTable, LConst.NBoolean))
            {
                return(0);
            }

            string eventName = Lua.Lua_tostring(L, 2).ToString();
            List <KeyValuePair <string, string> > eventParameters = null;
            bool isTimedEvent = false;

            if (Lua.Lua_gettop(L) > 2)
            {
                eventParameters = ParseTableToList(L, 3);
            }
            if (Lua.Lua_gettop(L) > 3)
            {
                if (Lua.Lua_toboolean(L, 4))
                {
                    isTimedEvent = true;
                }
            }
            //RYTTrackInstanse.AddTask(() => { RYTTrackInstanse.LogEvent(eventName, eventParameters, isTimedEvent); });
            System.Reflection.MethodInfo AddTask_MethodInfo = TrackType.GetMethod("AddTask");
            Action LogEvent_Action = delegate() { TrackType.GetMethod("LogEvent").Invoke(RYTTrackInstanse, new object[] { eventName, eventParameters, isTimedEvent }); };

            AddTask_MethodInfo.Invoke(RYTTrackInstanse, new object[] { LogEvent_Action });
            return(0);
        }
Beispiel #29
0
        static int openURL(int L)
        {
            if (!LuaCommon.CheckAndShowArgsError(L, LConst.String))
            {
                return(0);
            }

            if (Lua.Lua_isstring(L, 2))
            {
                String url = Lua.Lua_tostring(L, 2).ToString();
                if (url.StartsWith("tel:"))
                {
                    String number = url.Substring("tel:".Length);
                    RYTTasks.StartPhoneCallTask(string.Empty, number);
                }
                else if (url.StartsWith("mailto:"))
                {
                    String to = url.Substring("mailto:".Length);
                    RYTTasks.StartEmailTask(string.Empty, to);
                }
                else if (url.StartsWith("http://") || url.StartsWith("https://"))
                {
                    RYTTasks.StartWebBrowserTask(url);
                }
            }

            return(0);
        }
Beispiel #30
0
        static int play(int L)
        {
            if (!LuaCommon.CheckAndShowArgsError(L, LConst.UserData, LConst.Integer, LConst.NFuction))
            {
                return(0);
            }

            var callbackId    = Lua.LuaL_ref(L, Lua._LUA_REGISTRYINDEX);
            var objectParam   = Lua.Lua_touserdata(L, 2);
            int numberOfLoops = Lua.Lua_tointeger(L, 3);

            var info = Lua.Lua_touserdata(L, 2) as RYTAudioInfo;

            if (info != null)
            {
                Action playCompletedAction = () =>
                {
                    if (callbackId != -1)
                    {
                        LuaManager.GetLuaManager(L).ExecuteCallBackFunction(callbackId, info.LoopCurrentTimes == 0 ? true : false);
                    }
                };

                RYTAudio.Play(string.Empty, info, numberOfLoops, playCompletedAction);
            }

            return(0);
        }