public void StopAnimation()
 {
     if (displayLink != null && displayLink.IsRunning)
     {
         displayLink.Stop();
     }
 }
Ejemplo n.º 2
0
        protected override 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;
            }

            // if this is a one shot request, don't bother with the display link
            if (oneShot)
            {
                var nativeView = Control;
                nativeView?.BeginInvokeOnMainThread(() =>
                {
                    if (nativeView.Handle != IntPtr.Zero)
                    {
                        nativeView.NeedsDisplay = true;
                    }
                });
                return;
            }

            // create the loop
            displayLink = new CVDisplayLink();
            displayLink.SetOutputCallback(delegate
            {
                var nativeView = Control;
                var formsView  = Element;

                // stop the render loop if this was a one-shot, or the views are disposed
                if (nativeView == null || formsView == null || nativeView.Handle == IntPtr.Zero || !formsView.HasRenderLoop)
                {
                    displayLink.Stop();
                    displayLink.Dispose();
                    displayLink = null;
                    return(CVReturn.Success);
                }

                // redraw the view
                nativeView?.BeginInvokeOnMainThread(() =>
                {
                    if (nativeView != null)
                    {
                        nativeView.NeedsDisplay = true;
                    }
                });

                return(CVReturn.Success);
            });
            displayLink.Start();
        }
Ejemplo n.º 3
0
 public override void Stop()
 {
     if (link == null)
     {
         return;
     }
     link?.Stop();
     link?.Dispose();
     link = null;
 }
Ejemplo n.º 4
0
        void DeAllocate()
        {
            if (_displayLink == null)
            {
                return;
            }

            _displayLink.Stop();
            _displayLink.Dispose();
            _displayLink = null;
        }
Ejemplo n.º 5
0
        protected override void Dispose(bool disposing)
        {
            // stop the render loop
            if (displayLink != null)
            {
                displayLink.Stop();
                displayLink.Dispose();
                displayLink = null;
            }

            base.Dispose(disposing);
        }
Ejemplo n.º 6
0
 protected override void Dispose(bool disposing)
 {
     if (_disposed)
     {
         return;
     }
     if (disposing)
     {
         _displayLink.Stop();
         GraphicsDevice.Dispose();
     }
     _disposed = true;
     base.Dispose(disposing);
 }
Ejemplo n.º 7
0
        public void TryTranslateTimeValidTest()
        {
            TestRuntime.AssertNotVSTS();
            TestRuntime.AssertSystemVersion(ApplePlatform.MacOSX, 12, 0);
            var outTime = new CVTimeStamp {
                Version = 0,
                Flags   = (1L << 0) | (1L << 1),               // kCVTimeStampVideoTimeValid | kCVTimeStampHostTimeValid
            };

            using var displayLink = new CVDisplayLink();
            // it has to be running else you will get a crash
            if (displayLink.Start() == 0)
            {
                displayLink.GetCurrentTime(out var timeStamp);
                Assert.True(displayLink.TryTranslateTime(timeStamp, ref outTime));
                displayLink.Stop();
            }
        }
Ejemplo n.º 8
0
 public void Stop()
 {
     if (animating)
     {
         if (displayLinkSupported)
         {
             if (displayLink != null && displayLink.IsRunning)
             {
                 displayLink.Stop();
             }
         }
         else
         {
             animationTimer.Invalidate();
             animationTimer = null;
         }
     }
     animating = false;
 }
Ejemplo n.º 9
0
        partial void DoEnableRenderLoop(bool enable)
        {
            // stop the render loop
            if (!enable)
            {
                if (displayLink != null)
                {
                    displayLink.Stop();
                    displayLink.Dispose();
                    displayLink = null;
                }
                return;
            }

            // only start if we haven't already
            if (displayLink != null)
            {
                return;
            }

            // create the loop
            displayLink = new CVDisplayLink();
            displayLink.SetOutputCallback(delegate
            {
                // redraw the view
                glView?.BeginInvokeOnMainThread(() =>
                {
                    if (glView != null)
                    {
                        glView.NeedsDisplay = true;
                    }
                });

                // stop the render loop if it has been disabled or the views are disposed
                if (glView == null || !EnableRenderLoop)
                {
                    DoEnableRenderLoop(false);
                }

                return(CVReturn.Success);
            });
            displayLink.Start();
        }
Ejemplo n.º 10
0
        protected override 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 = new CVDisplayLink();
            displayLink.SetOutputCallback(delegate
            {
                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.Stop();
                    displayLink.Dispose();
                    displayLink = null;
                }

                return(CVReturn.Success);
            });
            displayLink.Start();
        }
Ejemplo n.º 11
0
 protected override void DisableTimer()
 {
     _link?.Stop();
     _link?.Dispose();
     _link = null;
 }