private void EmailList_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (EmailList.SelectedIndex == -1) { MarkRead.IsEnabled = false; } else { MarkRead.IsEnabled = true; if ((EmailList.SelectedItem as EmailItem).IsNotSeenIndicator == 0) { if (DisplayMode.SelectedIndex != 1) { MarkRead.Label = "标记为未读"; } } else { MarkRead.Label = "标记为已读"; } } if (Nav.CurrentSourcePageType.Name == "EmailSender") { Nav.GoBack(); } }
private void NewPouch() { JsonSerializer ser = new JsonSerializer(); ser.SerializePouch(this.Pouch); this.Pouch = ser.DeserializePouch(); Nav.GoBack(); }
private async void FileTree_ItemInvoked(TreeView sender, TreeViewItemInvokedEventArgs args) { /* * 同一文件夹内可能存在大量文件 * 因此切换不同文件夹时极有可能遍历文件夹仍未完成 * 此处激活取消指令,等待当前遍历结束,再开始下一次文件遍历 * 确保不会出现异常 */ //防止多次点击同一文件夹导致的多重查找 if ((args.InvokedItem as TreeViewNode).Content is StorageFolder folder) { if (folder.FolderRelativeId == CurrentFolder?.FolderRelativeId) { IsAdding = false; return; } if (IsAdding) { await Task.Run(() => { lock (SyncRootProvider.SyncRoot) { CancelToken.Cancel(); Locker.WaitOne(); } }); } IsAdding = true; CurrentFolder = folder; CurrentNode = args.InvokedItem as TreeViewNode; USBFilePresenter.ThisPage.DisplayNode = CurrentNode; //当处于USB其他附加功能的页面时,若点击文件目录则自动执行返回导航 if (Nav.CurrentSourcePageType.Name != "USBFilePresenter") { Nav.GoBack(); } USBFilePresenter.ThisPage.FileCollection.Clear(); QueryOptions Options = new QueryOptions(CommonFileQuery.DefaultQuery, null) { FolderDepth = FolderDepth.Shallow, IndexerOption = IndexerOption.UseIndexerWhenAvailable }; Options.SetThumbnailPrefetch(ThumbnailMode.ListView, 60, ThumbnailOptions.ResizeThumbnail); var FileQuery = folder.CreateFileQueryWithOptions(Options); var FileList = await FileQuery.GetFilesAsync(); USBFilePresenter.ThisPage.HasFile.Visibility = FileList.Count == 0 ? Visibility.Visible : Visibility.Collapsed; if (FileTracker != null) { FileTracker.Created -= FileTracker_Created; FileTracker.Deleted -= FileTracker_Deleted; FileTracker.Renamed -= FileTracker_Renamed; FileTracker.Dispose(); FileTracker = null; } FileTracker = new FileSystemTracker(FileQuery); FileTracker.Created += FileTracker_Created; FileTracker.Deleted += FileTracker_Deleted; FileTracker.Renamed += FileTracker_Renamed; foreach (var file in FileList) { if (CancelToken.IsCancellationRequested) { goto FLAG; } USBFilePresenter.ThisPage.FileCollection.Add(new RemovableDeviceFile(file)); } } FLAG: if (CancelToken.IsCancellationRequested) { CancelToken.Dispose(); CancelToken = new CancellationTokenSource(); Locker.Set(); } else { IsAdding = false; } }