Skip to content

Commit

Permalink
Merge pull request #268 from duke7553/testing
Browse files Browse the repository at this point in the history
Incorporate changes from Testing
  • Loading branch information
yaira2 authored Nov 3, 2019
2 parents b556239 + 29a1da3 commit 0d90f42
Show file tree
Hide file tree
Showing 17 changed files with 1,113 additions and 713 deletions.
400 changes: 338 additions & 62 deletions Files UWP/App.xaml.cs

Large diffs are not rendered by default.

Binary file added Files UWP/Assets/Files UWP Icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions Files UWP/Dialogs/ExtractFilesDialog.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<ContentDialog
x:Class="Files.Dialogs.ExtractFilesDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Files.Dialogs"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
CornerRadius="4"
Title="Extract Compressed Archive"
PrimaryButtonText="Extract"
CloseButtonText="Cancel"
DefaultButton="Primary"
PrimaryButtonClick="ContentDialog_PrimaryButtonClick"
CloseButtonClick="ContentDialog_CloseButtonClick">

<Grid MinWidth="375">
<StackPanel Orientation="Vertical">
<TextBlock TextWrapping="WrapWholeWords" Text="Pick a location to extract this compressed archive to. You'll need to stay in the current folder until we're done. A new tab will open up with the extracted items."/>
<Grid ColumnSpacing="5" Margin="0,14,0,0" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="75*"/>
<ColumnDefinition Width="25*"/>
</Grid.ColumnDefinitions>
<TextBox x:Name="DestPathText" Grid.Column="0"/>
<Button x:Name="BrowseButton" Grid.Column="1" Content="Browse" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Click="BrowseButton_Click"/>
</Grid>
</StackPanel>
</Grid>
</ContentDialog>
54 changes: 54 additions & 0 deletions Files UWP/Dialogs/ExtractFilesDialog.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The Content Dialog item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238

namespace Files.Dialogs
{
public sealed partial class ExtractFilesDialog : ContentDialog
{
public ExtractFilesDialog(string currentDirectory)
{
this.InitializeComponent();
DestPathText.Text = currentDirectory;
Windows.Storage.ApplicationData.Current.LocalSettings.Values["Extract_Destination_Path"] = currentDirectory;
}

private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
{
Windows.Storage.ApplicationData.Current.LocalSettings.Values["Extract_Destination_Cancelled"] = false;
}



private async void BrowseButton_Click(object sender, RoutedEventArgs e)
{
Windows.Storage.Pickers.FolderPicker folderPicker = new Windows.Storage.Pickers.FolderPicker();
folderPicker.CommitButtonText = "Select Folder";
folderPicker.FileTypeFilter.Add("*");
var selectedFolder = await folderPicker.PickSingleFolderAsync();
if(selectedFolder != null)
{
DestPathText.Text = selectedFolder.Path;
Windows.Storage.ApplicationData.Current.LocalSettings.Values["Extract_Destination_Path"] = selectedFolder.Path;
}
}

private void ContentDialog_CloseButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
{
Windows.Storage.ApplicationData.Current.LocalSettings.Values["Extract_Destination_Cancelled"] = true;
}
}
}
9 changes: 9 additions & 0 deletions Files UWP/FilesUWP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@
<Compile Include="Dialogs\ExceptionDialog.xaml.cs">
<DependentUpon>ExceptionDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Dialogs\ExtractFilesDialog.xaml.cs">
<DependentUpon>ExtractFilesDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Dialogs\LayoutDialog.xaml.cs">
<DependentUpon>LayoutDialog.xaml</DependentUpon>
</Compile>
Expand All @@ -146,6 +149,7 @@
<Compile Include="Filesystem\DriveItem.cs" />
<Compile Include="Filesystem\ItemViewModel.cs" />
<Compile Include="Filesystem\ListedItem.cs" />
<Compile Include="Filesystem\SidebarItem.cs" />
<Compile Include="GenericFileBrowser.xaml.cs">
<DependentUpon>GenericFileBrowser.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -198,6 +202,7 @@
</Compile>
</ItemGroup>
<ItemGroup>
<Content Include="Assets\Files UWP Icon.png" />
<Content Include="Assets\FilesHome.png" />
<Content Include="Assets\FilesDrive.png" />
<Content Include="Assets\logo.bmp" />
Expand Down Expand Up @@ -225,6 +230,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Dialogs\ExtractFilesDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Dialogs\LayoutDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down
4 changes: 4 additions & 0 deletions Files UWP/Filesystem/DriveItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Media.Imaging;

