示例#1
0
        public HotkeyHook(Window window, MainWindowViewModel viewModel)
        {
            _viewModel = viewModel;
            _windowHandle = new WindowInteropHelper(window).Handle;
            _source = HwndSource.FromHwnd(_windowHandle);
            _source.AddHook(HwndHook);

            RegisterHotKey(_windowHandle, KEY_X.GetHashCode(), MOD_ALT, KEY_X);
            RegisterHotKey(_windowHandle, KEY_Z.GetHashCode(), MOD_ALT, KEY_Z);
            RegisterHotKey(_windowHandle, KEY_C.GetHashCode(), MOD_ALT, KEY_C);
            RegisterHotKey(_windowHandle, KEY_S.GetHashCode(), MOD_ALT, KEY_S);
        }
 protected override async void OnSourceInitialized(EventArgs e)
 {
     base.OnSourceInitialized(e);
     NotPlayingList.Items.SortDescriptions.Add(new SortDescription(string.Empty, ListSortDirection.Ascending));
     PlayingList.Items.SortDescriptions.Add(new SortDescription(string.Empty, ListSortDirection.Ascending));
     NotPlayingList.ItemsSource = await Task.Run(() =>
     {
         _viewModel = new MainWindowViewModel();
         return _viewModel.NotPlayingList;
     });
     PlayingList.ItemsSource = _viewModel.PlayingList;
     _hotkeyHook = new HotkeyHook(this, _viewModel);
 }