Skip to content

Commit 359ace3

Browse files
committed
Ensure view model only fills up its own respective tab and remove support for 1803
1 parent c8469e9 commit 359ace3

File tree

4 files changed

+77
-71
lines changed

4 files changed

+77
-71
lines changed

Files UWP/FilesUWP.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<DefaultLanguage>en-US</DefaultLanguage>
1313
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
1414
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.18362.0</TargetPlatformVersion>
15-
<TargetPlatformMinVersion>10.0.17134.0</TargetPlatformMinVersion>
15+
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
1616
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
1717
<FileAlignment>512</FileAlignment>
1818
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

Files UWP/Filesystem/ItemViewModel.cs

Lines changed: 55 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@ public class ItemViewModel<PageType> where PageType : class
4848

4949
private const int _step = 250;
5050

51+
private ProHome tabInstance;
52+
5153
public ItemViewModel()
5254
{
53-
55+
tabInstance = GetCurrentSelectedTabInstance<ProHome>();
5456
_filesAndFolders = new ObservableCollection<ListedItem>();
5557
_classicFileList = new ObservableCollection<ListedItem>();
5658
_classicFolderList = new ObservableCollection<Classic_ListedFolderItem>();
@@ -60,91 +62,91 @@ public ItemViewModel()
6062
ClassicFolderList = new ReadOnlyObservableCollection<Classic_ListedFolderItem>(_classicFolderList);
6163
if(typeof(PageType) == typeof(GenericFileBrowser))
6264
{
63-
(GetCurrentSelectedTabInstance<ProHome>().accessibleContentFrame.Content as GenericFileBrowser).emptyTextGFB.Visibility = Visibility.Collapsed;
65+
(tabInstance.accessibleContentFrame.Content as GenericFileBrowser).emptyTextGFB.Visibility = Visibility.Collapsed;
6466
}
6567
else if(typeof(PageType) == typeof(PhotoAlbum))
6668
{
67-
(GetCurrentSelectedTabInstance<ProHome>().accessibleContentFrame.Content as PhotoAlbum).EmptyTextPA.Visibility = Visibility.Collapsed;
69+
(tabInstance.accessibleContentFrame.Content as PhotoAlbum).EmptyTextPA.Visibility = Visibility.Collapsed;
6870
}
6971
else if(typeof(PageType) == typeof(AddItem))
7072
{
71-
if((GetCurrentSelectedTabInstance<ProHome>().accessibleContentFrame.Content as GenericFileBrowser) != null)
73+
if((tabInstance.accessibleContentFrame.Content as GenericFileBrowser) != null)
7274
{
73-
(GetCurrentSelectedTabInstance<ProHome>().accessibleContentFrame.Content as GenericFileBrowser).emptyTextGFB.Visibility = Visibility.Collapsed;
75+
(tabInstance.accessibleContentFrame.Content as GenericFileBrowser).emptyTextGFB.Visibility = Visibility.Collapsed;
7476
}
75-
else if((GetCurrentSelectedTabInstance<ProHome>().accessibleContentFrame.Content as PhotoAlbum) != null)
77+
else if((tabInstance.accessibleContentFrame.Content as PhotoAlbum) != null)
7678
{
77-
(GetCurrentSelectedTabInstance<ProHome>().accessibleContentFrame.Content as PhotoAlbum).EmptyTextPA.Visibility = Visibility.Collapsed;
79+
(tabInstance.accessibleContentFrame.Content as PhotoAlbum).EmptyTextPA.Visibility = Visibility.Collapsed;
7880
}
7981
}
8082

81-
GetCurrentSelectedTabInstance<ProHome>().HomeItems.PropertyChanged += HomeItems_PropertyChanged;
82-
GetCurrentSelectedTabInstance<ProHome>().ShareItems.PropertyChanged += ShareItems_PropertyChanged;
83-
GetCurrentSelectedTabInstance<ProHome>().LayoutItems.PropertyChanged += LayoutItems_PropertyChanged;
84-
GetCurrentSelectedTabInstance<ProHome>().AlwaysPresentCommands.PropertyChanged += AlwaysPresentCommands_PropertyChanged;
83+
tabInstance.HomeItems.PropertyChanged += HomeItems_PropertyChanged;
84+
tabInstance.ShareItems.PropertyChanged += ShareItems_PropertyChanged;
85+
tabInstance.LayoutItems.PropertyChanged += LayoutItems_PropertyChanged;
86+
tabInstance.AlwaysPresentCommands.PropertyChanged += AlwaysPresentCommands_PropertyChanged;
8587
}
8688

