//---------------------------------------------------------------------------------------------------------------------- private void Window_Loaded_1(object sender, RoutedEventArgs e) { var viewModel = new PlayerViewModel(); DataContext = viewModel; IPlayerActionQueriable playerAction = DataContext as IPlayerActionQueriable; if (playerAction != null) { playerAction.PlayQuery += Play; playerAction.PauseQuery += Pause; playerAction.StopQuery += Stop; playerAction.ListChangeQuery += PlayerActionOnListChangeQuery; playerAction.FolderDialogQuery += playerAction_FolderDialogQuery; playerAction.ChangePathDialogQuery += playerAction_ChangePathDialogQuery; } ISavable saveModel = DataContext as ISavable; if (saveModel != null) { this.Closing += (s, ev) => saveModel.Save();; } // workPlayer.Stretch = Stretch.; workPlayer.StretchDirection = StretchDirection.Both; Binding bindingCurrentTrackDeletePressCommand = new Binding("CurrentTrackDeletePressCommand"); bindingCurrentTrackDeletePressCommand.Source = DataContext; BindingOperations.SetBinding(this, PlayerWindow.CurrentTrackDeletePressCommandProperty, bindingCurrentTrackDeletePressCommand); Binding bindingCurrentTrackDoubleClickCommand = new Binding("CurrentTrackDoubleClickCommand"); bindingCurrentTrackDoubleClickCommand.Source = DataContext; BindingOperations.SetBinding(this, PlayerWindow.CurrentTrackDoubleClickCommandProperty, bindingCurrentTrackDoubleClickCommand); IScrollIntoViewAction scrollIntoViewAction = (IScrollIntoViewAction)DataContext; scrollIntoViewAction.MainGridScrollIntoView += i => { ScrollIntoView(); }; playerAction.OnLoad(); DispatcherTimer timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromMilliseconds(500); timer.Tick += timer_Tick; timer.Start(); }
//------------------------------------------------------------------------------------------------------------------- private void Window_Loaded(object sender, RoutedEventArgs e) { var viewModel = new Fb2PlayerViewModel.Fb2PlayerViewModel(); DataContext = viewModel; ISavable saveModel = DataContext as ISavable; if (saveModel != null) { this.Closing += (s, ev) => saveModel.Save();; } IScrollIntoViewAction scrollIntoViewAction = (IScrollIntoViewAction)DataContext; if (scrollIntoViewAction != null) { scrollIntoViewAction.SpeechPhraseScrollIntoView += () => { SpeechPhraseScrollIntoView(); }; } }