コード例 #1
0
        private void AddExistingItem(ProjectDirectory root)
        {
            var dialog = ServiceProvider.Get <IOpenFileDialog>();

            dialog.AllowMultiple = false;
            dialog.Filter        = new FileDialogFilter("All files", "*");

            if (dialog.Show())
            {
                var newPath = Path.Combine(root.RelativePath, dialog.FileName);
                var absPath = Path.Combine(DirectoryPath, newPath);

                if (dialog.FilePath != absPath)
                {
                    File.Copy(dialog.FilePath, absPath, true);
                }

                if (!root.Children.Any(f => f.FullName == dialog.FileName))
                {
                    new ProjectFile(this, root, dialog.FileName);
                }
            }
        }
コード例 #2
0
        private async void CreateAndOpenGraphFile <T>(ProjectDirectory root) where T : Graph
        {
            var dialog = ServiceProvider.Get <IDialogManager>();
            var name   = await dialog.ShowInputAsync("New graph", "Enter file name");

            if (!string.IsNullOrWhiteSpace(name))
            {
                var factory = ServiceProvider.Get <IGraphFactory>();
                var archive = ServiceProvider.Get <IArchive>();
                var graph   = factory.Create <T>();
                graph.Name = name;

                archive.Write(nameof(System.Type), typeof(T));
                graph.Save(archive);

                var unique  = GetUniqueFileName(root, graph.Name, Extension.Graph);
                var newFile = new ProjectFile(this, root, unique);

                archive.Save(newFile.AbsolutePath);

                OpenFile(newFile);
            }
        }
コード例 #3
0
 public ProjectDirectory(Project project, ProjectDirectory root, string name) : base(project, root, name)
 {
     Children = new ObservableCollection <ProjectEntry>();
 }
コード例 #4
0
 private void AddImageGraph(ProjectDirectory root)
 {
     CreateAndOpenGraphFile <ImageGraph>(root);
 }
コード例 #5
0
 private void AddFunctionGraph(ProjectDirectory root)
 {
     CreateAndOpenGraphFile <FunctionGraph>(root);
 }
コード例 #6
0
 private void AddTextGraph(ProjectDirectory root)
 {
     CreateAndOpenGraphFile <TextGraph>(root);
 }
コード例 #7
0
 public ProjectFile(Project project, ProjectDirectory root, string name) : base(project, root, name)
 {
     Id        = Guid.NewGuid();
     Type      = name.GetFileType();
     Extension = System.IO.Path.GetExtension(name);
 }