Exemplo n.º 1
0
        private async Task SelectedSingleItem(FileExplorerItem selectedItem)
        {
            foreach (FileExplorerItem item in CurrentItems)
            {
                if (item != selectedItem)
                {
                    item.Selected = false;
                }
                else
                {
                    item.Selected = true;

                    if (SelectionMode == SelectionMode.FileWithOpen)
                    {
                        try
                        {
                            IStorageFolderEx folder = FolderTree.First();
                            IStorageFileEx   file   = await folder.GetFileAsync(item.Name);

                            if (_player != null)
                            {
                                _player.Dispose();
                            }

                            if (file != null)
                            {
                                _player = new SamplePlayer();

                                _player.WithVoicePool(AudioDefines.VoicePool)
                                .WithXAudio(AudioDefines.XAudio)
                                .WithWaveFormat(AudioDefines.WaveFormat)
                                .WithChannelVolume(0.8)
                                .WithInput(file)
                                .BuildAsync().ContinueWith(task => task.Result.Play(), TaskScheduler.Default);
                            }
                        }
                        catch (Exception ex)
                        {
                            Debug.WriteLine(ex.Message);
                        }
                    }
                }

                FileExplorerItem targetItem = GetItemFromPath(item.Path);
                if (item.Selected && targetItem == null)
                {
                    SelectedItems.Add(item);
                }
                else if (!item.Selected && targetItem != null)
                {
                    SelectedItems.Remove(GetItemFromPath(item.Path));
                }
            }
        }
Exemplo n.º 2
0
        //private async void FileExplorerItemSelect(object sender, GestureEventArgs e)
        //{
        //    var item = ((FrameworkElement) sender).Tag as FileExplorerItem;

        //    if (item == null)
        //    {
        //        return;
        //    }

        //    if (item.IsFolder)
        //    {
        //        GetTreeForFolder(await FolderTree.First()
        //            .GetFolderAsync(item.Name));
        //    }
        //    else
        //    {
        //        if (SelectionMode == SelectionMode.FileWithOpen)
        //        {

        //            SelectedSingleItem(item);
        //        }
        //    }
        //}

        private async void btnOpen_Click(object sender, RoutedEventArgs e)
        {
            var check = sender as CheckBox;

            if (check != null)
            {
                check.IsChecked = false;
            }

            ProcessSelectedItems();

            if (SelectionMode == SelectionMode.FileWithOpen)
            {
                try
                {
                    IStorageFolderEx folder = FolderTree.Pop();

                    if (SelectedItems == null || !SelectedItems.Any())
                    {
                        Dismiss(folder);
                        return;
                    }

                    IStorageFileEx file = await folder.GetFileAsync(SelectedItems.First().Name);

                    if (file != null)
                    {
                        Dismiss(file);
                        return;
                    }

                    Dismiss(folder);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("Can't Dismiss", ex.Message);
                }

                Dismiss(null);
            }
            else
            {
                Dismiss(SelectedItems);
            }
        }