namespace Files.Filesystem
{
Expand All @@ -16,5 +17,8 @@ public class DriveItem
public string tag { get; set; }
public Visibility progressBarVisibility { get; set; }
public string spaceText { get; set; }
public Visibility cloudGlyphVisibility { get; set; } = Visibility.Collapsed;
public Visibility driveGlyphVisibility { get; set; } = Visibility.Visible;

}
}
19 changes: 19 additions & 0 deletions Files UWP/Filesystem/SidebarItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Files.Filesystem
{
public class SidebarItem
{
public string IconGlyph { get; set; }

public string Text { get; set; }

public bool isDefaultLocation { get; set; } = false;

public string Path { get; set; } = null;
}
}
5 changes: 5 additions & 0 deletions Files UWP/GenericFileBrowser.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,11 @@
<Setter Property="ContextFlyout">
<Setter.Value>
<MenuFlyout Opened="RightClickContextMenu_Opened" x:Name="RightClickContextMenu" MenuFlyoutPresenterStyle="{StaticResource MenuFlyoutFluentThemeResources}">
<MenuFlyoutItem Text="Extract" x:Name="UnzipItem">
<MenuFlyoutItem.Icon>
<FontIcon Glyph="&#xED25;"/>
</MenuFlyoutItem.Icon>
</MenuFlyoutItem>
<MenuFlyoutItem Text="Open with..." x:Name="OpenItem">
<MenuFlyoutItem.Icon>
<FontIcon Glyph="&#xE7AC;"/>
Expand Down
93 changes: 65 additions & 28 deletions Files UWP/GenericFileBrowser.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.Toolkit.Uwp.UI;
using Microsoft.Toolkit.Uwp.UI;
using Microsoft.Toolkit.Uwp.UI.Controls;
using System;
using System.ComponentModel;
Expand All @@ -11,9 +11,12 @@
using Files.Filesystem;
using Files.Interacts;
using System.IO;
using Windows.UI.Xaml.Media;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using Windows.System;
using Windows.UI.Xaml.Input;
using System.Linq;

namespace Files
{
Expand Down Expand Up @@ -108,9 +111,10 @@ public GenericFileBrowser()
NewFolder.Click += tabInstance.instanceInteraction.NewFolder_Click;
NewBitmapImage.Click += tabInstance.instanceInteraction.NewBitmapImage_Click;
NewTextDocument.Click += tabInstance.instanceInteraction.NewTextDocument_Click;
UnzipItem.Click += tabInstance.instanceInteraction.ExtractItems_Click;
PropertiesItem.Click += tabInstance.ShowPropertiesButton_Click;
OpenInNewWindowItem.Click += tabInstance.instanceInteraction.OpenInNewWindowItem_Click;

switch (viewModelInstance.DirectorySortOption)
{
case SortOption.Name:
Expand Down Expand Up @@ -148,7 +152,8 @@ private void ViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e
SortedColumn = sizeColumn;
break;
}
} else if (e.PropertyName == "DirectorySortDirection")
}
else if (e.PropertyName == "DirectorySortDirection")
{
// Swap arrows
SortedColumn = _sortedColumn;
Expand Down Expand Up @@ -179,7 +184,7 @@ private void Clipboard_ContentChanged(object sender, object e)
protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
{
base.OnNavigatedTo(eventArgs);

tabInstance.BackButton.IsEnabled = tabInstance.accessibleContentFrame.CanGoBack;
tabInstance.ForwardButton.IsEnabled = tabInstance.accessibleContentFrame.CanGoForward;
tabInstance.RefreshButton.IsEnabled = true;
Expand Down Expand Up @@ -252,13 +257,13 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
data.Columns[0].GetCellContent(dataGridRow).Opacity = 1;
}
}

}

protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
{
base.OnNavigatingFrom(e);
if(tabInstance.instanceViewModel._fileQueryResult != null)
if (tabInstance.instanceViewModel._fileQueryResult != null)
{
tabInstance.instanceViewModel._fileQueryResult.ContentsChanged -= tabInstance.instanceViewModel.FileContentsChanged;
}
Expand All @@ -269,24 +274,24 @@ protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
private void AllView_DragOver(object sender, DragEventArgs e)
{
e.AcceptedOperation = DataPackageOperation.Copy;

}

private async void AllView_DropAsync(object sender, DragEventArgs e)
{
if (e.DataView.Contains(StandardDataFormats.StorageItems))
{
foreach (IStorageItem item in await e.DataView.GetStorageItemsAsync())
foreach (IStorageItem item in await e.DataView.GetStorageItemsAsync())
{
if (item.IsOfType(StorageItemTypes.Folder))
{
if (item.IsOfType(StorageItemTypes.Folder))
{
tabInstance.instanceInteraction.CloneDirectoryAsync((item as StorageFolder).Path, tabInstance.instanceViewModel.Universal.path, (item as StorageFolder).DisplayName);
}
else
{
await (item as StorageFile).CopyAsync(await StorageFolder.GetFolderFromPathAsync(tabInstance.instanceViewModel.Universal.path));
}
tabInstance.instanceInteraction.CloneDirectoryAsync((item as StorageFolder).Path, tabInstance.instanceViewModel.Universal.path, (item as StorageFolder).DisplayName);
}
else
{
await (item as StorageFile).CopyAsync(await StorageFolder.GetFolderFromPathAsync(tabInstance.instanceViewModel.Universal.path));
}
}
}
}

Expand Down Expand Up @@ -338,13 +343,13 @@ private void GenericItemView_PointerReleased(object sender, Windows.UI.Xaml.Inpu
private void AllView_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
AllView.CommitEdit();
if(e.AddedItems.Count > 0)
if (e.AddedItems.Count > 0)
{
tabInstance.HomeItems.isEnabled = true;
tabInstance.ShareItems.isEnabled = true;

}
else if(data.SelectedItems.Count == 0)
else if (data.SelectedItems.Count == 0)
{
tabInstance.HomeItems.isEnabled = false;
tabInstance.ShareItems.isEnabled = false;
Expand Down Expand Up @@ -373,34 +378,66 @@ private void AllView_DragStarting(UIElement sender, DragStartingEventArgs args)

private void AllView_DragLeave(object sender, DragEventArgs e)
{

}

private void RightClickContextMenu_Opened(object sender, object e)
{
var selectedDataItem = AllView.SelectedItem as ListedItem;
if (selectedDataItem.FileType != "Folder" || AllView.SelectedItems.Count > 1)

// Search selected items for non-Folders
if(AllView.SelectedItems.Cast<ListedItem>().Any(x => x.FileType != "Folder"))
{
SidebarPinItem.Visibility = Visibility.Collapsed;
OpenInNewTab.Visibility = Visibility.Collapsed;
OpenInNewWindowItem.Visibility = Visibility.Collapsed;
if (AllView.SelectedItems.Count == 1)
{
if (selectedDataItem.DotFileExtension.Equals(".zip", StringComparison.OrdinalIgnoreCase))
{
OpenItem.Visibility = Visibility.Collapsed;
UnzipItem.Visibility = Visibility.Collapsed;
}
else if (!selectedDataItem.DotFileExtension.Equals(".zip", StringComparison.OrdinalIgnoreCase))
{
OpenItem.Visibility = Visibility.Visible;
UnzipItem.Visibility = Visibility.Collapsed;
}
}
else if (AllView.SelectedItems.Count > 1)
{
OpenItem.Visibility = Visibility.Collapsed;
UnzipItem.Visibility = Visibility.Collapsed;
}
}
else if (selectedDataItem.FileType == "Folder")
else // All are Folders
{
SidebarPinItem.Visibility = Visibility.Visible;
OpenInNewTab.Visibility = Visibility.Visible;
OpenInNewWindowItem.Visibility = Visibility.Visible;
OpenItem.Visibility = Visibility.Collapsed;
if (AllView.SelectedItems.Count <= 5 && AllView.SelectedItems.Count > 0)
{
SidebarPinItem.Visibility = Visibility.Visible;
OpenInNewTab.Visibility = Visibility.Visible;
OpenInNewWindowItem.Visibility = Visibility.Visible;
UnzipItem.Visibility = Visibility.Collapsed;
}
else if (AllView.SelectedItems.Count > 5)
{
SidebarPinItem.Visibility = Visibility.Visible;
OpenInNewTab.Visibility = Visibility.Collapsed;
OpenInNewWindowItem.Visibility = Visibility.Collapsed;
UnzipItem.Visibility = Visibility.Collapsed;
}

}
}

private void AllView_Sorting(object sender, DataGridColumnEventArgs e)
{
if (e.Column == SortedColumn)
viewModelInstance.IsSortedAscending = !viewModelInstance.IsSortedAscending;
else if (e.Column != iconColumn)
SortedColumn = e.Column;
}

private void AllView_PreviewKeyDown(object sender, KeyRoutedEventArgs e)
{
if (e.Key == VirtualKey.Enter)
Expand All @@ -410,7 +447,7 @@ private void AllView_PreviewKeyDown(object sender, KeyRoutedEventArgs e)
}
}
}

public class EmptyFolderTextState : INotifyPropertyChanged
{
public Visibility _isVisible;
Expand All @@ -437,4 +474,4 @@ private void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}
}
Loading

0 comments on commit 0d90f42

Please sign in to comment.