Beispiel #1
0
        private void _cmbNetworkPrinters_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_ckNetworkEnabled.Checked && _btnSave.Enabled)
            {
                DialogResult dlgRes = MessageBox.Show("Printer Settings Changed\nDo you want to save them?", _strTittle, MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                if (dlgRes == DialogResult.Yes)
                {
                    _btnSave.PerformClick();
                }
            }

            _btnSave.Enabled = false;

            if (_printer == null || String.IsNullOrEmpty(_cmbNetworkPrinters.SelectedItem.ToString()) ||
                (_printer.PrinterName == _cmbNetworkPrinters.SelectedItem.ToString()))
            {
                return;
            }

            _printer.Dispose();

            _printer = new Printer(_cmbNetworkPrinters.SelectedItem.ToString());

            _ckNetworkEnabled.Checked = _printer.EnableNetworkPrinting;
            _ckSharePrinter.Checked   = PrinterConfiguration.IsPrinterShared(_printer.PrinterName);
            _ckNetworkEnabled_CheckedChanged(null, null);
        }
Beispiel #2
0
        private void FillLeadtoolsPrintersList(string strDefault, bool bDefaultEnable)
        {
            string setupPrinter = string.Empty;

#if LTV20_CONFIG
            if (Is64Bit())
            {
                setupPrinter = "LEADTOOLS 20 .NET Network Printer 64-bit";
            }
            else
            {
                setupPrinter = "LEADTOOLS 20 .NET Network Printer 32-bit";
            }
#endif

            if (!string.IsNullOrEmpty(strDefault))
            {
                setupPrinter = strDefault;
            }

            try
            {
                _cmbNetworkPrinters.Items.Clear();
                _cmbNetworkPrinters.Items.AddRange(PrintingUtilities.GetLeadtoolsPrintersList());

                if (_cmbNetworkPrinters.Items.Count > 0)
                {
                    _cmbNetworkPrinters.SelectedIndex = 0;

                    for (int i = 0; i < _cmbNetworkPrinters.Items.Count; i++)
                    {
                        if ((_cmbNetworkPrinters.Items[i] as string).ToLower() == setupPrinter.ToLower())
                        {
                            _cmbNetworkPrinters.SelectedIndex = i;
                        }
                    }

                    _printer = new Printer(_cmbNetworkPrinters.SelectedItem.ToString());

                    if (bDefaultEnable)
                    {
                        _printer.EnableNetworkPrinting = true;
                        _ckNetworkEnabled.Checked      = true;
                    }
                    else
                    {
                        _ckNetworkEnabled.Checked = _printer.EnableNetworkPrinting;
                        _ckSharePrinter.Checked   = PrinterConfiguration.IsPrinterShared(_printer.PrinterName);
                    }
                }
                else
                {
                    string errorMessage = "No printers are available.";
                    MessageBox.Show(errorMessage, _strTittle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            catch (Exception Ex)
            {
                MessageBox.Show(Ex.ToString(), _strTittle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }