private void OpenPartProjectDirectory(string projectPath) { if (!CloseCurrentProject()) { return; } PartProject loadedProject = null; try { loadedProject = PartProject.LoadFromDirectory(projectPath); } catch (Exception ex) { ErrorMessageBox.Show(this, Messages.Error_OpeningProject, Messages.Caption_OpeningProject, ex.ToString()); } if (loadedProject != null) { LoadPartProject(loadedProject); } }
public RecentFileInfo(PartProject project, string temporaryPath) { PartID = project.PartID; PartName = project.PartDescription; ProjectFile = project.ProjectPath; TemporaryPath = temporaryPath; }
public static void AddRecentProject(PartProject project, bool isSavedFile = false) { if (Current.RecentProjectFiles == null) { Current.RecentProjectFiles = new List <RecentFileInfo>(); } if (isSavedFile && !Current.RecentProjectFiles.Any(x => x.ProjectFile == project.ProjectPath)) { Current.RecentProjectFiles.Insert(0, new RecentFileInfo(project)); while (Current.RecentProjectFiles.Count > MaximumRecentFiles) { Current.RecentProjectFiles.RemoveAt(Current.RecentProjectFiles.Count - 1); } SaveSettings(); } else if (!isSavedFile) { Current.RecentProjectFiles.RemoveAll(x => x.ProjectFile == project.ProjectPath); Current.RecentProjectFiles.Insert(0, new RecentFileInfo(project)); while (Current.RecentProjectFiles.Count > MaximumRecentFiles) { Current.RecentProjectFiles.RemoveAt(Current.RecentProjectFiles.Count - 1); } SaveSettings(); } }
private void LoadNewPartProject(PartProject project) { try { if (!string.IsNullOrWhiteSpace(SettingsManager.Current.EditorSettings.Username)) { string username = SettingsManager.Current.EditorSettings.Username; if (string.IsNullOrWhiteSpace(project.ProjectInfo.Authors) /* || * !project.ProjectInfo.Authors.Contains(username)*/) { //if (!string.IsNullOrWhiteSpace(project.ProjectInfo.Authors)) // username = "******" + username; //project.ProjectInfo.Authors += username; project.ProjectInfo.Authors = username; } } LoadPartProject(project); } catch (Exception ex) { MessageBoxEX.ShowDetails(this, Messages.Error_CreatingProject, Messages.Caption_OpeningProject, ex.ToString()); } }
public ProjectDocument(PartProject project) { Project = project; _SelectedElements = new List <PartElement>(); _ValidationMessages = new List <ValidationMessage>(); NavigationTreeNodes = new ProjectTreeNodeCollection(this); UndoRedoManager = new UndoRedoManager(this); AttachPartProject(); }
public RecentFileInfo(PartProject project, bool includeWorkingDir = false) { PartID = project.PartID; PartName = project.PartDescription; ProjectFile = project.ProjectPath; //if (includeWorkingDir) // WorkingDirectory = project.TemporaryProjectPath; }
public void SaveProject(PartProject project, bool selectPath = false) { bool isNew = string.IsNullOrEmpty(project.ProjectPath); string targetPath = project.ProjectPath; if (selectPath || isNew) { using (var sfd = new SaveFileDialog()) { if (!string.IsNullOrEmpty(project.ProjectPath)) { sfd.InitialDirectory = Path.GetDirectoryName(project.ProjectPath); sfd.FileName = Path.GetFileName(project.ProjectPath); } else { if (SettingsManager.IsWorkspaceDefined) { sfd.InitialDirectory = SettingsManager.Current.ProjectWorkspace; } if (project.PartID > 0) { sfd.FileName = $"{project.PartID}.lpp"; } else { sfd.FileName = $"New part.lpp"; } } sfd.Filter = "LDD Part Project|*.lpp|All Files|*.*"; sfd.DefaultExt = ".lpp"; if (sfd.ShowDialog() == DialogResult.OK) { targetPath = sfd.FileName; } else { return; } } } string oldPath = project.ProjectPath; ProjectManager.SaveProject(targetPath); SettingsManager.AddRecentProject(project, true); if (oldPath != targetPath) { RebuildRecentFilesMenu(); } }
public RecentFileInfo(PartProject project, bool includeWorkingDir = false) { PartID = project.PartID; PartName = project.PartDescription; ProjectFile = project.ProjectPath; if (includeWorkingDir) { WorkingDirectory = project.ProjectWorkingDir; } }
private void File_CreateFromBrickMenu_Click(object sender, EventArgs e) { using (var dlg = new SelectBrickDialog()) { if (dlg.ShowDialog() == DialogResult.OK) { var selectedBrick = dlg.SelectedBrick; var project = PartProject.CreateFromLddPart(selectedBrick.PartId); LoadNewPartProject(project); } } }
private void LoadPartProject(PartProject project) { if (!CloseCurrentProject()) { return; } ProjectManager.SetCurrentProject(project); if (project != null) { AutoSaveTimer.Start(); } }
private void LoadNewPartProject(PartProject project) { try { string tmpProjectDir = GetTemporaryWorkingDir(); project.SaveExtracted(tmpProjectDir); SettingsManager.Current.LastOpenProject = new RecentFileInfo(project, true); SettingsManager.SaveSettings(); LoadPartProject(project); } catch (Exception ex) { ErrorMessageBox.Show(this, Messages.Error_CreatingProject, Messages.Caption_OpeningProject, ex.ToString()); } }
private void OpenPartProjectFile(string projectFilePath) { if (!CloseCurrentProject()) { return; } string tmpProjectDir = GetTemporaryWorkingDir(); PartProject loadedProject = null; bool exceptionThrown = false; try { using (var fs = File.OpenRead(projectFilePath)) loadedProject = PartProject.ExtractAndOpen(fs, tmpProjectDir); } catch (Exception ex) { ErrorMessageBox.Show(this, Messages.Error_OpeningProject, Messages.Caption_OpeningProject, ex.ToString()); exceptionThrown = true; } if (loadedProject != null) { loadedProject.ProjectPath = projectFilePath; loadedProject.ProjectWorkingDir = tmpProjectDir; SettingsManager.Current.LastOpenProject = new RecentFileInfo(loadedProject, true); SettingsManager.AddRecentProject(loadedProject); LoadPartProject(loadedProject); RebuildRecentFilesMenu(); } else if (!exceptionThrown) { ErrorMessageBox.Show(this, Messages.Error_OpeningProject, Messages.Caption_OpeningProject, "Invalid or corrupted project file. Missing \"project.xml\" file."); } }
private bool OpenPartProjectFile(string projectFilePath) { if (!CloseCurrentProject()) { return(false); } if (MultiInstanceManager.InstanceCount > 1) { if (MultiInstanceManager.CheckFileIsOpen(projectFilePath)) { MessageBoxEX.ShowDetails(this, Messages.Error_OpeningProject, Messages.Caption_OpeningProject, "The file is already opened in another instance."); //TODO: translate return(false); } } PartProject loadedProject = null; try { loadedProject = PartProject.Open(projectFilePath); } catch (Exception ex) { MessageBoxEX.ShowDetails(this, Messages.Error_OpeningProject, Messages.Caption_OpeningProject, ex.ToString()); } if (loadedProject != null) { LoadPartProject(loadedProject); } return(loadedProject != null); }
private bool LoadPartProject(PartProject project, string tempPath = null) { if (!CloseCurrentProject()) { return(false); } ViewportPanel.ForceRender(); ProjectManager.SetCurrentProject(project, tempPath); if (project != null) { if (!ProjectManager.IsNewProject && string.IsNullOrEmpty(tempPath)) { RebuildRecentFilesMenu(); SettingsManager.AddRecentProject(ProjectManager.GetCurrentProjectInfo(), true); } AutoSaveTimer.Start(); } return(project != null); }
public ProjectSerializerV1(PartProject project) : base(project) { }
public ProjectSerializerBase(PartProject project) { Project = project; }
protected virtual void OnProjectLoaded(PartProject project) { }
public static Scene PartProjectToAssimp(PartProject project, MeshExportOptions exportOptions = null) { var partWrapper = project.GenerateLddPart(); return(LddPartToAssimp(partWrapper, exportOptions)); }
public BaseProjectNode(PartProject project, string text) : this(project) { Text = text; Childrens = new ProjectTreeNodeCollection(this); }
private void File_NewProjectMenu_Click(object sender, EventArgs e) { var project = PartProject.CreateEmptyProject(); LoadNewPartProject(project); }
private void CheckCanRecoverProject() { SettingsManager.CleanUpFilesHistory(); if (SettingsManager.Current.OpenedProjects.Count > 0) { bool projectWasLoaded = false; foreach (var fileInfo in SettingsManager.Current.OpenedProjects.ToArray()) { //project was not correctly closed if (File.Exists(fileInfo.TemporaryPath)) { if (projectWasLoaded) { continue; } if (MultiInstanceManager.InstanceCount > 1) { bool isOpenInOtherInstance = MultiInstanceManager.CheckFileIsOpen(fileInfo.TemporaryPath); if (isOpenInOtherInstance) { return; } } bool projectRestored = false; if (MessageBoxEX.Show(this, Messages.Message_RecoverProject, Messages.Caption_RecoverLastProject, MessageBoxButtons.YesNo) == DialogResult.Yes) { PartProject loadedProject = null; try { loadedProject = PartProject.Open(fileInfo.TemporaryPath); loadedProject.ProjectPath = fileInfo.ProjectFile; if (LoadPartProject(loadedProject, fileInfo.TemporaryPath)) { projectRestored = true; projectWasLoaded = true; } } catch (Exception ex) { MessageBoxEX.ShowDetails(this, Messages.Error_OpeningProject, Messages.Caption_OpeningProject, ex.ToString()); //exceptionThrown = true; } } if (!projectRestored) { ProjectManager.DeleteTemporaryProject(fileInfo.TemporaryPath); } break; } } } }
public BaseProjectNode(PartProject project) { Project = project; Childrens = new ProjectTreeNodeCollection(this); }