void StartDisplayLinkIfNeeded () { if (displayLink == null) { displayLink = CADisplayLink.Create (() => CubeView.Display ()); displayLink.AddToRunLoop (NSRunLoop.Main, NSRunLoop.UITrackingRunLoopMode); } }
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); }
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); }
public override void Start() { if (link != null) { return; } link = CADisplayLink.Create(() => Fire?.Invoke()); link.AddToRunLoop(NSRunLoop.Current, NSRunLoop.NSRunLoopCommonModes); }
void SetupScrollTimerInDirection(ScrollingDirection direction) { scrollingDirection = direction; if (timer == null) { timer = CADisplayLink.Create(this, new Selector("handleScroll:")); timer.AddToRunLoop(NSRunLoop.Main, NSRunLoop.NSDefaultRunLoopMode); } }
public override void ViewDidLoad() { base.ViewDidLoad(); constantDataBufferIndex = 0; inflightSemaphore = new Semaphore(max_inflight_buffers, max_inflight_buffers); SetupMetal(); LoadAssets(); timer = CADisplayLink.Create(Gameloop); timer.FrameInterval = 1; #if NET timer.AddToRunLoop(NSRunLoop.Main, NSRunLoopMode.Default); #else timer.AddToRunLoop(NSRunLoop.Main, NSRunLoop.NSDefaultRunLoopMode); #endif }
/// <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 void Start () { waveBoundaryPath = new UIBezierPath (); waveLayer = new CAShapeLayer (); waveLayer.FillColor = new CGColor (0, 0, 0, 1); Layer.AddSublayer (waveLayer); waveDisplaylink = CADisplayLink.Create (() => GetCurrentWave (waveDisplaylink)); waveDisplaylink.AddToRunLoop (NSRunLoop.Main, 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 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); }
public void StartAnimating() { if (IsAnimating) return; CreateFrameBuffer(); displayLink = UIScreen.MainScreen.CreateDisplayLink(this, new Selector("drawFrame")); displayLink.FrameInterval = frameInterval; displayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoop.NSDefaultRunLoopMode); IsAnimating = true; }
public void StartRendering() { LayerColorFormat = EAGLColorFormat.RGBA8; CreateFrameBuffer(); GL.ClearColor(1, 1, 1, 1); CADisplayLink displayLink = UIScreen.MainScreen.CreateDisplayLink(this, new Selector("drawFrame")); displayLink.FrameInterval = 1; displayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoop.NSDefaultRunLoopMode); Map.ViewChanged(true); }
public void Open(LiquidFloatingCell[] cells) { Stop(); displayLink = CADisplayLink.Create(DidDisplayRefresh); displayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoopMode.Common); opening = true; foreach (var cell in cells) { cell.Layer.RemoveAllAnimations(); cell.Layer.EraseShadow(); openingCells.Add(cell); } }
public void StartAnimating() { if (IsAnimating) { return; } CreateFrameBuffer(); displayLink = UIScreen.MainScreen.CreateDisplayLink(this, new Selector("drawFrame")); displayLink.FrameInterval = frameInterval; displayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoop.NSDefaultRunLoopMode); IsAnimating = true; }
public void Close(LiquidFloatingCell[] cells) { Stop(); opening = false; displayLink = CADisplayLink.Create(DidDisplayRefresh); displayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoopMode.Common); foreach (var cell in cells) { cell.Layer.RemoveAllAnimations(); cell.Layer.EraseShadow(); openingCells.Add(cell); cell.UserInteractionEnabled = false; } }
void UpdateAnimation() { if (ShouldAnimate()) { displayLink = CADisplayLink.Create(TimerFired); displayLink.AddToRunLoop(NSRunLoop.Main, NSRunLoopMode.Common); displayLink.PreferredFramesPerSecond = 60; } else { displayLink?.Invalidate(); displayLink = null; } }
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"); }
public void Open(LiquidFloatingCell[] cells) { Stop(); _displayLink = CADisplayLink.Create(DidDisplayRefresh); _displayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoopMode.Common); _opening = true; foreach (var cell in cells) { // ISSUE: reference to a compiler-generated method cell.Layer.RemoveAllAnimations(); cell.Layer.EraseShadow(); _openingCells.Add(cell); } }
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.Display(); } }); return; } // create the loop _displayLink = CADisplayLink.Create(() => { 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.Invalidate(); _displayLink.Dispose(); _displayLink = null; return; } // redraw the view nativeView.Display(); }); _displayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoop.NSDefaultRunLoopMode); }
private void CreateDisplayLink() { if (_displayLink != null) { _displayLink.RemoveFromRunLoop(NSRunLoop.Main, NSRunLoop.NSDefaultRunLoopMode); } _displayLink = UIScreen.MainScreen.CreateDisplayLink(_viewController.View as iOSGameView, new Selector("doTick")); // FrameInterval represents how many frames must pass before the selector // is called again. We calculate this by dividing our target elapsed time by // the duration of a frame on iOS (Which is 1/60.0f at the time of writing this). _displayLink.FrameInterval = (int)Math.Round(60f * Game.TargetElapsedTime.TotalSeconds); _displayLink.AddToRunLoop(NSRunLoop.Main, NSRunLoop.NSDefaultRunLoopMode); }
public void StartRendering() { if (_isRendering) { return; } CreateFrameBuffer(); CADisplayLink displayLink = UIScreen.MainScreen.CreateDisplayLink(this, new Selector("drawFrame")); displayLink.FrameInterval = _frameInterval; displayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoop.NSDefaultRunLoopMode); _displayLink = displayLink; _isRendering = true; }
public void StartAnimating() { if (IsAnimating) { return; } base.UpdateFrame += onUpdateFrame; base.RenderFrame += onRenderFrame; IOSGameWindow.Instance.OnLoad(new EventArgs()); _displayLink = UIScreen.MainScreen.CreateDisplayLink(this, new Selector("drawFrame")); _displayLink.FrameInterval = _frameInterval; _displayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoop.NSDefaultRunLoopMode); IsAnimating = true; }
/// <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 override void MovedToWindow() { base.MovedToWindow(); var swapchainSource = SwapchainSource.CreateUIView(Handle); var swapchainDescription = new SwapchainDescription(swapchainSource, (uint)Frame.Width, (uint)Frame.Height, null, true, true); if (_backend == GraphicsBackend.Metal) { GraphicsDevice = GraphicsDevice.CreateMetal(_deviceOptions); } MainSwapchain = GraphicsDevice.ResourceFactory.CreateSwapchain(swapchainDescription); DeviceReady?.Invoke(); _displayLink = CADisplayLink.Create(HandleDisplayLinkOutputCallback); _displayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoopMode.Default); }
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 StartAnimating() { if (IsAnimating) { return; } CreateFrameBuffer(); SetupProjection(); keys.CreateTextTextures(CreateBitmapData); keys.InitModel(); keys.Start(); CADisplayLink displayLink = UIScreen.MainScreen.CreateDisplayLink(this, new Selector("drawFrame")); displayLink.FrameInterval = frameInterval; displayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoop.NSDefaultRunLoopMode); this.displayLink = displayLink; IsAnimating = true; }
private void createDisplayLinkWithScrollAmount(float scrollAmount, Action <CGPoint> updateEntryAction) { displayLink = CADisplayLink.Create(() => { if (shouldStopAutoScrollUp || shouldStopAutoScrollDown) { StopAutoScroll(); return; } var point = LastPoint; point.Y += scrollAmount; var targetOffset = CollectionView.ContentOffset; targetOffset.Y += scrollAmount; CollectionView.SetContentOffset(targetOffset, false); updateEntryAction(point); }); displayLink.PreferredFramesPerSecond = autoScrollsPerSecond; displayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoopMode.Default); }
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); } }
public override void StartRunLoop() { // Show the window _mainWindow.MakeKeyAndVisible(); BeginObservingUIApplication(); _viewController.View.BecomeFirstResponder(); //_runTimer = NSTimer.CreateRepeatingScheduledTimer(Game.TargetElapsedTime, Tick); _caDisplayLink = CADisplayLink.Create( delegate { Tick (); }); _caDisplayLink.FrameInterval = 1; _caDisplayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoop.NSDefaultRunLoopMode); }
/// <summary> /// Initialize the specified defaultMapCenter, defaultMap, defaultMapTilt and defaultMapZoom. /// </summary> /// <param name="defaultMapCenter">Default map center.</param> /// <param name="defaultMap">Default map.</param> /// <param name="defaultMapTilt">Default map tilt.</param> /// <param name="defaultMapZoom">Default map zoom.</param> public void Initialize(GeoCoordinate defaultMapCenter, Map defaultMap, Degree defaultMapTilt, float defaultMapZoom) { // register the default listener. (this as IInvalidatableMapSurface).RegisterListener(new DefaultTrigger(this)); _displayLink = CADisplayLink.Create (OnPreRender); _displayLink.AddToRunLoop (NSRunLoop.Current, NSRunLoopMode.Default); // enable all interactions by default. this.MapAllowPan = true; this.MapAllowTilt = true; this.MapAllowZoom = true; // set clip to bounds to prevent objects from being rendered/show outside of the mapview. this.ClipsToBounds = true; MapCenter = defaultMapCenter; _map = defaultMap; MapTilt = defaultMapTilt; MapZoom = defaultMapZoom; _map.MapChanged += MapChanged; _doubleTapAnimator = new MapViewAnimator(this); this.BackgroundColor = UIColor.White; this.UserInteractionEnabled = true; if (UIDevice.CurrentDevice.CheckSystemVersion(7, 0)) { var panGesture = new UIPanGestureRecognizer(Pan); panGesture.ShouldRecognizeSimultaneously += (UIGestureRecognizer r, UIGestureRecognizer other) => { return true; }; // TODO: workaround for xamarin bug, remove later! panGesture.ShouldRequireFailureOf = (a, b) => { return false; }; panGesture.ShouldBeRequiredToFailBy = (a, b) => { return false; }; this.AddGestureRecognizer(panGesture); var pinchGesture = new UIPinchGestureRecognizer(Pinch); pinchGesture.ShouldRecognizeSimultaneously += (UIGestureRecognizer r, UIGestureRecognizer other) => { return true; }; // TODO: workaround for xamarin bug, remove later! pinchGesture.ShouldRequireFailureOf = (a, b) => { return false; }; pinchGesture.ShouldBeRequiredToFailBy = (a, b) => { return false; }; this.AddGestureRecognizer(pinchGesture); var rotationGesture = new UIRotationGestureRecognizer(Rotate); rotationGesture.ShouldRecognizeSimultaneously += (UIGestureRecognizer r, UIGestureRecognizer other) => { return true; }; // TODO: workaround for xamarin bug, remove later! rotationGesture.ShouldRequireFailureOf = (a, b) => { return false; }; rotationGesture.ShouldBeRequiredToFailBy = (a, b) => { return false; }; this.AddGestureRecognizer(rotationGesture); var singleTapGesture = new UITapGestureRecognizer(SingleTap); singleTapGesture.NumberOfTapsRequired = 1; // TODO: workaround for xamarin bug, remove later! // singleTapGesture.ShouldRequireFailureOf = (a, b) => { return false; }; // singleTapGesture.ShouldBeRequiredToFailBy = (a, b) => { return false; }; var doubleTapGesture = new UITapGestureRecognizer(DoubleTap); doubleTapGesture.NumberOfTapsRequired = 2; // TODO: workaround for xamarin bug, remove later! // doubleTapGesture.ShouldRequireFailureOf = (a, b) => { return false; }; // doubleTapGesture.ShouldBeRequiredToFailBy = (a, b) => { return false; }; //singleTapGesture.RequireGestureRecognizerToFail (doubleTapGesture); this.AddGestureRecognizer(singleTapGesture); this.AddGestureRecognizer(doubleTapGesture); } else { var panGesture = new UIPanGestureRecognizer(Pan); var pinchGesture = new UIPinchGestureRecognizer(Pinch); var rotationGesture = new UIRotationGestureRecognizer(Rotate); panGesture.ShouldRecognizeSimultaneously += (UIGestureRecognizer r, UIGestureRecognizer other) => { return other != rotationGesture; }; this.AddGestureRecognizer(panGesture); pinchGesture.ShouldRecognizeSimultaneously += (UIGestureRecognizer r, UIGestureRecognizer other) => { return true; }; this.AddGestureRecognizer(pinchGesture); rotationGesture.ShouldRecognizeSimultaneously += (UIGestureRecognizer r, UIGestureRecognizer other) => { return true; }; this.AddGestureRecognizer(rotationGesture); var singleTapGesture = new UITapGestureRecognizer(SingleTap); singleTapGesture.NumberOfTapsRequired = 1; //singleTapGesture.ShouldRecognizeSimultaneously += ShouldRecognizeSimultaneouslySingle; //singleTapGesture.ShouldBeRequiredToFailBy += ShouldRecognizeSimultaneouslySingle; var doubleTapGesture = new UITapGestureRecognizer(DoubleTap); doubleTapGesture.NumberOfTapsRequired = 2; //doubleTapGesture.ShouldRecognizeSimultaneously += ShouldRecognizeSimultaneouslySingle; //doubleTapGesture.ShouldBeRequiredToFailBy += ShouldRecognizeSimultaneouslyDouble; singleTapGesture.RequireGestureRecognizerToFail(doubleTapGesture); this.AddGestureRecognizer(singleTapGesture); this.AddGestureRecognizer(doubleTapGesture); } // set scalefactor. _scaleFactor = (float)this.ContentScaleFactor; // create the cache renderer. _cacheRenderer = new MapRenderer<CGContextWrapper>( new CGContextRenderer(_scaleFactor)); _backgroundColor = SimpleColor.FromKnownColor(KnownColor.White).Value; }
/// <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); } }
/// <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 override void ViewDidLoad() { base.ViewDidLoad (); constantDataBufferIndex = 0; inflightSemaphore = new Semaphore (max_inflight_buffers, max_inflight_buffers); SetupMetal (); LoadAssets (); timer = CADisplayLink.Create (Gameloop); timer.FrameInterval = 1; timer.AddToRunLoop (NSRunLoop.Main, NSRunLoop.NSDefaultRunLoopMode); }
private void SetupDisplayLink () { _displayLink = CADisplayLink.Create (CalculateThatMesmerizingThing); _displayLink.AddToRunLoop (NSRunLoop.Current, NSRunLoopMode.Default); }
public void StartAnimation() { if(!Animating) { if(displayLinkSupported) { // CADisplayLink is API new to iPhone SDK 3.1. Compiling against earlier versions will result in a warning, but can // be dismissed. If the system version runtime check for CADisplayLink exists in the Constructor. The runtime ensure // this code will not be called in system versions earlier than 3.1. displayLink = CADisplayLink.Create(DrawView); displayLink.FrameInterval = AnimationFrameInterval; displayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoop.NSDefaultRunLoopMode); } else { animationTimer = NSTimer.CreateScheduledTimer((1.0 / 60.0) * AnimationFrameInterval, DrawView); } Animating = true; } }
public void DispatchGameLoop () { timer = CADisplayLink.Create (Gameloop); timer.FrameInterval = 1; timer.AddToRunLoop (NSRunLoop.Main, NSRunLoop.NSDefaultRunLoopMode); }
void resumeTimer() { if (_player != null) { _updateTimer = CADisplayLink.Create (this, new Selector ("_refresh")); _updateTimer.AddToRunLoop (NSRunLoop.Current, new NSString (NSRunLoop.NSDefaultRunLoopMode.ToString ())); } }
private void CreateFrameBuffer() { // Setup layer eaglLayer = (CAEAGLLayer)this.Layer; eaglLayer.Opaque = false; bool layerRetainsBacking = false; NSString layerColorFormat = EAGLColorFormat.RGBA8; eaglLayer.DrawableProperties = NSDictionary.FromObjectsAndKeys(new NSObject[] { NSNumber.FromBoolean(layerRetainsBacking), layerColorFormat }, new NSObject[] { EAGLDrawableProperty.RetainedBacking, EAGLDrawableProperty.ColorFormat }); // Create OpenGL drawing context EAGLRenderingAPI api = EAGLRenderingAPI.OpenGLES2; context = new EAGLContext(api); if (context == null) { throw new InvalidOperationException("Failed to initialize OpenGLES 2.0 context"); } if (!EAGLContext.SetCurrentContext(context)) { throw new InvalidOperationException("Failed to set current OpenGL context"); } // Create render buffer and assign it to the context GL.GenRenderbuffers(1, ref colorRenderBuffer); GL.BindRenderbuffer(All.Renderbuffer, colorRenderBuffer); context.RenderBufferStorage((uint)All.Renderbuffer, eaglLayer); // Create frame buffer uint frameBuffer = 0; GL.GenFramebuffers(1, ref frameBuffer); GL.BindFramebuffer(All.Framebuffer, frameBuffer); GL.FramebufferRenderbuffer(All.Framebuffer, All.ColorAttachment0, All.Renderbuffer, colorRenderBuffer); // Set viewport Size size = new Size((int)Math.Round((double)eaglLayer.Bounds.Size.Width), (int)Math.Round((double)eaglLayer.Bounds.Size.Height)); GL.Viewport(0, 0, size.Width, size.Height); // Create CADisplayLink for animation loop displayLink = CADisplayLink.Create(this, new Selector("render")); displayLink.FrameInterval = 1; displayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoop.NSDefaultRunLoopMode); }
public void StartAnimation () { if (!animating) { displayLink = CADisplayLink.Create (drawView); displayLink.FrameInterval = AnimationFrameInterval; displayLink.AddToRunLoop (NSRunLoop.Current, NSRunLoop.NSDefaultRunLoopMode); animating = true; } }
public void BeginAnimationWithLazyViews(ScrollingTickerLazyLoadingHandler dataSource,List<NSValue>subviewsSizes,ScrollDirection direction=ScrollDirection.FromRight, float scrollSpeed=0.0f, int loops=0,ScrollingTickerAnimationCompletition completition=null) { if (isAnimating) EndAnimation(false); lazyLoadingHandler = dataSource; animationCompletitionHandler = completition; numberOfLoops = loops; scrollViewDirection = direction; scrollViewSpeed = (scrollSpeed == 0 ? kLPScrollingAnimationPixelsPerSecond : scrollSpeed); displayLink = CADisplayLink.Create(this,new Selector("tickerDidScroll")); displayLink.AddToRunLoop(NSRunLoop.Main,NSRunLoop.NSDefaultRunLoopMode); LayoutTickerSubviewsWithItemSizes(subviewsSizes); BeginAnimation(); }
private void CreateDisplayLink() { if (_caDisplayLink != null) _caDisplayLink.RemoveFromRunLoop(NSRunLoop.Main, NSRunLoop.NSDefaultRunLoopMode); _caDisplayLink = UIScreen.MainScreen.CreateDisplayLink(_viewController.View as iOSGameView, new Selector("doTick")); // FrameInterval represents how many frames must pass before the selector // is called again. We calculate this by dividing our target elapsed time by // the duration of a frame on iOS (Which is 1/60.0f at the time of writing this). _caDisplayLink.FrameInterval = (int)Math.Round(60f * Game.TargetElapsedTime.TotalSeconds); _caDisplayLink.AddToRunLoop(NSRunLoop.Main, 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)); }