예제 #1
0
        private async void ConvertButton_Click(object sender, RoutedEventArgs e)
        {
            var picker = new Windows.Storage.Pickers.FileOpenPicker
            {
                ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail,
                SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary
            };

            picker.FileTypeFilter.Add(".xml");
            picker.FileTypeFilter.Add(".txt");

            StorageFile file = await picker.PickSingleFileAsync();

            var doc = CopticInterpreter.ReadDocXml(file.Path);

            if (String.IsNullOrWhiteSpace(OutputBox.Text))
            {
                //OutputBox.Text += CopticInterpreter.ConvertFromString(doc.Content);
                InputBox.Text += doc.Translations[0];
            }
            else
            {
                //string input = String.Join("\r\n", doc.Translations[0].Content.Select(s => s.Text));
                //OutputBox.Text += CopticInterpreter.ConvertFont(
                //    input, CopticFont.Coptic1, CopticFont.CopticUnicode
                //);
                //InputBox.Text += input;
            }
            //OutputBox.Text = CopticInterpreter.ConvertFromString(InputBox.Text);
        }
예제 #2
0
        private async void LoadDocs(bool present = false)
        {
            OutputBox.Text = "";
            InputBox.Text  = "";
            IReadOnlyList <StorageFile> files = await ApplicationData.Current.RoamingFolder.GetFilesAsync();

            try
            {
                if (files != null)
                {
                    if (files.Count > 0)
                    {
                        Common.Docs.Clear();
                        foreach (StorageFile file in files)
                        {
                            Debug.WriteLine(file.Path);
                            var doc = CopticInterpreter.ReadDocXml(file.Path);
                            Common.Docs.Add(doc);
                            Debug.WriteLine(doc.Name);
                        }

                        if (present)
                        {
                            Present();
                        }
                    }
                    else
                    {
                        Frame.Navigate(typeof(FilesPage));
                    }
                }
                else
                {
                    Frame.Navigate(typeof(FilesPage));
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);

                ContentDialog errorDialog = new ContentDialog()
                {
                    Title           = "Error",
                    Content         = ex,
                    CloseButtonText = "Ok"
                };

                await errorDialog.ShowAsync();

                Frame.Navigate(typeof(FilesPage));
            }
        }
예제 #3
0
        private void ImportDoc(StorageFile file)
        {
            Debug.WriteLine(file.Path);
            var doc = CopticInterpreter.ReadDocXml(file.Path);

            FileView.Items.Add(new ListViewItem()
            {
                Content = $"{doc.Name} [{doc.Uuid}]",
            });
            _files.Add(file);
            //Common.Docs.Add(doc);

            StatusBlock.Visibility = Visibility.Visible;
            StatusBlock.Foreground = new SolidColorBrush(Color.FromArgb(255, 15, 166, 0));
            StatusBlock.Text       = "Successfully copied " + file.Name;
        }
예제 #4
0
        private async void OpenButton_Click(object sender, RoutedEventArgs e)
        {
            var picker = new FileOpenPicker();

            picker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
            picker.FileTypeFilter.Add(".xml");
            picker.FileTypeFilter.Add(".zip");

            Windows.Storage.StorageFile file = await picker.PickSingleFileAsync();

            if (file == null)
            {
                return;
            }

            var mru = Windows.Storage.AccessCache.StorageApplicationPermissions.MostRecentlyUsedList;

            _ = mru.Add(file, file.Name);

            var stream = await file.OpenStreamForReadAsync();

            switch (Path.GetExtension(file.Name))
            {
            case ".xml":
                // Read the file
                var docXml = CopticInterpreter.ReadDocXml(stream);
                Docs.Add(docXml);
                MainTabControl.SelectedIndex = Docs.Count - 1;
                return;

            case ".zip":
                // Read the set
                var set = CopticInterpreter.ReadSet(stream, file.Name, Windows.Storage.ApplicationData.Current.TemporaryFolder.Path);
                Docs.Clear();
                set.IncludedDocs.ForEach(d => Docs.Add(d));
                MainTabControl.SelectedIndex = 0;
                CurrentStanza = (set.IncludedDocs[0].Translations[0].Content[0] as Stanza)?.Text;
                return;
            }
        }