Пример #1
0
        private async void ShowItemInfo(object sender, RoutedEventArgs e)
        {
            LibraryItem item = (sender as FrameworkElement).DataContext as LibraryItem;

            if (item != null)
            {
                LibraryItemInfo dialog = new LibraryItemInfo(item);
                await dialog.ShowAsync();
            }
        }
Пример #2
0
        // This is where I set up keyboard accelerators and do some ridiculous hacks
        // to get keyboard control+focus working the way I want it.
        // Space should ALWAYS toggle playback, unless the search box has focus.
        // Escape should clear+exit the search box.
        // Enter should start playing a file when in the file view

        #region KeyboardStuff

        private void SetUpKeyboardAccelerators()
        {
            KeyboardAccelerator CreateAccelerator(VirtualKeyModifiers modifier, VirtualKey key,
                                                  TypedEventHandler <KeyboardAccelerator, KeyboardAcceleratorInvokedEventArgs> eventHandler)
            {
                KeyboardAccelerator ret = new KeyboardAccelerator()
                {
                    Modifiers = modifier, Key = key
                };

                ret.Invoked += eventHandler;

                return(ret);
            }

            //pull

            KeyboardAccelerator pullAccelerator = CreateAccelerator(VirtualKeyModifiers.Control, VirtualKey.P,
                                                                    async(sender, args) => {
                args.Handled = true;
                await ViewModel.PullEventsCommand.ExecuteAsync(null);
            });

            KeyboardAccelerators.Add(pullAccelerator);

            //push
            KeyboardAccelerators.Add(CreateAccelerator(VirtualKeyModifiers.Control | VirtualKeyModifiers.Shift, VirtualKey.P,
                                                       async(sender, args) => {
                args.Handled = true;
                await ViewModel.PushEventsCommand.ExecuteAsync(null);
            }));

            //search accelerator
            KeyboardAccelerators.Add(CreateAccelerator(VirtualKeyModifiers.Control, VirtualKey.F,
                                                       (sender, args) => {
                args.Handled = true;
                FilterBox.Focus(FocusState.Keyboard);
                FilterBox.SelectAll();
            }));

            //open local folder
            KeyboardAccelerators.Add(CreateAccelerator(VirtualKeyModifiers.Control, VirtualKey.E,
                                                       async(sender, args) => {
                args.Handled = true;
                await Launcher.LaunchFolderAsync(Windows.Storage.ApplicationData.Current.LocalFolder);
            }));

            //open music folder
            KeyboardAccelerators.Add(CreateAccelerator(VirtualKeyModifiers.Control, VirtualKey.M,
                                                       async(sender, args) => {
                args.Handled = true;
                await ViewModel.OpenLibraryFolder();
            }));

            //open library DB
            KeyboardAccelerators.Add(CreateAccelerator(VirtualKeyModifiers.Control, VirtualKey.D,
                                                       async(sender, args) => {
                args.Handled = true;
                Windows.Storage.StorageFile dbFile = await FileHelper.GetLibraryDbFileAsync();
                await Launcher.LaunchFileAsync(dbFile);
            }));

            //show selected item(s) in File Explorer
            KeyboardAccelerators.Add(CreateAccelerator(VirtualKeyModifiers.Control, VirtualKey.L,
                                                       async(sender, args) => {
                args.Handled = true;

                LibraryItem selected = (LibraryItem)libraryDataGrid.SelectedItem;
                await ViewModel.ShowItemInExplorer(selected);
            }));

            //show item info
            KeyboardAccelerators.Add(CreateAccelerator(VirtualKeyModifiers.Control, VirtualKey.I,
                                                       async(sender, args) => {
                args.Handled = true;

                LibraryItem selected = libraryDataGrid.SelectedItem as LibraryItem;
                if (selected != null)
                {
                    LibraryItemInfo dialog = new LibraryItemInfo(selected);
                    await dialog.ShowAsync();
                }
            }));

            //play a random bookmark
            KeyboardAccelerators.Add(CreateAccelerator(VirtualKeyModifiers.Control, VirtualKey.R,
                                                       async(sender, args) => {
                args.Handled = true;
                await ViewModel.PlayRandomBookmark();
            }));
        }