protected override SolutionDocument NewCore(string fullFilePath) { SolutionDocumentType documentType = new SolutionDocumentType(); if (fullFilePath .Substring(fullFilePath.Length - documentType.FileExtension.Length) .CompareTo(documentType.FileExtension) != 0) { fullFilePath = fullFilePath + documentType.FileExtension; } SolutionDocument document = documentType.New(fullFilePath) as SolutionDocument; return document; }
private void SaveDocument(IDocument document) { IDocumentType documentType; if (document is SolutionDocument) { documentType = new SolutionDocumentType(); } else { IEnumerable<IDocumentType> saveTypes = documentTypes.Where(d => d.CanSave(document)); documentType = saveTypes.First(d => d.FileExtension == Path.GetExtension(document.FullFilePath)); } SaveCore(documentType, document); }
private SolutionDocument OpenSolutionCore(string fullFilePath) { if ((SolutionDoc != null) && (SolutionDoc.FullFilePath == fullFilePath)) { this.messageService.ShowMessage(shellService.ShellView, string.Format(CultureInfo.CurrentCulture, Resources.SolutionAlreadyOpened, Path.GetFileNameWithoutExtension(fullFilePath))); return null; } if (!CloseSolution()) { return SolutionDoc; } SolutionDocumentType documentType = new SolutionDocumentType(); SolutionDocument document = null; try { document = documentType.Open(fullFilePath) as SolutionDocument; } catch (Exception e) { Trace.TraceError(e.ToString()); this.messageService.ShowError(shellService.ShellView, string.Format(CultureInfo.CurrentCulture, Resources.CannotOpenSolution, Path.GetFileNameWithoutExtension(fullFilePath))); return null; } if (document != null) { fileService.AddDocument(document); this.recentSolutionList.AddFile(document.FullFilePath); } return document; }
private SolutionDocument NewSolutionCore(string fullFilePath) { if (String.IsNullOrWhiteSpace(Path.GetDirectoryName(fullFilePath))) { this.messageService.ShowError(shellService.ShellView, string.Format(CultureInfo.CurrentCulture, Resources.NewSolutionPathInvalid, fullFilePath)); return null; } // Check if solution already exists if (Directory.Exists(Path.GetDirectoryName(fullFilePath))) { this.messageService.ShowError(shellService.ShellView, string.Format(CultureInfo.CurrentCulture, Resources.SolutionAlreadyExisted, Path.GetFileNameWithoutExtension(fullFilePath))); return null; } SolutionDocumentType documentType = new SolutionDocumentType(); if (fullFilePath .Substring(fullFilePath.Length - documentType.FileExtension.Length) .CompareTo(documentType.FileExtension) != 0) { fullFilePath = fullFilePath + documentType.FileExtension; } SolutionDocument document = documentType.New(fullFilePath) as SolutionDocument; this.recentSolutionList.AddFile(fullFilePath); fileService.AddDocument(document); return this.fileService.SolutionDoc; }
private void NewSolutionCommand(object commandParameter) { IList<string> fileInfo = commandParameter as IList<string>; if ((fileInfo != null) && (fileInfo.Count == 2) && (!string.IsNullOrEmpty(fileInfo[0])) && (!string.IsNullOrEmpty(fileInfo[1]))) { SolutionDocumentType documentType = new SolutionDocumentType(); string fullFileName = Path.Combine(fileInfo[0], fileInfo[1], fileInfo[1] + documentType.FileExtension); NewSolution(fullFileName); } else { NewSolution(); } }
internal IDocument OpenSolution() { SolutionDocumentType documentType = new SolutionDocumentType(); FileType fileType = new FileType(documentType.Description, documentType.FileExtension); FileDialogResult result = fileDialogService.ShowOpenFileDialog(shellService.ShellView, fileType); if (result.IsValid) { return OpenSolutionCore(result.FileName); } return null; }
internal SolutionDocument NewSolution() { // Show the new solutiion view to the user INewSolutionDialogView newSolutionView = container.GetExportedValue<INewSolutionDialogView>(); if (!Directory.Exists(Settings.Default.DefaultNewSolutionLocation)) { Settings.Default.DefaultNewSolutionLocation = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), ApplicationInfo.ProductName); Directory.CreateDirectory(Settings.Default.DefaultNewSolutionLocation); } NewSolutionDialogViewModel newSolutionViewModel = new NewSolutionDialogViewModel(newSolutionView); bool? dialogResult = newSolutionViewModel.ShowDialog(shellService.ShellView); if (dialogResult == true) { if (!CloseSolution()) { return SolutionDoc; } SolutionDocumentType documentType = new SolutionDocumentType(); return NewSolutionCore(Path.Combine(newSolutionViewModel.Location, newSolutionViewModel.SolutionName, newSolutionViewModel.SolutionName + documentType.FileExtension)); } else return null; }
public SolutionDocument(SolutionDocumentType documentType, XDocument solutionXML) : base(documentType) { this.solutionXML = solutionXML; }