示例#1
0
        private void browse_guerilla_Click(object sender, RoutedEventArgs e)
        {
            var picker = new FilePicker(guerilla_path, null, toolExeOptions, null);

            picker.Prompt();
        }
示例#2
0
        /// <summary>
        /// выбрать файлы из файлововй системы
        /// </summary>
        /// <param name="sender">аргументы передаваемые с вызовом метода</param>
        /// <param name="args">объект который вызывает метод</param>
        public async void PickAudioFile(object sender, EventArgs args)
        {
            var files = (await FilePicker.PickMultipleAsync(CrossFileManipulation.optionsPicket)).ToArray();

            CrossFileManipulation.LoadToCache(files);
        }
示例#3
0
    public async void FileSelect()
    {
            #if __ANDROID__
        try
        {
            inputFile = await FilePicker.PickAsync();

            newInputFile = true;

            if (inputFile != null)
            {
                if (inputFile.FileName.EndsWith("txt", StringComparison.OrdinalIgnoreCase))
                {
                    using (var stream = await inputFile.OpenReadAsync())
                    {
                        using (var reader = new StreamReader(stream))
                        {
                            filePickerText = reader.ReadToEnd();
                        }
                    }
                }
                else if (inputFile.FileName.EndsWith("docx", StringComparison.OrdinalIgnoreCase))
                {
                    using (var stream = await inputFile.OpenReadAsync())
                    {
                        using (var doc = WordprocessingDocument.Open(stream, false))
                        {
                            filePickerText = doc.MainDocumentPart.Document.Body.InnerText;
                        }
                    }
                }
                else
                {
                    // break;
                }
            }
        }
        catch (Exception ex)
        {
            // user didn't pick or something bad happened in the OS (permission denied)
        }
            #else
        inputFile = await picker.PickSingleFileAsync();

        newInputFile = true;

        if (inputFile != null)
        {
            switch (inputFile.FileType.ToString())
            {
            case string s when(s == ".docx"):
                using (var stream = await inputFile.OpenStreamForReadAsync())
                {
                    using (var doc = WordprocessingDocument.Open(stream, false))
                    {
                        filePickerText = doc.MainDocumentPart.Document.Body.InnerText;
                    }
                }

                break;

            case string s when(s == ".txt"):
                filePickerText = await Windows.Storage.FileIO.ReadTextAsync(inputFile);

                break;

            default:
                break;
            }
        }
            #endif
    }
示例#4
0
 private void OpenCommand_Executed(object sender, ExecutedRoutedEventArgs e)
 {
     FilePicker.ShowChooseFileDialog();
 }
示例#5
0
 public async Task PickAsync_Fail_On_NetStandard()
 {
     await Assert.ThrowsAsync <NotImplementedInReferenceAssemblyException>(() => FilePicker.PickAsync());
 }
