PIbd-21 Potapov N.S. LabWork06 #6

Closed
ns.potapov wants to merge 6 commits from LabWork06 into LabWork05
Showing only changes of commit b46a5f46b0 - Show all commits

View File

@ -116,50 +116,41 @@ namespace ProjectStormtrooper
{
return false;
}
string bufferTextFromFile = "";
using (FileStream fs = new(filename, FileMode.Open))
using (StreamReader sr = new StreamReader(filename))
{
byte[] b = new byte[fs.Length];
UTF8Encoding temp = new(true);
while (fs.Read(b, 0, b.Length) > 0)
string? currentLine = sr.ReadLine();
if (currentLine == null || !currentLine.Contains("PlaneStorage"))
{
bufferTextFromFile += temp.GetString(b);
return false;
}
}
var strs = bufferTextFromFile.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
if (strs == null || strs.Length == 0)
{
return false;
}
if (!strs[0].StartsWith("PlaneStorage"))
{
// если нет такой записи, то это не те данные
return false;
}
_planeStorages.Clear();
foreach (string data in strs)
{
string[] record = data.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
if (record.Length != 2)
_planeStorages.Clear();
currentLine = sr.ReadLine();
while (currentLine != null)
{
continue;
}
PlanesGenericCollection<DrawingPlane, DrawingObjectPlane> collection = new(_pictureWidth, _pictureHeight);
string[] set = record[1].Split(_separatorRecords, StringSplitOptions.RemoveEmptyEntries);
foreach (string elem in set)
{
DrawingPlane? plane = elem?.CreateDrawingPlane(_separatorForObject, _pictureWidth, _pictureHeight);
if (plane != null)
string[] record = currentLine.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
if (record.Length != 2)
{
if (collection + plane == -1)
continue;
}
PlanesGenericCollection<DrawingPlane, DrawingObjectPlane> collection = new(_pictureWidth, _pictureHeight);
string[] set = record[1].Split(_separatorRecords, StringSplitOptions.RemoveEmptyEntries);
foreach (string elem in set)
{
DrawingPlane? plane = elem?.CreateDrawingPlane(_separatorForObject, _pictureWidth, _pictureHeight);
if (plane != null)
{
return false;
if (collection + plane == -1)
{
return false;
}
}
}
_planeStorages.Add(record[0], collection);
currentLine = sr.ReadLine();
}
_planeStorages.Add(record[0], collection);
return true;
}
return true;
}
}
}