public void Copy(JsonStructure model) { AmbientOcclusion = model.AmbientOcclusion; Textures = new List <JsonTexture>(model.Textures); Elements = new List <JsonElement>(model.Elements); FilePath = model.FilePath; Name = model.Name; }
private void saveFileDialogModel_FileOk(object sender, CancelEventArgs e) { Renderer.GetActiveModel().FilePath = saveFileDialogModel.FileName; FileInfo info = new FileInfo(saveFileDialogModel.FileName); Renderer.GetActiveModel().Name = info.Name; JsonStructure json = new JsonStructure(Renderer.GetActiveModel()); json.FilePath = saveFileDialogModel.FileName; json.Save(); }
public JsonStructure(string path) { JsonReader reader = new JsonReader(path); JsonStructure jsonStruc = reader.GetjsonModel(); if (jsonStruc != null) { jsonStruc.FilePath = path; FileInfo info = new FileInfo(path); jsonStruc.Name = info.Name; Copy(jsonStruc); } else { jsonStruc = new JsonStructure(); Copy(jsonStruc); } }
public Model(JsonStructure jsonModel) { _boxes = new List <Box>(); _textures = new List <ModelTexture>(); FilePath = jsonModel.FilePath; AddTexture("MissingT", "Tool\\MissingTexture"); _name = jsonModel.Name; AmbientOcclusion = jsonModel.AmbientOcclusion; foreach (JsonTexture tex in jsonModel.Textures) { AddTexture(tex.Name, tex.Path); } foreach (JsonElement element in jsonModel.Elements) { AddBox(new Box(element, this)); } _treeNode = new TreeNodeModel(this); }
private void Read() { _jsonModel = new JsonStructure(); _fileText = File.ReadAllText(_filePath); _readIndex = 0; bool done = false; while (!done) { int varNameIndex = _fileText.IndexOf("\"", _readIndex) + 1; int varNameLenght = _fileText.IndexOf("\"", varNameIndex) - varNameIndex; string varName = _fileText.Substring(varNameIndex, varNameLenght); _readIndex = _fileText.IndexOf(":", _readIndex) + 1; int result = ParseVariable(varName); if (result == 0) { done = true; } } }
public JsonWriter(JsonStructure jsonStruct) { _jsonStructure = jsonStruct; _filePath = jsonStruct.FilePath; Write(); }