Пример #1
0
        // ========== Save ==========
        protected void Save()
        {
            PrinterProfile printerProfile = Program.printer.GetPrinterProfile("Default");

            //printerProfile.SetPrintQueue (this.PrinterSelectionCombo.ActiveText);
            printerProfile.SetPrinterName(this.PrinterSelectionCombo.ActiveText);
            Program.printer.SaveConfig();
        }
Пример #2
0
        // ========== Load Config ==========
        public void LoadConfig()
        {
            this.Config = ConfigPrinter.LoadFile();

            // Create Default If Empty:
            if (this.Config.PrinterProfileEntries.Length == 0)
            {
                PrinterProfile.ConfigPrinterProfile printerProfileConfig = new PrinterProfile.ConfigPrinterProfile();
                this.Config.PrinterProfileEntries = new PrinterProfile.ConfigPrinterProfile[] { printerProfileConfig };
            }

            // Load Profiles:
            bool hasDefault = false;

            foreach (PrinterProfile.ConfigPrinterProfile printerProfileConfig in this.Config.PrinterProfileEntries)
            {
                if (printerProfileConfig.ProfileName == "Default")
                {
                    hasDefault = true;
                }
                PrinterProfile printerProfile = new PrinterProfile(printerProfileConfig.ProfileName);
                //printerProfile.SetPrintQueue (printerProfileConfig.PrinterName);
                printerProfile.SetPrinterName(printerProfileConfig.PrinterName);
                printerProfile.ImageScale = printerProfileConfig.ImageScale;
                printerProfile.PageWidth  = printerProfileConfig.PageWidth;
                printerProfile.PageHeight = printerProfileConfig.PageHeight;
                this.PrinterProfiles.Add(printerProfile.Name, printerProfile);
            }

            // Create Default If Missing:
            if (!hasDefault)
            {
                PrinterProfile printerProfile = new PrinterProfile("Default");
                //printerProfile.SetPrintQueue(DefaultPrinterName);
                printerProfile.SetPrinterName(DefaultPrinterName);
                this.PrinterProfiles.Add(printerProfile.Name, printerProfile);
            }
        }