private void updateProgressBar() { try { if (mediaplaying && !isdragging) { var MediaMilliseconds = PreviewMedia.Position.TotalMilliseconds; var MediaSeconds = PreviewMedia.Position.TotalSeconds; var MediaMinutes = PreviewMedia.Position.TotalMinutes; var MediaHours = PreviewMedia.Position.TotalHours; var RemainingMilliseconds = PreviewMedia.NaturalDuration.TimeSpan.TotalMilliseconds - PreviewMedia.Position.TotalMilliseconds; var RemainingSeconds = Math.Floor((RemainingMilliseconds / 1000) % 60); var RemainingMinutes = Math.Floor((RemainingMilliseconds / 60000) % 60); var RemainingHours = Math.Floor((RemainingMilliseconds / 3600000) % 60); SettingProgressBar = true; VideoProgress.Value = PreviewMedia.Position.TotalMilliseconds; SettingProgressBar = false; if (PreviewMedia.NaturalDuration.HasTimeSpan) { if (PreviewMedia.Position.TotalMilliseconds == PreviewMedia.NaturalDuration.TimeSpan.TotalMilliseconds) { if (LessThan10Seconds) { PreviewMedia.Stop(); PreviewMedia.Play(); } else { PreviewMedia.Stop(); mediaplaying = false; Play.Visibility = Visibility.Visible; Pause.Visibility = Visibility.Hidden; Pause2.Visibility = Visibility.Hidden; } } } mediatime.Content = (MediaHours >= 1 ? Math.Floor(MediaHours).ToString("00.") + ":" : "00:") + Math.Floor(MediaMinutes % 60).ToString("00.") + ":" + Math.Floor(MediaSeconds % 60).ToString("00."); RemainingMediaTime.Content = RemainingHours.ToString("00.") + ":" + RemainingMinutes.ToString("00.") + ":" + RemainingSeconds.ToString("00."); } } catch (Exception ex) { Error.WriteToLog(ex); } }
private void Fullscren_Click(object sender, RoutedEventArgs e) { try { returnposition = PreviewMedia.Position; playing = mediaplaying; VolumeOut = Volume.Value; PreviewMedia.Stop(); timer.Stop(); this.Close(); } catch (Exception ex) { Error.WriteToLog(ex); PreviewMedia.Stop(); timer.Stop(); this.Close(); } }
private void Stop_Click(object sender, RoutedEventArgs e) { try { mediaplaying = false; Pause.Visibility = Visibility.Hidden; Pause2.Visibility = Visibility.Hidden; Play.Visibility = Visibility.Visible; PreviewMedia.Stop(); timer.Stop(); VideoProgress.Value = 0; RemainingMediaTime.Content = MediaLength; mediatime.Content = "00:00:00"; } catch (Exception ex) { Error.WriteToLog(ex); } }
private void Window_KeyUp(object sender, KeyEventArgs e) { try { if (e.Key == Key.Escape) { returnposition = PreviewMedia.Position; playing = mediaplaying; VolumeOut = Volume.Value; PreviewMedia.Stop(); timer.Stop(); this.Close(); } else if (e.Key == Key.D1) { if (EventControls.Children.Count - 1 >= 0) { eventindex = 0; EventKey(eventindex); } } else if (e.Key == Key.D2) { if (EventControls.Children.Count - 1 >= 1) { eventindex = 1; EventKey(eventindex); } } else if (e.Key == Key.D3) { if (EventControls.Children.Count - 1 >= 2) { eventindex = 2; EventKey(eventindex); } } else if (e.Key == Key.D4) { if (EventControls.Children.Count - 1 >= 3) { eventindex = 3; EventKey(eventindex); } } else if (e.Key == Key.D5) { if (EventControls.Children.Count - 1 >= 4) { eventindex = 4; EventKey(eventindex); } } else if (e.Key == Key.D6) { if (EventControls.Children.Count - 1 >= 5) { eventindex = 5; EventKey(eventindex); } } else if (e.Key == Key.D7) { if (EventControls.Children.Count - 1 >= 6) { eventindex = 6; EventKey(eventindex); } } else if (e.Key == Key.D8) { if (EventControls.Children.Count - 1 >= 7) { eventindex = 7; EventKey(eventindex); } } else if (e.Key == Key.D9) { if (EventControls.Children.Count - 1 >= 8) { eventindex = 8; EventKey(eventindex); } } else if (e.Key == Key.D0) { if (EventControls.Children.Count - 1 >= 9) { eventindex = 9; EventKey(eventindex); } } else if (e.Key == Key.Right) { eventindex++; if (eventindex > EventControls.Children.Count - 1) { eventindex = 0; } EventKey(eventindex); } else if (e.Key == Key.Left) { eventindex--; if (eventindex < 0) { eventindex = EventControls.Children.Count - 1; } EventKey(eventindex); } else if (e.Key == Key.Space) { PlayControl(); } else if (e.Key == Key.OemComma) { SkipB(); } else if (e.Key == Key.OemPeriod) { SkipF(); } } catch (Exception ex) { Error.WriteToLog(ex); } }