Exemplo n.º 1
0
        public Task Run()
        {
            DeviceExtension e = new DeviceExtension
            {
                PendingIo     = 1,
                StoppingFlag  = false,
                StoppingEvent = false
            };

            this.Lock    = new Lock(1);
            this.Stopped = false;

            var mt = Task.Run(() =>
            {
                nekara.ContextSwitch();

                e.StoppingFlag = true;
                BCSP_IoDecrement(e);

                nekara.ContextSwitch();
                if (e.StoppingEvent)
                {
                    // Release allocated resource.
                    nekara.ContextSwitch();
                    this.Stopped = true;
                }
            });

            BCSP_PnpAdd(e);

            return(mt);
        }
Exemplo n.º 2
0
 public static IApp StartApp(Platform platform, string simulator, bool resetDevice = false)
 {
     Platform = platform;
     if (platform == Platform.Android)
     {
         if (resetDevice)
         {
             ResetAndroidEmulator();
         }
         return(ConfigureApp
                .Android
                .DeviceSerial(DeviceExtension.GetAndroidDevice(simulator))
                .InstalledApp(packageName)
                .StartApp());
     }
     try
     {
         if (resetDevice)
         {
             ResetiOSSimulator(simulator);
         }
         return(ConfigureApp
                .iOS
                .DeviceIdentifier(DeviceExtension.GetiOSDeviceID(simulator))
                .InstalledApp(packageName)
                .StartApp());
     }
     catch (Exception ex)
     {
         Console.WriteLine("********Error" + ex.Message);
         Console.WriteLine(ex.StackTrace);
         return(null);
     }
 }
Exemplo n.º 3
0
 private async void TapBackToDetailPage(object sender, System.EventArgs e)
 {
     await DeviceExtension.BeginInvokeOnMainThreadAsync(async() =>
     {
         await Navigation.PopPopupAsync();
     });
 }
Exemplo n.º 4
0
        public Task RunBluetoothDriver()
        {
            NekaraManagedClient nekara = RuntimeEnvironment.Client;

            DeviceExtension e = new DeviceExtension
            {
                PendingIo     = 1,
                StoppingFlag  = false,
                StoppingEvent = false
            };

            this.Lock    = new Lock(1);
            this.Stopped = false;

            var mt = Task.Run(() =>
            {
                nekara.Api.ContextSwitch();

                e.StoppingFlag = true;
                BCSP_IoDecrement(e);

                nekara.Api.ContextSwitch();
                if (e.StoppingEvent)
                {
                    // Release allocated resource.
                    nekara.Api.ContextSwitch();
                    this.Stopped = true;
                }
            });

            BCSP_PnpAdd(e);

            return(mt);
        }
Exemplo n.º 5
0
        public async Task <ConfirmPopup> Show(string title            = null, string message = null, string closeButtonText = null,
                                              ICommand closeCommand   = null, object closeCommandParameter = null,
                                              string acceptButtonText = null, ICommand acceptCommand       = null, object acceptCommandParameter = null,
                                              bool isAutoClose        = false, uint duration = 2000)
        {
            // Close Loading Popup if it is showing
            await LoadingPopup.Instance.Hide();

            await DeviceExtension.BeginInvokeOnMainThreadAsync(() =>
            {
                if (title != null)
                {
                    LabelConfirmTitle.Text = title;
                }

                if (message != null)
                {
                    LabelConfirmMessage.Text = message;
                }

                if (closeButtonText != null)
                {
                    ButtonConfirmClose.Text = closeButtonText;
                }

                ClosedPopupCommand          = closeCommand;
                ClosedPopupCommandParameter = closeCommandParameter;

                if (acceptButtonText != null)
                {
                    ButtonConfirmAccept.Text = acceptButtonText;
                }

                AcceptCommand          = acceptCommand;
                AcceptCommandParameter = acceptCommandParameter;

                IsAutoClose = isAutoClose;
                Duration    = duration;
            });

            if (IsClosed)
            {
                IsClosed = false;

                if (isAutoClose && duration > 0)
                {
                    AutoClosedPopupAfter(duration);
                }

                await DeviceExtension.BeginInvokeOnMainThreadAsync(async() =>
                {
                    await Application.Current.MainPage.Navigation.PushPopupAsync(this);
                });
            }

            return(this);
        }
