Ejemplo n.º 1
0
        /*
         *
         *  Project Loading
         *
         */


        public static EyeProject Load(string filepath)
        {
            XDocument _doc = XDocument.Load(filepath);


            if (_doc.Element("EyeProject") == null)
            {
                MessageBox.Show($"Invalid project file {filepath}");
                return(null);
            }

            var files = from p in _doc.Element("EyeProject").Element("Files").Descendants()
                        select p.Attribute("Path").Value;


            string _name    = _doc.Element("EyeProject").Attribute("Name").Value;
            string _version = _doc.Element("EyeProject").Attribute("Version").Value;
            string _type    = _doc.Element("EyeProject").Attribute("Type").Value;


            if (_version != Version)
            {
                Console.WriteLine($"Version mismatch, current version: {Version}, project version: {_version}");
            }

            EyeProject _proj = new EyeProject();

            _proj.Name        = _name;
            _proj.ProjectType = (ProjectType)Enum.Parse(typeof(ProjectType), _type);

            _proj.Files = new ObservableCollection <EyeProjectFile>();
            _proj.Files.AddRange(files.Select(f => new EyeProjectFile(f)));

            return(_proj);
        }
Ejemplo n.º 2
0
        public static EyeProject New(string name, ProjectType type)
        {
            EyeProject _proj = new EyeProject();

            _proj.Name        = name.Replace(" ", "_");
            _proj.ProjectType = type;


            if (!Directory.Exists(Environment.ProjectFolderPath))
            {
                Directory.CreateDirectory(Environment.ProjectFolderPath);
            }

            if (Directory.Exists(Environment.ProjectFolderPath + _proj.Name))
            {
                MessageBox.Show($"A project file with the name {name} already exists!");
                return(null);
            }

            Directory.CreateDirectory(Environment.ProjectFolderPath + _proj.Name);

            _proj.Files = new ObservableCollection <EyeProjectFile>();

            _proj.AddConfigFile($"{_proj.Name}");
            _proj.AddNewFile("script1");


            _proj.WriteProjectFile();

            return(_proj);
        }