public void Reset()
 {
     inactivityTimer.Invalidate();
     inactivityTimer.Dispose();
     inactivityTimer         = NSTimer.CreateScheduledTimer(TimeSpan.FromSeconds(AppConstant.InactivityTimeOut), InActivityTimer_Elapsed);
     lastActivityElapsedTime = NSProcessInfo.ProcessInfo.SystemUptime;
 }
Exemplo n.º 2
0
        void OnStartProgressTapped(object sender, EventArgs e)
        {
            standardProgressView.Progress = 0;
            bigRadialProgressView.Reset();
            smallRadialProgressView.Reset();
            tinyRadialProgressView.Reset();

            if (timer != null)
            {
                timer.Invalidate();
                timer = null;
            }

            // Start a timer to increment progress regularly until complete
            timer = NSTimer.CreateRepeatingScheduledTimer(1.0 / 30.0, () => {
                bigRadialProgressView.Value   += 0.005f;
                smallRadialProgressView.Value += 0.005f;
                tinyRadialProgressView.Value  += 0.005f;
                standardProgressView.Progress += 0.005f;

                if (bigRadialProgressView.IsDone)
                {
                    timer.Invalidate();
                    timer = null;
                }
            });
        }
Exemplo n.º 3
0
        void UserKnocked()
        {
            _state.didKnock = true;
            if (_state.CountDown > 0 && _state.CountDown < 5 && _state.PublishToTwitter == false)
            {
                _state.PublishToTwitter = true;
                session.StopRunning();
                session.Dispose();
                session = null;
                outputRecorder.Dispose();
                outputRecorder = null;
                queue.Dispose();
                queue = null;

                //Stop Both Timers
                AudioLoop.Invalidate();
                timer.Invalidate();

                //Stop Recording
                StopRecording();



                //Start up Resording
                NSTimer.CreateScheduledTimer(TimeSpan.FromSeconds(10), AudioReset);
                NSTimer.CreateScheduledTimer(TimeSpan.FromSeconds(1), PostToTwitter);
                _state.PublishToTwitter = true;
                _state.TopLabel.Text    = "";
                _state.BottomLabel.Text = "Posted to Twitter!";
                imgYouRock.Hidden       = false;
            }
        }
Exemplo n.º 4
0
 public void Suspend ()
 {
     if (timer != null) {
         timer.Invalidate ();
         timer = null;
     }
 }
        void flipGameBoardTiles(UIImageView gameBoardTile, int tileIndex, int imageIndex)
        {
            UIView.Transition(gameBoardTile, .5,
                              UIViewAnimationOptions.TransitionFlipFromRight,
                              () => // animation block, animation beginds
            {
                // get the image from our array that was chosen
                gameBoardTile.Image = GameTile.GameBoardObjects[imageIndex].Image;
            }, () => // animation complete
            {
                // check to see if we are performaing a comparison
                if (isComparing)
                {
                    //get the index of the second tile that was selected
                    indexOfSecondTile = tileIndex;
                    secondTileImage   = gameBoardTile;
                    doGameTilesMatch();

                    if (totalFound == gameBoardSize)
                    {
                        gameTimer.Invalidate();
                        startNewGame();
                    }
                    isComparing = false;
                }
                else
                {
                    indexOfFirstTile = tileIndex;
                    firstTileImage   = gameBoardTile;
                    isComparing      = true;
                }
            });
        }
