static void Main(string[] args) { configFile cnf = new configFile(); cnf.vars.setvar("a", "hello world"); cnf.vars.setvar("b", "10"); cnf.vars.setvar("c", "20"); cnf.vars.setvar("config", "config.txt"); cnf.save(cnf.vars.getvar("config")); cnf.clear(); cnf.load("config.txt"); cnf.vars.list(); }
/*private void initComboBoxes() * { * comboBoxTransType.Items * }*/ private void saveConfig(string cfgPath) { // System.IO.TextWriter config = new System.IO.StreamWriter(cfgPath); configFile config = new configFile(cfgPath); // I/O settings config.addParam("VideoSource", getVidSource()); config.addParam("ImageDir", textBoxDir.Text); config.addParam("VideoFile", textBoxVidFile.Text); config.addParam("MosaicDestination", getMosaicDestination()); config.addParam("MosaicSaveDir", textBoxSaveMosaic.Text); // Transform settings config.addParam("TransformType", comboBoxTransType.SelectedIndex); config.addParam("FeatureDetector", comboBoxFeatureDetector.SelectedIndex); config.addParam("NumFeatures", textBoxNumCorners.Text); config.addParam("NumBlobScales", textBoxBlobScales.Text); config.addParam("CorrespondenceQuality", textBoxCorrQuality.Text); config.addParam("LMIterations", textBoxLMIterations.Text); config.addParam("LM", checkBoxLM.Checked ? 1 : 0); config.addParam("PatchDescriptorType", comboBoxDescriptor.SelectedIndex); config.addParam("PatchDescriptorSize", comboBoxPatchSize.SelectedIndex); config.addParam("MaxRansacIters", textBoxMaxRansacIters.Text); config.addParam("MaxSearchForTransform", textBoxMaxSearchForTransform.Text); //Renderer settings config.addParam("MaxFrames", textBoxMaxFrames.Text); config.addParam("IncrementalRendering", checkBoxIncrementalRenderer.Checked ? 1 : 0); config.addParam("FullFrameUpdateFreq", textBoxFullFrameUpdateFreq.Text); config.addParam("SkipFrames", checkBoxSkipFrames.Checked ? 1 : 0); config.addParam("RendererType", comboBoxRenderer.SelectedIndex); config.addParam("FeatherRadius", textBoxFeatherRad.Text); config.addParam("DijkstraScale", textBoxDijkstraScale.Text); config.addParam("WarpMethod", comboBoxWarpMethod.SelectedIndex); config.addParam("MosaicX", textBoxMosaicX.Text); config.addParam("MosaicY", textBoxMosaicY.Text); //Evaluation settings config.addParam("EvaluationFunction", comboBoxEvalFunction.SelectedIndex); config.Close(); }
/// <summary> /// Read configuration file /// </summary> /// <returns>Read configuration in form of a list of finished legs</returns> public List <HexaLeg> Read() { List <HexaLeg> legs = new List <HexaLeg>(); Dictionary <string, configFile> x = new Dictionary <string, configFile>(); configFile cF = new configFile(); string config = File.ReadAllText(this.filePath); // Try to convert read text to structure try { x = JsonConvert.DeserializeObject <Dictionary <string, configFile> >(config); } catch (Exception ex) { throw new ConfigError("[Read]" + ex.Message); } // Try to break down structure to individually legs try { cF = x["Hexapod"]; HexaLeg hl; foreach (tempLeg tL in cF.Legs) { hl = new HexaLeg( tL.Lambda, new Vector3D(tL.Offset), new Vector3D(tL.Hip), new Vector3D(tL.Thigh), new Vector3D(tL.Shank), tL.Support, tL.Switch ); legs.Add(hl); } } catch (Exception ex) { throw new ConfigError("[Mapping]" + ex.Message); } return(legs); }
string valueAttribute = "value") => Init(configFile, element, keyAttribute, valueAttribute);
/*private void initComboBoxes() { comboBoxTransType.Items }*/ private void saveConfig(string cfgPath) { // System.IO.TextWriter config = new System.IO.StreamWriter(cfgPath); configFile config = new configFile(cfgPath); // I/O settings config.addParam("VideoSource", getVidSource()); config.addParam("ImageDir", textBoxDir.Text ); config.addParam("VideoFile", textBoxVidFile.Text); config.addParam("MosaicDestination", getMosaicDestination()); config.addParam("MosaicSaveDir", textBoxSaveMosaic.Text); // Transform settings config.addParam("TransformType", comboBoxTransType.SelectedIndex); config.addParam("FeatureDetector", comboBoxFeatureDetector.SelectedIndex); config.addParam("NumFeatures", textBoxNumCorners.Text); config.addParam("NumBlobScales", textBoxBlobScales.Text); config.addParam("CorrespondenceQuality", textBoxCorrQuality.Text); config.addParam("LMIterations", textBoxLMIterations.Text); config.addParam("LM", checkBoxLM.Checked ? 1 : 0); config.addParam("PatchDescriptorType", comboBoxDescriptor.SelectedIndex); config.addParam("PatchDescriptorSize", comboBoxPatchSize.SelectedIndex); config.addParam("MaxRansacIters", textBoxMaxRansacIters.Text); config.addParam("MaxSearchForTransform", textBoxMaxSearchForTransform.Text); //Renderer settings config.addParam("MaxFrames", textBoxMaxFrames.Text); config.addParam("IncrementalRendering", checkBoxIncrementalRenderer.Checked ? 1 : 0); config.addParam("FullFrameUpdateFreq", textBoxFullFrameUpdateFreq.Text); config.addParam("SkipFrames", checkBoxSkipFrames.Checked ? 1 : 0); config.addParam("RendererType", comboBoxRenderer.SelectedIndex); config.addParam("FeatherRadius", textBoxFeatherRad.Text); config.addParam("DijkstraScale", textBoxDijkstraScale.Text); config.addParam("WarpMethod", comboBoxWarpMethod.SelectedIndex); config.addParam("MosaicX", textBoxMosaicX.Text); config.addParam("MosaicY", textBoxMosaicY.Text); //Evaluation settings config.addParam("EvaluationFunction", comboBoxEvalFunction.SelectedIndex); config.Close(); }
Init(configFile, element, keyAttribute, valueAttribute);