/// <summary>
        /// 初始化
        /// </summary>
        public void Initialize(LuaEnv lua)
        {
            _onLoadAssetCompleted = lua.Global.GetInPath <OnLoadAssetCompletedDelegate>("AssetService.OnCsLoadAssetCompleted");
            _onChangeUIState      = lua.Global.GetInPath <OnChangeUIStateDelegate>("MVCService.OnCsChangeUIState");

            _onNativeCallBack = lua.Global.GetInPath <NativeServiceBaseDelegate>("NativeService.OnCommonCallback");

            _appEnterBackGroundCallBack = lua.Global.GetInPath <System.Action>("AppMoniter.OnCSAppEnterBackGround");
            _appEnterForeGroundCallBack = lua.Global.GetInPath <System.Action>("AppMoniter.OnCSAppEnterForeGround");

            //
            _arcadeInputOkCallBack      = lua.Global.GetInPath <ArcadeInputPressDelegate>("ArcadeInputService.OnCsOkInput");
            _arcadeInputRefreshCallBack = lua.Global.GetInPath <ArcadeInputRefreshDelegate>("ArcadeInputService.OnCsRefreshInput");
            _arcadeInputRotateCallBack  = lua.Global.GetInPath <ArcadeInputRotateDelegate>("ArcadeInputService.OnCsRotateInput");
            _arcadeInputRockerCallBack  = lua.Global.GetInPath <ArcadeInputRockerDelegate>("ArcadeInputService.OnCsRockerInput");
            //
            _gcCallBack = lua.Global.GetInPath <System.Action <bool> >("GCService.CollectGarbage");

            //挂接
            UIStateService.GetInstance().Hook    = this.ChangeUIState;
            AssetService.GetInstance().LuaGCHook = this.OnAssetServiceGC;
            //
            NativeService.GetInstance().RegisterBaseHandler(OnNativeBaseCallBackHook);
            //硬件输入
            ArcadeInputService.GetInstance().RockerHandler  = this.DealArcadeInputRockerInput;
            ArcadeInputService.GetInstance().RotateHandler  = this.DealArcadeInputRotateInput;
            ArcadeInputService.GetInstance().RefreshHandler = this.DealArcadeInputRefreshInput;
            ArcadeInputService.GetInstance().PressHandler   = this.DealArcadeInputOkInput;
            //
            _uiEventBridge = new LuaUIEventBridge();
            _uiEventBridge.Initialize(lua);
        }
        public async Task <ICharacteristic> GetCharacteristic(Guid charac)
        {
            var result = await NativeService.GetCharacteristicsForUuidAsync(charac);

            if (result.Characteristics.Count <= 0)
            {
                throw new Comms.Exceptions.ConnectException(new Exception($"Characteristic not found: {charac}"));
            }
            return(new Characteristic(result.Characteristics.First()));
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            nativeService = new NativeService();
            procHook      = (nCode, wParam, lParam) =>
            {
                if (nCode >= 0 && wParam == (IntPtr)WMType.KEYDOWN)
                {
                    int vkCode = Marshal.ReadInt32(lParam);
                    if (
                        (System.Windows.Forms.Keys)vkCode == System.Windows.Forms.Keys.VolumeDown ||
                        (System.Windows.Forms.Keys)vkCode == System.Windows.Forms.Keys.VolumeUp
                        )
                    {
                        if (this.WindowState == WindowState.Maximized)
                        {
                            this.WindowState = WindowState.Minimized;
                            this.Topmost     = false;
                        }
                        else
                        {
                            this.WindowState = WindowState.Maximized;
                            this.Topmost     = true;
                        }

                        return(new IntPtr(1));
                    }
                }

                if (this.WindowState == WindowState.Maximized)
                {
                    if (nCode >= 0 &&
                        (
                            wParam == (IntPtr)WMType.LBUTTONDOWN ||
                            wParam == (IntPtr)WMType.LBUTTONUP ||
                            wParam == (IntPtr)WMType.MOUSEHOVER ||
                            wParam == (IntPtr)WMType.MOUSEMOVE ||
                            wParam == (IntPtr)WMType.MOUSEACTIVATE ||
                            wParam == (IntPtr)WMType.MOUSELEAVE
                        ))
                    {
                        return(new IntPtr(1));
                    }
                }

                return(NativeAPIs.CallNextHookEx(handleKeyboardHook, nCode, wParam, lParam));
            };
            handleKeyboardHook = nativeService.SetHook(HookType.WH_KEYBOARD_LL, procHook);
            handleMouseHook    = nativeService.SetHook(HookType.WH_MOUSE_LL, procHook);

            nativeService.SuppressStandby();
        }
