diff --git a/Files UWP/App.xaml.cs b/Files UWP/App.xaml.cs index c37c6f56e256..6a8a7be60f5e 100644 --- a/Files UWP/App.xaml.cs +++ b/Files UWP/App.xaml.cs @@ -23,12 +23,21 @@ using System.Collections.ObjectModel; using Windows.Devices.Enumeration; using System.Text.RegularExpressions; +using Windows.Devices.Portable; +using Windows.UI.Xaml.Media.Imaging; +using Windows.ApplicationModel.Core; +using Windows.UI.Core; +using Windows.Storage.Search; +using Windows.UI.Xaml.Input; namespace Files { sealed partial class App : Application { public static ProHome selectedTabInstance { get; set; } + DeviceWatcher watcher; + public static ObservableCollection sideBarItems = new ObservableCollection(); + public App() { this.InitializeComponent(); @@ -55,12 +64,10 @@ public App() if (localSettings.Values["theme"].ToString() == "Light") { SettingsPages.Personalization.TV.ThemeValue = ApplicationTheme.Light; - //Debug.WriteLine("Theme Requested as Light"); } else if (localSettings.Values["theme"].ToString() == "Dark") { SettingsPages.Personalization.TV.ThemeValue = ApplicationTheme.Dark; - //Debug.WriteLine("Theme Requested as Dark"); } else { @@ -69,19 +76,15 @@ public App() if (color == Colors.White) { SettingsPages.Personalization.TV.ThemeValue = ApplicationTheme.Light; - // Debug.WriteLine("Theme Requested as Default (Light)"); - } else { SettingsPages.Personalization.TV.ThemeValue = ApplicationTheme.Dark; - //Debug.WriteLine("Theme Requested as Default (Dark)"); } } } this.RequestedTheme = SettingsPages.Personalization.TV.ThemeValue; - //Debug.WriteLine("!!Requested Theme!!" + RequestedTheme.ToString()); if (localSettings.Values["FavoritesDisplayed_Start"] == null) { @@ -113,91 +116,351 @@ public App() localSettings.Values["DrivesDisplayed_NewTab"] = false; } - FindDrives(); - //DeviceWatcher watcher = DeviceInformation.CreateWatcher(); - //watcher.Added += (sender, info) => FindDrives(); - //watcher.Removed += (sender, info) => FindDrives(); - //watcher.Start(); + PopulatePinnedSidebarItems(); } - private async void FindDrives() + public void PopulateDrivesListWithLocalDisks() { - foundDrives.Clear(); - var knownRemDevices = new ObservableCollection(); - foreach (var f in await KnownFolders.RemovableDevices.GetFoldersAsync()) - { - var path = f.Path; - knownRemDevices.Add(path); - } - var driveLetters = DriveInfo.GetDrives().Select(x => x.RootDirectory.Root).ToList().OrderBy(x => x.Root.FullName).ToList(); - - if (!driveLetters.Any()) return; - driveLetters.ForEach(async roots => { try { - //if (roots.Name == @"C:\") return; var content = string.Empty; - string icon; - if (knownRemDevices.Contains(roots.Name)) + string icon = null; + if (!(await KnownFolders.RemovableDevices.GetFoldersAsync()).Select(x => x.Path).ToList().Contains(roots.Name)) { - content = $"Removable Drive ({roots.Name})"; - icon = "\uE88E"; + // TODO: Display Custom Names for Local Disks as well + content = $"Local Disk ({roots.Name.TrimEnd('\\')})"; + icon = "\uEDA2"; + + await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Low, + async () => + { + StorageFolder drive = await StorageFolder.GetFolderFromPathAsync(roots.Name); + var retrivedProperties = await drive.Properties.RetrievePropertiesAsync(new string[] { "System.FreeSpace", "System.Capacity" }); + + ulong totalSpaceProg = 0; + ulong freeSpaceProg = 0; + string free_space_text = "Unknown"; + string total_space_text = "Unknown"; + Visibility capacityBarVis = Visibility.Visible; + try + { + var sizeAsGBString = ByteSizeLib.ByteSize.FromBytes((ulong)retrivedProperties["System.FreeSpace"]).GigaBytes; + freeSpaceProg = Convert.ToUInt64(sizeAsGBString); + + sizeAsGBString = ByteSizeLib.ByteSize.FromBytes((ulong)retrivedProperties["System.Capacity"]).GigaBytes; + totalSpaceProg = Convert.ToUInt64(sizeAsGBString); + + + free_space_text = ByteSizeLib.ByteSize.FromBytes((ulong)retrivedProperties["System.FreeSpace"]).ToString(); + total_space_text = ByteSizeLib.ByteSize.FromBytes((ulong)retrivedProperties["System.Capacity"]).ToString(); + } + catch (UnauthorizedAccessException) + { + capacityBarVis = Visibility.Collapsed; + } + catch (NullReferenceException) + { + capacityBarVis = Visibility.Collapsed; + } + + App.foundDrives.Add(new DriveItem() + { + driveText = content, + glyph = icon, + maxSpace = totalSpaceProg, + spaceUsed = totalSpaceProg - freeSpaceProg, + tag = roots.Name, + progressBarVisibility = capacityBarVis, + spaceText = free_space_text + " free of " + total_space_text, + }); + }); } - else + + } + catch (UnauthorizedAccessException e) + { + Debug.WriteLine(e.Message); + } + + }); + + + + } + + private async void Watcher_EnumerationCompleted(DeviceWatcher sender, object args) + { + PopulateDrivesListWithLocalDisks(); + DeviceAdded(sender, null); + await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Low, + () => + { + App.foundDrives.Add(new DriveItem() + { + driveText = "OneDrive", + tag = "OneDrive", + cloudGlyphVisibility = Visibility.Visible, + driveGlyphVisibility = Visibility.Collapsed + }); + }); + } + + private void DeviceUpdated(DeviceWatcher sender, DeviceInformationUpdate args) + { + Debug.WriteLine("Devices updated"); + } + + + private async void DeviceRemoved(DeviceWatcher sender, DeviceInformationUpdate args) + { + var devices = DriveInfo.GetDrives().Select(x => x.RootDirectory.Root).ToList().OrderBy(x => x.Root.FullName).ToList(); + + foreach (DriveItem driveItem in foundDrives) + { + if (!driveItem.tag.Equals("OneDrive")) + { + if (!devices.Any(x => x.Name == driveItem.tag) || devices.Equals(null)) { - content = $"Local Disk ({roots.Name})"; - icon = "\uEDA2"; + await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Low, + () => + { + foundDrives.Remove(driveItem); + }); + return; + } - StorageFolder drive = await StorageFolder.GetFolderFromPathAsync(roots.Name); - var retrivedProperties = await drive.Properties.RetrievePropertiesAsync(new string[] { "System.FreeSpace", "System.Capacity" }); - - ulong totalSpaceProg = 0; - ulong freeSpaceProg = 0; - string free_space_text = "Unknown"; - string total_space_text = "Unknown"; - Visibility capacityBarVis = Visibility.Visible; - try + } + + } + } + + private async void DeviceAdded(DeviceWatcher sender, DeviceInformation args) + { + try + { + //var device = StorageDevice.FromId(args.Id); + var devices = (await KnownFolders.RemovableDevices.GetFoldersAsync()).OrderBy(x => x.Path); + foreach(StorageFolder device in devices) + { + var letter = device.Path; + if(!foundDrives.Any(x => x.tag == letter)) { - var sizeAsGBString = ByteSizeLib.ByteSize.FromBytes((ulong)retrivedProperties["System.FreeSpace"]).GigaBytes; - freeSpaceProg = Convert.ToUInt64(sizeAsGBString); + //if (roots.Name == @"C:\") return; + var content = device.DisplayName; + string icon = null; + await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Low, + async () => + { + if (content.Contains("DVD")) + { + icon = "\uE958"; + } + else + { + icon = "\uE88E"; + } + + StorageFolder drive = await StorageFolder.GetFolderFromPathAsync(letter); + var retrivedProperties = await drive.Properties.RetrievePropertiesAsync(new string[] { "System.FreeSpace", "System.Capacity" }); + + ulong totalSpaceProg = 0; + ulong freeSpaceProg = 0; + string free_space_text = "Unknown"; + string total_space_text = "Unknown"; + Visibility capacityBarVis = Visibility.Visible; + try + { + var sizeAsGBString = ByteSizeLib.ByteSize.FromBytes((ulong)retrivedProperties["System.FreeSpace"]).GigaBytes; + freeSpaceProg = Convert.ToUInt64(sizeAsGBString); + + sizeAsGBString = ByteSizeLib.ByteSize.FromBytes((ulong)retrivedProperties["System.Capacity"]).GigaBytes; + totalSpaceProg = Convert.ToUInt64(sizeAsGBString); + + + free_space_text = ByteSizeLib.ByteSize.FromBytes((ulong)retrivedProperties["System.FreeSpace"]).ToString(); + total_space_text = ByteSizeLib.ByteSize.FromBytes((ulong)retrivedProperties["System.Capacity"]).ToString(); + } + catch (UnauthorizedAccessException) + { + capacityBarVis = Visibility.Collapsed; + } + catch (NullReferenceException) + { + capacityBarVis = Visibility.Collapsed; + } + + if (!foundDrives.Any(x => x.tag == letter)) + { + foundDrives.Add(new DriveItem() + { + driveText = content, + glyph = icon, + maxSpace = totalSpaceProg, + spaceUsed = totalSpaceProg - freeSpaceProg, + tag = letter, + progressBarVisibility = capacityBarVis, + spaceText = free_space_text + " free of " + total_space_text, + }); + } + }); + + } + } + } + catch (UnauthorizedAccessException e) + { + Debug.WriteLine(e.Message); + } + } - sizeAsGBString = ByteSizeLib.ByteSize.FromBytes((ulong)retrivedProperties["System.Capacity"]).GigaBytes; - totalSpaceProg = Convert.ToUInt64(sizeAsGBString); + public static List LinesToRemoveFromFile = new List(); + + public async void PopulatePinnedSidebarItems() + { + AddDefaultLocations(); - free_space_text = ByteSizeLib.ByteSize.FromBytes((ulong)retrivedProperties["System.FreeSpace"]).ToString(); - total_space_text = ByteSizeLib.ByteSize.FromBytes((ulong)retrivedProperties["System.Capacity"]).ToString(); + StorageFile ListFile; + StorageFolder cacheFolder = ApplicationData.Current.LocalCacheFolder; + try + { + ListFile = await cacheFolder.GetFileAsync("PinnedItems.txt"); + } + catch (FileNotFoundException) + { + ListFile = await cacheFolder.CreateFileAsync("PinnedItems.txt"); + } + + if (ListFile != null) + { + var ListFileLines = await FileIO.ReadLinesAsync(ListFile); + foreach (string locationPath in ListFileLines) + { + try + { + StorageFolder fol = await StorageFolder.GetFolderFromPathAsync(locationPath); + var name = fol.DisplayName; + var content = name; + var icon = "\uE8B7"; + + bool isDuplicate = false; + foreach (SidebarItem sbi in sideBarItems) + { + if (!string.IsNullOrWhiteSpace(sbi.Path) && !sbi.isDefaultLocation) + { + if (sbi.Path.ToString() == locationPath) + { + isDuplicate = true; + + } + } + } + + if (!isDuplicate) + { + sideBarItems.Add(new SidebarItem() { isDefaultLocation = false, Text = name, IconGlyph = icon, Path = locationPath }); + } } - catch (UnauthorizedAccessException) + catch (UnauthorizedAccessException e) { - capacityBarVis = Visibility.Collapsed; + Debug.WriteLine(e.Message); } - catch (NullReferenceException) + catch (FileNotFoundException e) { - capacityBarVis = Visibility.Collapsed; + Debug.WriteLine("Pinned item was deleted and will be removed from the file lines list soon: " + e.Message); + LinesToRemoveFromFile.Add(locationPath); } + catch (System.Runtime.InteropServices.COMException e) + { + Debug.WriteLine("Pinned item's drive was ejected and will be removed from the file lines list soon: " + e.Message); + LinesToRemoveFromFile.Add(locationPath); + } + } + + RemoveStaleSidebarItems(); + } + } + + private void AddDefaultLocations() + { + sideBarItems.Add(new SidebarItem() { Text = "Home", IconGlyph = "\uE737", isDefaultLocation = true }); + sideBarItems.Add(new SidebarItem() { Text = "Desktop", IconGlyph = "\uE8FC", isDefaultLocation = true }); + sideBarItems.Add(new SidebarItem() { Text = "Downloads", IconGlyph = "\uE896", isDefaultLocation = true }); + sideBarItems.Add(new SidebarItem() { Text = "Documents", IconGlyph = "\uE8A5", isDefaultLocation = true }); + sideBarItems.Add(new SidebarItem() { Text = "Pictures", IconGlyph = "\uEB9F", isDefaultLocation = true }); + sideBarItems.Add(new SidebarItem() { Text = "Music", IconGlyph = "\uEC4F", isDefaultLocation = true }); + sideBarItems.Add(new SidebarItem() { Text = "Videos", IconGlyph = "\uE8B2", isDefaultLocation = true }); + } + + public static async void RemoveStaleSidebarItems() + { + StorageFile ListFile; + StorageFolder cacheFolder = ApplicationData.Current.LocalCacheFolder; + try + { + ListFile = await cacheFolder.GetFileAsync("PinnedItems.txt"); + } + catch (FileNotFoundException) + { + ListFile = await cacheFolder.CreateFileAsync("PinnedItems.txt"); + } + + if (ListFile != null) + { + var ListFileLines = await FileIO.ReadLinesAsync(ListFile); + foreach (string path in LinesToRemoveFromFile) + { + ListFileLines.Remove(path); + } - foundDrives.Add(new DriveItem() + await FileIO.WriteLinesAsync(ListFile, ListFileLines); + ListFileLines = await FileIO.ReadLinesAsync(ListFile); + + // Remove unpinned items from sidebar + var sideBarItems_Copy = sideBarItems.ToList(); + foreach (SidebarItem location in sideBarItems) + { + if(!location.isDefaultLocation) { - driveText = content, - glyph = icon, - maxSpace = totalSpaceProg, - spaceUsed = totalSpaceProg - freeSpaceProg, - tag = roots.Name, - progressBarVisibility = capacityBarVis, - spaceText = free_space_text + " free of " + total_space_text, - }); + if (!ListFileLines.Contains(location.Path.ToString())) + { + sideBarItems_Copy.Remove(location); + } + } + } - catch (UnauthorizedAccessException e) + sideBarItems.Clear(); + foreach(SidebarItem correctItem in sideBarItems_Copy) { - Debug.WriteLine(e.Message); + sideBarItems.Add(correctItem); } - }); + LinesToRemoveFromFile.Clear(); + } + } + + public static SidebarItem rightClickedItem; + + public static async void FlyoutItem_Click(object sender, RoutedEventArgs e) + { + StorageFolder cacheFolder = ApplicationData.Current.LocalCacheFolder; + var ListFile = await cacheFolder.GetFileAsync("PinnedItems.txt"); + var ListFileLines = await FileIO.ReadLinesAsync(ListFile); + foreach (string path in ListFileLines) + { + if (path == App.rightClickedItem.Path.ToString()) + { + App.LinesToRemoveFromFile.Add(path); + RemoveStaleSidebarItems(); + return; + } + } } + + public static Windows.UI.Xaml.UnhandledExceptionEventArgs exceptionInfo { get; set; } public static string exceptionStackTrace { get; set; } public Dialogs.ExceptionDialog exceptionDialog; @@ -264,6 +527,12 @@ protected override void OnLaunched(LaunchActivatedEventArgs e) } + watcher = DeviceInformation.CreateWatcher(StorageDevice.GetDeviceSelector()); + watcher.Added += DeviceAdded; + watcher.Removed += DeviceRemoved; + watcher.Updated += DeviceUpdated; + watcher.EnumerationCompleted += Watcher_EnumerationCompleted; + watcher.Start(); // Ensure the current window is active Window.Current.Activate(); @@ -294,6 +563,12 @@ protected override void OnActivated(IActivatedEventArgs args) rootFrame.Navigate(typeof(InstanceTabsView), @trimmedPath, new SuppressNavigationTransitionInfo()); } // Ensure the current window is active. + watcher = DeviceInformation.CreateWatcher(StorageDevice.GetDeviceSelector()); + watcher.Added += DeviceAdded; + watcher.Removed += DeviceRemoved; + watcher.Updated += DeviceUpdated; + watcher.EnumerationCompleted += Watcher_EnumerationCompleted; + watcher.Start(); Window.Current.Activate(); return; } @@ -329,6 +604,7 @@ private void OnSuspending(object sender, SuspendingEventArgs e) { var deferral = e.SuspendingOperation.GetDeferral(); //TODO: Save application state and stop any background activity + watcher.Stop(); deferral.Complete(); } } diff --git a/Files UWP/Assets/Files UWP Icon.png b/Files UWP/Assets/Files UWP Icon.png new file mode 100644 index 000000000000..5e239ec227b7 Binary files /dev/null and b/Files UWP/Assets/Files UWP Icon.png differ diff --git a/Files UWP/Dialogs/ExtractFilesDialog.xaml b/Files UWP/Dialogs/ExtractFilesDialog.xaml new file mode 100644 index 000000000000..00cec3272f0c --- /dev/null +++ b/Files UWP/Dialogs/ExtractFilesDialog.xaml @@ -0,0 +1,30 @@ + + + + + + + + + + + + @@ -879,97 +880,55 @@ - - + + - - + + - + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - + + - - + + - - + + - - - - - - - - - - - - - + + + + + + + + - - + + diff --git a/Files UWP/ProHome.xaml.cs b/Files UWP/ProHome.xaml.cs index d65a39e2a39d..24f7ea5be62c 100644 --- a/Files UWP/ProHome.xaml.cs +++ b/Files UWP/ProHome.xaml.cs @@ -16,6 +16,7 @@ using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Input; +using Windows.UI.Xaml.Markup; using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Media.Animation; using Windows.UI.Xaml.Navigation; @@ -97,12 +98,12 @@ public ProHome() accessiblePathListView = PathViewInteract; accessiblePathListView.ItemsSource = pathBoxItems; ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings; - PopulatePinnedSidebarItems(); - PopulateNavViewWithExternalDrives(); + //PopulateNavViewWithExternalDrives(); BackButton.Click += NavigationActions.Back_Click; ForwardButton.Click += NavigationActions.Forward_Click; RefreshButton.Click += NavigationActions.Refresh_Click; UpButton.Click += NavigationActions.Up_Click; + UnpinItem.Click += App.FlyoutItem_Click; // Overwrite paths for common locations if Custom Locations setting is enabled if(localSettings.Values["customLocationsSetting"] != null) @@ -123,206 +124,6 @@ public ProHome() deleteProgressBoxTextInfo = deleteInfoCurrentText; } - List LinesToRemoveFromFile = new List(); - - public async void PopulatePinnedSidebarItems() - { - StorageFile ListFile; - StorageFolder cacheFolder = ApplicationData.Current.LocalCacheFolder; - try - { - ListFile = await cacheFolder.GetFileAsync("PinnedItems.txt"); - } - catch(FileNotFoundException) - { - ListFile = await cacheFolder.CreateFileAsync("PinnedItems.txt"); - } - - if(ListFile != null) - { - var ListFileLines = await FileIO.ReadLinesAsync(ListFile); - foreach (string s in ListFileLines) - { - try - { - StorageFolder fol = await StorageFolder.GetFolderFromPathAsync(s); - var name = fol.DisplayName; - var content = name; - var icon = "\uE8B7"; - - FontFamily fontFamily = new FontFamily("Segoe MDL2 Assets"); - FontIcon fontIcon = new FontIcon() - { - FontSize = 16, - FontFamily = fontFamily, - Glyph = icon - }; - - TextBlock text = new TextBlock() - { - Text = content, - FontSize = 12 - }; - - StackPanel stackPanel = new StackPanel() - { - Spacing = 15, - Orientation = Orientation.Horizontal - }; - - stackPanel.Children.Add(fontIcon); - stackPanel.Children.Add(text); - MenuFlyout flyout = new MenuFlyout(); - MenuFlyoutItem flyoutItem = new MenuFlyoutItem() - { - Text = "Unpin item" - }; - flyoutItem.Click += FlyoutItem_Click; - flyout.Items.Add(flyoutItem); - bool isDuplicate = false; - foreach (ListViewItem lvi in LocationsList.Items) - { - if (lvi.Tag.ToString() == s) - { - isDuplicate = true; - - } - } - - if (!isDuplicate) - { - ListViewItem newItem = new ListViewItem(); - newItem.Content = stackPanel; - newItem.Tag = s; - newItem.ContextFlyout = flyout; - newItem.IsRightTapEnabled = true; - newItem.RightTapped += NewItem_RightTapped; - LocationsList.Items.Add(newItem); - } - } - catch (UnauthorizedAccessException e) - { - Debug.WriteLine(e.Message); - } - catch (FileNotFoundException e) - { - Debug.WriteLine("Pinned item was deleted and will be removed from the file lines list soon: " + e.Message); - LinesToRemoveFromFile.Add(s); - } - catch (System.Runtime.InteropServices.COMException e) - { - Debug.WriteLine("Pinned item's drive was ejected and will be removed from the file lines list soon: " + e.Message); - LinesToRemoveFromFile.Add(s); - } - } - - foreach (string path in LinesToRemoveFromFile) - { - ListFileLines.Remove(path); - } - - await FileIO.WriteLinesAsync(ListFile, ListFileLines); - ListFileLines = await FileIO.ReadLinesAsync(ListFile); - - // Remove unpinned items from sidebar - foreach (ListViewItem location in LocationsList.Items) - { - if (!(location.Tag.ToString() == "Home" || location.Tag.ToString() == "Desktop" || location.Tag.ToString() == "Documents" || location.Tag.ToString() == "Downloads" || location.Tag.ToString() == "Pictures" || location.Tag.ToString() == "Music" || location.Tag.ToString() == "Videos")) - { - - if (!ListFileLines.Contains(location.Tag.ToString())) - { - if(LocationsList.SelectedItem == location) - { - LocationsList.SelectedIndex = 0; - accessibleContentFrame.Navigate(typeof(YourHome), "New tab"); - PathText.Text = "New tab"; - LayoutItems.isEnabled = false; - } - LocationsList.Items.Remove(location); - } - } - } - LinesToRemoveFromFile.Clear(); - } - } - - ListViewItem rightClickedItem; - - private void NewItem_RightTapped(object sender, RightTappedRoutedEventArgs e) - { - rightClickedItem = sender as ListViewItem; - } - - public void PopulateNavViewWithExternalDrives() - { - DrivesList.Items.Clear(); - foreach(var drive in App.foundDrives) - { - FontFamily fontFamily = new FontFamily("Segoe MDL2 Assets"); - FontIcon fontIcon = new FontIcon() - { - FontSize = 16, - FontFamily = fontFamily, - Glyph = drive.glyph - }; - - TextBlock text = new TextBlock() - { - Text = drive.driveText, - FontSize = 12 - }; - - StackPanel stackPanel = new StackPanel() - { - Spacing = 15, - Orientation = Orientation.Horizontal - }; - - stackPanel.Children.Add(fontIcon); - stackPanel.Children.Add(text); - DrivesList.Items.Add(new ListViewItem() - { - Content = stackPanel, - Tag = drive.tag - }); - } - - ListViewItem oneDriveItem = new ListViewItem(); - oneDriveItem.Tag = "OneDrive"; - StackPanel sp = new StackPanel() - { - Spacing = 15, - Orientation = Orientation.Horizontal - - }; - FontIcon fi = new FontIcon(); - fi.Glyph = "\uE753"; - fi.FontSize = 16; - sp.Children.Add(fi); - TextBlock textBlock = new TextBlock(); - textBlock.FontSize = 12; - textBlock.Text = "OneDrive"; - sp.Children.Add(textBlock); - oneDriveItem.Content = sp; - DrivesList.Items.Add(oneDriveItem); - } - - private async void FlyoutItem_Click(object sender, RoutedEventArgs e) - { - StorageFolder cacheFolder = Windows.Storage.ApplicationData.Current.LocalCacheFolder; - var ListFile = await cacheFolder.GetFileAsync("PinnedItems.txt"); - var ListFileLines = await FileIO.ReadLinesAsync(ListFile); - foreach (string s in ListFileLines) - { - if(s == rightClickedItem.Tag.ToString()) - { - LinesToRemoveFromFile.Add(s); - PopulatePinnedSidebarItems(); - return; - } - } - } private void VisiblePath_TextChanged(object sender, KeyRoutedEventArgs e) { @@ -528,103 +329,106 @@ public async void CheckPathInput(ItemViewModel instance, string CurrentInput) private void LocationsList_ItemClick(object sender, ItemClickEventArgs e) { - ListViewItem clickedItem = Interaction.FindParent(e.ClickedItem as DependencyObject); + SidebarItem clickedItem = e.ClickedItem as SidebarItem; - if (clickedItem.Tag.ToString() == "Home") + if (clickedItem.isDefaultLocation) { - ItemDisplayFrame.Navigate(typeof(YourHome), "New tab"); - PathText.Text = "New tab"; - HomeItems.isEnabled = false; - ShareItems.isEnabled = false; - if (DrivesList.SelectedItem != null) + if (clickedItem.Text.ToString() == "Home") { - DrivesList.SelectedItem = null; + ItemDisplayFrame.Navigate(typeof(YourHome), "New tab"); + PathText.Text = "New tab"; + HomeItems.isEnabled = false; + ShareItems.isEnabled = false; + if (DrivesList.SelectedItem != null) + { + DrivesList.SelectedItem = null; + LayoutItems.isEnabled = false; + } LayoutItems.isEnabled = false; } - LayoutItems.isEnabled = false; - } - else if (clickedItem.Tag.ToString() == "Desktop") - { - ItemDisplayFrame.Navigate(typeof(GenericFileBrowser), DesktopPath); - PathText.Text = "Desktop"; - HomeItems.isEnabled = false; - ShareItems.isEnabled = false; - if (DrivesList.SelectedItem != null) + else if (clickedItem.Text.ToString() == "Desktop") { - DrivesList.SelectedItem = null; - LayoutItems.isEnabled = false; + ItemDisplayFrame.Navigate(typeof(GenericFileBrowser), DesktopPath); + PathText.Text = "Desktop"; + HomeItems.isEnabled = false; + ShareItems.isEnabled = false; + if (DrivesList.SelectedItem != null) + { + DrivesList.SelectedItem = null; + LayoutItems.isEnabled = false; + } + LayoutItems.isEnabled = true; } - LayoutItems.isEnabled = true; - } - else if (clickedItem.Tag.ToString() == "Downloads") - { - ItemDisplayFrame.Navigate(typeof(GenericFileBrowser), DownloadsPath); - PathText.Text = "Downloads"; - HomeItems.isEnabled = false; - ShareItems.isEnabled = false; - if (DrivesList.SelectedItem != null) + else if (clickedItem.Text.ToString() == "Downloads") { - DrivesList.SelectedItem = null; - LayoutItems.isEnabled = false; + ItemDisplayFrame.Navigate(typeof(GenericFileBrowser), DownloadsPath); + PathText.Text = "Downloads"; + HomeItems.isEnabled = false; + ShareItems.isEnabled = false; + if (DrivesList.SelectedItem != null) + { + DrivesList.SelectedItem = null; + LayoutItems.isEnabled = false; + } + LayoutItems.isEnabled = true; } - LayoutItems.isEnabled = true; - } - else if (clickedItem.Tag.ToString() == "Documents") - { - ItemDisplayFrame.Navigate(typeof(GenericFileBrowser), DocumentsPath); - PathText.Text = "Documents"; - HomeItems.isEnabled = false; - ShareItems.isEnabled = false; - if (DrivesList.SelectedItem != null) + else if (clickedItem.Text.ToString() == "Documents") { - DrivesList.SelectedItem = null; - LayoutItems.isEnabled = false; + ItemDisplayFrame.Navigate(typeof(GenericFileBrowser), DocumentsPath); + PathText.Text = "Documents"; + HomeItems.isEnabled = false; + ShareItems.isEnabled = false; + if (DrivesList.SelectedItem != null) + { + DrivesList.SelectedItem = null; + LayoutItems.isEnabled = false; + } + LayoutItems.isEnabled = true; } - LayoutItems.isEnabled = true; - } - else if (clickedItem.Tag.ToString() == "Pictures") - { - ItemDisplayFrame.Navigate(typeof(PhotoAlbum), PicturesPath); - PathText.Text = "Pictures"; - HomeItems.isEnabled = false; - ShareItems.isEnabled = false; - if (DrivesList.SelectedItem != null) + else if (clickedItem.Text.ToString() == "Pictures") { - DrivesList.SelectedItem = null; - LayoutItems.isEnabled = false; + ItemDisplayFrame.Navigate(typeof(PhotoAlbum), PicturesPath); + PathText.Text = "Pictures"; + HomeItems.isEnabled = false; + ShareItems.isEnabled = false; + if (DrivesList.SelectedItem != null) + { + DrivesList.SelectedItem = null; + LayoutItems.isEnabled = false; + } + LayoutItems.isEnabled = true; } - LayoutItems.isEnabled = true; - } - else if (clickedItem.Tag.ToString() == "Music") - { - ItemDisplayFrame.Navigate(typeof(GenericFileBrowser), MusicPath); - PathText.Text = "Music"; - HomeItems.isEnabled = false; - ShareItems.isEnabled = false; - if (DrivesList.SelectedItem != null) + else if (clickedItem.Text.ToString() == "Music") { - DrivesList.SelectedItem = null; - LayoutItems.isEnabled = false; + ItemDisplayFrame.Navigate(typeof(GenericFileBrowser), MusicPath); + PathText.Text = "Music"; + HomeItems.isEnabled = false; + ShareItems.isEnabled = false; + if (DrivesList.SelectedItem != null) + { + DrivesList.SelectedItem = null; + LayoutItems.isEnabled = false; + } + LayoutItems.isEnabled = true; } - LayoutItems.isEnabled = true; - } - else if (clickedItem.Tag.ToString() == "Videos") - { - ItemDisplayFrame.Navigate(typeof(GenericFileBrowser), VideosPath); - PathText.Text = "Videos"; - HomeItems.isEnabled = false; - ShareItems.isEnabled = false; - if (DrivesList.SelectedItem != null) + else if (clickedItem.Text.ToString() == "Videos") { - DrivesList.SelectedItem = null; - LayoutItems.isEnabled = false; + ItemDisplayFrame.Navigate(typeof(GenericFileBrowser), VideosPath); + PathText.Text = "Videos"; + HomeItems.isEnabled = false; + ShareItems.isEnabled = false; + if (DrivesList.SelectedItem != null) + { + DrivesList.SelectedItem = null; + LayoutItems.isEnabled = false; + } + LayoutItems.isEnabled = true; } - LayoutItems.isEnabled = true; } else { - ItemDisplayFrame.Navigate(typeof(GenericFileBrowser), clickedItem.Tag); - PathText.Text = clickedItem.Tag.ToString(); + ItemDisplayFrame.Navigate(typeof(GenericFileBrowser), clickedItem.Path); + PathText.Text = clickedItem.Text; HomeItems.isEnabled = false; ShareItems.isEnabled = false; if (DrivesList.SelectedItem != null) @@ -639,102 +443,34 @@ private void LocationsList_ItemClick(object sender, ItemClickEventArgs e) private void DrivesList_ItemClick(object sender, ItemClickEventArgs e) { - if (this.accessibleContentFrame.SourcePageType == typeof(GenericFileBrowser)) + HomeItems.isEnabled = false; + ShareItems.isEnabled = false; + if (LocationsList.SelectedItem != null) { - var instance = instanceViewModel; - HomeItems.isEnabled = false; - ShareItems.isEnabled = false; - if (LocationsList.SelectedItem != null) - { - LocationsList.SelectedItem = null; - LayoutItems.isEnabled = false; - } - - ListViewItem clickedItem = Interaction.FindParent(e.ClickedItem as DependencyObject); - - if (clickedItem.Tag.ToString() == "LocalDisk") - { - ItemDisplayFrame.Navigate(typeof(GenericFileBrowser), @"C:\"); - PathText.Text = @"Local Disk (C:\)"; - LayoutItems.isEnabled = true; - } - else if (clickedItem.Tag.ToString() == "OneDrive") - { - ItemDisplayFrame.Navigate(typeof(GenericFileBrowser), OneDrivePath); - PathText.Text = "OneDrive"; - LayoutItems.isEnabled = true; - } - else - { - ItemDisplayFrame.Navigate(typeof(GenericFileBrowser), clickedItem.Tag.ToString()); - PathText.Text = clickedItem.Tag.ToString(); - LayoutItems.isEnabled = true; - } + LocationsList.SelectedItem = null; + LayoutItems.isEnabled = false; } - else if (this.accessibleContentFrame.SourcePageType == typeof(YourHome)) - { - HomeItems.isEnabled = false; - ShareItems.isEnabled = false; - if (LocationsList.SelectedItem != null) - { - LocationsList.SelectedItem = null; - LayoutItems.isEnabled = false; - } - ListViewItem clickedItem = Interaction.FindParent(e.ClickedItem as DependencyObject); + DriveItem clickedItem = e.ClickedItem as DriveItem; - if (clickedItem.Tag.ToString() == "LocalDisk") - { - ItemDisplayFrame.Navigate(typeof(GenericFileBrowser), @"C:\"); - PathText.Text = @"Local Disk (C:\)"; - LayoutItems.isEnabled = true; - } - else if (clickedItem.Tag.ToString() == "OneDrive") - { - ItemDisplayFrame.Navigate(typeof(GenericFileBrowser), OneDrivePath); - PathText.Text = "OneDrive"; - LayoutItems.isEnabled = true; - } - else - { - ItemDisplayFrame.Navigate(typeof(GenericFileBrowser), clickedItem.Tag.ToString()); - PathText.Text = clickedItem.Tag.ToString(); - LayoutItems.isEnabled = true; - } + if (clickedItem.tag.ToString() == "LocalDisk") + { + ItemDisplayFrame.Navigate(typeof(GenericFileBrowser), @"C:\"); + PathText.Text = @"Local Disk (C:\)"; + LayoutItems.isEnabled = true; } - else if (this.accessibleContentFrame.SourcePageType == typeof(PhotoAlbum)) + else if (clickedItem.tag.ToString() == "OneDrive") { - var instance = instanceViewModel; - HomeItems.isEnabled = false; - ShareItems.isEnabled = false; - if (LocationsList.SelectedItem != null) - { - LocationsList.SelectedItem = null; - LayoutItems.isEnabled = false; - } - - ListViewItem clickedItem = Interaction.FindParent(e.ClickedItem as DependencyObject); - - if (clickedItem.Tag.ToString() == "LocalDisk") - { - ItemDisplayFrame.Navigate(typeof(GenericFileBrowser), @"C:\"); - PathText.Text = @"Local Disk (C:\)"; - LayoutItems.isEnabled = true; - } - else if (clickedItem.Tag.ToString() == "OneDrive") - { - ItemDisplayFrame.Navigate(typeof(GenericFileBrowser), OneDrivePath); - PathText.Text = "OneDrive"; - LayoutItems.isEnabled = true; - } - else - { - ItemDisplayFrame.Navigate(typeof(GenericFileBrowser), clickedItem.Tag.ToString()); - PathText.Text = clickedItem.Tag.ToString(); - LayoutItems.isEnabled = true; - } + ItemDisplayFrame.Navigate(typeof(GenericFileBrowser), OneDrivePath); + PathText.Text = "OneDrive"; + LayoutItems.isEnabled = true; } - + else + { + ItemDisplayFrame.Navigate(typeof(GenericFileBrowser), clickedItem.tag.ToString()); + PathText.Text = clickedItem.tag.ToString(); + LayoutItems.isEnabled = true; + } } string NavParams = null; @@ -1065,6 +801,17 @@ private void ManualPathEntryItem_Click(object sender, RoutedEventArgs e) VisiblePath.Focus(FocusState.Programmatic); VisiblePath.SelectionStart = VisiblePath.Text.Length; } + + private void LocationsList_RightTapped(object sender, RightTappedRoutedEventArgs e) + { + ListView list = (ListView)sender; + var item = ((FrameworkElement)e.OriginalSource).DataContext as SidebarItem; + if (!item.isDefaultLocation) + { + SideBarItemContextFlyout.ShowAt(list, e.GetPosition(list)); + App.rightClickedItem = item; + } + } } public class NavigationActions @@ -1131,20 +878,20 @@ public static void Back_Click(object sender, RoutedEventArgs e) } else if (Parameter.ToString() == ProHome.OneDrivePath) { - CurrentTabInstance.drivesList.SelectedItem = CurrentTabInstance.drivesList.Items.Where(x => (x as ListViewItem).Tag.ToString() == "OneDrive").First(); + CurrentTabInstance.drivesList.SelectedItem = CurrentTabInstance.drivesList.Items.Where(x => (x as DriveItem).tag == "OneDrive").First(); CurrentTabInstance.PathText.Text = "OneDrive"; } else { if (Parameter.ToString().Contains("C:\\") || Parameter.ToString().Contains("c:\\")) { - CurrentTabInstance.drivesList.SelectedIndex = 0; + CurrentTabInstance.drivesList.SelectedItem = CurrentTabInstance.drivesList.Items.Where(x => (x as DriveItem).tag == "C:\\").First(); } else { - foreach (ListViewItem drive in CurrentTabInstance.drivesList.Items) + foreach (DriveItem drive in CurrentTabInstance.drivesList.Items) { - if (drive.Tag.ToString().Contains(Parameter.ToString().Split("\\")[0])) + if (drive.tag.ToString().Contains(Parameter.ToString().Split("\\")[0])) { CurrentTabInstance.drivesList.SelectedItem = drive; break; @@ -1207,20 +954,20 @@ public static void Back_Click(object sender, RoutedEventArgs e) } else if (Parameter.ToString() == ProHome.OneDrivePath) { - CurrentTabInstance.drivesList.SelectedItem = CurrentTabInstance.drivesList.Items.Where(x => (x as ListViewItem).Tag.ToString() == "OneDrive").First(); + CurrentTabInstance.drivesList.SelectedItem = CurrentTabInstance.drivesList.Items.Where(x => (x as DriveItem).tag.ToString() == "OneDrive").First(); CurrentTabInstance.PathText.Text = "OneDrive"; } else { if (Parameter.ToString().Contains("C:\\") || Parameter.ToString().Contains("c:\\")) { - CurrentTabInstance.drivesList.SelectedIndex = 0; + CurrentTabInstance.drivesList.SelectedItem = CurrentTabInstance.drivesList.Items.Where(x => (x as DriveItem).tag == "C:\\").First(); } else { - foreach (ListViewItem drive in CurrentTabInstance.drivesList.Items) + foreach (DriveItem drive in CurrentTabInstance.drivesList.Items) { - if (drive.Tag.ToString().Contains(Parameter.ToString().Split("\\")[0])) + if (drive.tag.ToString().Contains(Parameter.ToString().Split("\\")[0])) { CurrentTabInstance.drivesList.SelectedItem = drive; break; @@ -1283,20 +1030,20 @@ public static void Back_Click(object sender, RoutedEventArgs e) } else if (Parameter.ToString() == ProHome.OneDrivePath) { - CurrentTabInstance.drivesList.SelectedItem = CurrentTabInstance.drivesList.Items.Where(x => (x as ListViewItem).Tag.ToString() == "OneDrive").First(); + CurrentTabInstance.drivesList.SelectedItem = CurrentTabInstance.drivesList.Items.Where(x => (x as DriveItem).tag.ToString() == "OneDrive").First(); CurrentTabInstance.PathText.Text = "OneDrive"; } else { if (Parameter.ToString().Contains("C:\\") || Parameter.ToString().Contains("c:\\")) { - CurrentTabInstance.drivesList.SelectedIndex = 0; + CurrentTabInstance.drivesList.SelectedItem = CurrentTabInstance.drivesList.Items.Where(x => (x as DriveItem).tag == "C:\\").First(); } else { - foreach (ListViewItem drive in CurrentTabInstance.drivesList.Items) + foreach (DriveItem drive in CurrentTabInstance.drivesList.Items) { - if (drive.Tag.ToString().Contains(Parameter.ToString().Split("\\")[0])) + if (drive.tag.ToString().Contains(Parameter.ToString().Split("\\")[0])) { CurrentTabInstance.drivesList.SelectedItem = drive; break; @@ -1368,20 +1115,20 @@ public static void Forward_Click(object sender, RoutedEventArgs e) } else if (Parameter.ToString() == ProHome.OneDrivePath) { - CurrentTabInstance.drivesList.SelectedItem = CurrentTabInstance.drivesList.Items.Where(x => (x as ListViewItem).Tag.ToString() == "OneDrive").First(); + CurrentTabInstance.drivesList.SelectedItem = CurrentTabInstance.drivesList.Items.Where(x => (x as DriveItem).tag.ToString() == "OneDrive").First(); CurrentTabInstance.PathText.Text = "OneDrive"; } else { if (Parameter.ToString().Contains("C:\\") || Parameter.ToString().Contains("c:\\")) { - CurrentTabInstance.drivesList.SelectedIndex = 0; + CurrentTabInstance.drivesList.SelectedItem = CurrentTabInstance.drivesList.Items.Where(x => (x as DriveItem).tag == "C:\\").First(); } else { - foreach (ListViewItem drive in CurrentTabInstance.drivesList.Items) + foreach (DriveItem drive in CurrentTabInstance.drivesList.Items) { - if (drive.Tag.ToString().Contains(Parameter.ToString().Split("\\")[0])) + if (drive.tag.ToString().Contains(Parameter.ToString().Split("\\")[0])) { CurrentTabInstance.drivesList.SelectedItem = drive; break; @@ -1446,20 +1193,20 @@ public static void Forward_Click(object sender, RoutedEventArgs e) } else if (Parameter.ToString() == ProHome.OneDrivePath) { - CurrentTabInstance.drivesList.SelectedItem = CurrentTabInstance.drivesList.Items.Where(x => (x as ListViewItem).Tag.ToString() == "OneDrive").First(); + CurrentTabInstance.drivesList.SelectedItem = CurrentTabInstance.drivesList.Items.Where(x => (x as DriveItem).tag.ToString() == "OneDrive").First(); CurrentTabInstance.PathText.Text = "OneDrive"; } else { if (Parameter.ToString().Contains("C:\\") || Parameter.ToString().Contains("c:\\")) { - CurrentTabInstance.drivesList.SelectedIndex = 0; + CurrentTabInstance.drivesList.SelectedItem = CurrentTabInstance.drivesList.Items.Where(x => (x as DriveItem).tag == "C:\\").First(); } else { - foreach (ListViewItem drive in CurrentTabInstance.drivesList.Items) + foreach (DriveItem drive in CurrentTabInstance.drivesList.Items) { - if (drive.Tag.ToString().Contains(Parameter.ToString().Split("\\")[0])) + if (drive.tag.ToString().Contains(Parameter.ToString().Split("\\")[0])) { CurrentTabInstance.drivesList.SelectedItem = drive; break; @@ -1523,20 +1270,20 @@ public static void Forward_Click(object sender, RoutedEventArgs e) } else if (Parameter.ToString() == ProHome.OneDrivePath) { - CurrentTabInstance.drivesList.SelectedItem = CurrentTabInstance.drivesList.Items.Where(x => (x as ListViewItem).Tag.ToString() == "OneDrive").First(); + CurrentTabInstance.drivesList.SelectedItem = CurrentTabInstance.drivesList.Items.Where(x => (x as DriveItem).tag.ToString() == "OneDrive").First(); CurrentTabInstance.PathText.Text = "OneDrive"; } else { if (Parameter.ToString().Contains("C:\\") || Parameter.ToString().Contains("c:\\")) { - CurrentTabInstance.drivesList.SelectedIndex = 0; + CurrentTabInstance.drivesList.SelectedItem = CurrentTabInstance.drivesList.Items.Where(x => (x as DriveItem).tag == "C:\\").First(); } else { - foreach (ListViewItem drive in CurrentTabInstance.drivesList.Items) + foreach (DriveItem drive in CurrentTabInstance.drivesList.Items) { - if (drive.Tag.ToString().Contains(Parameter.ToString().Split("\\")[0])) + if (drive.tag.ToString().Contains(Parameter.ToString().Split("\\")[0])) { CurrentTabInstance.drivesList.SelectedItem = drive; break; @@ -1606,20 +1353,20 @@ public static void Up_Click(object sender, RoutedEventArgs e) } else if (parentDirectoryOfPath == ProHome.OneDrivePath) { - CurrentTabInstance.drivesList.SelectedItem = CurrentTabInstance.drivesList.Items.Where(x => (x as ListViewItem).Tag.ToString() == "OneDrive").First(); + CurrentTabInstance.drivesList.SelectedItem = CurrentTabInstance.drivesList.Items.Where(x => (x as DriveItem).tag.ToString() == "OneDrive").First(); CurrentTabInstance.PathText.Text = "OneDrive"; } else { if (parentDirectoryOfPath.Contains("C:\\") || parentDirectoryOfPath.Contains("c:\\")) { - CurrentTabInstance.drivesList.SelectedIndex = 0; + CurrentTabInstance.drivesList.SelectedItem = CurrentTabInstance.drivesList.Items.Where(x => (x as DriveItem).tag == "C:\\").First(); } else { - foreach (ListViewItem drive in CurrentTabInstance.drivesList.Items) + foreach (DriveItem drive in CurrentTabInstance.drivesList.Items) { - if (drive.Tag.ToString().Contains(parentDirectoryOfPath.Split("\\")[0])) + if (drive.tag.ToString().Contains(parentDirectoryOfPath.Split("\\")[0])) { CurrentTabInstance.drivesList.SelectedItem = drive; break; @@ -1682,20 +1429,20 @@ public static void Up_Click(object sender, RoutedEventArgs e) } else if (parentDirectoryOfPath == ProHome.OneDrivePath) { - CurrentTabInstance.drivesList.SelectedItem = CurrentTabInstance.drivesList.Items.Where(x => (x as ListViewItem).Tag.ToString() == "OneDrive").First(); + CurrentTabInstance.drivesList.SelectedItem = CurrentTabInstance.drivesList.Items.Where(x => (x as DriveItem).tag.ToString() == "OneDrive").First(); CurrentTabInstance.PathText.Text = "OneDrive"; } else { if (parentDirectoryOfPath.Contains("C:\\") || parentDirectoryOfPath.Contains("c:\\")) { - CurrentTabInstance.drivesList.SelectedIndex = 0; + CurrentTabInstance.drivesList.SelectedItem = CurrentTabInstance.drivesList.Items.Where(x => (x as DriveItem).tag == "C:\\").First(); } else { - foreach (ListViewItem drive in CurrentTabInstance.drivesList.Items) + foreach (DriveItem drive in CurrentTabInstance.drivesList.Items) { - if (drive.Tag.ToString().Contains(parentDirectoryOfPath.Split("\\")[0])) + if (drive.tag.ToString().Contains(parentDirectoryOfPath.Split("\\")[0])) { CurrentTabInstance.drivesList.SelectedItem = drive; break; diff --git a/Files UWP/SettingsPages/About.xaml b/Files UWP/SettingsPages/About.xaml index 34130facdf64..4db10f68c967 100644 --- a/Files UWP/SettingsPages/About.xaml +++ b/Files UWP/SettingsPages/About.xaml @@ -1,4 +1,4 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - diff --git a/FilesUwp.Package/Package.appxmanifest b/FilesUwp.Package/Package.appxmanifest index 72127a6995ac..7fc3511e69aa 100644 --- a/FilesUwp.Package/Package.appxmanifest +++ b/FilesUwp.Package/Package.appxmanifest @@ -1,6 +1,6 @@  - + Files UWP Yair A @@ -15,7 +15,7 @@ - + @@ -23,7 +23,7 @@ - + diff --git a/ProcessLauncher/Program.cs b/ProcessLauncher/Program.cs index 21818e8e2733..3d96fd8e8e35 100644 --- a/ProcessLauncher/Program.cs +++ b/ProcessLauncher/Program.cs @@ -17,7 +17,7 @@ static void Main(string[] args) Process process = new Process(); process.StartInfo.UseShellExecute = false; process.StartInfo.FileName = executable; - if(arguments != "") + if(!string.IsNullOrWhiteSpace(arguments)) { process.StartInfo.CreateNoWindow = false; process.StartInfo.Arguments = arguments;