Пример #1
0
        void CreateNativeWindow(WindowClass @class, WindowAttributes attrib, Rect r)
        {
            Debug.Print("Creating window...");

            OSStatus err = API.CreateNewWindow(@class, attrib, ref r, out WinHandle);

            API.CheckReturn(err);
            Debug.Print("Created window " + WinHandle.ToString());

            IntPtr titleCF = CF.CFSTR(title);

            Debug.Print("Setting window title: {0},   CFstring : {1},  Text : {2}", WinHandle, titleCF, title);
            API.SetWindowTitleWithCFString(WinHandle, titleCF);

            SetLocation(r.X, r.Y);
            SetSize(r.Width, r.Height);
            LoadSize();

            Rect titleSize = API.GetWindowBounds(WinHandle, WindowRegionCode.TitleBarRegion);

            mTitlebarHeight = titleSize.Height;
            Debug.Print("Titlebar size: {0}", titleSize);
            ConnectEvents();
            Debug.Print("Attached window events.");
        }
Пример #2
0
 private void RegisterHIDCallbacks(IntPtr hidmanager)
 {
     HIDInput.NativeMethods.IOHIDManagerRegisterDeviceMatchingCallback(hidmanager, this.HandleDeviceAdded, IntPtr.Zero);
     HIDInput.NativeMethods.IOHIDManagerRegisterDeviceRemovalCallback(hidmanager, this.HandleDeviceRemoved, IntPtr.Zero);
     HIDInput.NativeMethods.IOHIDManagerScheduleWithRunLoop(hidmanager, this.RunLoop, this.InputLoopMode);
     HIDInput.NativeMethods.IOHIDManagerSetDeviceMatching(hidmanager, this.DeviceTypes.Ref);
     HIDInput.NativeMethods.IOHIDManagerOpen(hidmanager, IntPtr.Zero);
     int num = (int)CF.CFRunLoopRunInMode(this.InputLoopMode, 0.0, true);
 }
Пример #3
0
        IntPtr GetPasteboard()
        {
            if (pbStr == IntPtr.Zero)
            {
                pbStr = CF.CFSTR("com.apple.pasteboard.clipboard");
                utf16 = CF.CFSTR("public.utf16-plain-text");
                utf8  = CF.CFSTR("public.utf8-plain-text");
            }

            IntPtr   pbRef;
            OSStatus err = API.PasteboardCreate(pbStr, out pbRef);

            if (err != OSStatus.NoError)
            {
                throw new MacOSException(err, "Creating Pasteboard reference.");
            }
            API.PasteboardSynchronize(pbRef);
            return(pbRef);
        }