public override void ViewDidLoad() { base.ViewDidLoad(); sessionManager = new SessionManager(); sessionManager.StartRunning(); previewLayer = new AVCaptureVideoPreviewLayer(sessionManager.CaptureSession) { Frame = previewView.Bounds, VideoGravity = AVLayerVideoGravity.ResizeAspectFill }; if (previewLayer.Connection != null && previewLayer.Connection.SupportsVideoOrientation) { previewLayer.Connection.VideoOrientation = AVCaptureVideoOrientation.LandscapeLeft; } previewView.Layer.AddSublayer(previewLayer); previewView.Layer.MasksToBounds = true; barcodeTargetLayer = new CALayer() { Frame = View.Layer.Bounds }; View.Layer.AddSublayer(barcodeTargetLayer); synth = new Synth(); synth.LoadPreset(this); stepTimer = NSTimer.CreateRepeatingScheduledTimer(0.15, step); }
private void lowDifficultySwitchingChoices() { count = 0; leftFilterDark("On", FilterRotation); rightFilterDark("Off", FilterRotation); blackout = "right"; soundSelect = "right"; SwitchingChoices = NSTimer.CreateRepeatingScheduledTimer(TimeSpan.FromSeconds(5), delegate { switch (count) { case 0: count++; imvLayerLeft.Image = empty; rightFilterDark("On", FilterRotation); blackout = "left"; soundSelect = "left"; break; case 1: count--; imvLayerRight.Image = empty; leftFilterDark("On", FilterRotation); blackout = "right"; soundSelect = "right"; break; } }); }
public override void DidEnterBackground(UIApplication application) { Mvx.TaggedTrace(Tag, "DidEnterBackground"); BackgroundTimeTimer = NSTimer.CreateRepeatingScheduledTimer(1, OnBackgroundTimeTimerAction); BackgroundTimeTimer.Fire(); }
public static void ScrollOutHeaderAfterReload( UIScrollView scrollView, nfloat headerHeight, IListViewSource viewSource, bool animated) { var existingKey = GetTimerKey(scrollView); if (viewSource.ItemsSource != null && viewSource.ItemsSource.Cast <object>().Any()) { if (existingKey == null) { var newKey = new WeakReference <UIScrollView>(scrollView); _timers[newKey] = NSTimer.CreateRepeatingScheduledTimer( TimeSpan.MinValue, t => { if (scrollView.ContentSize.Height > headerHeight) { ScrollOutHeader(scrollView, headerHeight, animated); DisposeTimer(newKey); } }); } } else { DisposeTimer(existingKey); } }
public MonoMacNotifier(NSUserNotificationCenter center, IReport report) { _center = center; _report = report; _center.ShouldPresentNotification = (c, n) => true; // Show notification even if app is TopMost. _center.DidActivateNotification += (s, a) => _notificationActivated.OnNext(GetId(a.Notification)); _timer = NSTimer.CreateRepeatingScheduledTimer( TimeSpan.FromMilliseconds(500), timer => { try { var currentNotifications = _center.DeliveredNotifications.Select(GetId).ToImmutableHashSet(); _currentNotifications.OnNext(currentNotifications); } catch (Exception e) { _report.Exception("Updating current notifications failed", e); } }); }
public override void WindowDidLoad() { loadCounter(); NSTimer timer = NSTimer.CreateRepeatingScheduledTimer(TimeSpan.FromSeconds(5.0), delegate { loadCounter(); }); }
public ClockTimer() : base() { outputString = DateTime.Now.ToString("hh:mm:ss"); myTTimer = NSTimer.CreateRepeatingScheduledTimer(1, delegate { outputString = DateTime.Now.ToString("hh:mm:ss"); }); }
public override void ViewDidLoad() { base.ViewDidLoad(); NSTimer.CreateRepeatingScheduledTimer(2, () => { var rest = new RestClient("https://intense-escarpment-3682.herokuapp.com/"); rest.ExecuteAsync(new RestRequest("organization"), response => InvokeOnMainThread(() => { var results = JsonConvert.DeserializeObject <OrganizationViewModel[]> (response.Content); var cellSource = new TableSource(results); cellSource.Tap += (obj) => { Organizationpage.Model = obj; PerformSegue("GoToOrganization", this); }; TableView.Source = cellSource; TableView.ReloadData(); if (Organizationpage.Model != null) { var newModel = results.SingleOrDefault(x => x.Id == Organizationpage.Model.Id); if (newModel != null) { Organizationpage.Model = newModel; Console.WriteLine("updated model"); } } })); }); // Perform any additional setup after loading the view, typically from a nib. }
public override void DidFinishLaunching(NSNotification notification) { mainWindowController = new MainWindowController(); mainWindowController.Window.MakeKeyAndOrderFront(this); var progressIndicator = new NSProgressIndicator(new CGRect(50, 0, 400, 200)) { DoubleValue = 0, Indeterminate = false }; double progressValue = 0; NSTimer.CreateRepeatingScheduledTimer(.5, timer => { if (!NSThread.Current.IsMainThread) { throw new System.InvalidOperationException("NSTimer should invoke on main?"); } if (progressValue >= 100) { progressValue = 0; } progressValue += 20; progressIndicator.DoubleValue = progressValue; }); mainWindowController.Window.ContentView.AddSubview(progressIndicator); }
public void StartAnimationTimer() { Timer = NSTimer.CreateRepeatingScheduledTimer(new TimeSpan(0, 0, 0, 0, 33), t => { Frame++; Invalidate(); // This is a bit lazy }); }
public override void ViewDidLoad() { base.ViewDidLoad(); var backbutton = new UIBarButtonItem("Back", UIBarButtonItemStyle.Done, null) { TintColor = UIColor.White }; backbutton.Clicked += (sender, e) => NavigationController.PopViewControllerAnimated(true); NavigationItem.SetLeftBarButtonItem(backbutton, false); Title = Organizationpage.Model.Name + "'s Expenses"; var restClient = new RestClient("https://intense-escarpment-3682.herokuapp.com/"); var request = new RestRequest("expenses/" + Organizationpage.Model.Id); timer = NSTimer.CreateRepeatingScheduledTimer(2, () => restClient.ExecuteAsync(request, response => InvokeOnMainThread(() => { var results = JsonConvert.DeserializeObject <X> (response.Content).Items; var source = new SpentTableSource(results); TableView.Source = source; TableView.ReloadData(); }))); }
void RunTests() { if (running) { Console.WriteLine("Already running"); return; } running = true; cmdRun.SetEnabled(false); lblStatus.SetText("Running in background"); var timer = NSTimer.CreateRepeatingScheduledTimer(TimeSpan.FromSeconds(1), (v) => RenderResults()); var runnerThread = new Thread(() => { runner.Run(); InvokeOnMainThread(() => { cmdRun.SetEnabled(true); lblStatus.SetText("Done"); running = false; timer.Dispose(); RenderResults(); }); }) { IsBackground = true, }; runnerThread.Start(); }
public override bool FinishedLaunching(UIApplication app, NSDictionary options) { window = new UIWindow(UIScreen.MainScreen.Bounds); vc = new UIViewController(); vc.View.BackgroundColor = UIColor.Blue; window.RootViewController = vc; UIColor lastColor = UIColor.Green; NSTimer.CreateRepeatingScheduledTimer(1, () => { var defs = new NSUserDefaults("group.com.xamarin.todaysharing", NSUserDefaultsType.SuiteName); var value = defs.ValueForKey(new NSString("key")); if (value == null) { if (lastColor == UIColor.Yellow) { lastColor = UIColor.Orange; } else { lastColor = UIColor.Yellow; } vc.View.BackgroundColor = lastColor; } else { vc.View.BackgroundColor = UIColor.Green; } }); window.MakeKeyAndVisible(); return(true); }
public void StartBGProcess() { try { var sampleTimer = NSTimer.CreateRepeatingScheduledTimer(TimeSpan.FromSeconds(TimerWait), delegate { if (isStarted) { if (tempCount < Count) { tempCount = Count = 0; prepairNotification(); TimeSpan runtime = DateTime.UtcNow.Subtract(startTime); } } else { startTime = DateTime.UtcNow; timer = new Timer(HandleTimerCallback, startTime, 0, TimerWait); isStarted = true; } }); } catch (System.Exception e) { ExceptioHandler(); } }
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++; } }); }
public void StartSyncThread() { Console.WriteLine("Start sync thread"); if (syncThread == null || !syncThread.IsAlive) { syncThread = new Thread(new ThreadStart(() => { using (var pool = new NSAutoreleasePool()) { Console.WriteLine("Sync thread started"); NSTimer.CreateRepeatingScheduledTimer(60, delegate { //MyMoodService.Current.CheckForServiceUpdates (); SyncData(); }); SyncData(); NSRunLoop.Current.Run(); } })); syncThread.IsBackground = true; Console.WriteLine("Starting sync thread"); syncThread.Start(); } }
public void Init() { if (store != null) { return; } DBError error; store = DBDatastore.OpenDefaultStoreForAccount(DBAccountManager.SharedManager.LinkedAccount, out error); var sync = store.Sync(null); store.AddObserver(store, () => { LoadData(); }); AutoUpdating = true; store.BeginInvokeOnMainThread(() => { timer = NSTimer.CreateRepeatingScheduledTimer(1, () => { if (!AutoUpdating) { return; } store.Sync(null); }); }); }
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, delegate { bigRadialProgressView.Value += 0.005f; smallRadialProgressView.Value += 0.005f; tinyRadialProgressView.Value += 0.005f; standardProgressView.Progress += 0.005f; if (bigRadialProgressView.IsDone) { timer.Invalidate(); timer = null; } }); }
void StartRecording() { var session = AVAudioSession.SharedInstance(); NSError error = null; session.SetCategory(AVAudioSession.CategoryRecord, out error); if (error != null) { return; } session.SetActive(true, out error); if (error != null) { return; } if (!PrepareAudioRecording()) { return; } if (!recorder.Record()) { return; } timer = NSTimer.CreateRepeatingScheduledTimer(TimeSpan.FromSeconds(.1), UpdateMeter); }
public void Resume() { if (timeout != new TimeSpan(-1)) { timer = NSTimer.CreateRepeatingScheduledTimer(timeout, view.RunIteration); } }
public override bool FinishedLaunching(UIApplication app, NSDictionary options) { Rg.Plugins.Popup.Popup.Init(); Forms.Init(); SQLitePCL.Batteries.Init(); ImageCircleRenderer.Init(); Bootstrapper.Initialize(); RegisterPlatformServices(); LoadApplication(new App()); if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0)) { UNUserNotificationCenter.Current.RequestAuthorization( UNAuthorizationOptions.Alert | UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound, (approved, error) => { }); } NSTimer.CreateRepeatingScheduledTimer( TimeSpan.FromSeconds(ToDoCheckInterval), delegate { CheckNotifications(); }); App.ScreenHeight = (int)UIScreen.MainScreen.Bounds.Height; App.ScreenWidth = (int)UIScreen.MainScreen.Bounds.Width; return(base.FinishedLaunching(app, options)); }
//++++++++++++ДОПОЛНИТЕЛЬНЫЕ МЕТОДЫ+++++++++++++ /// <summary> /// Начать игру, перемешав камешки на уровне и запустив таймер обратного /// отсчета /// </summary> private void BeginGame() { // перемешиваем камешки в модели и заполняем спрайтами сцену ShuffleGems(); // запуск таймера gameTimer = NSTimer.CreateRepeatingScheduledTimer(TimeSpan.FromSeconds(1.0), delegate { // когда таймер дойдет до 0 if (TimerAction() == 0) { // деактивировать таймер gameTimer.Invalidate(); // Записать в файл новый лучший счет int newHighScore = Math.Max(highScore, Convert.ToInt32(scoreLabel.Text)); File.WriteAllText(highScoresFileName, "score, " + newHighScore); // перейти к экрану конца игры GameOverViewController gameOver = Storyboard.InstantiateViewController("GameOver") as GameOverViewController; // Передаем счет игры экрану конца игры gameOver.score.Text = scoreLabel.Text; NavigationController.PushViewController(gameOver, true); } }); }
public override void ViewDidLoad() { base.ViewDidLoad(); time = 0; timer = NSTimer.CreateRepeatingScheduledTimer(0.02, () => { if (ProgressBar.Superview != null) { //Console.WriteLine ("Something something"); ProgressBar.Progress = time / 100f; time++; if (time > 130) { time = -30; } return; } time++; AlertView.ProgressBar.Progress = time / 200f; if (time > 240) { View.AddSubview(ProgressBar); View.AddSubview(Loading); AlertView.Hide(); time = 0; } }); NSRunLoop.Current.AddTimer(timer, NSRunLoopMode.Default); }
public override void ViewDidLoad() { base.ViewDidLoad(); UIApplication.SharedApplication.StatusBarHidden = true; // this.ControlsOverlay.Frame = this.View.Frame; // this.ControlsOverlay.SetNeedsDisplay (); InitializeCameraLayer(); // Next set up our UI this.FinishRoundButton.TouchUpInside += (sender, e) => { }; this.PlayerOneViewContainer.Layer.BorderColor = this.PlayerTwoViewContainer.Layer.BorderColor = new CGColor(0, 0, 0); this.PlayerOneViewContainer.Layer.BorderWidth = this.PlayerTwoViewContainer.Layer.BorderWidth = 3; this.PlayerOneViewContainer.Layer.CornerRadius = this.PlayerTwoViewContainer.Layer.CornerRadius = 5; this.gameplayView = new GameplayView(this.ControlsOverlay.Frame, this.viewModel); // gameplayView.SetImages (backgroundImage, balloonImage); gameplayView.BalloonPopped += HandleBalloonPopped; this.View.InsertSubview(gameplayView, 0); this.View.UserInteractionEnabled = true; if (this.viewModel != null) { // Go through and set up all of the UI! this.PlayerOneTimeElapsed.Text = viewModel.PlayerTime1; this.PlayerOnePlayerNameLabel.Text = viewModel.PlayerName1; IOSUtilities.SetImageFromStream(PopPicImageCache.GetUserProfileImage( this.viewModel.model.GameRequesterId, this.viewModel.PlayerProfileImage1), this.PlayerOneProfilePictureImage, this); this.PlayerTwoTimeElapsed.Text = viewModel.PlayerTime2; this.PlayerTwoPlayerNameLabel.Text = viewModel.PlayerName2; IOSUtilities.SetImageFromStream(PopPicImageCache.GetUserProfileImage( this.viewModel.model.GameResponderId, this.viewModel.PlayerProfileImage2), this.PlayerTwoProfilePictureImage, this); this.viewModel.Tick += (object sender, bool e) => { InvokeOnMainThread(() => { this.PlayerOneTimeElapsed.Text = viewModel.PlayerTime1; this.PlayerTwoTimeElapsed.Text = viewModel.PlayerTime2; }); }; this.timer = NSTimer.CreateRepeatingScheduledTimer(TimeSpan.FromMilliseconds(40), delegate { this.viewModel.TickExternal(); }); } }
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(); }; }
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); } }); }
void startStopPushed(object sender, EventArgs ea) { if (!weAreRecording) { var screenSize = UIScreen.MainScreen.Bounds; var screenWidth = screenSize.Width; var screenHeight = screenSize.Height; var time = 16; timer = NSTimer.CreateRepeatingScheduledTimer(TimeSpan.FromSeconds(1.0), delegate { time -= 1; if (time >= 10) { timerLabel.Text = "00:" + time.ToString(); } else { timerLabel.Text = "00:0" + time.ToString(); } if (time == 0) { StopRecording(); } }); timer.Fire(); var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); var library = System.IO.Path.Combine(documents, "..", "Library"); var urlpath = System.IO.Path.Combine(library, "Report.mov"); url = new NSUrl(urlpath, false); NSFileManager manager = new NSFileManager(); NSError error = new NSError(); if (manager.FileExists(urlpath)) { Console.WriteLine("Deleting File"); manager.Remove(urlpath, out error); Console.WriteLine("Deleted File"); } AVCaptureFileOutputRecordingDelegate avDel = new MyRecordingDelegate(cameraView, this, Element); output.StartRecordingToOutputFile(url, avDel); Console.WriteLine(urlpath); weAreRecording = true; btnStartRecording.SetImage(UIImage.FromFile("captureButton_red.png"), UIControlState.Normal); timer.Fire(); View.AddSubview(timerLabel); } //we were already recording. Stop recording else { StopRecording(); } }
// set up our game timer void setupGameTimer() { gameTimer = NSTimer.CreateRepeatingScheduledTimer(TimeSpan.FromSeconds(1.0), delegate { startTimerCountDown(); }); }
//----------------------------------------------------------------------------------------------------------------------- static public void RestartUpdateTimer() { StopUpdateTimer(); updateTimer = NSTimer.CreateRepeatingScheduledTimer(0.1, delegate { lastUpdateTimerCallback?.Invoke(); }); }
public override void ViewDidLoad() { base.ViewDidLoad(); //any additional setup after loading the view, typically from a nib. timer = NSTimer.CreateRepeatingScheduledTimer(TimeSpan.FromSeconds(1), oneSecondTimerShot); }