void IWindowFrameBackend.Dispose(bool disposing) { if (disposing) { Messaging.void_objc_msgSend(this.Handle, closeSel.Handle); } }
static NSImage LoadStockIcon(string id) { switch (id) { case StockIconId.ZoomIn: return(NSImageFromResource("zoom-in-16.png")); case StockIconId.ZoomOut: return(NSImageFromResource("zoom-out-16.png")); } NSImage image = null; IntPtr iconRef; var type = Util.ToIconType(id); if (type != 0 && GetIconRef(-32768 /*kOnSystemDisk*/, 1835098995 /*kSystemIconsCreator*/, type, out iconRef) == 0) { try { var alloced = Messaging.IntPtr_objc_msgSend(cls_NSImage, sel_alloc); image = (NSImage)Runtime.GetNSObject(Messaging.IntPtr_objc_msgSend_IntPtr(alloced, sel_initWithIconRef, iconRef)); // NSImage (IntPtr) ctor retains, but since it is the sole owner, we don't want that Messaging.void_objc_msgSend(image.Handle, sel_release); } finally { ReleaseIconRef(iconRef); } } return(image); }
static NSImage LoadStockIcon(string id, IconSize size) { NSImage image = null; switch (id) { case StockIcons.ZoomIn: image = FromResource("magnifier-zoom-in.png"); break; case StockIcons.ZoomOut: image = FromResource("magnifier-zoom-out.png"); break; } IntPtr iconRef; var type = Util.ToIconType(id); if (type != 0 && GetIconRef(-32768 /*kOnSystemDisk*/, 1835098995 /*kSystemIconsCreator*/, type, out iconRef) == 0) { try { image = new NSImage(Messaging.IntPtr_objc_msgSend_IntPtr(Messaging.IntPtr_objc_msgSend(cls_NSImage, sel_alloc), sel_initWithIconRef, iconRef)); // NSImage (IntPtr) ctor retains, but since it is the sole owner, we don't want that Messaging.void_objc_msgSend(image.Handle, sel_release); } finally { ReleaseIconRef(iconRef); } } if (image != null) { image.Size = Util.ToIconSize(size); } return(image); }
void IWindowFrameBackend.Dispose() { disposing = true; try { Messaging.void_objc_msgSend(this.Handle, closeSel.Handle); } finally { disposing = false; } }
protected virtual bool SizeToFit(NSView view) { if (view.RespondsToSelector(sizeToFitSel)) { Messaging.void_objc_msgSend(view.Handle, sizeToFitSel.Handle); return(true); } return(false); }
public void SizeToFit() { if (Child.RespondsToSelector(sizeToFitSel)) { Messaging.void_objc_msgSend(Child.Handle, sizeToFitSel.Handle); } else { throw new NotSupportedException(); } Frame = new System.Drawing.RectangleF(Frame.X, Frame.Y, Child.Frame.Width, Child.Frame.Height); }
protected override void Dispose(bool disposing) { if (!disposed && disposing) { this.disposing = true; try { if (VisibilityEventsEnabled() && ContentView != null) { ContentView.RemoveObserver(this, HiddenProperty); } // HACK: Xamarin.Mac/MonoMac limitation: no direct way to release a window manually // A NSWindow instance will be removed from NSApplication.SharedApplication.Windows // only if it is being closed with ReleasedWhenClosed set to true but not on Dispose // and there is no managed way to tell Cocoa to release the window manually (and to // remove it from the active window list). // see also: https://bugzilla.xamarin.com/show_bug.cgi?id=45298 // WORKAROUND: // bump native reference count by calling DangerousRetain() // base.Dispose will now unref the window correctly without crashing #if MONOMAC Messaging.void_objc_msgSend(this.Handle, retainSel.Handle); #else DangerousRetain(); #endif // tell Cocoa to release the window on Close ReleasedWhenClosed = true; // Close the window (Cocoa will do its job even if the window is already closed) Messaging.void_objc_msgSend(this.Handle, closeSel.Handle); } finally { this.disposing = false; this.disposed = true; } } if (controller != null) { controller.Dispose(); controller = null; } base.Dispose(disposing); }
void IDisposable.Dispose() { Messaging.void_objc_msgSend(this.Handle, closeSel.Handle); }