Exemplo n.º 6
0
 private async void BackToDetailPageExe()
 {
     if (ViewImagePopUp.Scale == 1)
     {
         await DeviceExtension.BeginInvokeOnMainThreadAsync(async() =>
         {
             await Navigation.PopPopupAsync();
         });
     }
 }
Exemplo n.º 7
0
        public async Task <MessagePopup> Show(string message        = null, string closeButtonText = null,
                                              ICommand closeCommand = null, object closeCommandParameter = null, string textBackgroundColor = null,
                                              bool isAutoClose      = false, uint duration = 2000)
        {
            // Close Loading Popup if it is showing
            await LoadingPopup.Instance.Hide();

            await DeviceExtension.BeginInvokeOnMainThreadAsync(() =>
            {
                if (textBackgroundColor != null)
                {
                    LayoutButton.BackgroundColor = Color.FromHex(textBackgroundColor);
                }
                else
                {
                    LayoutButton.BackgroundColor = backGroundDefault;
                }

                if (message != null)
                {
                    LabelMessageContent.Text = message;
                }

                if (closeButtonText != null)
                {
                    ButtonMessageClose.Text = closeButtonText;
                }

                ClosedPopupCommand          = closeCommand;
                ClosedPopupCommandParameter = closeCommandParameter;

                IsAutoClose = isAutoClose;
                Duration    = duration;
            });

            if (IsClosed)
            {
                IsClosed = false;

                if (isAutoClose && duration > 0)
                {
                    AutoClosedPopupAfter(duration);
                }

                await DeviceExtension.BeginInvokeOnMainThreadAsync(async() =>
                {
                    await Application.Current.MainPage.Navigation.PushPopupAsync(this);
                });
            }

            return(this);
        }
Exemplo n.º 8
0
        private void BCSP_PnpAdd(DeviceExtension e)
        {
            int status = BCSP_IoIncrement(e);

            if (status == 0)
            {
                // Do work here.
                nekara.ContextSwitch();
                nekara.Assert(!this.Stopped, "Bug found!");
            }

            BCSP_IoDecrement(e);
        }
Exemplo n.º 9
0
        private async void LogoutExecute()
        {
            await CheckBusy(async() =>
            {
                SqLiteService.DeleteAll <UserModel>();

                // Navigate to Login page
                await DeviceExtension.BeginInvokeOnMainThreadAsync(async() =>
                {
                    await Navigation.NavigateAsync(new Uri($"{ManagerPage.NavigationHomeUri}/{ManagerPage.LoginPage}"));
                });
            });
        }
Exemplo n.º 10
0
        public async Task Hide()
        {
            if (IsLoading)
            {
                await Task.Delay(200);

                IsLoading = false;

                await DeviceExtension.BeginInvokeOnMainThreadAsync(async() =>
                {
                    Indicator.IsRunning = false;
                    await Navigation.PopPopupAsync();
                });
            }
        }
Exemplo n.º 11
0
        private async void AcceptPopupEvent(object sender, EventArgs e)
        {
            await DeviceExtension.BeginInvokeOnMainThreadAsync(async() =>
            {
                await Navigation.PopPopupAsync();
            });

            // waiting for close animation finished
            await Task.Delay(300);

            AcceptCommand?.Execute(AcceptCommandParameter);

            //_popupId++;
            IsClosed = true;
        }
Exemplo n.º 12
0
        private int BCSP_IoIncrement(DeviceExtension e)
        {
            nekara.ContextSwitch();
            if (e.StoppingFlag)
            {
                return(-1);
            }

            nekara.ContextSwitch();
            using (this.Lock.Acquire())
            {
                e.PendingIo++;
            }

            return(0);
        }