Exemplo n.º 6
0
        public override void LoadView()
        {
            base.LoadView();
            View.BackgroundColor = UIColor.LightGray;

            MakeButton("Show", () => {
                BTProgressHUD.Show();
                KillAfter();
            });

            MakeButton("Show Message", () => {
                BTProgressHUD.Show(status: "Processing your image");
                KillAfter();
            });

            MakeButton("Show Success", () => {
                BTProgressHUD.ShowSuccessWithStatus("Great success!");
            });

            MakeButton("Show Fail", () => {
                BTProgressHUD.ShowErrorWithStatus("Oh, thats bad");
            });

            MakeButton("Toast", () => {
                BTProgressHUD.ShowToast("Hello from the toast", showToastCentered: false);
            });


            MakeButton("Dismiss", () => {
                BTProgressHUD.Dismiss();
            });

            MakeButton("Progress", () => {
                progress = 0;
                BTProgressHUD.Show("Hello!", progress);
                if (timer != null)
                {
                    timer.Invalidate();
                }
                timer = NSTimer.CreateRepeatingTimer(0.5f, delegate {
                    progress += 0.1f;
                    if (progress > 1)
                    {
                        timer.Invalidate();
                        timer = null;
                        BTProgressHUD.Dismiss();
                    }
                    else
                    {
                        BTProgressHUD.Show("Hello!", progress);
                    }
                });
                NSRunLoop.Current.AddTimer(timer, NSRunLoopMode.Common);
            });

            MakeButton("Dismiss", () => {
                BTProgressHUD.Dismiss();
            });
        }
Exemplo n.º 7
0
 public void StopWorker()
 {
     // starting timer
     if (null != _timer)
     {
         _timer.Invalidate();
         _timer.Dispose();
         _timer = null;
     }
 }
    public override void Changed(UITextView textView)
    {
        Console.WriteLine("-----" + secureText);
        if (secureTextViewEntry)
        {
            string text = textView.Text;
            if (text.Length > 0)
            {
                if ("" == lastText)
                {
                    secureText.DeleteCharacters(new NSRange(secureText.Length - 1, 1));
                    onlyPassword();
                    timer.Invalidate();
                    //base.Changed(textView);
                    return;
                }
                else
                {
                    NSString one = new NSString(text.Substring(text.Length - 1));
                    secureText.Append(one);
                    NSMutableString temp = new NSMutableString();
                    for (int i = 0; i < secureText.Length - 1; i++)
                    {
                        temp.Append(new NSString("•"));
                    }
                    temp.Append(new NSString(secureText.ToString().Substring(secureText.ToString().Length - 1)));
                    myTextView.Text = temp;

                    //timer.Invalidate();
                    timer = NSTimer.CreateScheduledTimer(2, onlyPassword);
                }
            }
            else
            {
                secureText = new NSMutableString();
            }
            //base.Changed(textView);
        }
        else
        {
            if (textView.Text.Length == 0)
            {
                secureText = new NSMutableString();
            }
            else
            {
                secureText = new NSMutableString();
                secureText.SetString(new NSString(textView.Text));
            }

            timer.Invalidate();
            //base.Changed(textView);
        }
    }
Exemplo n.º 9
0
        public override void ViewDidDisappear(bool animated)
        {
            base.ViewDidDisappear(animated);

            if (timer != null)
            {
                timer.Invalidate();
                timer.Dispose();
                timer = null;
            }
        }
        public override void ViewDidDisappear(bool animated)
        {
            base.ViewDidDisappear(animated);

            if (updatingTimer != null)
            {
                updatingTimer.Invalidate();
            }

            if (player != null)
            {
                player.FlushAndClose();
                player = null;
            }
        }
        public override void ViewWillDisappear(bool animated)
        {
            base.ViewWillDisappear(animated);

            _timer.Invalidate();
            _timer = null;
        }
Exemplo n.º 12
0
        private void ShowOrUpdateToast(string message, ToastLength length)
        {
            var startTimer = false;

            if (_ToastTimer == null || !_ToastTimer.IsValid)
            {   // close any alert (EXCEPT working toast!) before the showing new toast
                CancelAlertController();

                _AlertController = UIAlertController.Create(null, message, UIAlertControllerStyle.ActionSheet);
                UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(_AlertController, true, () => {
                    // handle outside click
                    _AlertController.View?.Superview?.Subviews?.FirstOrDefault()?.AddGestureRecognizer(new UITapGestureRecognizer(CancelAlertController));
                });
                startTimer = true;
            }
            else if (_ToastTimer != null && _ToastTimer.IsValid &&
                     _AlertController != null && _AlertController == UIApplication.SharedApplication.KeyWindow.RootViewController.PresentedViewController)
            {
                _ToastTimer.Invalidate();
                _AlertController.Message = message;
                startTimer = true;
            }

            if (startTimer)
            {
                var toastMilliseconds = length == ToastLength.Long ? DialogConstants.TOAST_LONG_LENGTH : DialogConstants.TOAST_SHORT_LENGTH;
                _ToastTimer = NSTimer.CreateScheduledTimer(TimeSpan.FromMilliseconds(toastMilliseconds), ToastTimeComplete);
            }
        }
