public ProjectFile CreateProjectFile(Project parentProject, string basePath)
        {
            NewFileDialog nfd = new NewFileDialog ();
            int res = nfd.Run ();
            nfd.Dispose ();
            if (res != (int) Gtk.ResponseType.Ok) return null;

            IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
            int count = 1;

            string baseName  = Path.GetFileNameWithoutExtension(window.ViewContent.UntitledName);
            string extension = Path.GetExtension(window.ViewContent.UntitledName);

            // first try the default untitled name of the viewcontent filename
            string fileName = Path.Combine (basePath, baseName +  extension);

            // if it is already in the project, or it does exists we try to get a name that is
            // untitledName + Numer + extension
            while (parentProject.IsFileInProject (fileName) || System.IO.File.Exists (fileName)) {
                fileName = Path.Combine (basePath, baseName + count.ToString() + extension);
                ++count;
            }

            // now we have a valid filename which we could use
            window.ViewContent.Save (fileName);

            ProjectFile newFileInformation = new ProjectFile(fileName, BuildAction.Compile);
            parentProject.ProjectFiles.Add (newFileInformation);
            return newFileInformation;
        }
Ejemplo n.º 2
0
 protected override void Run()
 {
     NewFileDialog fd = new NewFileDialog ();
     fd.Run ();
 }