Exemple #4
0
    //网络检查
    private void DoNetworkCheck()
    {
        if (NativeService.GetInstance().GetIsNetEnable())
        {
            JW.Common.Log.LogD("Net OK");
            _isNetCheck = false;
            ScheduleService.GetInstance().RemoveFrame(this);
            //版本检查
#if UNITY_EDITOR
            DoMainResCheck();
#else
            DoForceVersionCheck();
#endif
        }
        else
        {
            JW.Common.Log.LogD("Net Not Ok");
            if (_isNetCheck == false)
            {
                _isNetCheck         = true;
                _stateArg.Progress  = 0f;
                _stateArg.StateInfo = "...等待检查网络...";
                JW.Framework.UGUI.UICommonService.GetInstance().ShowBubble("当前无网络等待!");
                EventService.GetInstance().SendEvent((uint)EventId.UpdateStateChange, _stateArg);
            }
            _netCheckCnt--;
            if (_netCheckCnt <= 0)
            {
                _stateArg.Progress  = 0f;
                _stateArg.StateInfo = "...网络检查失败即将重启设备...";
                EventService.GetInstance().SendEvent((uint)EventId.UpdateStateChange, _stateArg);
                ScheduleService.GetInstance().RemoveFrame(this);
                ScheduleService.GetInstance().AddTimer(2000, false, this);
            }
            else
            {
                ScheduleService.GetInstance().RemoveFrame(this);
                _netCheckSId = ScheduleService.GetInstance().AddFrame(60, false, this);
            }
        }
    }
Exemple #5
0
 /// <summary>
 /// 初始化框架层
 /// </summary>
 /// <param name="initialize">初始化/反初始化</param>
 public static void InitFramework(bool initialize)
 {
     if (initialize)
     {
         NativeService.GetInstance();
         IFSService.GetInstance();
         AssetService.GetInstance();
         ScheduleService.GetInstance();
         EventService.GetInstance();
         StateService.GetInstance();
         HttpService.GetInstance();
         UGUIRoot.GetInstance();
         UIStateService.GetInstance();
         SceneService.GetInstance();
         UICommonService.GetInstance();
         AudioService.GetInstance();
         QualityService.GetInstance();
         NetworkService.GetInstance();
         NetAssetService.GetInstance();
     }
     else
     {
         IFSService.DestroyInstance();
         EventService.DestroyInstance();
         StateService.DestroyInstance();
         HttpService.DestroyInstance();
         UIStateService.DestroyInstance();
         SceneService.DestroyInstance();
         UICommonService.DestroyInstance();
         UGUIRoot.DestroyInstance();
         AudioService.DestroyInstance();
         NetworkService.DestroyInstance();
         NativeService.DestroyInstance();
         NetAssetService.DestroyInstance();
         QualityService.DestroyInstance();
         //最后
         ScheduleService.DestroyInstance();
         AssetService.GetInstance().Destroy();
         AssetService.DestroyInstance();
     }
 }
Exemple #6
0
    //网络检查时钟 重启时钟
    public void OnScheduleHandle(ScheduleType type, uint id)
    {
        if (type == ScheduleType.Frame)
        {
            if (id == _netCheckSId)
            {
                DoNetworkCheck();
                return;
            }
            if (id == _versionCheckSId)
            {
                DoForceVersionCheck();
                return;
            }
        }
        //重启时钟
        if (type == ScheduleType.Timer)
        {
#if !UNITY_EDITOR
            NativeService.GetInstance().RebootDevice();
#endif
            return;
        }
    }
 public static NativeService GetNativeService()
 {
     return(NativeService.GetInstance());
 }
 public async Task <Interfaces.ICharacteristic> GetCharacteristic(Guid charac)
 {
     return(new Characteristic(await NativeService.GetCharacteristicAsync(charac)));
 }
Exemple #9
0
        public async Task <ICharacteristic> GetCharacteristic(Guid charac)
        {
            var result = await NativeService.GetCharacteristicsForUuidAsync(charac);

            return(new Characteristic(result.Characteristics.First()));
        }