void MainWindow_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) { if (e.Key == Key.S) { ModelIO.Save(model); return; } currentMode.ProcessKey(e); e.Handled = true; }
void Synchronize_Click(object sender, RoutedEventArgs e) { if (model.Montage.Shift != 0) { var response = MessageBox.Show("Вы уже синхронизировали это видео. Точно хотите пересинхронизировать?", "", MessageBoxButton.YesNoCancel); if (response != MessageBoxResult.Yes) { return; } } model.Montage.Shift = model.WindowState.CurrentPosition; model.WindowState.CurrentPosition = model.WindowState.CurrentPosition + 1; ModelIO.Save(model); }
void Infos_Click(object sender, RoutedEventArgs e) { var times = new List <int>(); var current = 0; foreach (var c in model.Montage.Chunks) { if (c.StartsNewEpisode) { times.Add(current); current = 0; } if (c.Mode == Mode.Face || c.Mode == Mode.Screen) { current += c.Length; } } times.Add(current); if (model.Montage.Information.Episodes.Count == 0) { model.Montage.Information.Episodes.AddRange(Enumerable.Range(0, times.Count).Select(z => new EpisodInfo())); } else if (model.Montage.Information.Episodes.Count != times.Count) { MessageBox.Show("The stored information contains wrong count of records, i.e. describes wrong number of episodes. Please check it", "", MessageBoxButton.OK, MessageBoxImage.Information); while (model.Montage.Information.Episodes.Count < times.Count) { model.Montage.Information.Episodes.Add(new EpisodInfo()); } } for (int i = 0; i < times.Count; i++) { model.Montage.Information.Episodes[i].Duration = TimeSpan.FromMilliseconds(times[i]); } var wnd = new InfoWindow(); wnd.DataContext = model.Montage.Information; wnd.ShowDialog(); ModelIO.Save(model); }
void MainWindow_Initialized(object sender, EventArgs e) { model = (EditorModel)DataContext; model.WindowState.PropertyChanged += WindowState_PropertyChanged; FaceVideo.Source = new Uri(model.Locations.FaceVideo.FullName); ScreenVideo.Source = new Uri(model.Locations.DesktopVideo.FullName); FaceVideo.LoadedBehavior = MediaState.Manual; ScreenVideo.LoadedBehavior = MediaState.Manual; ModeChanged(); PositionChanged(); PausedChanged(); RatioChanged(); videoAvailable = model.Locations.FaceVideo.Exists; DispatcherTimer timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromMilliseconds(timerInterval); timer.Tick += (s, a) => { CheckPlayTime(); }; timer.Start(); PreviewKeyDown += MainWindow_KeyDown; ModelView.MouseDown += Timeline_MouseDown; Slider.MouseDown += Timeline_MouseDown; Save.Click += (s, a) => { ModelIO.Save(model); }; Synchronize.Click += Synchronize_Click; Infos.Click += Infos_Click; }