示例#6
0
        /// <summary>
        /// Open platform specific FilePicker and allow user to pick audio file of supported type.
        /// </summary>
        /// <param name="writeResult">Action accepting result of Upload process described in string.</param>
        /// <returns>True if picked song was sucessfuly uploaded, false otherwise.</returns>
        public async Task <bool> UploadRecording(Action <string> writeResult, ulong maxSize_MB)
        {
            #region UWP
#if NETFX_CORE
            // Setup FilePicker
            var picker = new Windows.Storage.Pickers.FileOpenPicker();
            picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail;
            picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.MusicLibrary;
            picker.FileTypeFilter.Add(".wav");

            // Open FilePicker
            StorageFile file = await picker.PickSingleFileAsync();

            if (file == null)
            {
                writeResult("No song uploaded.");
                return(false);
            }

            // Check size of uploaded file
            var fileProperties = await file.GetBasicPropertiesAsync();

            if (fileProperties.Size > maxSize_MB * 1024 * 1024)
            {
                writeResult($"Selected file is too big." + Environment.NewLine + $"Maximum allowed size is {maxSize_MB} MB.");
                return(false);
            }
            else
            {
                buffer = await file.OpenAsync(FileAccessMode.ReadWrite);

                writeResult(file.Name);
                return(true);
            }
#endif
            #endregion

            #region ANDROID
#if __ANDROID__
            if (await Utils.Permissions.Droid.GetExternalStoragePermission())
            {
                // Setup FilePicker
                PickOptions options = new PickOptions
                {
                    PickerTitle = "Please select a wav song file",
                    FileTypes   = new FilePickerFileType(new Dictionary <DevicePlatform, IEnumerable <string> >
                    {
                        { DevicePlatform.Android, new[] { "audio/x-wav", "audio/wav" } }
                    })
                };

                // Open FilePicker
                FileResult result = await FilePicker.PickAsync(options);

                // Process picked file
                if (result != null)
                {
                    var audioFileData = await result.OpenReadAsync();

                    if ((ulong)audioFileData.Length > maxSize_MB * 1024 * 1024)
                    {
                        writeResult($"File is too large." + Environment.NewLine + $"Maximum allowed size is {maxSize_MB} MB.");
                        return(false);
                    }

                    buffer = new byte[(int)audioFileData.Length];
                    audioFileData.Read(buffer, 0, (int)audioFileData.Length);
                    writeResult(result.FileName);

                    return(true);
                }
                // No file picked
                else
                {
                    writeResult("No song uploaded");
                    return(false);
                }
            }
            // External Sotrage Permission not granted
            else
            {
                writeResult("Acces to read storage denied.");
                return(false);
            }
#endif
            #endregion
            // Fallback value for unsupported platforms
            return(false);
        }
        protected override async void OnAppearing()
        {
            Folder.OnClickCommand = new Command(async() =>
            {
                var fileData = await FilePicker.PickAsync();
                if (fileData != null)
                {
                    switch (TypeOfMedia)
                    {
                    case 1:
                        MediaToIns.SearchMovieFromFile(Path.GetDirectoryName(fileData.FullPath));
                        MovieList.ItemsSource = MediaToIns.Movies;
                        break;

                    case 2:
                        MediaToIns.SearchTvShowFromFolder(Path.GetDirectoryName(fileData.FullPath));
                        MovieList.ItemsSource = MediaToIns.TvShows;
                        break;

                    default:
                        break;
                    }
                }
            });

            Csv.OnClickCommand = new Command(async() =>
            {
                //FileResult fileData = await FilePicker.PickAsync();
                //if (fileData != null)
                //{
                //    ;
                //    switch (TypeOfMedia)
                //    {
                //        case 1:
                //            await MediaToIns.ImportMovieFromFile(fileData.OpenReadAsync().Result);
                //            break;
                //        case 2:
                //            await MediaToIns.ImportTvShowFromFile(fileData.DataArray);
                //            break;
                //        default:
                //            break;
                //    }
                //}
            });
            WebApi.OnClickCommand = new Command(async() =>
            {
                try
                {
                    if (TypeOfMedia == 1)
                    {
                        await MediaToIns.ImportMovieFromWebService();
                        DependencyService.Get <IMessage>().ShortAlert(String.Format(AppResources.MessageNMovieImported, MediaToIns.Movies.Count.ToString()));
                    }
                }
                catch (Exception ex) { Crashes.TrackError(ex); }
            });

            if (PY.WebApiAddress != null && PY.WebApiAddress != "" && TypeOfMedia == 1)
            {
                WebApi.IsEnabled = true;
            }
            else
            {
                WebApi.IsEnabled = false;
            }
        }
示例#8
0
 private void BTN_BrowsePOLPath_Click(object sender, EventArgs e)
 {
     this.TB_POLPath.Text = FilePicker.SelectFolder();
 }
示例#9
0
 private void BTN_BrowseEcompileEXEPath_Click(object sender, EventArgs e)
 {
     this.TB_ECompileEXEPath.Text = FilePicker.SelectFile("Exe files (*.exe)|*.exe");
 }
示例#10
0
 void Start()
 {
     Picker               = new FilePicker();
     Picker.Folder        = PlayerPrefs.GetString("LoaderLocation", "\\");
     Picker.OnFileLoaded += OnLoad;
 }
示例#11
0
 public async Task <FileResult> PickVideoAsync(MediaPickerOptions options)
 => await FilePicker.PickAsync(new PickOptions
 {
     PickerTitle = options?.Title,
     FileTypes   = FilePickerFileType.Videos
 });
示例#12
0
 public void Shutdown() => FilePicker.Hide();
