Esempio n. 1
0
        public async void OpenDocument()
        {
            try
            {
                FileOpenPicker openPicker = new FileOpenPicker();
                openPicker.ViewMode = PickerViewMode.List;
                openPicker.FileTypeFilter.Add(".json");

                StorageFile file = await openPicker.PickSingleFileAsync();

                if (file != null)
                {
                    string token = StorageApplicationPermissions.FutureAccessList.Add(file);
                    OpenDocuments.Add(await DocumentViewModel.LoadFromFileAsync(this, file, token));
                    CurrentDocument = OpenDocuments.LastOrDefault();
                    SaveFileTokensAsync();
                }
                else
                {
                }
            }
            catch { }
        }
Esempio n. 2
0
        public async void CloseDocument(BaseDocumentViewModel document)
        {
            // TODO: Check if not saved
            int index = OpenDocuments.IndexOf(document);

            if (index != -1)
            {
                OpenDocuments.RemoveAt(index);

                if (index < OpenDocuments.Count)
                {
                    CurrentDocument = OpenDocuments[index];
                }
                else
                {
                    CurrentDocument = OpenDocuments.LastOrDefault();
                }

                if (document.Token != null)
                {
                    await SaveFileTokensAsync();
                }
            }
        }
Esempio n. 3
0
 private async void AddAndSelectDocument(BaseDocumentViewModel doc)
 {
     AddDocument(doc);
     CurrentDocument = OpenDocuments.LastOrDefault();
     await SaveFileTokensAsync();
 }