Exemplo n.º 13
0
        static void ResetiOSSimulator(string iOSSimulator)
        {
            if (TestEnvironment.Platform.Equals(TestPlatform.Local))
            {
                var deviceId = DeviceExtension.GetiOSDeviceID(iOSSimulator);

                if (string.IsNullOrEmpty(deviceId))
                {
                    throw new ArgumentException($"No simulator found with device name [{iOSSimulator}]", iOSSimulator);
                }

                var shutdownProcess = Process.Start("xcrun", string.Format("simctl shutdown {0}", deviceId));
                shutdownProcess.WaitForExit();
                var eraseProcess = Process.Start("xcrun", string.Format("simctl erase {0}", deviceId));
                eraseProcess.WaitForExit();
            }
        }
Exemplo n.º 14
0
        private void BCSP_IoDecrement(DeviceExtension e)
        {
            int pendingIo;

            nekara.ContextSwitch();
            using (this.Lock.Acquire())
            {
                e.PendingIo--;
                pendingIo = e.PendingIo;
            }

            if (pendingIo == 0)
            {
                nekara.ContextSwitch();
                e.StoppingEvent = true;
            }
        }
Exemplo n.º 15
0
        private int BCSP_IoIncrement(DeviceExtension e)
        {
            NekaraManagedClient nekara = RuntimeEnvironment.Client;

            nekara.Api.ContextSwitch();
            if (e.StoppingFlag)
            {
                return(-1);
            }

            nekara.Api.ContextSwitch();
            using (this.Lock.Acquire())
            {
                e.PendingIo++;
            }

            return(0);
        }
Exemplo n.º 16
0
        private void BCSP_PnpAdd(DeviceExtension e)
        {
            NekaraManagedClient nekara = RuntimeEnvironment.Client;

            int status = BCSP_IoIncrement(e);

            if (status == 0)
            {
                // Do work here.
                nekara.Api.ContextSwitch();
                // nekara.Assert(!this.Stopped, "Bug found!");
                if (this.Stopped)
                {
                    bugFoundBluetoothDriver = true;
                }
            }

            BCSP_IoDecrement(e);
        }
Exemplo n.º 17
0
        private void BCSP_IoDecrement(DeviceExtension e)
        {
            NekaraManagedClient nekara = RuntimeEnvironment.Client;

            int pendingIo;

            nekara.Api.ContextSwitch();
            using (this.Lock.Acquire())
            {
                e.PendingIo--;
                pendingIo = e.PendingIo;
            }

            if (pendingIo == 0)
            {
                nekara.Api.ContextSwitch();
                e.StoppingEvent = true;
            }
        }
Exemplo n.º 18
0
        public async Task <QRCodePopup> Show(string qrCodeValue,
                                             ICommand closeCommand = null, object closeCommandParameter = null,
                                             bool isAutoClose      = false, uint duration = 2000)
        {
            IsClosed = false;

            if (qrCodeValue == null)
            {
                Debug.WriteLine("[Error][Exception]: QRCodePopup cannot be shown because of null QR code value");
                return(null);
            }
            else
            {
                QRCodeView.BarcodeValue = qrCodeValue;
            }

            if (closeCommand != null)
            {
                ClosePopupCommand = closeCommand;
            }

            if (closeCommandParameter != null)
            {
                ClosePopupCommandParameter = closeCommandParameter;
            }

            IsAutoClose = isAutoClose;
            Duration    = duration;

            if (isAutoClose && duration > 0)
            {
                AutoClosePopupAfter(duration);
            }

            await DeviceExtension.BeginInvokeOnMainThreadAsync(async() =>
            {
                await App.Current.MainPage.Navigation.PushPopupAsync(this);
            });

            return(this);
        }
Exemplo n.º 19
0
        public async Task Show(string loadingMessage = null)
        {
            await DeviceExtension.BeginInvokeOnMainThreadAsync(() =>
            {
                LabelMessage.Text = !string.IsNullOrWhiteSpace(loadingMessage)
                    ? loadingMessage : TranslateExtension.Get("Loading");
            });

            if (IsLoading)
            {
                return;
            }

            IsLoading = true;

            await DeviceExtension.BeginInvokeOnMainThreadAsync(async() =>
            {
                Indicator.IsRunning = true;
                await Application.Current.MainPage.Navigation.PushPopupAsync(this);
            });
        }