예제 #1
0
        // ========== Save Config ==========
        public void SaveConfig()
        {
            List <PrinterProfile.ConfigPrinterProfile> printerProfileConfigs = new List <PrinterProfile.ConfigPrinterProfile> ();

            foreach (PrinterProfile printerProfile in this.PrinterProfiles.Values)
            {
                PrinterProfile.ConfigPrinterProfile printerProfileConfig = new PrinterProfile.ConfigPrinterProfile();
                printerProfileConfig.ProfileName = printerProfile.Name;
                printerProfileConfig.ImageScale  = printerProfile.ImageScale;
                printerProfileConfig.PageWidth   = printerProfile.PageWidth;
                printerProfileConfig.PageHeight  = printerProfile.PageHeight;
                printerProfileConfig.PrinterName = printerProfile.GetPrinterName();
                printerProfileConfigs.Add(printerProfileConfig);
            }
            this.Config.PrinterProfileEntries = printerProfileConfigs.ToArray();
            this.Config.SaveFile();
        }
예제 #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);
            }
        }