8789
private void AlwaysPresentCommands_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
8890
{
89-
if(GetCurrentSelectedTabInstance<ProHome>().AlwaysPresentCommands.isEnabled == true)
91+
if(tabInstance.AlwaysPresentCommands.isEnabled == true)
9092
{
91-
GetCurrentSelectedTabInstance<ProHome>().AlwaysPresentCommands.isEnabled = true;
93+
tabInstance.AlwaysPresentCommands.isEnabled = true;
9294
}
9395
else
9496
{
95-
GetCurrentSelectedTabInstance<ProHome>().AlwaysPresentCommands.isEnabled = false;
97+
tabInstance.AlwaysPresentCommands.isEnabled = false;
9698
}
9799
}
98100

99101
private void LayoutItems_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
100102
{
101-
if (GetCurrentSelectedTabInstance<ProHome>().LayoutItems.isEnabled == true)
103+
if (tabInstance.LayoutItems.isEnabled == true)
102104
{
103-
GetCurrentSelectedTabInstance<ProHome>().LayoutItems.isEnabled = true;
105+
tabInstance.LayoutItems.isEnabled = true;
104106
}
105107
else
106108
{
107-
GetCurrentSelectedTabInstance<ProHome>().LayoutItems.isEnabled = false;
109+
tabInstance.LayoutItems.isEnabled = false;
108110
}
109111
}
110112

111113
private void ShareItems_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
112114
{
113-
if (GetCurrentSelectedTabInstance<ProHome>().ShareItems.isEnabled == true)
115+
if (tabInstance.ShareItems.isEnabled == true)
114116
{
115-
GetCurrentSelectedTabInstance<ProHome>().ShareItems.isEnabled = true;
117+
tabInstance.ShareItems.isEnabled = true;
116118
}
117119
else
118120
{
119-
GetCurrentSelectedTabInstance<ProHome>().ShareItems.isEnabled = false;
121+
tabInstance.ShareItems.isEnabled = false;
120122
}
121123
}
122124

123125
private void HomeItems_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
124126
{
125-
if (GetCurrentSelectedTabInstance<ProHome>().HomeItems.isEnabled == true)
127+
if (tabInstance.HomeItems.isEnabled == true)
126128
{
127-
GetCurrentSelectedTabInstance<ProHome>().HomeItems.isEnabled = true;
129+
tabInstance.HomeItems.isEnabled = true;
128130
}
129131
else
130132
{
131-
GetCurrentSelectedTabInstance<ProHome>().HomeItems.isEnabled = false;
133+
tabInstance.HomeItems.isEnabled = false;
132134
}
133135

134136
}
135137

