Beispiel #1
0
        /// <summary>
        /// choose a default for this MachineModel.
        /// </summary>
        void set_default_preset(MachineModel model)
        {
            if (model.Presets.Count == 0)
            {
                throw new Exception("MachinDatabase.set_default_settings: no presets to choose from!");
            }

            MachinePreset defaultPreset =
                model.Presets.Find((s) => { return(s.Settings.Identifier.Equals("Defaults", StringComparison.OrdinalIgnoreCase)); });

            if (defaultPreset != null)
            {
                model.DefaultPreset = defaultPreset;
                return;
            }

            model.DefaultPreset = model.Presets[0];
        }
Beispiel #2
0
        public MachineModel CreateManufacturer(string mfgName, string mfgUUID, string defaultMachineUUID)
        {
            Manufacturer new_mfg = new Manufacturer()
            {
                Name = mfgName, UUID = mfgUUID
            };

            add_manufacturer(new_mfg);

            MachinePreset preset = new MachinePreset(new GenericPrinterSettings(mfgName, mfgUUID, defaultMachineUUID));

            MachineModel model = new MachineModel()
            {
                Name    = "Unknown", UUID = defaultMachineUUID,
                Presets = new List <MachinePreset>()
                {
                    preset
                }
            };

            add_machine(new_mfg, model);

            SettingsSerializer serializer  = new SettingsSerializer();
            string             machinePath = serializer.CreateNewSettingsFolder(this, new_mfg, model, cotangent.CCOptions.SettingsDBPath);

            preset.Settings.Identifier = "Defaults";
            preset.Settings.BaseMachine.ManufacturerName = mfgName;
            preset.Settings.BaseMachine.ManufacturerUUID = mfgUUID;
            preset.Settings.BaseMachine.ModelIdentifier  = "(Unknown)";
            preset.Settings.BaseMachine.ModelUUID        = defaultMachineUUID;

            preset.SourcePath = Path.Combine(machinePath, "Default.txt");
            serializer.StoreSettings(this, preset, true);

            model.Presets.Add(preset);
            model.DefaultPreset = preset;

            return(model);
        }
Beispiel #3
0
 public MachinePreset DefaultPresetForModel(MachineModel model)
 {
     return(model.DefaultPreset);
 }
Beispiel #4
0
 public IReadOnlyList <MachinePreset> PresetsForModel(MachineModel model)
 {
     return(model.Presets);
 }