public static void ShowOpenProject(this ScreenLayerManager screenLayerManager)
        {
            if (!Directory.Exists(Project.ProjectsFolder))
            {
                Directory.CreateDirectory(Project.ProjectsFolder);
            }

            screenLayerManager.OpenFilePicker("", "", Project.ProjectsFolder, Project.FileFilter, (projectPath) =>
            {
                if (!PathHelper.FolderContainsPath(Project.ProjectsFolder, projectPath) ||
                    PathHelper.GetRelativePath(Project.ProjectsFolder, projectPath).Count(c => c == '/') != 1)
                {
                    screenLayerManager.ShowMessage("Projects must be placed in a folder directly inside the 'projects' folder.");
                }
                else
                {
                    screenLayerManager.AsyncLoading("Loading project", () =>
                    {
                        var resourceContainer = screenLayerManager.GetContext <Editor>().ResourceContainer;

                        var project = Project.Load(projectPath, true, resourceContainer);
                        Program.Schedule(() => screenLayerManager.Set(new ProjectMenu(project)));
                    });
                }
            });
        }
 public static void OpenFolderPicker(this ScreenLayerManager screenLayerManager, string description, string initialValue, Action <string> callback)
 {
     screenLayerManager.AsyncLoading("Select a folder", () =>
     {
         using (var dialog = new System.Windows.Forms.FolderBrowserDialog()
         {
             Description = description,
             ShowNewFolderButton = true,
             SelectedPath = initialValue,
         })
             if (dialog.ShowDialog(screenLayerManager.GetContext <Editor>().FormsWindow) == System.Windows.Forms.DialogResult.OK)
             {
                 var path = dialog.SelectedPath;
                 Program.Schedule(() => callback.Invoke(path));
             }
     });
 }
 public static void OpenFilePicker(this ScreenLayerManager screenLayerManager, string description, string initialValue, string initialDirectory, string filter, Action <string> callback)
 {
     screenLayerManager.AsyncLoading("Select a file", () =>
     {
         using (var dialog = new System.Windows.Forms.OpenFileDialog()
         {
             Title = description,
             RestoreDirectory = true,
             ShowHelp = false,
             FileName = initialValue,
             Filter = filter,
             InitialDirectory = initialDirectory != null ? Path.GetFullPath(initialDirectory) : string.Empty,
         })
             if (dialog.ShowDialog(screenLayerManager.GetContext <Editor>().FormsWindow) == System.Windows.Forms.DialogResult.OK)
             {
                 var path = dialog.FileName;
                 Program.Schedule(() => callback.Invoke(path));
             }
     });
 }
 public static void OpenSaveLocationPicker(this ScreenLayerManager screenLayerManager, string description, string initialValue, string extension, string filter, Action <string> callback)
 {
     screenLayerManager.AsyncLoading("Select a location", () =>
     {
         using (var dialog = new System.Windows.Forms.SaveFileDialog()
         {
             Title = description,
             RestoreDirectory = true,
             ShowHelp = false,
             FileName = initialValue,
             OverwritePrompt = true,
             DefaultExt = extension,
             Filter = filter,
         })
             if (dialog.ShowDialog(screenLayerManager.GetContext <Editor>().FormsWindow) == System.Windows.Forms.DialogResult.OK)
             {
                 var path = dialog.FileName;
                 Program.Schedule(() => callback.Invoke(path));
             }
     });
 }