void ConfigureCADisplayLinkForFFT() { displayLink = CADisplayLink.Create(() => { var arraysCount = arraysToPickUp; arraysToPickUp = 0; for (int j = 0; j < arraysCount; j++) { int[] yArray; samplesQueue.TryDequeue(out yArray); if (yArray == null) { return; } var xArray = new int[yArray.Length]; for (int i = 0; i < yArray.Length; i++) { xArray[i] = i; } if (surfaceDataSeries.XValues.Count == 0) { surfaceDataSeries.Append(xArray, yArray); } else { surfaceDataSeries.UpdateRangeYAt(0, yArray); } } Control.InvalidateElement(); }); displayLink.AddToRunLoop(NSRunLoop.Main, NSRunLoopMode.Common); }
void SetupRenderLoop(bool oneShot) { if (_displayLink != null) { return; } if (!oneShot && !Element.HasRenderLoop) { return; } _displayLink = CADisplayLink.Create(() => { var control = Control; var model = Element; if (control != null) { control.Display(); } if (control == null || model == null || !model.HasRenderLoop) { _displayLink.Invalidate(); _displayLink.Dispose(); _displayLink = null; } }); _displayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoop.NSDefaultRunLoopMode); }
public override void ViewDidLoad() { base.ViewDidLoad(); panningScrollView = new UIScrollView(View.Bounds) { AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight, BackgroundColor = UIColor.Blue, WeakDelegate = this, ScrollEnabled = false, AlwaysBounceVertical = false, MaximumZoomScale = 2f, }; panningScrollView.PinchGestureRecognizer.AddTarget(PinchRecognized); View.AddSubview(panningScrollView); panningImageView = new UIImageView(View.Bounds) { AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight, BackgroundColor = UIColor.Red, ContentMode = UIViewContentMode.ScaleAspectFit }; panningScrollView.AddSubview(panningImageView); scrollbarView = new ImagePanScrollBarView(View.Bounds, new UIEdgeInsets(0, 10, 50, 10)) { AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight, UserInteractionEnabled = false, }; View.AddSubview(scrollbarView); displayLink = CADisplayLink.Create(DisplayLinkUpdate); displayLink.AddToRunLoop(NSRunLoop.Main, NSRunLoop.NSRunLoopCommonModes); View.AddGestureRecognizer(new UITapGestureRecognizer(ToggleMotionBasedPan)); }
/// <summary> /// Views the did load. /// </summary> public override void ViewDidLoad() { base.ViewDidLoad(); // Perform any additional setup after loading the view, typically from a nib. UIColor color = new UIColor(0f, 0.6f, 0.8f, 1.0f); for (int i = 0; i < maxFrequencies; i++) { layers [i] = new CALayer(); layers [i].BackgroundColor = color.CGColor; layers [i].Frame = new CGRect(); View.Layer.AddSublayer(layers[i]); } superpowered = new SuperpoweredFrequencies(); displayLink = CADisplayLink.Create(onDisplayLink); displayLink.PreferredFramesPerSecond = 1; displayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoopMode.Common); bRunStop.SetTitle(runFlag ? "Stop" : "Run", UIControlState.Normal); var path = "lycka.mp3"; var sourcePath = Path.Combine(NSBundle.MainBundle.BundlePath, path); aAudioPlayer.Open1(sourcePath); //fixme - this will not generate error even if empty string passed as track path }
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(); }
private void SetupRenderLoop(bool oneShot) { // only start if we haven't already if (displayLink != null) { return; } // bail out if we are requesting something that the view doesn't want to if (!oneShot && !Element.HasRenderLoop) { return; } // create the loop displayLink = CADisplayLink.Create(() => { var formsView = Control; var nativeView = Element; // redraw the view formsView?.Display(); // stop the render loop if this was a one-shot, or the views are disposed if (formsView == null || nativeView == null || !nativeView.HasRenderLoop) { displayLink.Invalidate(); displayLink.Dispose(); displayLink = null; } }); displayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoop.NSDefaultRunLoopMode); }
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); }
public void DispatchGameLoop() { timer = CADisplayLink.Create(Gameloop); timer.FrameInterval = 1; timer.AddToRunLoop(NSRunLoop.Main, NSRunLoop.NSDefaultRunLoopMode); Running = true; }
private void SetupRenderLoop(bool oneShot) { if (this.displayLink != null || !oneShot && !this.Element.HasRenderLoop) { return; } this.displayLink = CADisplayLink.Create((Action)(() => { GLKView control = this.Control; OpenGLView element = this.Element; if (control != null) { // ISSUE: reference to a compiler-generated method control.Display(); } if (control != null && element != null && element.HasRenderLoop) { return; } // ISSUE: reference to a compiler-generated method this.displayLink.Invalidate(); this.displayLink.Dispose(); this.displayLink = (CADisplayLink)null; })); // ISSUE: reference to a compiler-generated method this.displayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoop.NSDefaultRunLoopMode); }
public void DispatchGameLoop() { mDisplayLink = CADisplayLink.Create(Game.CGameEngine.GameEngine.MainTick); //mDisplayLink.FrameInterval = 1; mDisplayLink.PreferredFramesPerSecond = 30; mDisplayLink.AddToRunLoop(NSRunLoop.Main, NSRunLoop.NSDefaultRunLoopMode); }
private CGSize showStartTimerSuccess(string description) { entryInfoView.DescriptionLabel.Text = string.Empty; entryInfoView.TimeLabel.Text = string.Empty; var attributedString = new NSMutableAttributedString(string.IsNullOrEmpty(description) ? Resources.NoDescription : description); entryInfoView.DescriptionLabel.AttributedText = attributedString; var start = DateTimeOffset.Now; var displayLink = CADisplayLink.Create(() => { var passed = DateTimeOffset.Now - start; entryInfoView.TimeLabel.Text = secondsToString(passed.Seconds); }); displayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoopMode.Default); View.AddSubview(entryInfoView); var width = ExtensionContext?.GetHostedViewMaximumAllowedSize().Width ?? 320; var frame = new CGRect(0, 0, width, 60); entryInfoView.Frame = frame; return(frame.Size); }
void ConfigureCADisplayLinkForSamples() { displayLink = CADisplayLink.Create(() => { var arraysCount = arraysToPickUp; arraysToPickUp = 0; for (int j = 0; j < arraysCount; j++) { int[] yArray; samplesQueue.TryDequeue(out yArray); if (j == 0) { if (yArray == null) { return; } var xArray = new int[yArray.Length]; for (int i = 0; i < yArray.Length; i++) { xArray[i] = lastElement++; } surfaceDataSeries.Append(xArray, yArray); } } Control.ZoomExtentsX(); Control.InvalidateElement(); }); displayLink.AddToRunLoop(NSRunLoop.Main, NSRunLoopMode.Common); }
public void Start() { if (_isDisposed) { throw new ObjectDisposedException(GetType().Name); } PrebuildFrames(); //Preload as much of the animation as possible IsRunning = true; _startTime = 0; // Start time will be set if it is equal to zero if (!_isAttachedToLooper) { #if __IOS__ //http://www.bigspaceship.com/ios-animation-intervals/ _displayLink = CADisplayLink.Create(OnFrame); //OnFrame is called when an animation frame is ready //Need to attach the _displayLink to the MainLoop (uiThread) so that the call back will be called on the UI thread //Default == normal UI updates _displayLink.AddToRunLoop(NSRunLoop.Main, NSRunLoopMode.Default); //UITracking == updates during scrolling _displayLink.AddToRunLoop(NSRunLoop.Main, NSRunLoopMode.UITracking); #else ScheduleTimer(); #endif _isAttachedToLooper = true; } }
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); }
void StartDisplayLinkIfNeeded() { if (displayLink == null) { displayLink = CADisplayLink.Create(() => CubeView.Display()); displayLink.AddToRunLoop(NSRunLoop.Main, NSRunLoop.UITrackingRunLoopMode); } }
public void StartAnimation() { if (dl == null) { dl = CADisplayLink.Create(DrawFrame); } dl.AddToRunLoop(NSRunLoop.Current, NSRunLoop.NSDefaultRunLoopMode); }
public override void Start() { if (link != null) { return; } link = CADisplayLink.Create(() => Fire?.Invoke()); link.AddToRunLoop(NSRunLoop.Current, NSRunLoop.NSRunLoopCommonModes); }
partial void OnStart() { startTime = Environment.TickCount; endTime = startTime + duration; // Take care of the first frame if rendering is already scheduled... OnUpdate(0); displayLink = CADisplayLink.Create(UpdateAnimation); displayLink.AddToRunLoop(Foundation.NSRunLoop.Main, Foundation.NSRunLoopMode.Common); }
void SetupScrollTimerInDirection(ScrollingDirection direction) { scrollingDirection = direction; if (timer == null) { timer = CADisplayLink.Create(this, new Selector("handleScroll:")); timer.AddToRunLoop(NSRunLoop.Main, NSRunLoop.NSDefaultRunLoopMode); } }
/// <summary> /// Sets up the timer for drawing the waveform if it is playing. /// </summary> private void SetupTimer() { var link = CADisplayLink.Create(() => { this.waveform.Offset = (int)(this.player.CurrentTime * this.sampleRate); BeginInvokeOnMainThread(this.canvasView.SetNeedsDisplay); }); link.AddToRunLoop(NSRunLoop.Main, NSRunLoopMode.Default); }
/// <summary> /// Starts the updating meter. /// </summary> private void StartUpdatingMeter() { if (mmeterUpdateDisplayLink != null) { mmeterUpdateDisplayLink.Invalidate(); } mmeterUpdateDisplayLink = CADisplayLink.Create(UpdateMeters); mmeterUpdateDisplayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoopMode.Common); }
void ThreadProc(object o) { _link = CADisplayLink.Create(OnUpdate); _link.AddToRunLoop(NSRunLoop.Current, NSRunLoop.NSDefaultRunLoopMode); _link.FrameInterval = _interval; NSRunLoop.Current.Run(); _threadPaused = true; }
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; }
public void StartAnimation() { if (!animating) { displayLink = CADisplayLink.Create(drawView); displayLink.FrameInterval = AnimationFrameInterval; displayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoop.NSDefaultRunLoopMode); animating = true; } }
protected virtual void InitDeceleration(CGPoint velocity) { link = CADisplayLink.Create(OnDisplayLinkLoop); decelerationVelocityX = velocity.X; decelerationVelocityY = velocity.Y; var decelerationAgility = Math.Max(Math.Abs(decelerationVelocityX), Math.Abs(decelerationVelocityY)) * DecelerationMultiplier; var decelerationTimeX = decelerationVelocityX / decelerationAgility; var decelerationTimeY = decelerationVelocityY / decelerationAgility; var ratio = Math.Abs(decelerationTimeX) / Math.Abs(decelerationTimeY); var fasterScrollingByX = Math.Abs(decelerationTimeX) > Math.Abs(decelerationTimeY); if (Math.Abs(decelerationVelocityX) > 0) { decelerationX = fasterScrollingByX ? decelerationAgility : decelerationAgility * ratio; if (decelerationVelocityX < 0) { decelerationX *= -1; } } else { decelerationX = 0; } if (Math.Abs(decelerationVelocityY) > 0) { decelerationY = fasterScrollingByX ? decelerationAgility / ratio : decelerationAgility; if (decelerationVelocityY < 0) { decelerationY *= -1; } } else { decelerationY = 0; } lastDecelerationFramePositionX = 0; lastDecelerationFramePositionY = 0; decelerationStartTime = CAAnimation.CurrentMediaTime(); link.AddToRunLoop(NSRunLoop.Current, NSRunLoop.NSDefaultRunLoopMode); }
public override void ViewDidLoad() { base.ViewDidLoad(); backgroundQueue = new DispatchQueue("com.videotimeline.backgroundqueue", false); displayLink = CADisplayLink.Create(DisplayLinkCallback); displayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoopMode.Default); displayLink.Paused = true; lastCallbackTime = 0.0; bufferSemaphore = new SemaphoreSlim(0); }
public override void ViewDidLoad() { base.ViewDidLoad(); View.BackgroundColor = UIColor.SystemPinkColor; // device init GraphicsDeviceOptions options = new GraphicsDeviceOptions(false, null, false, ResourceBindingModel.Improved); #if DEBUG options.Debug = true; #endif SwapchainSource ss = SwapchainSource.CreateUIView(this.View.Handle); SwapchainDescription scd = new SwapchainDescription( ss, width, height, PixelFormat.R32_Float, false); graphicsDevice = GraphicsDevice.CreateMetal(options); swapchain = graphicsDevice.ResourceFactory.CreateSwapchain(ref scd); factory = graphicsDevice.ResourceFactory; // resource init CreateSizeDependentResources(); VertexPosition[] quadVertices = { new VertexPosition(new Vector3(-1, 1, 0)), new VertexPosition(new Vector3(1, 1, 0)), new VertexPosition(new Vector3(-1, -1, 0)), new VertexPosition(new Vector3(1, -1, 0)) }; uint[] quadIndices = new uint[] { 0, 1, 2, 1, 3, 2 }; vertexBuffer = factory.CreateBuffer(new BufferDescription(4 * VertexPosition.SizeInBytes, BufferUsage.VertexBuffer)); indexBuffer = factory.CreateBuffer(new BufferDescription(6 * sizeof(uint), BufferUsage.IndexBuffer)); graphicsDevice.UpdateBuffer(vertexBuffer, 0, quadVertices); graphicsDevice.UpdateBuffer(indexBuffer, 0, quadIndices); commandList = factory.CreateCommandList(); viewLoaded = true; displayLink = CADisplayLink.Create(Render); displayLink.PreferredFramesPerSecond = 60; displayLink.AddToRunLoop(NSRunLoop.Main, NSRunLoop.NSDefaultRunLoopMode); }
private void SetupTimer() { if (this.updateTimer != null) { this.updateTimer.Invalidate(); this.updateTimer.Dispose(); this.updateTimer = null; } this.updateTimer = CADisplayLink.Create(this.Refresh); this.updateTimer.AddToRunLoop(NSRunLoop.Current, NSRunLoopMode.Default); }
public DisplayLinkTimer() { var link = CADisplayLink.Create(OnLinkTick); TimerThread = new Thread(() => { link.AddToRunLoop(NSRunLoop.Current, NSRunLoopMode.Common); NSRunLoop.Current.Run(); }); TimerThread.Start(); UIApplication.Notifications.ObserveDidEnterBackground((_,__) => link.Paused = true); UIApplication.Notifications.ObserveWillEnterForeground((_, __) => link.Paused = false); }
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; }