示例#1
0
        private void _btnAddNewPrinter_Click(object sender, EventArgs e)
        {
            try
            {
                FrmInstallPrinter frmInstallPrinter = new FrmInstallPrinter();
                DialogResult      dialogResult      = frmInstallPrinter.ShowDialog();

                if (dialogResult == DialogResult.OK)
                {
                    Cursor = Cursors.WaitCursor;
                    string newPrinterName     = _currentPrinterName = frmInstallPrinter.PrinterName;
                    string newPrinterPassword = "";

                    PrintingUtilities.InstallNewPrinter(newPrinterName, newPrinterPassword);
                    _currentPrinterName    = newPrinterName;
                    _EnableNetworkPrinting = frmInstallPrinter.EnableNetwork;

                    FillLeadtoolsPrintersList(_currentPrinterName, _EnableNetworkPrinting);
                    if (_cmbNetworkPrinters.Items.Count == 0)
                    {
                        _cmbNetworkPrinters.Enabled = false;
                        _ckNetworkEnabled.Enabled   = false;
                        _ckSharePrinter.Enabled     = false;
                        _grpPrinterSettings.Enabled = false;
                        _btnUninstall.Enabled       = false;
                    }
                    else
                    {
                        _cmbNetworkPrinters.Enabled = true;
                        _ckNetworkEnabled.Enabled   = true;
                        _ckSharePrinter.Enabled     = true;
                        _grpPrinterSettings.Enabled = true;
                        _btnUninstall.Enabled       = true;

                        _EnableNetworkPrinting = _printer.EnableNetworkPrinting;
                        _ckNetworkEnabled_CheckedChanged(null, null);

                        _ckSharePrinter.Checked = true;
                        PrinterConfiguration.SharePrinter(_cmbNetworkPrinters.SelectedItem.ToString(), _ckSharePrinter.Checked);
                    }
                }
            }
            catch (Exception Ex)
            {
                MessageBox.Show(Ex.ToString(), "LEADTOOLS Printer Demo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            finally
            {
                Cursor = Cursors.Default;
            }
        }
示例#2
0
 private void _ckSharePrinter_CheckedChanged(object sender, EventArgs e)
 {
     PrinterConfiguration.SharePrinter(_cmbNetworkPrinters.SelectedItem.ToString(), _ckSharePrinter.Checked);
 }