示例#1
0
 void IWindowFrameBackend.Dispose(bool disposing)
 {
     if (disposing)
     {
         Messaging.void_objc_msgSend(this.Handle, closeSel.Handle);
     }
 }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
 void IWindowFrameBackend.Dispose()
 {
     disposing = true;
     try {
         Messaging.void_objc_msgSend(this.Handle, closeSel.Handle);
     } finally {
         disposing = false;
     }
 }
示例#5
0
 protected virtual bool SizeToFit(NSView view)
 {
     if (view.RespondsToSelector(sizeToFitSel))
     {
         Messaging.void_objc_msgSend(view.Handle, sizeToFitSel.Handle);
         return(true);
     }
     return(false);
 }
示例#6
0
 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);
 }
示例#7
0
        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);
        }
示例#8
0
 void IDisposable.Dispose()
 {
     Messaging.void_objc_msgSend(this.Handle, closeSel.Handle);
 }