示例#1
0
        /// <summary>
        /// Start editing a cell in a given row and column. Yeah, the name is a little off.
        /// </summary>
        /// <param name="table">The <see cref=">NSTable"/> in which the edit operation is to occur.</param>
        /// <param name="column">The column number of the cell to edit.</param>
        /// <param name="row">The row number of the cell to edit.</param>
        internal static void EditColumn(this NSTableView table, nint column, nint row)
        {
            NSApplication.EnsureUIThread();
#if __UNIFIED__
            void_objc_msgSend_nint_nint_IntPtr_bool(table.Handle, SelEditColumnRowWithEventSelectHandle, column, row, System.IntPtr.Zero, true);
#else
            Messaging.void_objc_msgSend_int_int_IntPtr_bool(table.Handle, SelEditColumnRowWithEventSelectHandle, column, row, System.IntPtr.Zero, true);
#endif // __UNIFIED__
        }
示例#2
0
 public static void Test()
 {
     try {
         exception_thrown = false;
         NSApplication.EnsureUIThread();
     } catch (AppKitThreadAccessException) {
         exception_thrown = true;
     } finally {
         mre.Set();
     }
 }
示例#3
0
        public static bool CanReadItemWithDataConformingToTypes(this NSPasteboard pasteboard, NSString[] utiTypes)
        {
            NSApplication.EnsureUIThread();
            if (utiTypes == null)
            {
                throw new ArgumentNullException(nameof(utiTypes));
            }
            NSArray nSArray = NSArray.FromNSObjects(utiTypes);
            bool    result  = Messaging.bool_objc_msgSend_IntPtr(pasteboard.Handle, selCanReadItemWithDataConformingToTypes_Handle, nSArray.Handle);

            nSArray.Dispose();
            return(result);
        }
示例#4
0
        public void EnsureUIThreadException()
        {
            // works on main/ui thread
            NSApplication.EnsureUIThread();

            ThreadPool.QueueUserWorkItem((v) => Tester.Test());
            Assert.IsTrue(Tester.mre.WaitOne(TimeSpan.FromSeconds(10)), "Successful wait");
            // The UI thread check only happens for debug builds, on release build it's linked away.
#if DEBUG
            var expected_ex_thrown = true;
#else
            var expected_ex_thrown = false;
#endif
            Assert.AreEqual(expected_ex_thrown, Tester.exception_thrown, "Success");
        }
示例#5
0
    public NSToolbarItemGroup(string itemIdentifier)
        : base(NSObjectFlag.Empty)
    {
        NSApplication.EnsureUIThread();
        if (itemIdentifier == null)
        {
            throw new ArgumentNullException(nameof(itemIdentifier));
        }
        IntPtr nsitemIdentifier = NSString.CreateNative(itemIdentifier);

        InitializeHandle(
            IsDirectBinding
                                ? IntPtr_objc_msgSend_IntPtr(Handle, s_selInitWithItemIdentifierHandle, nsitemIdentifier)
                                : IntPtr_objc_msgSendSuper_IntPtr(SuperHandle, s_selInitWithItemIdentifierHandle, nsitemIdentifier),
            "initWithItemIdentifier:");
        NSString.ReleaseNative(nsitemIdentifier);
    }
示例#6
0
        public static void Test()
        {
            try {
                NSApplication.EnsureUIThread();
#if !DEBUG
                success = true;
#endif
            }
            catch (AppKitThreadAccessException) {
#if DEBUG
                success = true;
#endif
            }
            catch {
            }
            finally {
                mre.Set();
            }
        }
示例#7
0
        static void Main(string[] args)
        {
            NSApplication.Init();

            Test.EnsureLinker(true);

            // works on main/ui thread
            NSApplication.EnsureUIThread();

            Tester.mre = new ManualResetEvent(false);
            ThreadPool.QueueUserWorkItem((v) => Tester.Test());
            Tester.mre.WaitOne();
            Test.Log.WriteLine("{0}\tEnsureUIThread {1} on non-ui thread: {2}", Tester.success ? "[PASS]" : "[FAIL]",
#if DEBUG
                               "enabled",
#else
                               "disabled",
#endif
                               Tester.success);
            Test.Terminate();
        }
示例#8
0
 public static NSColor NSColorFromCGColor(CGColor cgColor)
 {
     NSApplication.EnsureUIThread();
     return(Messaging.GetNSObject <NSColor>(Messaging.IntPtr_objc_msgSend_IntPtr(NSColorClassPtr, selColorWithCGColor, cgColor.Handle)));
 }