Esempio n. 1
0
        public PMStatusCode CreatePrinterList(out string [] printerList, out int index, out PMPrinter printer)
        {
            IntPtr array, printerHandle;
            var    code = PMSessionCreatePrinterList(handle, out array, out index, out printerHandle);

            if (code != PMStatusCode.Ok)
            {
                printerList = null;
                printer     = null;
                return(code);
            }

            printerList = NSArray.StringArrayFromHandle(array);
            CFObject.CFRelease(array);
            if (printerHandle != IntPtr.Zero)
            {
                // Now get the printer, we do not own it, so retain.
                printer = new PMPrinter(printerHandle, owns: false);
            }
            else
            {
                printer = null;
            }

            return(PMStatusCode.Ok);
        }
Esempio n. 2
0
        public static PMStatusCode TryCreate(out PMPrinter printer)
        {
            IntPtr value;
            var    code = PMCreateGenericPrinter(out value);

            if (code == PMStatusCode.Ok)
            {
                printer = new PMPrinter(value, owns: true);
                return(PMStatusCode.Ok);
            }
            printer = null;
            return(code);
        }
Esempio n. 3
0
        public string GetLocalizedName(PMPrinter printer)
        {
            if (printer == null)
            {
                throw new ArgumentNullException(nameof(printer));
            }
            IntPtr name;
            var    code = PMPaperCreateLocalizedName(handle, printer.handle, out name);

            if (code != PMStatusCode.Ok)
            {
                return(null);
            }
            var str = CFString.FetchString(name);

            CFObject.CFRelease(name);
            return(str);
        }
Esempio n. 4
0
        public static PMStatusCode CreatePrinterList(out PMPrinter [] printerList)
        {
            IntPtr arr;
            var    code = PMServerCreatePrinterList(IntPtr.Zero /* ServerLocal */, out arr);

            if (code != PMStatusCode.Ok)
            {
                printerList = null;
                return(code);
            }
            int c = (int)CFArray.GetCount(arr);

            printerList = new PMPrinter [c];
            for (int i = 0; i < c; i++)
            {
                printerList [i] = new PMPrinter(CFArray.CFArrayGetValueAtIndex(arr, i), owns: false);
            }

            CFObject.CFRelease(arr);
            return(PMStatusCode.Ok);
        }