136138
public void AddFileOrFolder(ListedItem item)
137139
{
138140
_filesAndFolders.Add(item);
139-
if ((GetCurrentSelectedTabInstance<ProHome>().accessibleContentFrame.Content as GenericFileBrowser) != null || (GetCurrentSelectedTabInstance<ProHome>().accessibleContentFrame.Content as PhotoAlbum) != null)
141+
if ((tabInstance.accessibleContentFrame.Content as GenericFileBrowser) != null || (tabInstance.accessibleContentFrame.Content as PhotoAlbum) != null)
140142
{
141143
if (typeof(PageType) == typeof(GenericFileBrowser))
142144
{
143-
(GetCurrentSelectedTabInstance<ProHome>().accessibleContentFrame.Content as GenericFileBrowser).emptyTextGFB.Visibility = Visibility.Collapsed;
145+
(tabInstance.accessibleContentFrame.Content as GenericFileBrowser).emptyTextGFB.Visibility = Visibility.Collapsed;
144146
}
145147
else if (typeof(PageType) == typeof(PhotoAlbum))
146148
{
147-
(GetCurrentSelectedTabInstance<ProHome>().accessibleContentFrame.Content as PhotoAlbum).EmptyTextPA.Visibility = Visibility.Collapsed;
149+
(tabInstance.accessibleContentFrame.Content as PhotoAlbum).EmptyTextPA.Visibility = Visibility.Collapsed;
148150
}
149151
}
150152

@@ -155,15 +157,15 @@ public void RemoveFileOrFolder(ListedItem item)
155157
_filesAndFolders.Remove(item);
156158
if (_filesAndFolders.Count == 0)
157159
{
158-
if ((GetCurrentSelectedTabInstance<ProHome>().accessibleContentFrame.Content as GenericFileBrowser) != null || (GetCurrentSelectedTabInstance<ProHome>().accessibleContentFrame.Content as PhotoAlbum) != null)
160+
if ((tabInstance.accessibleContentFrame.Content as GenericFileBrowser) != null || (tabInstance.accessibleContentFrame.Content as PhotoAlbum) != null)
159161
{
160162
if (typeof(PageType) == typeof(GenericFileBrowser))
161163
{
162-
(GetCurrentSelectedTabInstance<ProHome>().accessibleContentFrame.Content as GenericFileBrowser).emptyTextGFB.Visibility = Visibility.Visible;
164+
(tabInstance.accessibleContentFrame.Content as GenericFileBrowser).emptyTextGFB.Visibility = Visibility.Visible;
163165
}
164166
else if (typeof(PageType) == typeof(PhotoAlbum))
165167
{
166-
(GetCurrentSelectedTabInstance<ProHome>().accessibleContentFrame.Content as PhotoAlbum).EmptyTextPA.Visibility = Visibility.Visible;
168+
(tabInstance.accessibleContentFrame.Content as PhotoAlbum).EmptyTextPA.Visibility = Visibility.Visible;
167169
}
168170
}
169171
}
@@ -200,7 +202,7 @@ public static T GetCurrentSelectedTabInstance<T>()
200202

201203
public async void DisplayConsentDialog()
202204
{
203-
await GetCurrentSelectedTabInstance<ProHome>().permissionBox.ShowAsync();
205+
await tabInstance.permissionBox.ShowAsync();
204206
}
205207

206208
public async void AddItemsToCollectionAsync(string path, Page currentPage)
@@ -212,14 +214,14 @@ public async void AddItemsToCollectionAsync(string path, Page currentPage)
212214

213215
_cancellationTokenSource = new CancellationTokenSource();
214216

215-
//GetCurrentSelectedTabInstance<ProHome>().TextState.isVisible = Visibility.Collapsed;
217+
//tabInstance.TextState.isVisible = Visibility.Collapsed;
216218
if (typeof(PageType) == typeof(GenericFileBrowser))
217219
{
218-
(GetCurrentSelectedTabInstance<ProHome>().accessibleContentFrame.Content as GenericFileBrowser).TextState.isVisible = Visibility.Collapsed;
220+
(tabInstance.accessibleContentFrame.Content as GenericFileBrowser).TextState.isVisible = Visibility.Collapsed;
219221
}
220222
else if (typeof(PageType) == typeof(PhotoAlbum))
221223
{
222-
(GetCurrentSelectedTabInstance<ProHome>().accessibleContentFrame.Content as PhotoAlbum).TextState.isVisible = Visibility.Collapsed;
224+
(tabInstance.accessibleContentFrame.Content as PhotoAlbum).TextState.isVisible = Visibility.Collapsed;
223225
}
224226

225227
_filesAndFolders.Clear();
@@ -230,11 +232,11 @@ public async void AddItemsToCollectionAsync(string path, Page currentPage)
230232

231233
if (typeof(PageType) == typeof(GenericFileBrowser))
232234
{
233-
(GetCurrentSelectedTabInstance<ProHome>().accessibleContentFrame.Content as GenericFileBrowser).progressBar.Visibility = Visibility.Visible;
235+
(tabInstance.accessibleContentFrame.Content as GenericFileBrowser).progressBar.Visibility = Visibility.Visible;
234236
}
235237
else if (typeof(PageType) == typeof(PhotoAlbum))
236238
{
237-
(GetCurrentSelectedTabInstance<ProHome>().accessibleContentFrame.Content as PhotoAlbum).progressBar.Visibility = Visibility.Visible;
239+
(tabInstance.accessibleContentFrame.Content as PhotoAlbum).progressBar.Visibility = Visibility.Visible;
238240
}
239241

240242
switch (Universal.path)
@@ -268,8 +270,8 @@ public async void AddItemsToCollectionAsync(string path, Page currentPage)
268270

269271
//History.AddToHistory(Universal.path);
270272

271-
GetCurrentSelectedTabInstance<ProHome>().BackButton.IsEnabled = GetCurrentSelectedTabInstance<ProHome>().accessibleContentFrame.CanGoBack;
272-
GetCurrentSelectedTabInstance<ProHome>().ForwardButton.IsEnabled = GetCurrentSelectedTabInstance<ProHome>().accessibleContentFrame.CanGoForward;
273+
tabInstance.BackButton.IsEnabled = tabInstance.accessibleContentFrame.CanGoBack;
274+
tabInstance.ForwardButton.IsEnabled = tabInstance.accessibleContentFrame.CanGoForward;
273275

274276
switch (await _rootFolder.GetIndexedStateAsync())
275277
{
@@ -354,11 +356,11 @@ public async void AddItemsToCollectionAsync(string path, Page currentPage)
354356
{
355357
if (typeof(PageType) == typeof(GenericFileBrowser))
356358
{
357-
(GetCurrentSelectedTabInstance<ProHome>().accessibleContentFrame.Content as GenericFileBrowser).TextState.isVisible = Visibility.Visible;
359+
(tabInstance.accessibleContentFrame.Content as GenericFileBrowser).TextState.isVisible = Visibility.Visible;
358360
}
359361
else if (typeof(PageType) == typeof(PhotoAlbum))
360362
{
361-
(GetCurrentSelectedTabInstance<ProHome>().accessibleContentFrame.Content as PhotoAlbum).TextState.isVisible = Visibility.Visible;
363+
(tabInstance.accessibleContentFrame.Content as PhotoAlbum).TextState.isVisible = Visibility.Visible;
362364
}
363365
}
364366
stopwatch.Stop();
@@ -397,11 +399,11 @@ public async void AddItemsToCollectionAsync(string path, Page currentPage)
397399

398400
if (typeof(PageType) == typeof(GenericFileBrowser))
399401
{
400-
(GetCurrentSelectedTabInstance<ProHome>().accessibleContentFrame.Content as GenericFileBrowser).progressBar.Visibility = Visibility.Collapsed;
402+
(tabInstance.accessibleContentFrame.Content as GenericFileBrowser).progressBar.Visibility = Visibility.Collapsed;
401403
}
402404
else if (typeof(PageType) == typeof(PhotoAlbum))
403405
{
404-
(GetCurrentSelectedTabInstance<ProHome>().accessibleContentFrame.Content as PhotoAlbum).progressBar.Visibility = Visibility.Collapsed;
406+
(tabInstance.accessibleContentFrame.Content as PhotoAlbum).progressBar.Visibility = Visibility.Collapsed;
405407
}
406408
}
407409

@@ -444,13 +446,13 @@ private async Task AddFolder(StorageFolder folder, CancellationToken token)
444446
FileSize = null,
445447
RowIndex = _filesAndFolders.Count
446448
});
447-
if((GetCurrentSelectedTabInstance<ProHome>().accessibleContentFrame.Content as GenericFileBrowser) != null)
449+
if((tabInstance.accessibleContentFrame.Content as GenericFileBrowser) != null)
448450
{
449-
(GetCurrentSelectedTabInstance<ProHome>().accessibleContentFrame.Content as GenericFileBrowser).emptyTextGFB.Visibility = Visibility.Collapsed;
451+
(tabInstance.accessibleContentFrame.Content as GenericFileBrowser).emptyTextGFB.Visibility = Visibility.Collapsed;
450452
}
451-
else if((GetCurrentSelectedTabInstance<ProHome>().accessibleContentFrame.Content as PhotoAlbum) != null)
453+
else if((tabInstance.accessibleContentFrame.Content as PhotoAlbum) != null)
452454
{
453-
(GetCurrentSelectedTabInstance<ProHome>().accessibleContentFrame.Content as PhotoAlbum).EmptyTextPA.Visibility = Visibility.Collapsed;
455+
(tabInstance.accessibleContentFrame.Content as PhotoAlbum).EmptyTextPA.Visibility = Visibility.Collapsed;
454456
}
455457
}
456458
else if (typeof(PageType) == typeof(ClassicMode))
@@ -556,11 +558,11 @@ private async Task AddFile(StorageFile file, CancellationToken token)
556558