Exemplo n.º 13
0
 public void Stop()
 {
     if (timer != null)
     {
         timer.Invalidate();
     }
 }
Exemplo n.º 14
0
        public static void Animate(this Stage stage)
        {
            if (stage.IsAnimating || stage.Timelines.Count == 0)
            {
                return;
            }
            var timeline = stage.Timelines [0];

            if (timeline.Frames.Count == 0)
            {
                return;
            }
            stage.IsAnimating = true;
            int     currentFrameIndex = 0;
            NSTimer timer             = null;

            timer = NSTimer.CreateRepeatingScheduledTimer(.001, () => {
                stage.CurrentAnimationTime++;
                if (stage.CurrentAnimationTime > timeline.Duration || currentFrameIndex >= timeline.Frames.Count)
                {
                    timer.Invalidate();
                    stage.IsAnimating = false;
                }
                if (timeline.Frames.Count <= currentFrameIndex || !timeline.Frames[currentFrameIndex].ShouldAnimate(stage.CurrentAnimationTime))
                {
                    return;
                }
                while (timeline.Frames.Count > currentFrameIndex && timeline.Frames[currentFrameIndex].ShouldAnimate(stage.CurrentAnimationTime))
                {
                    timeline.Frames[currentFrameIndex].Animate(stage);
                    currentFrameIndex++;
                }
            });
        }
Exemplo n.º 15
0
 private void ButtonTimer()
 {
     _Timer.Invalidate();
     _Timer      = null;
     Highlighted = false;
     SetNeedsDisplay();
 }
Exemplo n.º 16
0
        private void FocusTimer()
        {
            _Timer.Invalidate();
            _Timer = null;

            _Focus.Entry.BecomeFirstResponder();
        }
Exemplo n.º 17
0
        private void FocusTimer()
        {
            _Timer.Invalidate();
            _Timer = null;

            _Focus.InputControl.BecomeFirstResponder();
        }
Exemplo n.º 18
0
        public void Bug2443()
        {
            var evt = new CountdownEvent(2);

            NSTimer timer = null;

            using (timer = NSTimer.CreateRepeatingTimer(0.1f, delegate {
                if (evt.Signal())
                {
                    timer.Invalidate();
                }
            })) {
                var thread = new Thread(() => {
                    NSRunLoop.Current.AddTimer(timer, NSRunLoopMode.Default);
                    NSRunLoop.Current.RunUntil(NSRunLoopMode.Default, NSDate.Now.AddSeconds(5));
                })
                {
                    IsBackground = true,
                };
                thread.Start();

                Assert.IsTrue(evt.Wait(TimeSpan.FromSeconds(5)), "Not signalled twice in 5s");
                thread.Join();
            }
        }
Exemplo n.º 19
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Perform any additional setup after loading the view, typically from a nib.
            btnStart.Enabled = true;
            btnStop.Enabled  = false;


            btnStart.TouchUpInside += delegate {
                btnStart.Enabled = false;
                btnStop.Enabled  = true;
                timer            = NSTimer.CreateRepeatingScheduledTimer(TimeSpan.FromSeconds(1), timer_tick);
            };

            btnStop.TouchUpInside += delegate {
                btnStart.Enabled = true;
                btnStop.Enabled  = false;
                timer.Invalidate();
            };

            btnReset.TouchUpInside += delegate {
                MyTimerLogic.Reset();
                lblDisplay.Text = MyTimerLogic.GetCurrentTickCount();
            };
        }
Exemplo n.º 20
0
        public override void ViewDidDisappear(bool animated)
        {
            base.ViewDidDisappear(animated);

            _autoRefreshTimer.Invalidate();
            _autoRefreshTimer = null;
        }
