// does the update method private void button1_Click(object sender, EventArgs e) { try { CBOItem printerInfo = (CBOItem)cboPrinters.SelectedItem; string selectedPrinterID = printerInfo.Value; //if (txtNewName.Text == string.Empty) throw new Exception("Need new name"); if (lblNewDefaultDisplayName.Text == string.Empty) { throw new Exception("Need new display name"); } var gcpService = new GoogleCloudPrintService(serviceAccount, P12FileLocation, P12Secret, ThisProgramName, GoogleCloudPrintService.CallingProgramConstants.Desktop); GoogleCloudPrint.Model.UnregisteredCloudPrinter pReg = new GoogleCloudPrint.Model.UnregisteredCloudPrinter(); // fill printer object to rename //pReg.name = txtNewName.Text; pReg.default_display_name = lblNewDefaultDisplayName.Text; pReg.id = selectedPrinterID; gcpService.UpdatePrinter(pReg); GetPrinters(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnRegister_Click(object sender, EventArgs e) { this.Text = "trying to register printer"; var gcpService = new GoogleCloudPrintService(serviceAccount, P12FileLocation, P12Secret, ThisProgramName, GoogleCloudPrintService.CallingProgramConstants.Desktop); GoogleCloudPrint.Model.UnregisteredCloudPrinter pReg = new GoogleCloudPrint.Model.UnregisteredCloudPrinter(); // fill printer object to register pReg.name = txtName.Text; pReg.default_display_name = txtDefault_display_name.Text; pReg.proxy = txtProxy.Text; pReg.tag = txtTag.Text; pReg.capabilities = txtCapabilities.Text; pReg = gcpService.RegisterPrinter(pReg); if (pReg.id == "failure") { MessageBox.Show("Failure" + CRLF + pReg.name + CRLF + pReg.description); this.Text = "failure :( "; } else { this.Text = "Success!!!"; } }