async private void FileExplorerItemSelect(object sender, System.Windows.Input.GestureEventArgs e)
        {
            FileExplorerItem item = ((FrameworkElement)sender).Tag as FileExplorerItem;

            if (item.IsFolder)
            {
                if (StorageTarget == Interop.StorageTarget.ExternalStorage)
                {
                    GetTreeForExternalFolder(await _externalFolderTree.First().GetFolderAsync(item.Name));
                }
                else
                {
                    GetTreeForInternalFolder(await _internalFolderTree.First().GetFolderAsync(item.Name));
                }
            }
            else
            {
                if (SelectionMode == Interop.SelectionMode.File)
                {
                    if (StorageTarget == Interop.StorageTarget.ExternalStorage)
                    {
                        ExternalStorageFile file = await _currentStorageDevice.GetFileAsync(item.Path);

                        Dismiss(file);
                    }
                    else
                    {
                        StorageFolder folder = _internalFolderTree.Pop();
                        StorageFile   file   = await folder.GetFileAsync(item.Name);

                        Dismiss(file);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        async void SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (lstCore.SelectedItem != null)
            {
                FileExplorerItem item = (FileExplorerItem)lstCore.SelectedItem;
                if (item.IsFolder)
                {
                    GetTreeForFolder(await _folderTree.First().GetFolderAsync(item.Name));
                }
                else
                {
                    ExternalStorageFile file = await _currentStorageDevice.GetFileAsync(item.Path);

                    Dismiss(file);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets a file from SD Card
        /// </summary>
        /// <param name="sdfilePath"></param>
        /// <returns>File Stream</returns>
        public async Task <Stream> SDCard_ReadFile(string sdfilePath)
        {
            try
            {
                ExternalStorageDevice sdcard = (await ExternalStorage.GetExternalStorageDevicesAsync()).FirstOrDefault();

                if (sdcard != null)
                {
                    ExternalStorageFile file = await sdcard.GetFileAsync(sdfilePath);

                    return(await file.OpenForReadAsync());
                }
                else
                {
                    MessageBox.Show("Please check SD Card");
                    return(null);
                }
            }
            catch (FileNotFoundException)
            {
                MessageBox.Show("File not found.");
                return(null);
            }
        }
Ejemplo n.º 4
0
        async public void readfile(string filepath)
        {
            // enables progress indicator
            //ProgressIndicator indicator = SystemTray.ProgressIndicator;
            //if (indicator != null)
            //{
            //    //indicator.Text = "载入文件中 ...";
            //    //indicator.IsVisible = true;
            //}

            // Connect to the current SD card.
            ExternalStorageDevice _sdCard = (await ExternalStorage.GetExternalStorageDevicesAsync()).FirstOrDefault();

            // If the SD card is present, add GPX files to the Routes collection.
            if (_sdCard != null)
            {
                try
                {
                    // get file of the specific path
                    ExternalStorageFile esf = await _sdCard.GetFileAsync(filepath);

                    if (esf != null)
                    {
                        Debug.WriteLine("found file " + esf.Name);
                        if (esf.Path.EndsWith(".txtx"))
                        {
                            // print its content
                            Stream x = await esf.OpenForReadAsync();

                            byte[] buffer = new byte[x.Length];
                            x.Read(buffer, 0, (int)x.Length);
                            x.Close();

                            string result = System.Text.Encoding.UTF8.GetString(buffer, 0, buffer.Length);
                            //Debug.WriteLine(result);
                            //this.title.Text = "阅读器";
                            //Debug.WriteLine("title changed");
                            //this.content.Text = result.Substring(0, 10000);
                            //Debug.WriteLine("content changed");
                            this.contentString = result;

                            // cut content into pages
                            this.cutContentIntoPages();

                            // display first page
                            this.currentPage = 0;
                            this.displayCurrentPage();
                        }
                    }
                    Debug.WriteLine("done");
                }
                catch (FileNotFoundException)
                {
                    // No Routes folder is present.
                    this.content.Text = "Error loading file, reason: file not found";
                    Debug.WriteLine("file not found.");
                }
            }
            else
            {
                // No SD card is present.
                Debug.WriteLine("The SD card is mssing.");
            }
        }