Exemplo n.º 1
0
        private static async Task <DocumentFile> CreateNewAsync(string name, Document document, StorageFile storageFile)
        {
            var file = new DocumentFile(storageFile, document ?? Document.CreateNew(name));

            await file.SaveAsync();

            return(file);
        }
Exemplo n.º 2
0
 private static async Task LoadFilesFromLocalStoreAsync(IDictionary <string, DocumentFile> unsortedFiles)
 {
     foreach (var file in await LocalStore.GetFilesQueuedAsync())
     {
         if (!unsortedFiles.ContainsKey(file.Path) && file.FileType == ".mmd")
         {
             unsortedFiles.Add(file.Path, await DocumentFile.OpenAsync(file, true));
         }
     }
 }
Exemplo n.º 3
0
        private async Task LoadFilesFromRecentListAsync(IDictionary <string, DocumentFile> unsortedFiles)
        {
            if (!PlattformDetector.IsDesktop)
            {
                return;
            }

            tokenMapping.Clear();

            var filesHandled = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            foreach (var entry in recentList.Entries.ToList())
            {
                try
                {
                    var file = await recentList.GetFileAsync(entry.Token);

                    if (!filesHandled.Add(file.Path))
                    {
                        continue;
                    }

                    tokenMapping[file.Path] = entry.Token;

                    if (unsortedFiles.ContainsKey(file.Path))
                    {
                        recentList.Remove(entry.Token);
                    }
                    else
                    {
                        unsortedFiles.Add(file.Path, await DocumentFile.OpenAsync(file, false));
                    }
                }
                catch (FileNotFoundException)
                {
                    recentList.Remove(entry.Token);
                }
            }
        }