public void CountFrom(nfloat startValue, nfloat endValue, double duration) { startingValue = startValue; destinationValue = endValue; if (timer != null) { timer.Invalidate(); timer = null; } if (duration == 0) { SetTextValue(endValue); //Complete(); return; } progress = 0; totalTime = duration; lastUpdate = NSDate.Now.SecondsSinceReferenceDate; timer = CADisplayLink.Create(UpdateValue); timer.FrameInterval = 2; timer.AddToRunLoop(NSRunLoop.Main, NSRunLoopMode.Default); timer.AddToRunLoop(NSRunLoop.Main, NSRunLoopMode.UITracking); }
/// <summary> /// Starts the updating meter. /// </summary> private void StartUpdatingMeter() { if (mmeterUpdateDisplayLink != null) { mmeterUpdateDisplayLink.Invalidate(); } mmeterUpdateDisplayLink = CADisplayLink.Create(UpdateMeters); mmeterUpdateDisplayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoopMode.Common); }
public CADisplayLinkTimeSource (iPhoneOSGameView view, int frameInterval) { this.view = view; if (displayLink != null) displayLink.Invalidate (); displayLink = CADisplayLink.Create (this, selRunIteration); displayLink.FrameInterval = frameInterval; displayLink.Paused = true; }
protected override void Dispose(bool disposing) { // stop the render loop if (_displayLink != null) { _displayLink.Invalidate(); _displayLink.Dispose(); _displayLink = null; } base.Dispose(disposing); }
public CADisplayLinkTimeSource(iOSGameView view, int preferredFramesPerSecond) { this.view = view; if (displayLink != null) { displayLink.Invalidate(); } displayLink = CADisplayLink.Create(this, selRunIteration); displayLink.PreferredFramesPerSecond = preferredFramesPerSecond; displayLink.Paused = true; }
protected override void Dispose(bool disposing) { displayLink.Invalidate(); motionManager.StopDeviceMotionUpdates(); base.Dispose(disposing); }
private void PlayerStatusDidChange(NSObject arg0, NSObject arg1, NSDictionary <NSString, NSObject> arg2) { System.Diagnostics.Debug.WriteLine(_Player.Status); System.Diagnostics.Debug.WriteLine(_Player.TimeControlStatus); System.Diagnostics.Debug.WriteLine("======================="); switch (_Player.TimeControlStatus) { case AVPlayerTimeControlStatus.Playing: if (_PlayerStatus != PlayerStatus.Playing) { _PlayerStatus = PlayerStatus.Playing; _DisplayLink = CADisplayLink.Create(UpdateDisplay); _DisplayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoopMode.Default); } break; case AVPlayerTimeControlStatus.Paused: _DisplayLink?.Invalidate(); _DisplayLink = null; break; default: break; } UpdateToolbarButtons(); }
partial void DoEnableRenderLoop(bool enable) { // stop the render loop if (!enable) { if (displayLink != null) { displayLink.Invalidate(); displayLink.Dispose(); displayLink = null; } return; } // only start if we haven't already if (displayLink != null) { return; } // create the loop displayLink = CADisplayLink.Create(delegate { // redraw the view glView?.BeginInvokeOnMainThread(() => glView?.Display()); // stop the render loop if it has been disabled or the views are disposed if (glView == null || !EnableRenderLoop) { DoEnableRenderLoop(false); } }); displayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoop.NSDefaultRunLoopMode); }
public void Stop() { if (timer != null) { Running = false; timer.Invalidate(); } }
public void Dispose() { if (link != null) { link.Invalidate(); link = null; } }
void StopDisplayLink() { if (displayLink != null) { displayLink.Invalidate(); displayLink = null; } }
/// <summary> /// Plaies the action. /// </summary> /// <param name="item">Item.</param> /// <param name="args">Arguments.</param> private void PlayAction(object item, EventArgs args) { m_oldSessionCategory = AVAudioSession.SharedInstance().Category; AVAudioSession.SharedInstance().SetCategory(AVAudioSessionCategory.Playback); // m_audioPlayer = AVAudioPlayer.FromUrl(NSUrl.FromFilename(m_recordingFilePath)); m_audioPlayer.WeakDelegate = this; m_audioPlayer.MeteringEnabled = true; m_audioPlayer.PrepareToPlay(); m_audioPlayer.Play(); //UI Update { this.SetToolbarItems(new UIBarButtonItem[] { m_pauseButton, m_flexItem1, m_recordButton, m_flexItem2, m_trashButton }, true); this.ShowNavigationButton(false); m_recordButton.Enabled = false; m_trashButton.Enabled = false; } //Start regular update { m_playerSlider.Value = (float)m_audioPlayer.CurrentTime; m_playerSlider.MaxValue = (float)m_audioPlayer.Duration; m_viewPlayerDuration.Frame = this.NavigationController.NavigationBar.Bounds; m_labelCurrentTime.Text = NSStringExtensions.TimeStringForTimeInterval(m_audioPlayer.CurrentTime); m_labelRemainingTime.Text = NSStringExtensions.TimeStringForTimeInterval((m_ShouldShowRemainingTime) ? (m_audioPlayer.Duration - m_audioPlayer.CurrentTime): m_audioPlayer.Duration); m_viewPlayerDuration.SetNeedsLayout(); m_viewPlayerDuration.LayoutIfNeeded(); this.NavigationItem.TitleView = m_viewPlayerDuration; if (mplayProgressDisplayLink != null) { mplayProgressDisplayLink.Invalidate(); } mplayProgressDisplayLink = CADisplayLink.Create(UpdatePlayProgress); mplayProgressDisplayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoopMode.Common); } }
public void StopAnimation() { if (animating) { displayLink.Invalidate(); displayLink = null; animating = false; } }
void InvalidatesScrollTimer() { if (timer != null) { timer.Invalidate(); timer = null; } scrollingDirection = ScrollingDirection.Unknown; }
protected override void Dispose(bool disposing) { base.Dispose(disposing); if (_Player != null) { _Player.Pause(); _Player = null; } _DisplayLink.Invalidate(); }
public void StopRendering() { if (!_isRendering) { return; } _displayLink.Invalidate(); _displayLink = null; DestroyFrameBuffer(); _isRendering = false; }
private void Stop() { foreach (var openingCell in _openingCells) { openingCell.Layer.AppendShadow(); } _openingCells.Clear(); _keyDuration = 0; // ISSUE: reference to a compiler-generated method _displayLink?.Invalidate(); }
public void StopAnimating() { if (!IsAnimating) { return; } displayLink.Invalidate(); displayLink = null; DestroyFrameBuffer(); IsAnimating = false; }
void addInputTraitsObservers() { // note that KVO doesn't work on textDocumentProxy, so we have to poll if (traitPollingTimer != null) { traitPollingTimer.Invalidate(); } traitPollingTimer = UIScreen.MainScreen.CreateDisplayLink(() => pollTraits()); if (traitPollingTimer != null) { traitPollingTimer.AddToRunLoop(NSRunLoop.Current, mode: NSRunLoopMode.Default); } //Console.WriteLine("addInputTraitsObservers done"); }
private void Stop() { foreach (var cell in openingCells) { if (enableShadow) { cell.Layer.AppendShadow(); } } openingCells.Clear(); keyDuration = 0; if (displayLink != null) { displayLink.Invalidate(); } }
private bool PerformPendingExit() { if (!_isExitPending) { return(false); } _isExitPending = false; if (_displayLink != null) { _displayLink.Invalidate(); _displayLink.Dispose(); _displayLink = null; } UIApplication.SharedApplication.SetStatusBarHidden(false, UIStatusBarAnimation.Fade); if (_viewController != null) { _viewController.InterfaceOrientationChanged -= ViewController_InterfaceOrientationChanged; _viewController.View.RemoveFromSuperview(); _viewController.View.Dispose(); _viewController.RemoveFromParentViewController(); //this might crash ventus? _viewController.Dispose(); _viewController = null; } if (_mainWindow != null) { _mainWindow.RemoveFromSuperview(); _mainWindow.Dispose(); _mainWindow = null; } if (Window != null) { Window = null; } StopObservingUIApplication(); RaiseAsyncRunLoopEnded(); //this.Game=null; return(true); }
void AddProgress() { UIBezierPath pr_path = UIBezierPath.FromRoundedRect(new CGRect(pr_width / 2f, pr_width / 2f, this.Bounds.Width - pr_width, this.Bounds.Height - pr_width), (this.Bounds.Width - pr_width) / 2f); progress_layer = new CAShapeLayer { StrokeColor = COLOR_PROGRESS.CGColor, Path = pr_path.CGPath, LineWidth = pr_width, StrokeStart = 0.0f, StrokeEnd = 0.0f, FillColor = UIColor.Clear.CGColor, FillRule = CAShapeLayer.FillRuleEvenOdd }; this.Layer.AddSublayer(progress_layer); dl2 = CADisplayLink.Create(() => { if (progress_layer.StrokeEnd < progress) { progress_layer.StrokeEnd += step; if (lbl != null) { var radio = progress_layer.StrokeEnd; if (radio <= progress) { var str = (radio * 100).ToString("0.0") + "%"; lbl.Text = str; } } } else { dl2.Invalidate(); if (lbl != null) { var str = (progress * 100).ToString("0.0") + "%"; lbl.Text = str; } ChangeColor(); } }); dl2.AddToRunLoop(NSRunLoop.Current, NSRunLoopMode.Common); }
private void PlayEventHandler(object sender, EventArgs e) { UIBarButtonItem button = sender as UIBarButtonItem; if (this.laAnimation.IsAnimationPlaying) { this.ResetButton(button, highlighted: false); this.laAnimation.Pause(); } else { CADisplayLink displayLink = CADisplayLink.Create(UpdateProgressSlider); displayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoopMode.Common); this.ResetButton(button, highlighted: true); this.laAnimation.PlayWithCompletion((arg0) => { displayLink.Invalidate(); this.ResetButton(button, highlighted: false); }); } }
public void UpdatePercent(nfloat newP) { progress = newP; if (progress_layer != null) { CADisplayLink dl = null; //progress_layer.StrokeEnd = 0; progress_layer.StrokeColor = COLOR_PROGRESS.CGColor; if (lbl != null) { lbl.TextColor = COLOR_PROGRESS; } dl = CADisplayLink.Create(() => { if (progress_layer.StrokeEnd < progress) { progress_layer.StrokeEnd += step; if (lbl != null) { var radio = progress_layer.StrokeEnd; if (radio <= progress) { var str = (radio * 100).ToString("0.0") + "%"; lbl.Text = str; } } } else { dl.Invalidate(); if (lbl != null) { var str = (progress * 100).ToString("0.0") + "%"; lbl.Text = str; } ChangeColor(); } }); dl.AddToRunLoop(NSRunLoop.Current, NSRunLoopMode.Common); } }
private void StopDisplayLink() { _displayLink.Invalidate(); _displayLink = null; }
private void LongPress(UILongPressGestureRecognizer gesture) { var location = gesture.LocationInView(this); NSIndexPath indexPath = IndexPathForRowAtPoint(location); int sections = NumberOfSections(); int rows = 0; for (int i = 0; i < sections; i++) { rows += NumberOfRowsInSection(i); } // get out of here if the long press was not on a valid row or our table is empty // or the dataSource tableView:canMoveRowAtIndexPath: doesn't allow moving the row if (rows == 0 || (gesture.State == UIGestureRecognizerState.Began && indexPath == null) || (gesture.State == UIGestureRecognizerState.Ended && currentLocationIndexPath == null) || (gesture.State == UIGestureRecognizerState.Began && indexPath != null && !Source.CanMoveRow(this, indexPath))) { CancelGesture(); return; } // started if (gesture.State == UIGestureRecognizerState.Began) { var cell = this.CellAt(indexPath); draggingRowHeight = cell.Frame.Size.Height; cell.SetSelected(false, false); cell.SetHighlighted(false, false); // make an image from the pressed tableview cell UIGraphics.BeginImageContextWithOptions(cell.Bounds.Size, false, 0); cell.Layer.RenderInContext(UIGraphics.GetCurrentContext()); var cellImage = UIGraphics.GetImageFromCurrentImageContext(); UIGraphics.EndImageContext(); // create and image view that we will drag around the screen if (draggingView == null) { draggingView = new UIImageView(cellImage); AddSubview(draggingView); var rect = RectForRowAtIndexPath(indexPath); draggingView.Frame = new RectangleF(rect.X, rect.Y, draggingView.Bounds.Width, draggingView.Bounds.Height); // add drop shadow to image and lower opacity draggingView.Layer.MasksToBounds = false; draggingView.Layer.ShadowColor = UIColor.Black.CGColor; draggingView.Layer.ShadowOffset = new SizeF(0, 0); draggingView.Layer.ShadowRadius = 4.0f; draggingView.Layer.ShadowOpacity = 0.7f; draggingView.Layer.Opacity = draggingViewOpacity; // zoom image towards user UIView.BeginAnimations(@"zoom"); //draggingView.Transform = new MonoTouch.CoreGraphics.CGAffineTransform(1.1f, 1.1f,1.1f,1.1f,1.1f,1.1f); draggingView.Center = new PointF(Center.X, location.Y); UIView.CommitAnimations(); } BeginUpdates(); DeleteRows(new NSIndexPath[] { indexPath }, UITableViewRowAnimation.None); InsertRows(new NSIndexPath[] { indexPath }, UITableViewRowAnimation.None); savedObject = ((IReorder)Source).SaveObjectAndInsertBlankRowAtIndexPath(this, indexPath); currentLocationIndexPath = indexPath; initialIndexPath = indexPath; EndUpdates(); // enable scrolling for cell scrollDisplayLink = CADisplayLink.Create(ScrollTableWithCell); //scrollDisplayLink = new CADisplayLink (); //scrollDisplayLink.PerformSelector(scrollTableWithCell, //displayLinkWithTarget:self selector:@selector(scrollTableWithCell:)]; scrollDisplayLink.AddToRunLoop(NSRunLoop.Main, NSRunLoop.NSDefaultRunLoopMode); } // dragging else if (gesture.State == UIGestureRecognizerState.Changed) { // update position of the drag view // don't let it go past the top or the bottom too far if (location.Y >= 0 && location.Y <= ContentSize.Height + 30) { draggingView.Center = new PointF(Center.X, location.Y); } var rect = Bounds; // adjust rect for content inset as we will use it below for calculating scroll zones rect.Size.Height -= ContentInset.Top; location = gesture.LocationInView(this); UpdateCurrentLocation(gesture); // tell us if we should scroll and which direction var scrollZoneHeight = rect.Size.Height / 6; var bottomScrollBeginning = ContentOffset.Y + ContentInset.Top + rect.Size.Height - scrollZoneHeight; var topScrollBeginning = ContentOffset.Y + ContentInset.Top + scrollZoneHeight; // we're in the bottom zone if (location.Y >= bottomScrollBeginning) { scrollRate = (location.Y - bottomScrollBeginning) / scrollZoneHeight; } // we're in the top zone else if (location.Y <= topScrollBeginning) { scrollRate = (location.Y - topScrollBeginning) / scrollZoneHeight; } else { scrollRate = 0; } } // dropped else if (gesture.State == UIGestureRecognizerState.Ended) { var indexPathTemp = currentLocationIndexPath; // remove scrolling CADisplayLink scrollDisplayLink.Invalidate(); scrollDisplayLink = null; scrollRate = 0; // animate the drag view to the newly hovered cell UIView.Animate(0.3, new NSAction(() => { var rect = RectForRowAtIndexPath(indexPathTemp); //draggingView.Transform = CGAffineTransform.MakeIdentity(); draggingView.Frame = new RectangleF(rect.X, rect.Y, draggingView.Bounds.Width, draggingView.Bounds.Height); }), new NSAction(() => { draggingView.RemoveFromSuperview(); BeginUpdates(); DeleteRows(new NSIndexPath[] { indexPathTemp }, UITableViewRowAnimation.None); InsertRows(new NSIndexPath[] { indexPathTemp }, UITableViewRowAnimation.None); ((IReorder)Source).FinishReorderingWithObject(savedObject, indexPathTemp); // reload the rows that were affected just to be safe var visibleRows = IndexPathsForVisibleRows.ToList(); visibleRows.Remove(indexPathTemp); ReloadRows(visibleRows.ToArray(), UITableViewRowAnimation.None); EndUpdates(); currentLocationIndexPath = null; draggingView = null; })); } }
protected virtual void StopDeceleration() { link?.Invalidate(); link = null; }
protected override void Dispose(bool disposing) { displayLink?.Invalidate(); base.Dispose(disposing); }