public bool SaveProject() { if (Project == null) { return(true); } if (string.IsNullOrEmpty(FileName)) { if (SaveProjectDialog.ShowDialog() != DialogResult.OK) { return(false); } FileName = SaveProjectDialog.FileName; } Serializer.SaveProject(FileName, Project); UnsavedChanges = false; UpdateTitleBar(); ProjectSaved?.Invoke(this, null); return(true); }
//сохранение проекта void SaveProject() { if (ProjectPath == "") { if (SaveProjectDialog.ShowDialog() == DialogResult.Cancel) { return; } ProjectPath = SaveProjectDialog.FileName; } BinaryWriter proj = new BinaryWriter(File.Open(ProjectPath, FileMode.Create, FileAccess.Write)); proj.Write(Sprites.Count()); foreach (Sprite spr in Sprites) { proj.Write(spr.name); proj.Write(spr.lenght); proj.Write(spr.width); proj.Write(spr.height); for (int y = 0; y < spr.height; y++) { for (int x = 0; x < spr.width; x++) { for (int i = 0; i < 9; i++) { proj.Write(spr.data[x, y][i]); } } } } proj.Write(Screens.Count()); foreach (Screen scr in Screens) { proj.Write(scr.name); proj.Write(scr.visible); proj.Write(scr.sprites.Count()); foreach (ScreenSprite scrspr in scr.sprites) { proj.Write(scrspr.sprite.name); proj.Write(scrspr.x_cord); proj.Write(scrspr.y_cord); proj.Write(scrspr.attr); } } proj.Close(); MessageBox.Show("Project saved!", "Successful!", MessageBoxButtons.OK, MessageBoxIcon.Information); ShowProjectName(); ProjectChanged = false; }
private bool SaveProject() { if (currentProject == null) { return(false); } if (currentProject.Name == "Unnamed") { using (var nameDlg = new SaveProjectDialog()) { if (nameDlg.ShowDialog() != DialogResult.OK) { return(false); } currentProject.Name = nameDlg.ProjectName; this.Text = $"Editing project {currentProject.Name}"; currentFile = currentProject.Name + ".resproj"; } } using (var save = new SaveFileDialog()) { save.Filter = "Archivos de proyecto de recursos (*.resproj)|*.resproj"; save.FileName = Path.GetFileName(currentFile); save.InitialDirectory = Path.GetDirectoryName(currentFile); if (save.ShowDialog() != DialogResult.OK) { return(false); } var sets = csManager.CharSets; currentProject.Sprites = sets.Sprites; currentProject.Tiles = sets.Tiles; currentProject.StoredData = PluginManager.GetPluginsData(); string content = JsonConvert.SerializeObject(currentProject, Formatting.Indented); File.WriteAllText(save.FileName, content); currentFile = save.FileName; return(true); } }
/// <summary> /// Creates a new instance of <see cref="ProjectFileService"/>. /// </summary> /// <param name="directoryServiceFactory">A factory that returns an <see cref="IDirectoryService"/>.</param> /// <param name="loadSaveFactory">A factory that returns an <see cref="IProjectLoadSave"/>.</param> /// <param name="saveProjectDialogFactory">A factory that returns a <see cref="SaveProjectDialog"/>.</param> /// <param name="loadProjectDialogFactory">A factory that returns a <see cref="LoadProjectDialog"/>.</param> /// <param name="dialogHostFactory">A factory that returns a <see cref="DialogHostBase"/>.</param> public ProjectFileService( Func <IDirectoryService> directoryServiceFactory, Func <IProjectLoadSave> loadSaveFactory, Func <SaveProjectDialog> saveProjectDialogFactory, Func <LoadProjectDialog> loadProjectDialogFactory, Func <DialogHostBase> dialogHostFactory) { _directoryService = directoryServiceFactory(); _loadSave = loadSaveFactory(); _saveProjectDialog = saveProjectDialogFactory(); _loadProjectDialog = loadProjectDialogFactory(); _dialogHost = dialogHostFactory(); // TODO: Get rid of all three of these lines. ProjectsSaveDirectoryPath = _directoryService.GetCurrentDirectory() + "\\" + "Projects"; TemplatesSaveDirectoryPath = _directoryService.GetCurrentDirectory() + "\\" + "Templates"; DirectoryToService = ProjectsSaveDirectoryPath; // Default to the project directory. Probably want to remove this. }
public void DeferredSaveWithDot() { // http://pytools.codeplex.com/workitem/623 // enable deferred saving on projects using (var app = new VisualStudioApp()) { var props = app.Dte.get_Properties("Environment", "ProjectsAndSolution"); var prevValue = props.Item("SaveNewProjects").Value; props.Item("SaveNewProjects").Value = false; app.OnDispose(() => props.Item("SaveNewProjects").Value = prevValue); // now run the test var newProjDialog = app.FileNewProject(); newProjDialog.FocusLanguageNode("JavaScript"); var consoleApp = newProjDialog.ProjectTypes.FindItem("Blank Node.js Application"); consoleApp.Select(); newProjDialog.ProjectName = "Fob.Baz"; newProjDialog.ClickOK(); // wait for new solution to load... for (int i = 0; i < 100 && app.Dte.Solution.Projects.Count == 0; i++) { System.Threading.Thread.Sleep(1000); } TestUtils.DteExecuteCommandOnThreadPool("File.SaveAll"); var saveProjDialog = new SaveProjectDialog(app.WaitForDialog()); saveProjDialog.Save(); app.WaitForDialogDismissed(); var fullname = app.Dte.Solution.FullName; app.Dte.Solution.Close(false); Directory.Delete(Path.GetDirectoryName(fullname), true); } }