Exemplo n.º 1
0
        public void Load(string filename)
        {
            StreamReader reader = new StreamReader(filename);
            try
            {
                this.Name = reader.ReadLine();
                string dir = filename.Substring(0, filename.Length - 4);
                if (!Directory.Exists(dir))
                {
                    reader.Close();
                    return;
                }

                string subdir = dir + "\\Classes\\";
                string[] items = Directory.GetFiles(subdir);
                Classes.Clear();
                GC_Class currentClass;
                foreach(string c in items)
                {
                    currentClass = new GC_Class(c.Substring(0,c.Length-4), this);
                    currentClass.Load(c);
                    Classes.Add(currentClass);
                }

                subdir = dir + "\\Images\\";
                items = Directory.GetFiles(subdir);
                Images.Clear();
                GC_Image currentImage;
                foreach(string i in items)
                {
                    currentImage = new GC_Image(i.Substring(0, i.Length - 4), this);
                    currentImage.Load(i);
                    Images.Add(currentImage);
                }

                subdir = dir + "\\Objects\\";
                items = Directory.GetFiles(subdir);
                Objects.Clear();
                GC_Object currentObject;
                foreach (string o in items)
                {
                    currentObject = new GC_Object(o.Substring(0, o.Length - 4), this);
                    currentObject.Load(o);
                    Objects.Add(currentObject);
                }

                subdir = dir + "\\Levels\\";
                items = Directory.GetFiles(subdir);
                Levels.Clear();
                GC_Level currentLevel;
                foreach (string l in items)
                {
                    currentLevel = new GC_Level(l.Substring(0, l.Length - 4), this);
                    currentLevel.Load(l);
                    Levels.Add(currentLevel);
                }

                reader.Close();
            }
            catch
            {
                reader.Close();
                MessageBox.Show(Application.Current.FindResource("FileCorrupt").ToString());
            }
        }
Exemplo n.º 2
0
        public void Load(string filename)
        {
            StreamReader reader = new StreamReader(filename);

            try
            {
                this.Name = reader.ReadLine();
                string dir = filename.Substring(0, filename.Length - 4);
                if (!Directory.Exists(dir))
                {
                    reader.Close();
                    return;
                }

                string   subdir = dir + "\\Classes\\";
                string[] items  = Directory.GetFiles(subdir);
                Classes.Clear();
                GC_Class currentClass;
                foreach (string c in items)
                {
                    currentClass = new GC_Class(c.Substring(0, c.Length - 4), this);
                    currentClass.Load(c);
                    Classes.Add(currentClass);
                }

                subdir = dir + "\\Images\\";
                items  = Directory.GetFiles(subdir);
                Images.Clear();
                GC_Image currentImage;
                foreach (string i in items)
                {
                    currentImage = new GC_Image(i.Substring(0, i.Length - 4), this);
                    currentImage.Load(i);
                    Images.Add(currentImage);
                }

                subdir = dir + "\\Objects\\";
                items  = Directory.GetFiles(subdir);
                Objects.Clear();
                GC_Object currentObject;
                foreach (string o in items)
                {
                    currentObject = new GC_Object(o.Substring(0, o.Length - 4), this);
                    currentObject.Load(o);
                    Objects.Add(currentObject);
                }

                subdir = dir + "\\Levels\\";
                items  = Directory.GetFiles(subdir);
                Levels.Clear();
                GC_Level currentLevel;
                foreach (string l in items)
                {
                    currentLevel = new GC_Level(l.Substring(0, l.Length - 4), this);
                    currentLevel.Load(l);
                    Levels.Add(currentLevel);
                }

                reader.Close();
            }
            catch
            {
                reader.Close();
                MessageBox.Show(Application.Current.FindResource("FileCorrupt").ToString());
            }
        }