Esempio n. 1
0
        public void GenerateSettingsFolder(MachineDatabase db, string rootPath)
        {
            JsonSerializerSettings jsonSettings = makeWriteSerializer();

            foreach (Manufacturer mfg in db.Manufacturers)
            {
                string mfgPath = Path.Combine(rootPath, mfg.Name);
                if (!Directory.Exists(mfgPath))
                {
                    Directory.CreateDirectory(mfgPath);
                    if (!Directory.Exists(mfgPath))
                    {
                        throw new Exception("SettingsSerializer: cannot create directory for manufacturer " + mfg.Name);
                    }
                }

                IReadOnlyList <MachineModel> machines = db.ModelsForManufacturer(mfg);
                foreach (MachineModel machine in machines)
                {
                    string machinePath = Path.Combine(mfgPath, machine.Name);
                    if (!Directory.Exists(machinePath))
                    {
                        Directory.CreateDirectory(machinePath);
                        if (!Directory.Exists(machinePath))
                        {
                            throw new Exception("SettingsSerializer: cannot create directory for machine " + mfg.Name + "::" + machine.Name);
                        }
                    }


                    PlanarAdditiveSettings settings = machine.DefaultPreset.Settings;
                    string settingsPath             = Path.Combine(machinePath, settings.Identifier + ".txt");

                    var save_culture = Thread.CurrentThread.CurrentCulture;
                    Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
                    string json = JsonConvert.SerializeObject(settings, jsonSettings);
                    System.IO.File.WriteAllText(settingsPath, json);
                    Thread.CurrentThread.CurrentCulture = save_culture;
                }
            }
        }
Esempio n. 2
0
 protected virtual void CopyFieldsTo(PlanarAdditiveSettings to)
 {
     to.Identifier    = this.Identifier;
     to.LayerHeightMM = this.LayerHeightMM;
 }
Esempio n. 3
0
 public MachinePreset(PlanarAdditiveSettings settings, string sourcePath = "")
 {
     UUID       = System.Guid.NewGuid().ToString(); // [RMS] we don't have uuids for settings?
     Settings   = settings;
     SourcePath = sourcePath;
 }