Skip to content

Commit 260bd8c

Browse files
committed
Merge branch 'v0.7-changes' of https://github.com/duke7553/files-uwp into v0.7-changes
2 parents 7b4f5d6 + 118cf5c commit 260bd8c

File tree

5 files changed

+38
-0
lines changed

5 files changed

+38
-0
lines changed

Files.Launcher/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ static void Main(string[] args)
1818
ApplicationData.Current.LocalSettings.Values["DetectedPicturesLocation"] = Microsoft.Win32.Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "My Pictures", null);
1919
ApplicationData.Current.LocalSettings.Values["DetectedMusicLocation"] = Microsoft.Win32.Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "My Music", null);
2020
ApplicationData.Current.LocalSettings.Values["DetectedVideosLocation"] = Microsoft.Win32.Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "My Video", null);
21+
ApplicationData.Current.LocalSettings.Values["DetectedOneDriveLocation"] = Microsoft.Win32.Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\OneDrive", "UserFolder", null);
2122
}
2223
else
2324
{

Files/App.xaml.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ private async void DetectCustomLocations(ApplicationDataContainer localSettings)
189189
App.PicturesPath = localSettings.Values["DetectedPicturesLocation"] as string;
190190
App.MusicPath = localSettings.Values["DetectedMusicLocation"] as string;
191191
App.VideosPath = localSettings.Values["DetectedVideosLocation"] as string;
192+
App.OneDrivePath = localSettings.Values["DetectedOneDriveLocation"] as string;
192193

193194
// Overwrite paths for common locations if Custom Locations setting is enabled
194195
if (localSettings.Values["customLocationsSetting"] != null)
@@ -201,6 +202,7 @@ private async void DetectCustomLocations(ApplicationDataContainer localSettings)
201202
App.PicturesPath = localSettings.Values["PicturesLocation"] as string;
202203
App.MusicPath = localSettings.Values["MusicLocation"] as string;
203204
App.VideosPath = localSettings.Values["VideosLocation"] as string;
205+
App.OneDrivePath = localSettings.Values["DetectedOneDriveLocation"] as string;
204206
}
205207
}
206208
}

Files/SettingsPages/Preferences.xaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@
4040
<TextBlock Text="Videos" VerticalAlignment="Center" Margin="0,0,25,0" HorizontalAlignment="Left"/>
4141
<TextBox CornerRadius="2" Name="VideosL" PlaceholderText="Set Custom Videos Location" HorizontalAlignment="Left" Margin="125,0,0,0" Width="500"/>
4242
</Grid>
43+
<Grid Margin="0, 0, 0, 12.5">
44+
<TextBlock Text="OneDrive" VerticalAlignment="Center" Margin="0,0,25,0" HorizontalAlignment="Left"/>
45+
<TextBox CornerRadius="2" Name="OneDriveL" PlaceholderText="Set Custom OneDrive Location" HorizontalAlignment="Left" Margin="125,0,0,0" Width="500"/>
46+
</Grid>
4347
<StackPanel Orientation="Horizontal">
4448
<Button CornerRadius="2" Content="Save Locations" x:Name="SaveCustomL" HorizontalAlignment="Left" Click="SaveCustomL_Click" />
4549
<StackPanel x:Name="SuccessMark" Orientation="Horizontal" Spacing="15">

Files/SettingsPages/Preferences.xaml.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ public Preferences()
4141
VideosL.IsEnabled = true;
4242
VideosL.Text = localSettings.Values["VideosLocation"].ToString();
4343

44+
OneDriveL.IsEnabled = true;
45+
OneDriveL.Text = localSettings.Values["OneDriveLocation"].ToString();
46+
4447
SaveCustomL.IsEnabled = true;
4548
}
4649
else
@@ -53,6 +56,7 @@ public Preferences()
5356
MusicL.IsEnabled = false;
5457
VideosL.IsEnabled = false;
5558
SaveCustomL.IsEnabled = false;
59+
OneDriveL.IsEnabled = false;
5660
}
5761
}
5862
else
@@ -65,6 +69,7 @@ public Preferences()
6569
MusicL.IsEnabled = false;
6670
VideosL.IsEnabled = false;
6771
SaveCustomL.IsEnabled = false;
72+
OneDriveL.IsEnabled = false;
6873
}
6974
SuccessMark.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
7075
}
@@ -93,12 +98,16 @@ private void ToggleSwitch_Toggled(object sender, Windows.UI.Xaml.RoutedEventArgs
9398
VideosL.IsEnabled = true;
9499
localSettings.Values["VideosLocation"] = App.VideosPath;
95100

101+
OneDriveL.IsEnabled = true;
102+
localSettings.Values["OneDriveLocation"] = App.OneDrivePath;
103+
96104
DesktopL.Text = localSettings.Values["DesktopLocation"].ToString();
97105
DownloadsL.Text = localSettings.Values["DownloadsLocation"].ToString();
98106
DocumentsL.Text = localSettings.Values["DocumentsLocation"].ToString();
99107
PictureL.Text = localSettings.Values["PicturesLocation"].ToString();
100108
MusicL.Text = localSettings.Values["MusicLocation"].ToString();
101109
VideosL.Text = localSettings.Values["VideosLocation"].ToString();
110+
OneDriveL.Text = localSettings.Values["OneDriveLocation"].ToString();
102111

103112
SaveCustomL.IsEnabled = true;
104113
}
@@ -111,6 +120,7 @@ private void ToggleSwitch_Toggled(object sender, Windows.UI.Xaml.RoutedEventArgs
111120
PictureL.IsEnabled = false;
112121
MusicL.IsEnabled = false;
113122
VideosL.IsEnabled = false;
123+
OneDriveL.IsEnabled = false;
114124
SaveCustomL.IsEnabled = false;
115125
}
116126
}
@@ -241,6 +251,26 @@ private async void SaveCustomL_Click(object sender, Windows.UI.Xaml.RoutedEventA
241251
}
242252
}
243253

254+
if (!string.IsNullOrEmpty(OneDriveL.Text))
255+
{
256+
try
257+
{
258+
newLocationSetting = await StorageFolder.GetFolderFromPathAsync(OneDriveL.Text);
259+
localSettings.Values["OneDriveLocation"] = OneDriveL.Text;
260+
OneDriveL.BorderBrush = new SolidColorBrush(Colors.Black);
261+
}
262+
catch (ArgumentException)
263+
{
264+
OneDriveL.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 255, 0, 0));
265+
isFlawless = false;
266+
}
267+
catch (FileNotFoundException)
268+
{
269+
OneDriveL.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 255, 0, 0));
270+
isFlawless = false;
271+
}
272+
}
273+
244274
if (isFlawless)
245275
{
246276
SuccessMark.Visibility = Windows.UI.Xaml.Visibility.Visible;

Files/YourHome.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public YourHome()
4040
App.PicturesPath = localSettings.Values["PicturesLocation"].ToString();
4141
App.MusicPath = localSettings.Values["MusicLocation"].ToString();
4242
App.VideosPath = localSettings.Values["VideosLocation"].ToString();
43+
App.OneDrivePath = localSettings.Values["OneDriveLocation"].ToString();
4344
}
4445
}
4546

0 commit comments

Comments
 (0)