557559
if(typeof(PageType) == typeof(GenericFileBrowser))
558560
{
559-
(GetCurrentSelectedTabInstance<ProHome>().accessibleContentFrame.Content as GenericFileBrowser).emptyTextGFB.Visibility = Visibility.Collapsed;
561+
(tabInstance.accessibleContentFrame.Content as GenericFileBrowser).emptyTextGFB.Visibility = Visibility.Collapsed;
560562
}
561563
else if(typeof(PageType) == typeof(PhotoAlbum))
562564
{
563-
(GetCurrentSelectedTabInstance<ProHome>().accessibleContentFrame.Content as PhotoAlbum).EmptyTextPA.Visibility = Visibility.Collapsed;
565+
(tabInstance.accessibleContentFrame.Content as PhotoAlbum).EmptyTextPA.Visibility = Visibility.Collapsed;
564566
}
565567
}
566568
else
@@ -595,15 +597,15 @@ public async void FileContentsChanged(IStorageQueryResultBase sender, object arg
595597
await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
596598
() =>
597599
{
598-
if((GetCurrentSelectedTabInstance<ProHome>().accessibleContentFrame.Content as GenericFileBrowser) != null || (GetCurrentSelectedTabInstance<ProHome>().accessibleContentFrame.Content as PhotoAlbum) != null)
600+
if((tabInstance.accessibleContentFrame.Content as GenericFileBrowser) != null || (tabInstance.accessibleContentFrame.Content as PhotoAlbum) != null)
599601
{
600602
if (typeof(PageType) == typeof(GenericFileBrowser))
601603
{
602-
(GetCurrentSelectedTabInstance<ProHome>().accessibleContentFrame.Content as GenericFileBrowser).progressBar.Visibility = Visibility.Visible;
604+
(tabInstance.accessibleContentFrame.Content as GenericFileBrowser).progressBar.Visibility = Visibility.Visible;
603605
}
604606
else if (typeof(PageType) == typeof(PhotoAlbum))
605607
{
606-
(GetCurrentSelectedTabInstance<ProHome>().accessibleContentFrame.Content as PhotoAlbum).progressBar.Visibility = Visibility.Visible;
608+
(tabInstance.accessibleContentFrame.Content as PhotoAlbum).progressBar.Visibility = Visibility.Visible;
607609
}
608610
}
609611
});
@@ -661,15 +663,15 @@ await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPrio
661663
await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
662664
() =>
663665
{
664-
if ((GetCurrentSelectedTabInstance<ProHome>().accessibleContentFrame.Content as GenericFileBrowser) != null || (GetCurrentSelectedTabInstance<ProHome>().accessibleContentFrame.Content as PhotoAlbum) != null)
666+
if ((tabInstance.accessibleContentFrame.Content as GenericFileBrowser) != null || (tabInstance.accessibleContentFrame.Content as PhotoAlbum) != null)
665667
{
666668
if (typeof(PageType) == typeof(GenericFileBrowser))
667669
{
668-
(GetCurrentSelectedTabInstance<ProHome>().accessibleContentFrame.Content as GenericFileBrowser).progressBar.Visibility = Visibility.Collapsed;
670+
(tabInstance.accessibleContentFrame.Content as GenericFileBrowser).progressBar.Visibility = Visibility.Collapsed;
669671
}
670672
else if (typeof(PageType) == typeof(PhotoAlbum))
671673
{
672-
(GetCurrentSelectedTabInstance<ProHome>().accessibleContentFrame.Content as PhotoAlbum).progressBar.Visibility = Visibility.Collapsed;
674+
(tabInstance.accessibleContentFrame.Content as PhotoAlbum).progressBar.Visibility = Visibility.Collapsed;
673675
}
674676
}
675677
});

0 commit comments

Comments
 (0)