示例#13
0
        public override void DrawEditor(double delta)
        {
            foreach (var entity in _selectedEntities.GetEntities())
            {
                if (entity.Has <VoxelSpace>())
                {
                    ImGui.Text($"Entity {entity}");
                    ImGui.SameLine();
                    if (ImGui.Button("Save"))
                    {
                        FilePicker.Open("save-voxel-space");
                    }

                    if (FilePicker.Window("save-voxel-space", ref _fileLocation, new[] { ".cvx" }))
                    {
                        if (!Directory.Exists(_fileLocation))
                        {
                            ref var space          = ref entity.Get <VoxelSpace>();
                            var     voxelSpaceData = new VoxelSpaceData()
                            {
                                VoxelSize = space.VoxelSize,
                                GridSize  = space.GridSize,
                                Grids     = space.Select(kvp => (kvp.Key, kvp.Value.Get <VoxelGrid>().Voxels)).ToArray()
                            };
                            VoxelSpaceDataSerializer.Serialize(voxelSpaceData, File.OpenWrite(_fileLocation));
                        }
                    }

                    ImGui.Separator();
                }
            }

            if (ImGui.Button("Load File"))
            {
                FilePicker.Open("load-voxel-space");
            }

            if (FilePicker.Window("load-voxel-space", ref _fileLocation, new[] { ".cvx" }))
            {
                if (File.Exists(_fileLocation))
                {
                    var name           = Path.GetFileNameWithoutExtension(_fileLocation);
                    var voxelSpaceData = VoxelSpaceDataSerializer.Deserialize(File.OpenRead(_fileLocation));
                    _serverChannel.AddBuffered <VoxelSpaceLoadReciever, VoxelSpaceLoadMessage>(new VoxelSpaceLoadMessage()
                    {
                        VoxelSpaceData = voxelSpaceData,
                        Position       = CameraTransform.WorldPosition,
                        Name           = name
                    });
                }
            }

            if (ImGui.Button("Load Empty"))
            {
                var voxels = new Voxel[8 * 8 * 8];
                voxels[0] = new Voxel()
                {
                    Exists = true
                };
                var voxelSpaceData = new VoxelSpaceData()
                {
                    VoxelSize = 1,
                    GridSize  = 8,
                    Grids     = new[]
示例#14
0
        private static async Task <GpxClass> PickAndParse()
        {
            try
            {
                var options = new PickOptions
                {
                    PickerTitle = "Please select a GPX file",
                    FileTypes   = new FilePickerFileType(new Dictionary <DevicePlatform, IEnumerable <string> >
                    {
                        /**///What is mime type for GPX files?!?
                        //{ DevicePlatform.Android, new string[] { "gpx/gpx"} },
                        { DevicePlatform.Android, null },
                    })
                };

                var result = await FilePicker.PickAsync(options);

                if (result == null)
                {
                    return(null);
                }

                Console.WriteLine("FileName: " + result.FileName + ", FilePath: " + result.FullPath);
                if (result.FileName.EndsWith("gpx", StringComparison.OrdinalIgnoreCase) == false)
                {
                    return(null);
                }

                var stream = await result.OpenReadAsync();

                string contents = string.Empty;
                using (var reader = new StreamReader(stream))
                {
                    contents = reader.ReadToEnd();
                }

                GpxClass gpx    = GpxClass.FromXml(contents);
                var      bounds = gpx.GetBounds();

                Console.WriteLine("Waypoints.Count: " + gpx.Waypoints.Count.ToString());
                Console.WriteLine("Routes.Count: " + gpx.Routes.Count.ToString());
                Console.WriteLine("Track.Count: " + gpx.Tracks.Count.ToString());
                Console.WriteLine("Lower Left - MinLat: " + bounds.minlat.ToString() + ", MaxLon: " + bounds.maxlon.ToString());
                Console.WriteLine("Top Right  - MaxLat: " + bounds.maxlat.ToString() + ", MinLon: " + bounds.minlon.ToString());

                string r = "routes";
                if (gpx.Routes.Count == 1)
                {
                    r = "route";
                }

                string t = "tracks";
                if (gpx.Tracks.Count == 1)
                {
                    t = "track";
                }

                Show_Dialog msg1 = new Show_Dialog(MainActivity.mContext);
                if (await msg1.ShowDialog($"{result.FileName}", $"Found {gpx.Routes.Count} {r} and {gpx.Tracks.Count} {t}. Import?", Android.Resource.Attribute.DialogIcon, true, Show_Dialog.MessageResult.YES, Show_Dialog.MessageResult.NO) != Show_Dialog.MessageResult.YES)
                {
                    return(null);
                }

                return(gpx);
            }
            catch (Exception)
            {
                // The user canceled or something went wrong
            }

            return(null);
        }