Exemplo n.º 1
0
        private FileItem ParseProject(XElement elem, Project project)
        {
            if (elem.Name == "Folder")
            {
                Folder folder = new Folder(project)
                {
                    Name = elem.Attribute("Name").Value,
                    Path = elem.Attribute("Path").Value,
                    UUID = Guid.Parse(elem.Attribute("UUID").Value)
                };

                foreach (var u in elem.Elements())
                {
                    folder.Items.Add(ParseProject(u, project));
                }

                return folder;
            }
            else if (elem.Name == "File")
            {
                Source source = new Source(project)
                {
                    Name = elem.Attribute("Name").Value,
                    Path = elem.Attribute("Path").Value,
                    UUID = Guid.Parse(elem.Attribute("UUID").Value)
                };
                return source;
            }
            else
            {
                throw new Exception("Illegal Node");
            }
        }
Exemplo n.º 2
0
        public void NewProject(Project project)
        {
            project.Save();

            Projects.Add(project);
            ProjectUpdated();
        }
Exemplo n.º 3
0
        private void miNewProject_Click(object sender, RoutedEventArgs e)
        {
            SaveFileDialog dialog = new SaveFileDialog();
            dialog.Filter = "SNL工程(*.snlproj)|*.snlproj";
            if ((bool)dialog.ShowDialog())
            {
                Project project = new Project()
                {
                    Path = dialog.FileName.Remove(dialog.FileName.Length - dialog.SafeFileName.Length),
                    Name = dialog.SafeFileName.Remove(dialog.SafeFileName.Length - (".snlproj").Length)
                };

                ProjectManager.GetManager().NewProject(project);
            }
        }
Exemplo n.º 4
0
        public void OpenProject(string path)
        {
            FileReader reader = new FileReader(path);
            XDocument doc = XDocument.Parse(reader.Read());

            var elem = doc.Element("Project");

            Project project = new Project()
            {
                Name = elem.Attribute("Name").Value,
                Path = path,
                UUID = Guid.Parse(elem.Attribute("UUID").Value)
            };

            foreach (var u in elem.Elements())
            {
                project.Items.Add(ParseProject(u, project));
            }

            Projects.Add(project);

            ProjectUpdated();
        }
Exemplo n.º 5
0
 public Source(Project project)
 {
     this.FileType = FileTypes.File;
     this._Project = project;
 }
Exemplo n.º 6
0
 public Folder(Project _Project)
 {
     this.FileType = FileTypes.Folder;
     this._Project = _Project;
     this.Items = new List<FileItem>();
 }