Exemplo n.º 21
0
 /// <summary>
 /// Stop the timer.
 /// </summary>
 public void Stop()
 {
     DebugOutput("!!!!! STOPPING TIMER from thread: " + NSThread.Current.Handle + ", MAIN: " + NSThread.MainThread.Handle);
     _timer.Invalidate();
     _timer.Dispose();
     _timer = null;
 }
Exemplo n.º 22
0
        void exportCompleted(AVAssetExportSession session)
        {
            exportProgressView.Hidden = true;
            currentTimeLabel.Hidden   = false;
            var outputUrl = session.OutputUrl;

            progressTimer.Invalidate();
            progressTimer = null;

            if (session.Status != AVAssetExportSessionStatus.Completed)
            {
                Console.WriteLine("exportSession error:{0}", session.Error.LocalizedDescription);
                reportError(session.Error);
                return;
            }

            exportProgressView.Progress = 1f;

            var library = new ALAssetsLibrary();

            library.WriteVideoToSavedPhotosAlbum(outputUrl, (assetURL, error) => {
                if (error != null)
                {
                    Console.WriteLine("writeVideoToAssetsLibrary failed: {0}", error.LocalizedDescription);
                    reportError(error);
                }
            });

            Player.Play();
            playPauseButton.Enabled  = true;
            transitionButton.Enabled = true;
            scrubber.Enabled         = true;
            exportButton.Enabled     = true;
        }
        //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        public override void ViewWillDisappear(bool animated)
        {
            base.ViewWillDisappear(animated);

            timer.Invalidate();
            timer.Dispose();
        }
Exemplo n.º 24
0
        public void Bug17793()
        {
            var evt = new CountdownEvent(2);

            NSTimer timer = null;

            using (timer = NSTimer.CreateRepeatingTimer(0.1f, delegate {
                // This is the real test - not a timer test, but properly preserving VFP registers.
                // When bug #17793 manifests, this method is only called once instead of repeatedly.
                Func(0, 0, 0, 0, 0, 0, 0);
                if (evt.Signal())
                {
                    timer.Invalidate();
                }
            })) {
                var thread = new Thread(() => {
                    NSRunLoop.Current.AddTimer(timer, NSRunLoopMode.Default);
                    NSRunLoop.Current.RunUntil(NSRunLoopMode.Default, NSDate.Now.AddSeconds(5));
                })
                {
                    IsBackground = true,
                };
                thread.Start();

                Assert.IsTrue(evt.Wait(TimeSpan.FromSeconds(5)), "Not signalled twice in 5s");
                thread.Join();
            }
        }
Exemplo n.º 25
0
        async Task TimerDone()
        {
            tickTimer.Invalidate();
            await ReportScore();

            PresentScene(new ResultsScreen(View.Bounds.Size));
        }
