コード例 #1
0
        public async Task Init()
        {
            var folderList = await App._instance.IO.GetLocalDataAsync <List <FolderItem> >(StaticString.FolderListFileName);

            var historyList = await App._instance.IO.GetLocalDataAsync <List <HistoryItem> >(StaticString.HistoryListFileName);

            FolderCollection.Clear();
            DisplayHistoryCollection.Clear();
            if (!folderList.IsNullOrEmpty())
            {
                folderList.ForEach(p => FolderCollection.Add(p));
            }
            else
            {
                var folderItem = new FolderItem(App._instance.App.GetLocalizationTextFromResource(LanguageName.Default), FeatherSymbol.Activity);
                FolderCollection.Add(folderItem);
                await SaveFolderList();
            }

            string lastSelectedFolderId = App._instance.App.GetLocalSetting(Settings.LastSelectFolderId, "");

            if (!FolderCollection.Any(p => p.Id == lastSelectedFolderId))
            {
                lastSelectedFolderId = FolderCollection.First().Id;
            }

            CurrentSelectedFolder = FolderCollection.Where(p => p.Id == lastSelectedFolderId).First();

            if (!historyList.IsNullOrEmpty())
            {
                AllHistoryList = historyList;
                historyList.Where(p => p.FolderId == lastSelectedFolderId).ToList().ForEach(p => DisplayHistoryCollection.Add(p));
                HistoryChanged?.Invoke(this, EventArgs.Empty);
            }
        }
コード例 #2
0
        public async Task RemoveFolder(FolderItem item)
        {
            if (FolderCollection.Count == 1)
            {
                ShowPopup(LanguageName.NeedOneFolder, true);
                return;
            }
            var confirmDialog = new ConfirmDialog(LanguageName.ConfirmRemoveFolder);

            confirmDialog.PrimaryButtonClick += (_s, _e) =>
            {
                FolderCollection.Remove(item);
                AllHistoryList.RemoveAll(p => p.FolderId == item.Id);
                if (CurrentSelectedFolder.Equals(item))
                {
                    var first = FolderCollection.First();
                    CurrentSelectedFolder = first;
                }
                IsFolderListChanged  = true;
                IsHistoryListChanged = true;
            };
            await confirmDialog.ShowAsync();
        }