Beispiel #1
0
        /// <summary>
        /// Get Printer Info
        /// </summary>
        /// <param name="printer"></param>
        /// <returns></returns>
        public PRINTER_INFO_2 GetPrinter(Printer printer)
        {
            IntPtr pHandle;
            PRINTER_INFO_2 Info2 = new PRINTER_INFO_2();
            PRINTER_DEFAULTS defaults = new PRINTER_DEFAULTS();
            OpenPrinter(printer.Name, out pHandle, defaults);
            uint cbNeeded = 0;

            bool bRet = GetPrinter(pHandle, 2, IntPtr.Zero, 0, ref cbNeeded);
            if (cbNeeded > 0)
            {
                IntPtr pAddr = Marshal.AllocHGlobal((int)cbNeeded);
                bRet = GetPrinter(pHandle, 2, pAddr, cbNeeded, ref cbNeeded);
                if (bRet)
                {

                    Info2 = (PRINTER_INFO_2)Marshal.PtrToStructure(pAddr, typeof(PRINTER_INFO_2));
                }
                Marshal.FreeHGlobal(pAddr);

            }

            ClosePrinter(pHandle);
            return Info2;
        }
Beispiel #2
0
        public PrinterInfo(Printer printer)
        {
            tooltip = new ToolTip();
            InitializeComponent();

            info = Main.Manager.GetPrinter(printer);
        }
Beispiel #3
0
        public Main()
        {
            _man = new Manager();

            InitializeComponent();

            listPrinters.Items.AddRange(_man.Printers.ToArray());

            listPrinters.ContextMenu = PrinterListContextMenu();

            _selectedPrinter = listPrinters.Items[0] as Printer;
        }
Beispiel #4
0
 public bool SetDefaultPrinter(Printer printer)
 {
     return SetDefaultPrinter(printer.Name);
 }
Beispiel #5
0
 public bool FlushPrinter(Printer printer)
 {
     int i=0;
     var result = FlushPrinter(printer.Pointer,IntPtr.Zero,0,out i,1000);
     return result;
 }
Beispiel #6
0
 /// <summary>
 /// Open printer's properties dialog
 /// </summary>
 /// <param name="printer"></param>
 /// <returns></returns>
 public int DocumentProperty(Printer printer)
 {
     return DocumentProperties(IntPtr.Zero, printer.Pointer, printer.Name, IntPtr.Zero, IntPtr.Zero, (fModes)14);
 }
Beispiel #7
0
 private void listPrinters_SelectedIndexChanged(object sender, EventArgs e)
 {
     _selectedPrinter = ((ListBox)sender).SelectedItem as Printer;
 }