public GraphicsHandler(NSView view) { this.view = view; graphicsContext = NSGraphicsContext.FromWindow(view.Window); graphicsContext = graphicsContext.IsFlipped ? graphicsContext : NSGraphicsContext.FromGraphicsPort(graphicsContext.GraphicsPortHandle, true); disposeContext = true; Control = graphicsContext.GraphicsPort; view.PostsFrameChangedNotifications = true; AddObserver(NSView.FrameChangedNotification, FrameDidChange, view); // if control is in a scrollview, we need to trap when it's scrolled as well var parent = view.Superview; while (parent != null) { var scroll = parent as NSScrollView; if (scroll != null) { scroll.ContentView.PostsBoundsChangedNotifications = true; AddObserver(NSView.BoundsChangedNotification, FrameDidChange, scroll.ContentView); } parent = parent.Superview; } SetDefaults(); InitializeContext(view.IsFlipped); }
public GraphicsHandler(NSView view, Control ctl) { this.view = view; #if OSX graphicsContext = NSGraphicsContext.FromWindow(view.Window); disposeContext = true; Control = graphicsContext.GraphicsPort; this.Flipped = view.IsFlipped; #elif IOS this.Control = UIGraphics.GetCurrentContext(); this.Flipped = view != null && view.Layer != null && !view.Layer.GeometryFlipped; #endif Control.InterpolationQuality = CGInterpolationQuality.High; Control.SetAllowsSubpixelPositioning(false); Control.SaveState(); #if OSX view.PostsFrameChangedNotifications = true; AddObserver(NSView.FrameChangedNotification, FrameDidChange, view); // if control is in a scrollview, we need to trap when it's scrolled as well var parent = view.Superview; while (parent != null) { var scroll = parent as NSScrollView; if (scroll != null) { scroll.ContentView.PostsBoundsChangedNotifications = true; AddObserver(NSView.BoundsChangedNotification, FrameDidChange, scroll.ContentView); } parent = parent.Superview; } SetViewClip(); #endif }