-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Farewell, Interaction]: Step 2 of removing the Interaction class (#4189
- Loading branch information
Showing
32 changed files
with
1,682 additions
and
1,374 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
using Files.Dialogs; | ||
using Files.Views; | ||
using Microsoft.Toolkit.Uwp; | ||
using System; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Windows.ApplicationModel.Core; | ||
using Windows.Foundation; | ||
using Windows.Foundation.Metadata; | ||
using Windows.UI.Core; | ||
using Windows.UI.ViewManagement; | ||
using Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Controls; | ||
using Windows.UI.Xaml.Media.Animation; | ||
using static Files.Views.Properties; | ||
|
||
namespace Files.Helpers | ||
{ | ||
public static class FilePropertiesHelpers | ||
{ | ||
public static async void ShowProperties(IShellPage associatedInstance) | ||
{ | ||
if (associatedInstance.SlimContentPage.IsItemSelected) | ||
{ | ||
if (associatedInstance.SlimContentPage.SelectedItems.Count > 1) | ||
{ | ||
await OpenPropertiesWindowAsync(associatedInstance.SlimContentPage.SelectedItems, associatedInstance); | ||
} | ||
else | ||
{ | ||
await OpenPropertiesWindowAsync(associatedInstance.SlimContentPage.SelectedItem, associatedInstance); | ||
} | ||
} | ||
else | ||
{ | ||
if (!System.IO.Path.GetPathRoot(associatedInstance.FilesystemViewModel.CurrentFolder.ItemPath) | ||
.Equals(associatedInstance.FilesystemViewModel.CurrentFolder.ItemPath, StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
await OpenPropertiesWindowAsync(associatedInstance.FilesystemViewModel.CurrentFolder, associatedInstance); | ||
} | ||
else | ||
{ | ||
await OpenPropertiesWindowAsync(App.DrivesManager.Drives | ||
.SingleOrDefault(x => x.Path.Equals(associatedInstance.FilesystemViewModel.CurrentFolder.ItemPath)), associatedInstance); | ||
} | ||
} | ||
} | ||
|
||
public static async Task OpenPropertiesWindowAsync(object item, IShellPage associatedInstance) | ||
{ | ||
if (item == null) | ||
{ | ||
return; | ||
} | ||
|
||
if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8)) | ||
{ | ||
CoreApplicationView newWindow = CoreApplication.CreateNewView(); | ||
ApplicationView newView = null; | ||
|
||
await newWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => | ||
{ | ||
Frame frame = new Frame(); | ||
frame.Navigate(typeof(Properties), new PropertiesPageNavigationArguments() | ||
{ | ||
Item = item, | ||
AppInstanceArgument = associatedInstance | ||
}, new SuppressNavigationTransitionInfo()); | ||
Window.Current.Content = frame; | ||
Window.Current.Activate(); | ||
newView = ApplicationView.GetForCurrentView(); | ||
newWindow.TitleBar.ExtendViewIntoTitleBar = true; | ||
newView.Title = "PropertiesTitle".GetLocalized(); | ||
newView.PersistedStateId = "Properties"; | ||
newView.SetPreferredMinSize(new Size(400, 550)); | ||
newView.Consolidated += delegate | ||
{ | ||
Window.Current.Close(); | ||
}; | ||
}); | ||
|
||
bool viewShown = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(newView.Id); | ||
// Set window size again here as sometimes it's not resized in the page Loaded event | ||
newView.TryResizeView(new Size(400, 550)); | ||
} | ||
else | ||
{ | ||
var propertiesDialog = new PropertiesDialog(); | ||
propertiesDialog.propertiesFrame.Tag = propertiesDialog; | ||
propertiesDialog.propertiesFrame.Navigate(typeof(Properties), new PropertiesPageNavigationArguments() | ||
{ | ||
Item = item, | ||
AppInstanceArgument = associatedInstance | ||
}, new SuppressNavigationTransitionInfo()); | ||
await propertiesDialog.ShowAsync(ContentDialogPlacement.Popup); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.