static NSNotificationCenter() { IntPtr nsncClass = Class.Get("NSNotificationCenter"); Handle = Cocoa.SendIntPtr(nsncClass, sel_default_center); WINDOW_DID_ENTER_FULL_SCREEN = Cocoa.GetStringConstant(Cocoa.AppKitLibrary, "NSWindowDidEnterFullScreenNotification"); WINDOW_DID_EXIT_FULL_SCREEN = Cocoa.GetStringConstant(Cocoa.AppKitLibrary, "NSWindowDidExitFullScreenNotification"); }
internal static unsafe NSData FromBytes(byte[] bytes) { fixed(byte *ptr = bytes) { var handle = Cocoa.SendIntPtr(class_pointer, sel_data_with_bytes, (IntPtr)ptr, (ulong)bytes.LongLength); return(new NSData(handle)); } }
internal byte[] ToBytes() { var pointer = Cocoa.SendIntPtr(Handle, sel_bytes); int size = Cocoa.SendInt(Handle, sel_length); byte[] bytes = new byte[size]; Marshal.Copy(pointer, bytes, 0, size); return(bytes); }
internal static NSArray ArrayWithObjects(IntPtr[] objs) { var mutableArray = Cocoa.SendIntPtr(mutable_class_pointer, sel_array); foreach (IntPtr obj in objs) { Cocoa.SendVoid(mutableArray, sel_add_object, obj); } return(new NSArray(mutableArray)); }
internal NSArray?ReadObjectsForClasses(NSArray classArray, NSDictionary?optionDict) { var result = Cocoa.SendIntPtr(Handle, sel_read_objects_for_classes, classArray.Handle, optionDict?.Handle ?? IntPtr.Zero); return(result == IntPtr.Zero ? (NSArray?)null : new NSArray(result)); }
internal static NSPasteboard GeneralPasteboard() => new NSPasteboard(Cocoa.SendIntPtr(class_pointer, sel_general_pasteboard));
internal IntPtr ObjectAtIndex(int index) => Cocoa.SendIntPtr(Handle, sel_object_at_index, index);
internal static NSArray ArrayWithObject(IntPtr obj) => new NSArray(Cocoa.SendIntPtr(class_pointer, sel_array_with_object, obj));
static NSApplication() { IntPtr nsappClass = Class.Get("NSApplication"); Handle = Cocoa.SendIntPtr(nsappClass, sel_shared_application); }