public void Load(string filename) { StreamReader reader = new StreamReader(filename); try { int count; Shape s; string kind; _background = Color.FromArgb(reader.ReadInteger()); count = reader.ReadInteger(); for (int i = 0; i < count; i++) { kind = reader.ReadLine(); s = Shape.CreateShape(kind); //No longer needs to know about the different shape classes. s.LoadFrom(reader); _shapes.Add(s); } } finally { reader.Close(); } }
public void Load(string filename) { StreamReader reader = reader = new StreamReader(filename);; try { int count; Shape s; string kind; _background = Color.FromArgb(reader.ReadInteger()); count = reader.ReadInteger(); for (int i = 0; i < count; i++) { kind = reader.ReadLine(); s = Shape.CreateShape(kind); s.LoadFrom(reader); _shapes.Add(s); } } catch (Exception e) { Console.Error.WriteLine("Error loading file: {0}", e.Message); } finally { reader.Close(); } }
public void Load(string filename) { StreamReader reader = new StreamReader(Path.Combine("/users/jack/Desktop/", filename)); try { Background = Color.FromArgb(reader.ReadInteger()); int count = reader.ReadInteger(); for (int i = 0; i < count; i++) { Shape s = Shape.CreateShape(reader.ReadLine()); s.LoadFrom(reader); _shapes.Add(s); } } finally { reader.Close(); } }
public void Load(string filename) { StreamReader reader = new StreamReader(filename); int count; Shape shape; string kind = null; Background = Color.FromArgb(reader.ReadInteger()); count = reader.ReadInteger(); try { for (int i = 0; i < count; i++) { kind = reader.ReadLine(); shape = Shape.CreateShape(kind); shape.LoadFrom(reader); AddShape(shape); } } finally { reader.Close(); } }
public void Load(string filename) { int _count, i; Shape s = default(Shape); string kind; StreamReader reader = new StreamReader(FilePath + filename); try{ BackgroundColor = Color.FromArgb(reader.ReadInteger()); _count = reader.ReadInteger(); for (i = 0; i < _count; i++) { kind = reader.ReadLine(); s = Shape.CreateShape(kind); s.LoadFrom(reader); AddShape(s); } } finally { reader.Close(); } }