protected override void OnFileActivated(FileActivatedEventArgs args) { //int i = 0; //i++; //System.Diagnostics.Debug.WriteLine("On File Activated"); if (args.PreviousExecutionState != ApplicationExecutionState.Running) { // TODO: Load state from previously suspended application startCN1(""); Windows.Storage.IStorageItem item = args.Files.First(); //System.Diagnostics.Debug.WriteLine("Item is " + item); if (item.IsOfType(Windows.Storage.StorageItemTypes.File)) { Main.appArg = item as Windows.Storage.StorageFile; } } else { Windows.Storage.IStorageItem item = args.Files.First(); //System.Diagnostics.Debug.WriteLine("Item is " + item); if (item.IsOfType(Windows.Storage.StorageItemTypes.File)) { Main.appArg = item as Windows.Storage.StorageFile; } if (item.IsOfType(Windows.Storage.StorageItemTypes.File)) { Main.stopStatic(); Main.appArg = item as Windows.Storage.StorageFile; Main.startStatic(); } } }
public StorageItem(Windows.Storage.IStorageItem item, bool bookmark = false) { _item = item; if (bookmark) { AddToFutureAccessList(); } }
public void OpenTabBook(Windows.Storage.IStorageItem file) { var(frame, newTab) = OpenTab("BookViewer"); if (file is Windows.Storage.IStorageFile item) { UIHelper.FrameOperation.OpenBook(item, frame, newTab); } }
public void OpenTabBook(Windows.Storage.IStorageItem file) { if (file is Windows.Storage.IStorageFile item) { UIHelper.FrameOperation.OpenBook(item, () => OpenTab("BookViewer"), () => { //Dialog:Open dangerous file? //Open. //Or just ignore. }); } }
protected override async void OnShareTargetActivated(ShareTargetActivatedEventArgs args) { ShareTargetActivatedEventArgs shareArgs = args as ShareTargetActivatedEventArgs; Windows.ApplicationModel.DataTransfer.ShareTarget.ShareOperation op = shareArgs.ShareOperation; Windows.Storage.StorageFile storageArg = null; string stringArg = null; if (op.Data.Contains(Windows.ApplicationModel.DataTransfer.StandardDataFormats.StorageItems)) { System.Collections.Generic.IReadOnlyList <Windows.Storage.IStorageItem> items = await op.Data.GetStorageItemsAsync(); Windows.Storage.IStorageItem item = items.First(); if (item.IsOfType(Windows.Storage.StorageItemTypes.File)) { storageArg = item as Windows.Storage.StorageFile; } } else if (op.Data.Contains(Windows.ApplicationModel.DataTransfer.StandardDataFormats.Uri)) { Uri uri = await op.Data.GetUriAsync(); stringArg = uri.AbsoluteUri; } if (args.PreviousExecutionState != ApplicationExecutionState.Running) { startCN1(""); if (storageArg != null) { Main.appArg = storageArg; } else if (stringArg != null) { Main.appArgStr = stringArg; } } else { Main.stopStatic(); if (storageArg != null) { Main.appArg = storageArg; } else if (stringArg != null) { Main.appArgStr = stringArg; } Main.startStatic(); } }
public static string GetFileTypeDescription(Windows.Storage.IStorageItem item) { if (item is null) { return(null); } _ = Path.GetExtension(item.Path); if (item is Windows.Storage.StorageFolder) { return(kurema.FileExplorerControl.Application.ResourceLoader.Loader.GetString("FileType/Folder")); } return(kurema.FileExplorerControl.Models.FileItems.StorageFileItem.GetGeneralFileType(item.Path)); }
private async void AsyncTest() { var local = Windows.Storage.ApplicationData.Current.LocalSettings; var mruToken = local.Values["mru"]; var mru = Windows.Storage.AccessCache.StorageApplicationPermissions.MostRecentlyUsedList; foreach (Windows.Storage.AccessCache.AccessListEntry entry in mru.Entries) { string token = entry.Token; Windows.Storage.IStorageItem item = await mru.GetItemAsync(token); Debug.WriteLine(item.Path); } }
async internal void CopyImage(Windows.Storage.IStorageItem file, Windows.Storage.StorageFolder imageFolder) { try { Windows.Storage.StorageFile sFile = (Windows.Storage.StorageFile)file; await sFile.CopyAsync(imageFolder, sFile.Name); WriteMessageText(sFile.Name + " copied.\n"); } catch (Exception e) { WriteMessageText("Failed to copy file.\n" + e.Message + "\n"); } }
public static async Task <Windows.Storage.IStorageItem> StorageItemGet(string token, string[] Path) { Windows.Storage.IStorageItem currentFolder = await StorageItemGet(token); foreach (var item in Path) { if (currentFolder == null) { return(null); } if (currentFolder is Windows.Storage.StorageFolder) { currentFolder = await(currentFolder as Windows.Storage.StorageFolder).TryGetItemAsync(item); } else { return(null); } } return(currentFolder); }
public async void Init() { var mru = Windows.Storage.AccessCache.StorageApplicationPermissions.MostRecentlyUsedList; foreach (Windows.Storage.AccessCache.AccessListEntry entry in mru.Entries) { string mruToken = entry.Token; if (mruToken != null) { Windows.Storage.IStorageItem item = await mru.GetItemAsync(mruToken); using (var md5 = System.Security.Cryptography.MD5.Create()) using (var stream = await Task.Run(() => (File.Open(item.Path, FileMode.Open)))) { RecentFiles.Add(new FileData { name = item.Name, created = item.DateCreated.LocalDateTime, type = "CSV", path = item.Path, hash = md5.ComputeHash(stream), IsSelected = false }); } } } }
async private void DisplayImage(Windows.Storage.IStorageItem file, int index) { try { var sFile = (Windows.Storage.StorageFile)file; Windows.Storage.Streams.IRandomAccessStream imageStream = await sFile.OpenAsync(Windows.Storage.FileAccessMode.Read); Windows.UI.Xaml.Media.Imaging.BitmapImage imageBitmap = new Windows.UI.Xaml.Media.Imaging.BitmapImage(); imageBitmap.SetSource(imageStream); var element = new Image(); element.Source = imageBitmap; element.Height = 100; Thickness margin = new Thickness(); margin.Top = index * 100; element.Margin = margin; filescanvas.Children.Add(element); } catch (Exception e) { WriteMessageText(e.Message + "\n"); } }
public static MenuCommand GetAddLibraryMenu(Windows.Storage.IStorageItem content, string path) { return(GetAddLibraryMenu(async() => await Managers.BookManager.GetTokenFromPathOrRegister(content), System.IO.Path.GetFileName(path))); }
public static string StorageItemRegister(Windows.Storage.IStorageItem file) { var acl = Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList; return(acl.Add(file)); }
protected override bool Supports(Windows.Storage.IStorageItem item, ref bool furtherChecks) { furtherChecks = false; return(item.Name.EndsWith(".txt")); }