// sets up the scrolling in the correct direction // utilizes CSDisplayLink, a timer synchronized to the display refresh rate, to execute the smooth automated scrolling private void SetupScrollTimerInDirection(ScrollingDirection direction) { if (DisplayLink != null && !DisplayLink.Paused) { var userInfo = userInfos[DisplayLink]; var scrollingDirection = userInfo[ScrollingDirectionKey]; var number = (NSNumber)NSNumber.FromObject(scrollingDirection); ScrollingDirection oldDirection = (ScrollingDirection)number.Int32Value; if (direction == oldDirection) { return; } } InvalidatesScrollTimer(); DisplayLink = CADisplayLink.Create(HandleScroll); userInfos.Add(DisplayLink, NSDictionary.FromObjectAndKey(NSNumber.FromInt32((int)direction), new NSString(ScrollingDirectionKey))); DisplayLink.AddToRunLoop(NSRunLoop.Main, NSRunLoop.NSRunLoopCommonModes); }
public override void EnterMessageLoop(bool runInBackground) { DisplayLink = CADisplayLink.Create(Window, new Selector("Render")); DisplayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoopMode.Default); NSRunLoop.Current.Run(); }