private void CommitSliceSettings(Dictionary <string, string> settingsDict, int collectionId)
 {
     foreach (KeyValuePair <string, string> item in settingsDict)
     {
         SliceSetting sliceSetting = new SliceSetting();
         sliceSetting.Name  = item.Key;
         sliceSetting.Value = item.Value;
         sliceSetting.SettingsCollectionId = collectionId;
         sliceSetting.Commit();
     }
 }
Beispiel #2
0
        private void onPresetLoad(OpenFileDialogParams openParams)
        {
            if (openParams.FileNames != null)
            {
                SliceSettingsCollection settingsCollection;
                try
                {
                    if (File.Exists(openParams.FileName))
                    {
                        //Create collection to hold preset settings
                        settingsCollection           = new SliceSettingsCollection();
                        settingsCollection.Tag       = windowController.filterTag;
                        settingsCollection.PrinterId = ActivePrinterProfile.Instance.ActivePrinter.Id;
                        settingsCollection.Name      = System.IO.Path.GetFileNameWithoutExtension(openParams.FileName);
                        settingsCollection.Commit();

                        string[] lines = System.IO.File.ReadAllLines(openParams.FileName);
                        foreach (string line in lines)
                        {
                            //Ignore commented lines
                            if (!line.StartsWith("#"))
                            {
                                string[] settingLine         = line.Split('=');
                                string   keyName             = settingLine[0].Trim();
                                string   settingDefaultValue = settingLine[1].Trim();

                                //To do - validate imported settings as valid (KP)
                                SliceSetting sliceSetting = new SliceSetting();
                                sliceSetting.Name  = keyName;
                                sliceSetting.Value = settingDefaultValue;
                                sliceSetting.SettingsCollectionId = settingsCollection.Id;
                                sliceSetting.Commit();
                            }
                        }
                        windowController.ChangeToSlicePresetList();
                    }
                }
                catch (Exception)
                {
                    // Error loading configuration
                }
            }
        }