Exemplo n.º 1
0
        private void GetPrinters()
        {
            GoogleCloudPrint.Model.CloudPrinters printerCollection = GetPrinterCollection();

            List <CloudPrinter> allPrinters = new List <CloudPrinter>();

            //CloudPrinters cPrinters = GetPrinters();
            foreach (var aPrinter in printerCollection.printers)
            {
                allPrinters.Add(aPrinter);
            }

            ClearComboBox(cboPrinters);

            cboPrinters.DataSource = allPrinters;

            cboPrinters.DisplayMember = "defaultDisplayName";
            cboPrinters.ValueMember   = "id";

            cboPrinters.Text = string.Empty;

            //foreach (var printer in printerCollection.printers)
            //{
            //    //cboPrinters.Items.Add(new CBOItem(printer.defaultDisplayName, printer.id));
            //    GoogleCloudPrint.Model.CloudPrinter cpItem = new GoogleCloudPrint.Model.CloudPrinter();
            //    cpItem.defaultDisplayName = printer.defaultDisplayName;
            //    cpItem.id = printer.id;
            //    cboPrinters.Items.Add(cpItem);
            //    cboPrinters.DisplayMember = "defaultDisplayName";
            //    cboPrinters.ValueMember = "id";
            //}
        }
Exemplo n.º 2
0
        private void btnPrintDocFromName_Click(object sender, EventArgs e)
        {
            var gcpService = new GoogleCloudPrintService(serviceAccount, P12FileLocation, P12Secret, ThisProgramName, GoogleCloudPrintService.CallingProgramConstants.Desktop);

            GoogleCloudPrint.Model.CloudPrinters myPrinters = GetPrinterCollection();

            string localPrinterID = string.Empty;

            foreach (var aPrinter in myPrinters.printers)
            {
                if (aPrinter.defaultDisplayName == lblPrinterNameFromList.Text)
                {
                    localPrinterID = aPrinter.id;
                    break;
                }
            }
            byte[] docBytes = GetDocumentOnDisk();
            // note PrintJobName and MimeType come from the CONFIG file
            gcpService.PrintDocument(localPrinterID, PrintJobName, docBytes, MimeType);
        }
Exemplo n.º 3
0
        private void btnTestCapabilities_Click(object sender, EventArgs e)
        {
            var gcpService = new GoogleCloudPrintService(serviceAccount, P12FileLocation, P12Secret, ThisProgramName, GoogleCloudPrintService.CallingProgramConstants.Desktop);

            GoogleCloudPrint.Model.CloudPrinters myPrinters = GetPrinterCollection();

            string localPrinterID = string.Empty;

            foreach (var aPrinter in myPrinters.printers)
            {
                if (aPrinter.defaultDisplayName == lblPrinterNameFromList.Text)
                {
                    localPrinterID = aPrinter.id;
                    break;
                }
            }
            string content = "abc";
            // note PrintJobName and MimeType come from the CONFIG file
            string localMimeType = "text/plain";

            gcpService.PrintDocument(localPrinterID, "Title", content, localMimeType);
        }