private void OpenProject() { OpenFileDialog fileDialog = new OpenFileDialog(); fileDialog.Filter = "My3Dformat files (*.my3Dformat)|*.my3Dformat"; Nullable <bool> result = fileDialog.ShowDialog(); if (result == true) { string filename = Path.GetFileName(fileDialog.FileName); string path = Path.GetDirectoryName(fileDialog.FileName); // открыть файлы со специальным расширением // и прочитать их построчно :)))) // Read file using (var streamReader = new StreamReader(fileDialog.FileName)) { string line; string floorW = "floorWidth "; string floorL = "floorLength "; string ceilingV = "ceiling "; string modelsC = "models "; bool floorWFound = false, floorLFound = false, ceilingVFound = false, modelsCFound = false; int modelsCount = 0; myScene.ClearScene(); // do while its not the end of file while ((line = streamReader.ReadLine()) != null) { #region scene settings if (!floorWFound && line.IndexOf(floorW) != -1) { FloorWidth.Value = Ceiling.Width = Convert.ToDouble(line.Substring(line.IndexOf(floorW) + floorW.Length)); floorWFound = !floorWFound; continue; } if (!floorLFound && line.IndexOf(floorL) != -1) { FloorLength.Value = Ceiling.Length = Convert.ToDouble(line.Substring(line.IndexOf(floorL) + floorL.Length)); floorLFound = !floorLFound; continue; } if (!ceilingVFound && line.IndexOf(ceilingV) != -1) { Ceiling.Visible = Convert.ToBoolean(line.Substring(line.IndexOf(ceilingV) + ceilingV.Length)); ceilingVFound = !ceilingVFound; continue; } if (!modelsCFound && line.IndexOf(modelsC) != -1) { modelsCount = Convert.ToInt32(line.Substring(line.IndexOf(modelsC) + modelsC.Length)); modelsCFound = !modelsCFound; continue; } if (line == "name source coordinateX coordinateY coordinateZ rotationX rotationY rotationZ size") { continue; } #endregion #region model opening string[] delimiters = new string[] { " " }; string[] modelData = line.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); myScene.AddElementFromArray(modelData); #endregion } } lvScene.ItemsSource = myScene.Names; lvScene.Items.Refresh(); } }