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()); } }
private void InitializeAfterShown() { WaitPopup.Message = Messages.Message_InitializingResources; WaitPopup.UpdateProgress(0, 0); Application.DoEvents(); var documentPanels = DockPanelControl.Contents.OfType <ProjectDocumentPanel>().ToList(); foreach (var documentPanel in documentPanels) { documentPanel.Enabled = true; documentPanel.DefferedInitialization(); } if (!UIRenderHelper.LoadFreetype6()) { MessageBoxEX.Show(this, Messages.Message_CouldNotLoadFreetype6, Messages.Caption_UnexpectedError, MessageBoxButtons.OK, MessageBoxIcon.Warning); } Task.Factory.StartNew(() => { ViewportPanel.InitGlResourcesAsync(); BeginInvoke(new MethodInvoker(OnInitializationFinished)); }); }
private void OpenPartFromFiles(string primitiveFilepath) { string filename = Path.GetFileNameWithoutExtension(primitiveFilepath); string fileType = Path.GetExtension(primitiveFilepath); if (!int.TryParse(filename, out int partID)) { //TODO: Show message return; } LDD.Primitives.Primitive primitive = null; if (fileType.ToLower() == ".xml") { try { primitive = LDD.Primitives.Primitive.Load(primitiveFilepath); } catch { MessageBoxEX.ShowDetails(this, Messages.Error_OpeningFile, //TODO: change Messages.Caption_OpeningProject, "File is not an LDD Primitive."); //TODO: translate return; } } else if (fileType.ToLower().StartsWith(".g")) { } string fileDir = Path.GetDirectoryName(primitiveFilepath); string fileDirLod0 = Path.Combine(fileDir, "Lod0"); var meshFiles = Directory.GetFiles(fileDir, primitive.ID + ".g*"); if (meshFiles.Length == 0 && Directory.Exists(fileDirLod0)) { meshFiles = Directory.GetFiles(fileDirLod0, primitive.ID + ".g*"); } if (meshFiles.Length == 0) { MessageBoxEX.ShowDetails(this, Messages.Error_OpeningFile, //TODO: change Messages.Caption_OpeningProject, "No mesh file found."); //TODO: translate return; } }
public static DialogResult Show(IWin32Window owner, string text, string caption, string errorDetails, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, FormStartPosition startPosition) { using (var dlg = new MessageBoxEX()) { dlg.Text = caption; dlg.MessageTextLabel.Text = text; dlg.StartPosition = startPosition; dlg.SetDialogButtons(buttons); dlg.SelectDefaultButton(defaultButton); dlg.SetMessageIcon(icon); dlg.SetMessageDetails(errorDetails); return(dlg.ShowDialog(owner)); } }
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 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; } } } }