Skip to content

Commit 0b9705f

Browse files
committed
Improve and Organize ContentDialogs
1 parent c158835 commit 0b9705f

24 files changed

+458
-217
lines changed

Files UWP/AddItem.xaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,8 @@
1010

1111
<Grid>
1212
<StackPanel Spacing="25" Orientation="Vertical">
13-
<Grid Name="HeaderArea">
14-
<StackPanel>
15-
<TextBlock Name="Heading" Text="Create New Item" FontSize="36" FontWeight="Bold"/>
16-
<TextBlock Name="Description" Text="Choose a type below for this new item."/>
17-
</StackPanel>
13+
<Grid Name="SubtitleArea">
14+
<TextBlock Name="Description" Text="Choose a type below for this new item."/>
1815
</Grid>
1916
<Grid Name="SelectionListContent" HorizontalAlignment="Stretch">
2017
<StackPanel>

Files UWP/AddItem.xaml.cs

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
using Windows.UI.Xaml.Controls;
55
using System;
66
using Files.Filesystem;
7-
using System.Collections.ObjectModel;
8-
using System.Threading.Tasks;
97
using Microsoft.Toolkit.Uwp.UI.Controls;
108
using Windows.UI.Xaml.Navigation;
9+
using Files.Dialogs;
1110

1211
namespace Files
1312
{
@@ -66,7 +65,7 @@ public T GetCurrentSelectedTabInstance<T>()
6665
private async void ListView_ItemClick(object sender, ItemClickEventArgs e)
6766
{
6867
var TabInstance = GetCurrentSelectedTabInstance<ProHome>();
69-
TabInstance.AddItemBox.Hide();
68+
TabInstance.addItemDialog.Hide();
7069
string currentPath = null;
7170
if (TabInstance.accessibleContentFrame.SourcePageType == typeof(GenericFileBrowser))
7271
{
@@ -77,35 +76,51 @@ private async void ListView_ItemClick(object sender, ItemClickEventArgs e)
7776
currentPath = (TabInstance.accessibleContentFrame.Content as PhotoAlbum).instanceViewModel.Universal.path;
7877
}
7978
StorageFolder folderToCreateItem = await StorageFolder.GetFolderFromPathAsync(currentPath);
79+
RenameDialog renameDialog = new RenameDialog();
8080
if ((e.ClickedItem as AddListItem).Header == "Folder")
8181
{
82-
await TabInstance.NameBox.ShowAsync();
83-
var userInput = TabInstance.inputForRename;
84-
if (userInput != null)
82+
await renameDialog.ShowAsync();
83+
var userInput = renameDialog.storedRenameInput;
84+
if (userInput != "")
8585
{
8686
var folder = await folderToCreateItem.CreateFolderAsync(userInput, CreationCollisionOption.FailIfExists);
8787
instanceViewModel.AddFileOrFolder(new ListedItem(folder.FolderRelativeId){ FileName = userInput, FileDateReal = DateTimeOffset.Now, EmptyImgVis = Visibility.Collapsed, FolderImg = Visibility.Visible, FileIconVis = Visibility.Collapsed, FileType = "Folder", FileImg = null, FilePath = (instanceViewModel.Universal.path + "\\" + userInput) });
8888
}
89+
else
90+
{
91+
var folder = await folderToCreateItem.CreateFolderAsync("New Folder", CreationCollisionOption.GenerateUniqueName);
92+
instanceViewModel.AddFileOrFolder(new ListedItem(folder.FolderRelativeId) { FileName = userInput, FileDateReal = DateTimeOffset.Now, EmptyImgVis = Visibility.Collapsed, FolderImg = Visibility.Visible, FileIconVis = Visibility.Collapsed, FileType = "Folder", FileImg = null, FilePath = (instanceViewModel.Universal.path + "\\" + userInput) });
93+
}
8994
}
9095
else if ((e.ClickedItem as AddListItem).Header == "Text Document")
9196
{
92-
await TabInstance.NameBox.ShowAsync();
93-
var userInput = TabInstance.inputForRename;
94-
if (userInput != null)
97+
await renameDialog.ShowAsync();
98+
var userInput = renameDialog.storedRenameInput;
99+
if (userInput != "")
95100
{
96101
var folder = await folderToCreateItem.CreateFileAsync(userInput + ".txt", CreationCollisionOption.FailIfExists);
97102
instanceViewModel.AddFileOrFolder(new ListedItem(folder.FolderRelativeId) { FileName = userInput, FileDateReal = DateTimeOffset.Now, EmptyImgVis = Visibility.Visible, FolderImg = Visibility.Collapsed, FileIconVis = Visibility.Collapsed, FileType = "Text Document", FileImg = null, FilePath = (instanceViewModel.Universal.path + "\\" + userInput + ".txt"), DotFileExtension = ".txt" });
98103
}
104+
else
105+
{
106+
var folder = await folderToCreateItem.CreateFileAsync("New Text Document" + ".txt", CreationCollisionOption.GenerateUniqueName);
107+
instanceViewModel.AddFileOrFolder(new ListedItem(folder.FolderRelativeId) { FileName = userInput, FileDateReal = DateTimeOffset.Now, EmptyImgVis = Visibility.Visible, FolderImg = Visibility.Collapsed, FileIconVis = Visibility.Collapsed, FileType = "Text Document", FileImg = null, FilePath = (instanceViewModel.Universal.path + "\\" + userInput + ".txt"), DotFileExtension = ".txt" });
108+
}
99109
}
100110
else if ((e.ClickedItem as AddListItem).Header == "Bitmap Image")
101111
{
102-
await GetCurrentSelectedTabInstance<ProHome>().NameBox.ShowAsync();
103-
var userInput = GetCurrentSelectedTabInstance<ProHome>().inputForRename;
104-
if (userInput != null)
112+
await renameDialog.ShowAsync();
113+
var userInput = renameDialog.storedRenameInput;
114+
if (userInput != "")
105115
{
106116
var folder = await folderToCreateItem.CreateFileAsync(userInput + ".bmp", CreationCollisionOption.FailIfExists);
107117
instanceViewModel.AddFileOrFolder(new ListedItem(folder.FolderRelativeId) { FileName = userInput, FileDateReal = DateTimeOffset.Now, EmptyImgVis = Visibility.Visible, FolderImg = Visibility.Collapsed, FileIconVis = Visibility.Collapsed, FileType = "BMP File", FileImg = null, FilePath = (instanceViewModel.Universal.path + "\\" + userInput + ".bmp"), DotFileExtension = ".bmp" });
108118
}
119+
else
120+
{
121+
var folder = await folderToCreateItem.CreateFileAsync("New Bitmap Image" + ".bmp", CreationCollisionOption.GenerateUniqueName);
122+
instanceViewModel.AddFileOrFolder(new ListedItem(folder.FolderRelativeId) { FileName = userInput, FileDateReal = DateTimeOffset.Now, EmptyImgVis = Visibility.Visible, FolderImg = Visibility.Collapsed, FileIconVis = Visibility.Collapsed, FileType = "BMP File", FileImg = null, FilePath = (instanceViewModel.Universal.path + "\\" + userInput + ".bmp"), DotFileExtension = ".bmp" });
123+
}
109124
}
110125
}
111126

Files UWP/Dialogs/AddItemDialog.xaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<ContentDialog
2+
x:Class="Files.Dialogs.AddItemDialog"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:local="using:Files.Dialogs"
6+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
7+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8+
mc:Ignorable="d"
9+
xmlns:Windows10version1903="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract, 8)"
10+
CornerRadius="4" Title="Create a New Item" Grid.RowSpan="4" Background="{StaticResource ApplicationPageBackgroundThemeBrush}" BorderThickness="0" Name="AddDialog" PrimaryButtonText="Cancel">
11+
12+
<Frame Width="450" Name="AddDialogFrame"/>
13+
</ContentDialog>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Runtime.InteropServices.WindowsRuntime;
6+
using Windows.Foundation;
7+
using Windows.Foundation.Collections;
8+
using Windows.UI.Xaml;
9+
using Windows.UI.Xaml.Controls;
10+
using Windows.UI.Xaml.Controls.Primitives;
11+
using Windows.UI.Xaml.Data;
12+
using Windows.UI.Xaml.Input;
13+
using Windows.UI.Xaml.Media;
14+
using Windows.UI.Xaml.Navigation;
15+
16+
// The Content Dialog item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
17+
18+
namespace Files.Dialogs
19+
{
20+
public sealed partial class AddItemDialog : ContentDialog
21+
{
22+
public Frame addDialogContentFrame;
23+
public AddItemDialog()
24+
{
25+
this.InitializeComponent();
26+
addDialogContentFrame = AddDialogFrame;
27+
}
28+
29+
}
30+
}

Files UWP/Dialogs/ConsentDialog.xaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<ContentDialog
2+
x:Class="Files.Dialogs.ConsentDialog"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:local="using:Files.Dialogs"
6+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
7+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8+
mc:Ignorable="d"
9+
xmlns:Windows10version1903="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract, 8)"
10+
CornerRadius="4" Grid.RowSpan="4" DefaultButton="Primary" PrimaryButtonClick="PermissionDialog_PrimaryButtonClick" PrimaryButtonText="Grant Permission" Name="PermissionDialog" Title="Welcome to Files">
11+
12+
<Grid>
13+
<TextBlock TextWrapping="WrapWholeWords" Text="To get started, you'll need to grant us permission to display your files. This will open a Settings page where you can grant us this permission. You'll need to reopen the app once completed. "/>
14+
</Grid>
15+
</ContentDialog>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Runtime.InteropServices.WindowsRuntime;
6+
using Windows.Foundation;
7+
using Windows.Foundation.Collections;
8+
using Windows.System;
9+
using Windows.UI.Xaml;
10+
using Windows.UI.Xaml.Controls;
11+
using Windows.UI.Xaml.Controls.Primitives;
12+
using Windows.UI.Xaml.Data;
13+
using Windows.UI.Xaml.Input;
14+
using Windows.UI.Xaml.Media;
15+
using Windows.UI.Xaml.Navigation;
16+
17+
// The Content Dialog item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
18+
19+
namespace Files.Dialogs
20+
{
21+
public sealed partial class ConsentDialog : ContentDialog
22+
{
23+
public ConsentDialog()
24+
{
25+
this.InitializeComponent();
26+
}
27+
28+
private async void PermissionDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
29+
{
30+
await Launcher.LaunchUriAsync(new Uri("ms-settings:privacy-broadfilesystemaccess"));
31+
32+
}
33+
}
34+
}

Files UWP/Dialogs/LayoutDialog.xaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<ContentDialog
2+
x:Class="Files.Dialogs.LayoutDialog"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:local="using:Files.Dialogs"
6+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
7+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8+
xmlns:Windows10version1903="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract, 8)"
9+
mc:Ignorable="d"
10+
CornerRadius="4" Title="Pick an Item Layout" Name="LayoutDialogMarkup" Grid.RowSpan="4" CloseButtonText="Cancel" PrimaryButtonText="OK" DefaultButton="Primary">
11+
12+
<Grid Width="450">
13+
<StackPanel Spacing="25" Orientation="Vertical">
14+
<StackPanel>
15+
<RadioButton Content="Details - Displays a sortable DataGrid containing item details"/>
16+
<RadioButton Content="Icons - Displays all items as larger icons with less information"/>
17+
</StackPanel>
18+
<CheckBox Content="Always use this layout for the current directory"/>
19+
</StackPanel>
20+
</Grid>
21+
</ContentDialog>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Runtime.InteropServices.WindowsRuntime;
6+
using Windows.Foundation;
7+
using Windows.Foundation.Collections;
8+
using Windows.UI.Xaml;
9+
using Windows.UI.Xaml.Controls;
10+
using Windows.UI.Xaml.Controls.Primitives;
11+
using Windows.UI.Xaml.Data;
12+
using Windows.UI.Xaml.Input;
13+
using Windows.UI.Xaml.Media;
14+
using Windows.UI.Xaml.Navigation;
15+
16+
// The Content Dialog item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
17+
18+
namespace Files.Dialogs
19+
{
20+
public sealed partial class LayoutDialog : ContentDialog
21+
{
22+
public LayoutDialog()
23+
{
24+
this.InitializeComponent();
25+
}
26+
27+
private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
28+
{
29+
}
30+
31+
private void ContentDialog_SecondaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
32+
{
33+
}
34+
}
35+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<ContentDialog
2+
x:Class="Files.Dialogs.PropertiesDialog"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:local="using:Files.Dialogs"
6+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
7+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8+
mc:Ignorable="d"
9+
xmlns:Windows10version1903="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract, 8)"
10+
Background="{StaticResource ApplicationPageBackgroundThemeBrush}" PrimaryButtonText="OK" DefaultButton="Primary" CloseButtonText="Cancel" CornerRadius="4" Name="PropertiesDialogMarkup" Title="Properties" >
11+
12+
<Frame Width="400" Height="450" Name="propertiesFrame" />
13+
</ContentDialog>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Runtime.InteropServices.WindowsRuntime;
6+
using Windows.Foundation;
7+
using Windows.Foundation.Collections;
8+
using Windows.UI.Xaml;
9+
using Windows.UI.Xaml.Controls;
10+
using Windows.UI.Xaml.Controls.Primitives;
11+
using Windows.UI.Xaml.Data;
12+
using Windows.UI.Xaml.Input;
13+
using Windows.UI.Xaml.Media;
14+
using Windows.UI.Xaml.Navigation;
15+
16+
// The Content Dialog item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
17+
18+
namespace Files.Dialogs
19+
{
20+
public sealed partial class PropertiesDialog : ContentDialog
21+
{
22+
public Frame accessiblePropertiesFrame;
23+
24+
public PropertiesDialog()
25+
{
26+
this.InitializeComponent();
27+
accessiblePropertiesFrame = propertiesFrame;
28+
}
29+
30+
}
31+
}

0 commit comments

Comments
 (0)