Exemplo n.º 26
0
            public void StartTimer(TimeSpan interval, Func <bool> callback)
            {
                NSTimer timer = null;

#if __UNIFIED__
                timer = NSTimer.CreateRepeatingScheduledTimer(interval, t =>
                {
#else
                timer = NSTimer.CreateRepeatingScheduledTimer(interval, () => {
                                #endif
                    if (!callback())
#if __UNIFIED__
                    { t.Invalidate(); }
#else
                    { timer.Invalidate(); }
                                                #endif
                });
                NSRunLoop.Main.AddTimer(timer, NSRunLoopMode.Common);
            }

            HttpClient GetHttpClient()
            {
                var proxy   = CFNetwork.GetSystemProxySettings();
                var handler = new HttpClientHandler();

                if (!string.IsNullOrEmpty(proxy.HTTPProxy))
                {
                    handler.Proxy    = CFNetwork.GetDefaultProxy();
                    handler.UseProxy = true;
                }
                return(new HttpClient(handler));
            }
 private void CancelTimer()
 {
     if (timer != null && timer.IsValid)
     {
         timer.Invalidate();
     }
 }
Exemplo n.º 28
0
        // 表示開始
        private void Show(UIView parent, string message)
        {
            // 既に表示中の場合は、処理を停止する
            if (_timer != null)
            {
                _timer.Invalidate();
                _view.RemoveFromSuperview(); // 親ビューから削除する
            }

            // 当初、アルファ値0.7で表示を開始する
            _view.Alpha = (nfloat)0.7;

            // 親Viewからトーストのサイズを調整する
            _view.Frame = new CGRect(
                (parent.Bounds.Width - _width) / 2,
                parent.Bounds.Height - _height - _margin,
                _width,
                _height);

            _label.Frame = new CGRect(0, 0, _width, _height);
            _label.Text  = message; // ラベルの表示文字列を設定する

            parent.AddSubview(_view);

            //タイマー開始
            var wait = 10; // 消え始めるまでのウエイト

            _timer = NSTimer.CreateRepeatingScheduledTimer(TimeSpan.FromMilliseconds(100), delegate {
                // alpha値が0になったらViewのサイズを0にしてタイマーを停止する
                if (_view.Alpha <= 0)
                {
                    _timer.Invalidate();
                    _view.RemoveFromSuperview(); // 親ビューから削除する
                }
                else
                {
                    if (wait > 0)
                    {
                        wait--;
                    }
                    else
                    {
                        _view.Alpha -= (nfloat)0.05;
                    }
                }
            });
        }
        private void StartRecordingAndRecognizing()
        {
            _timer = NSTimer.CreateRepeatingScheduledTimer(5, delegate
            {
                DidFinishTalk();
            });

            _recognitionTask?.Cancel();
            _recognitionTask = null;

            var     audioSession = AVAudioSession.SharedInstance();
            NSError nsError;

            nsError = audioSession.SetCategory(AVAudioSessionCategory.PlayAndRecord);
            audioSession.SetMode(AVAudioSession.ModeDefault, out nsError);
            nsError = audioSession.SetActive(true, AVAudioSessionSetActiveOptions.NotifyOthersOnDeactivation);
            audioSession.OverrideOutputAudioPort(AVAudioSessionPortOverride.Speaker, out nsError);
            _recognitionRequest = new SFSpeechAudioBufferRecognitionRequest();

            var inputNode = _audioEngine.InputNode;

            if (inputNode == null)
            {
                throw new Exception();
            }

            var recordingFormat = inputNode.GetBusOutputFormat(0);

            inputNode.InstallTapOnBus(0, 1024, recordingFormat, (buffer, when) =>
            {
                _recognitionRequest?.Append(buffer);
            });

            _audioEngine.Prepare();
            _audioEngine.StartAndReturnError(out nsError);

            _recognitionTask = _speechRecognizer.GetRecognitionTask(_recognitionRequest, (result, error) =>
            {
                var isFinal = false;
                if (result != null)
                {
                    _recognizedString = result.BestTranscription.FormattedString;
                    //MessagingCenter.Send<ISpeechToText, string>(this, "STT", _recognizedString);
                    _timer.Invalidate();
                    _timer = null;
                    _timer = NSTimer.CreateRepeatingScheduledTimer(2, delegate
                    {
                        DidFinishTalk();
                    });
                }
                if (error != null || isFinal)
                {
                    MessagingCenter.Send <ISpeechToText, string>(this, "STT", _recognizedString);

                    MessagingCenter.Send <ISpeechToText>(this, "Final");
                    StopRecordingAndRecognition(audioSession);
                }
            });
        }
Exemplo n.º 30
0
 static void EndBumpingGtkLoop()
 {
     if (--bumperCount == 0)
     {
         bumperTimer.Invalidate();
         bumperTimer = null;
     }
 }
        protected void AdvancedHudActionForRow(int row)
        {
            switch (row) {
                case 0:
                    hud.SetCaption("This HUD will auto-hide in 2 seconds.");
                    hud.BlockTouches = true;
                    hud.Show();
                    hud.HideAfter(2.0);
                    break;

                case 1:
                    hud.SetCaption("This HUD will update in 2 seconds.");
                    hud.BlockTouches = true;
                    hud.SetActivity(true);
                    hud.Show();
                    NSTimer.CreateScheduledTimer(2.0, () => { UpdatedHud(); });
                    break;

                case 2:
                {
                    float progress = 0.08f;

                    //NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:.02 target:self selector:@selector(tick:) userInfo:nil repeats:YES];
                    //[[NSRunLoop currentRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];

                    NSTimer timer = new NSTimer();
                    timer = NSTimer.CreateRepeatingScheduledTimer(0.02, () => {

                        progress += 0.01f;
                        hud.SetProgress(progress);
                        if (progress >= 1) {
                            progress = 0;
                            timer.Invalidate();
                            hud.Hide();

                            NSTimer.CreateScheduledTimer(0.2, () => { ResetProgress(); });
                        }
                    });

                    hud.SetCaption("Performing operation...");
                    hud.SetProgress(0.08f);
                    hud.BlockTouches = true;
                    hud.Show();
                    break;
                }

                case 3:
                {
                    string[] captions = new [] { "Display #1", "Display #2", "Display #3" };
                    // Would love to just use UIImage but breaks when using a "null" image.
                    NSArray images = NSArray.FromObjects("", "", UIImage.FromBundle("19-check"));
                    NSNumber[] positions = new NSNumber[] { new NSNumber(2), new NSNumber(1), new NSNumber(2) };
                    NSNumber[] flags = new NSNumber[] { new NSNumber(false), new NSNumber(true), new NSNumber(false) };

                    hud.AddToQueue(captions, images, positions, flags);
                    hud.StartQueue();

                    NSTimer.CreateScheduledTimer(2.0, () => { ShowNextDisplayInQueue();	});
                    break;
                }
            }
        }
        protected void AdvancedHudActionForRow(int row)
        {
            switch (row) {
                case 0:
                    hud.SetCaption("This HUD will auto-hide in 2 seconds.");
                    hud.BlockTouches = true;
                    hud.Show();
                    hud.HideAfter(2.0);
                    break;

                case 1:
                    hud.SetCaption("This HUD will update in 2 seconds.");
                    hud.BlockTouches = true;
                    hud.SetActivity(true);
                    hud.Show();
                    NSTimer.CreateScheduledTimer(2.0, () => { UpdatedHud(); });
                    break;

                case 2:
                {
                    float progress = 0.08f;

                    //NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:.02 target:self selector:@selector(tick:) userInfo:nil repeats:YES];
                    //[[NSRunLoop currentRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];

                    NSTimer timer = new NSTimer();
                    timer = NSTimer.CreateRepeatingScheduledTimer(0.02, () => {

                        progress += 0.01f;
                        hud.SetProgress(progress);
                        if (progress >= 1) {
                            progress = 0;
                            timer.Invalidate();
                            hud.Hide();

                            NSTimer.CreateScheduledTimer(0.2, () => { ResetProgress(); });
                        }
                    });

                    hud.SetCaption("Performing operation...");
                    hud.SetProgress(0.08f);
                    hud.BlockTouches = true;
                    hud.Show();
                    break;
                }

                case 3:
                {

                    var item1 = new ATMHudQueueItem { Caption = "Display #1", AccessoryPosition = ATMHudAccessoryPosition.ATMHudAccessoryPositionBottom };
                    var item2 = new ATMHudQueueItem { Caption = "Display #2", AccessoryPosition = ATMHudAccessoryPosition.ATMHudAccessoryPositionRight, ShowActivity = true };
                    var item3 = new ATMHudQueueItem { Caption = "Display #3", Image = UIImage.FromBundle("19-check"), AccessoryPosition = ATMHudAccessoryPosition.ATMHudAccessoryPositionBottom };

                    hud.AddToQueue(new ATMHudQueueItem[] { item1, item2, item3 });
                    hud.StartQueue();

                    NSTimer.CreateScheduledTimer(2.0, () => { ShowNextDisplayInQueue();	});
                    break;
                }
            }
        }
Exemplo n.º 33
0
        void OneSecondTimer(NSTimer timer)
        {
            timerCount++;
            var userInfoString = timer.UserInfo.ToString();
            Console.WriteLine (String.Format("One Second Timer (Number {0}) With Timer Passed In fired with User Info '{1}'", timerCount, userInfoString));

            // Invalidate the timer after 5 calls.
            if(timerCount == 5)
            {
                timer.Invalidate();
                timer = null;
            }
        }