示例#1
0
        public static async Task SwitchToProfile(string printerID)
        {
            ProfileManager.Instance.LastProfileID = printerID;

            var printer = new PrinterConfig(await ProfileManager.LoadProfileAsync(printerID));

            await printer.LoadPlateFromHistory();

            await ApplicationController.Instance.SetActivePrinter(printer);
        }
示例#2
0
        internal static async Task <PrinterConfig> CreateProfileAsync(string make, string model, string printerName)
        {
            string guid = Guid.NewGuid().ToString();

            var publicDevice = OemSettings.Instance.OemProfiles[make][model];

            if (publicDevice == null)
            {
                return(null);
            }

            var printerSettings = await LoadOemProfileAsync(publicDevice, make, model);

            if (printerSettings == null)
            {
                return(null);
            }

            printerSettings.ID = guid;
            printerSettings.DocumentVersion = PrinterSettings.LatestVersion;

            printerSettings.UserLayer[SettingsKey.printer_name.ToString()] = printerName;

            //If the active printer has no theme we set it to the current theme color
            printerSettings.UserLayer[SettingsKey.active_theme_name] = ActiveTheme.Instance.Name;

            // Add to Profiles - fires ProfileManager.Save due to ObservableCollection event listener
            Instance.Profiles.Add(new PrinterInfo
            {
                Name  = printerName,
                ID    = guid,
                Make  = make,
                Model = model
            });

            // Persist changes to PrinterSettings - must come after adding to Profiles above
            printerSettings.Save();

            // Set as active profile
            ProfileManager.Instance.LastProfileID = guid;

            var printer = new PrinterConfig(printerSettings);
            await printer.LoadPlateFromHistory();

            await ApplicationController.Instance.SetActivePrinter(printer);

            return(printer);
        }