Ejemplo n.º 1
0
        public static async Task <RecentFile> RegisterFile(IStorageFile storageFile, bool overrideEntry = false)
        {
            RecentFile file = new RecentFile(storageFile: storageFile, printErrors: true);
            await file.Check();

            if (file.IsValid)
            {
                if (file.IsFullPathSupported)
                {
                    if (overrideEntry)
                    {
                        RecentFiles.RemoveAll(rf => rf.FullPath == file.FullPath);
                    }
                    if (!RecentFiles.Any(rf => rf.FullPath == file.FullPath))
                    {
                        RecentFiles.Add(file);
                        Save();
                    }
                }
                return(file);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
        public static async Task OpenFile(Frame frame, RecentFile info)
        {
            try
            {
                if (info != null)
                {
                    await info.Check();
                }

                if (info != null && info.IsValid)
                {
                    if (info.Language.FileType == FileType.TEXT)
                    {
                        frame.Navigate(typeof(MarkdownEditPage), info.GUID);
                    }
                    else if (info.Language.FileType == FileType.INK)
                    {
                        frame.Navigate(typeof(InkEditPage), info.GUID);
                    }
                    else
                    {
                        Log.FatalError("Unknown file type.");
                    }
                }
                else
                {
                    Log.FatalError("The file is not valid.");
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }