/// <summary> /// Attempts to load the session corresponding to the given path. /// </summary> /// <param name="filePath">The path to a solution or package file.</param> /// <returns><c>True</c> if the session was successfully loaded, <c>False</c> if an error occurred, <c>Null</c> if the operation was cancelled by user.</returns> public async Task <bool?> OpenSession(UFile filePath) { if (Session != null) { throw new InvalidOperationException("A session is already open in this instance."); } if (filePath != null && !File.Exists(filePath)) { MRU.RemoveFile(filePath); await ServiceProvider.Get <IDialogService>().MessageBox(string.Format(Tr._p("Message", @"The file '{0}' does not exist."), filePath), MessageBoxButton.OK, MessageBoxImage.Information); return(false); } var sessionResult = new PackageSessionResult(); var loadedSession = await SessionViewModel.OpenSession(filePath, ServiceProvider, this, sessionResult); // Loading has failed if (loadedSession == null) { // Null means the user has cancelled the loading operation. return(sessionResult.OperationCancelled ? (bool?)null : false); } MRU.AddFile(filePath); Session = loadedSession; InternalSettings.FileDialogLastOpenSessionDirectory.SetValue(new UFile(filePath).GetFullDirectory()); InternalSettings.Save(); return(true); }
public void RemoveRecentFile(UFile filePath) { //Get all versions of showing on recent files var xenkoVersions = RecentFiles?.Select(x => x.Version).Distinct().ToList(); if (xenkoVersions != null) { foreach (var item in xenkoVersions) { MRU.RemoveFile(filePath, item); } } }
public void RemoveRecentFile(UFile filePath) { var packageVersion = PackageSessionHelper.GetPackageVersion(filePath); //Remove considering old projects that have been deleted or upgraded from older versions if (packageVersion == null || string.Compare(packageVersion.ToString(), "3.0", StringComparison.Ordinal) <= 0) { //Get all versions of showing on recent files var xenkoVersions = RecentFiles?.Select(x => x.Version).ToList(); if (xenkoVersions != null) { foreach (var item in xenkoVersions) { MRU.RemoveFile(filePath, item); } } } else { MRU.RemoveFile(filePath, packageVersion.ToString()); } }