|
15 | 15 | using System.Diagnostics;
|
16 | 16 | using Windows.UI.Xaml.Media.Animation;
|
17 | 17 | using System.ComponentModel;
|
| 18 | +using System.Collections.ObjectModel; |
| 19 | +using System.Collections.Generic; |
| 20 | +using Windows.UI.Xaml.Data; |
18 | 21 |
|
19 | 22 | namespace Files
|
20 | 23 | {
|
21 | 24 |
|
22 | 25 | public sealed partial class PhotoAlbum : Page
|
23 | 26 | {
|
24 |
| - public GridView gv; |
| 27 | + public AdaptiveGridView gv; |
25 | 28 | public Image largeImg;
|
26 | 29 | public MenuFlyout context;
|
27 | 30 | public MenuFlyout gridContext;
|
@@ -213,5 +216,46 @@ internal void TextState_PropertyChanged(object sender, PropertyChangedEventArgs
|
213 | 216 | {
|
214 | 217 | TextState.isVisible = ItemViewModel<PhotoAlbum>.GetCurrentSelectedTabInstance<ProHome>().TextState.isVisible;
|
215 | 218 | }
|
| 219 | + |
| 220 | + |
| 221 | + private void StackPanel_RightTapped(object sender, RightTappedRoutedEventArgs e) |
| 222 | + { |
| 223 | + //ObjectPressed = ((ReadOnlyObservableCollection<ListedItem>)FileList.ItemsSource)[(int)(sender as StackPanel).Tag]; |
| 224 | + } |
| 225 | + |
| 226 | + private void FileList_RightTapped(object sender, RightTappedRoutedEventArgs e) |
| 227 | + { |
| 228 | + var ItemPressed = Interaction<PhotoAlbum>.FindParent<GridViewItem>(e.OriginalSource as DependencyObject); |
| 229 | + List<StackPanel> stackPanels = new List<StackPanel>(); |
| 230 | + Interaction<PhotoAlbum>.FindChildren<StackPanel>(stackPanels, ItemPressed); |
| 231 | + var ObjectPressed = ((ReadOnlyObservableCollection<ListedItem>)FileList.ItemsSource)[(int) stackPanels[0].Tag]; |
| 232 | + //List<int> indexes = new List<int>(); |
| 233 | + //foreach (ItemIndexRange range in FileList.SelectedRanges) |
| 234 | + //{ |
| 235 | + // for (int x = range.FirstIndex; x <= range.LastIndex; x++) { indexes.Add(x); } |
| 236 | + //} |
| 237 | + List<GridViewItem> items = new List<GridViewItem>(); |
| 238 | + List<GridViewItem> selitems = new List<GridViewItem>(); |
| 239 | + Interaction<PhotoAlbum>.FindChildren<GridViewItem>(items, FileList); |
| 240 | + foreach (GridViewItem gvi in items) |
| 241 | + { |
| 242 | + if (gvi.IsSelected) |
| 243 | + { |
| 244 | + selitems.Add(gvi); |
| 245 | + } |
| 246 | + } |
| 247 | + |
| 248 | + foreach (GridViewItem selectedItem in selitems) |
| 249 | + { |
| 250 | + if (FileList.IndexFromContainer(FileList.ContainerFromItem(selectedItem)) == FileList.IndexFromContainer(FileList.ContainerFromItem(ItemPressed))) |
| 251 | + { |
| 252 | + return; |
| 253 | + } |
| 254 | + } |
| 255 | + |
| 256 | + // The following code is only reachable when a user RightTapped an unselected row |
| 257 | + FileList.SelectedItems.Clear(); |
| 258 | + FileList.SelectedItems.Add(ObjectPressed); |
| 259 | + } |
216 | 260 | }
|
217 | 261 | }
|
0 commit comments