Ejemplo n.º 1
0
        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();
                }
            }
        }
Ejemplo n.º 2
0
 public StorageItem(Windows.Storage.IStorageItem item, bool bookmark = false)
 {
     _item = item;
     if (bookmark)
     {
         AddToFutureAccessList();
     }
 }
Ejemplo n.º 3
0
 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);
     }
 }
Ejemplo n.º 4
0
 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.
         });
     }
 }
Ejemplo n.º 5
0
        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();
            }
        }
Ejemplo n.º 6
0
 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));
 }
Ejemplo n.º 7
0
        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);
            }
        }
Ejemplo n.º 8
0
        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");
            }
        }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
        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
                            });
                        }
                }
            }
        }
Ejemplo n.º 11
0
        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");
            }
        }
Ejemplo n.º 12
0
 public static MenuCommand GetAddLibraryMenu(Windows.Storage.IStorageItem content, string path)
 {
     return(GetAddLibraryMenu(async() => await Managers.BookManager.GetTokenFromPathOrRegister(content), System.IO.Path.GetFileName(path)));
 }
Ejemplo n.º 13
0
        public static string StorageItemRegister(Windows.Storage.IStorageItem file)
        {
            var acl = Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList;

            return(acl.Add(file));
        }
Ejemplo n.º 14
0
 protected override bool Supports(Windows.Storage.IStorageItem item, ref bool furtherChecks)
 {
     furtherChecks = false;
     return(item.Name.EndsWith(".txt"));
 }