private void btnCalibrate_Click(object sender, EventArgs e) { SceneControlToolbarManager.SelectedPrinter = SelectedPrinter; using (var frmCalibratePrinter = new frmCalibratePrinter(SelectedPrinter)) { frmCalibratePrinter.StartPosition = FormStartPosition.CenterParent; var dialogResult = frmCalibratePrinter.ShowDialog(); if (dialogResult == DialogResult.OK) { var previousLocation = this._frmPrinterEditor.Location; var centerPointYOfParent = (this._frmPrinterEditor.Height / 2) + this._frmPrinterEditor.Top; var centerPointXOfParent = this._frmPrinterEditor.Left; this._frmPrinterEditor.Location = new Point(-100000, 100000); var frmCalibrationComplete = new frmCalibrationComplete(frmCalibratePrinter); frmCalibrationComplete.StartPosition = FormStartPosition.Manual; frmCalibrationComplete.Top = centerPointYOfParent - (frmCalibrationComplete.Height / 2); frmCalibrationComplete.Left = centerPointXOfParent; frmCalibrationComplete.ShowDialog(); this._frmPrinterEditor.Location = previousLocation; } } }
internal static AtumPrinter CalibratePrinter(string printerId, string printerName) { if (!string.IsNullOrEmpty(printerId) && !string.IsNullOrEmpty(printerName)) { var availablePrinters = PrinterManager.AvailablePrinters; var existingPrinter = availablePrinters.Where(x => x.SerialNumber == printerId).FirstOrDefault(); if (existingPrinter != null) { //printer already available in the list Console.WriteLine(printerName + " with the serial key " + printerId + " is already exist."); } else { AtumPrinter atumPrinter = new LoctiteV10(); atumPrinter.SerialNumber = printerId; atumPrinter.DisplayName = printerName; atumPrinter.SetDefaultPrinterResolution(AtumPrinter.PrinterXYResolutionType.Micron100); (atumPrinter as LoctiteV10).CalcDefaultTrapezoidValues(); atumPrinter.ID = Guid.NewGuid().ToString().ToUpper(); PrinterManager.AvailablePrinters.Add(atumPrinter); PrinterManager.Save(); Console.WriteLine(printerName + " added successfully."); } } else { Console.WriteLine("PrinterId and PrinterName must be provided."); return(null); } var selectedPrinter = PrinterManager.AvailablePrinters.Where(x => x.SerialNumber == printerId).FirstOrDefault(); var printerCalibrationDialog = new frmCalibratePrinter(selectedPrinter); printerCalibrationDialog.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; var result = printerCalibrationDialog.ShowDialog(); PrinterManager.Save(); return(selectedPrinter); }