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); }
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); }
public string?GetLocalizedName(PMPrinter printer) { if (printer is null) { throw new ArgumentNullException(nameof(printer)); } var code = PMPaperCreateLocalizedName(Handle, printer.Handle, out var name); if (code != PMStatusCode.Ok) { return(null); } return(CFString.FromHandle(name, true)); }
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); }
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); }
public PMStatusCode CreatePrinterList(out string? []?printerList, out int index, out PMPrinter?printer) { var code = PMSessionCreatePrinterList(Handle, out var array, out index, out var printerHandle); if (code != PMStatusCode.Ok) { printerList = null; printer = null; return(code); } printerList = CFArray.StringArrayFromHandle(array, true); 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); }