Пример #1
0
        private void ControlDone(object sender, EventArgs e)
        {
            string compName = SystemInformation.ComputerName;

            if (checkSimple.Checked && !PrefC.GetBool(PrefName.EasyHidePrinters))
            {
                Printers.ClearAll();
                Printers.RefreshCache();
                string printerName = "";
                if (comboDefault.SelectedIndex == 0)
                {
                    printerName = "";
                }
                else
                {
                    printerName = PrinterSettings.InstalledPrinters[comboDefault.SelectedIndex - 1];
                }
                Printers.PutForSit(PrintSituation.Default, compName, printerName, true);
            }
            else
            {
                for (int i = 0; i < Enum.GetValues(typeof(PrintSituation)).Length; i++)
                {
                    //loop through each printSituation
                    string printerName = "";
                    bool   isChecked   = false;
                    //PrintSituation sit=PrintSituation.Default;
                    //first: main Default, since not in panel Simple
                    if (i == 0)           //printSituation.Default
                    {
                        if (comboDefault.SelectedIndex == 0)
                        {
                            printerName = "";
                        }
                        else
                        {
                            printerName = PrinterSettings.InstalledPrinters[comboDefault.SelectedIndex - 1];
                        }
                    }
                    foreach (Control control in panelSimple.Controls)
                    {
                        if (control.GetType() != typeof(ComboBox) &&          //skip anything but comboBoxes and CheckBoxes
                            control.GetType() != typeof(CheckBox))
                        {
                            continue;
                        }
                        //so only two controls out of all will be used in each Enum loop
                        if (GetSit(control) != (PrintSituation)i)
                        {
                            continue;
                        }
                        if (control.GetType() == typeof(ComboBox))
                        {
                            if (((ComboBox)control).SelectedIndex == 0)
                            {
                                printerName = "";
                            }
                            else
                            {
                                printerName = PrinterSettings.InstalledPrinters[((ComboBox)control).SelectedIndex - 1];
                            }
                        }
                        else                  //checkBox
                        {
                            isChecked = ((CheckBox)control).Checked;
                        }
                    }
                    Printers.PutForSit((PrintSituation)i, compName, printerName, isChecked);
                }
            }
            DataValid.SetInvalid(InvalidType.Computers);
            if (checkSimple.Checked != PrefC.GetBool(PrefName.EasyHidePrinters))
            {
                Prefs.UpdateBool(PrefName.EasyHidePrinters, checkSimple.Checked);
                DataValid.SetInvalid(InvalidType.Prefs);
            }
            Printers.RefreshCache();            //the other computers don't care
            ComputerPrefs.LocalComputer.ScanDocSelectSource = checkScanDocSelectSource.Checked;
            ComputerPrefs.LocalComputer.ScanDocShowOptions  = radioScanDocShowOptions.Checked;
            ComputerPrefs.LocalComputer.ScanDocDuplex       = checkScanDocDuplex.Checked;
            ComputerPrefs.LocalComputer.ScanDocGrayscale    = checkScanDocGrayscale.Checked;
            ComputerPrefs.LocalComputer.ScanDocResolution   = PIn.Int(textScanDocResolution.Text);
            ComputerPrefs.LocalComputer.ScanDocQuality      = PIn.Byte(textScanDocQuality.Text);
            ComputerPrefs.Update(ComputerPrefs.LocalComputer);
            DataValid.SetInvalid(InvalidType.Prefs);
        }