From 53c040d19f1df410f706074b294f74d9fcd59d96 Mon Sep 17 00:00:00 2001 From: Mike Ward Date: Sun, 21 Feb 2021 19:01:19 -0600 Subject: [PATCH] v2021.1, mouse wheel volume --- CHANGELOG.md | 23 ++++--- .../Converters/IsNotNullConverter.cs | 2 +- src/tweetz.core/Converters/IsNullConverter.cs | 2 +- .../Converters/NotBooleanConverter.cs | 1 - .../NotBooleanToVisibilityConverter.cs | 1 - .../NotNullToVisibilityConverter.cs | 8 +-- .../Converters/NullToVisibilityConverter.cs | 4 +- src/tweetz.core/Models/VersionInfo.cs | 2 +- .../MediaViewerBlock/MediaViewerBlock.xaml | 62 ++++--------------- .../MediaViewerBlock/MediaViewerBlock.xaml.cs | 48 +++++++++----- .../MediaViewerBlockControls.xaml.cs | 5 ++ src/tweetz.core/app.manifest | 2 +- src/tweetz.core/tweetz.core.csproj | 6 +- src/twitter.core/twitter.core.csproj | 6 +- tweetz.core.setup.iss | 4 +- 15 files changed, 80 insertions(+), 96 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ca9ef16..2ba50663 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,69 +1,69 @@ # Changelog All notable changes to this project will be documented in this file. -## 2.9.5 - 2021-01-31 +## 2021.1 - 2021-02-21 + +### Added +- Mouse wheel controls volume when playing videos ### Changed +- Version numbers are year the revision based +- Image viewer uses media element for videos only. Other images use image element +- Update packages and SDK to latest releases +- Removed cache hinting option from profile images + +## 2.9.5 - 2021-01-31 +### Changed - Change link colors - Extend timeout to 5 seconds for reverse lookup of short urls ## 2.9.4 - 2021-01-12 ### Changed - - UI tweaks ## 2.9.3 - 2021-01-05 ### Fixed - - [Menu takes up 2 rows since 2.9.1 #64](https://github.com/mike-ward/tweetz/issues/64) ## 2.9.2 - 2021-01-05 ### Added - - "Hide translate link" option ## 2.9.1 - 2021-01-04 ### Fixed - - Use new service provider for translations #61 ## 2.9.0 - 2020-12-05 ### Added - - Translate tweets on demand ### Changed - - Improved image layout for multiple images ## 2.8.6 - 2020-11-11 ### Changed - - Update to .Net 5.0 ## 2.8.5 - 2020-09-27 ### Changed - - Smooth scrolling [688ab45](https://github.com/mike-ward/tweetz/commit/688ab45e49f5aeb5d7d14fa02e4e1c738c5e2020) ## 2.8.4 - 2020-09-13 ### Fixed - - Move ColorConverter reference to theme files to avoid crash [a245e42](https://github.com/mike-ward/tweetz/commit/a245e424da8f2bc0aa1fc3ac636a2a8e9b544142) ## 2.8.3 - 2020-09-13 ### Fixed - - Follow/Followed By statuses didn't sync sometimes [759c07f](https://github.com/mike-ward/tweetz/commit/759c07f845e379f348ab6479b522d50c8960cf09) - Custom color not working in Nord and Dark themes [55449d0](https://github.com/mike-ward/tweetz/commit/55449d08acf1980ea6bf021efac2db4aa4661cc5) @@ -98,7 +98,6 @@ All notable changes to this project will be documented in this file. ### Fixed - Fix line height issue [#35](https://github.com/mike-ward/tweetz/issues/35) - ## 2.7.1 - 2020-06-30 ### Fixed diff --git a/src/tweetz.core/Converters/IsNotNullConverter.cs b/src/tweetz.core/Converters/IsNotNullConverter.cs index f7e946ab..a382cf2d 100644 --- a/src/tweetz.core/Converters/IsNotNullConverter.cs +++ b/src/tweetz.core/Converters/IsNotNullConverter.cs @@ -6,7 +6,7 @@ namespace tweetz.core.Converters { public class IsNotNullConverter : IValueConverter { - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + public object Convert(object? value, Type targetType, object parameter, CultureInfo culture) { return value is not null; } diff --git a/src/tweetz.core/Converters/IsNullConverter.cs b/src/tweetz.core/Converters/IsNullConverter.cs index aa291e16..a7d4516f 100644 --- a/src/tweetz.core/Converters/IsNullConverter.cs +++ b/src/tweetz.core/Converters/IsNullConverter.cs @@ -6,7 +6,7 @@ namespace tweetz.core.Converters { public class IsNullConverter : IValueConverter { - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + public object Convert(object? value, Type targetType, object parameter, CultureInfo culture) { return value is null; } diff --git a/src/tweetz.core/Converters/NotBooleanConverter.cs b/src/tweetz.core/Converters/NotBooleanConverter.cs index 861c48ae..040dd69f 100644 --- a/src/tweetz.core/Converters/NotBooleanConverter.cs +++ b/src/tweetz.core/Converters/NotBooleanConverter.cs @@ -6,7 +6,6 @@ namespace tweetz.core.Converters { public class NotBooleanConverter : IValueConverter { - [System.Diagnostics.CodeAnalysis.SuppressMessage("Major Code Smell", "S2589:Boolean expressions should not be gratuitous", Justification = "https://github.com/SonarSource/sonar-dotnet/issues/3123")] public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { return value is false; diff --git a/src/tweetz.core/Converters/NotBooleanToVisibilityConverter.cs b/src/tweetz.core/Converters/NotBooleanToVisibilityConverter.cs index ff9fb6b9..914b69fe 100644 --- a/src/tweetz.core/Converters/NotBooleanToVisibilityConverter.cs +++ b/src/tweetz.core/Converters/NotBooleanToVisibilityConverter.cs @@ -7,7 +7,6 @@ namespace tweetz.core.Converters { public class NotBooleanToVisibilityConverter : IValueConverter { - [System.Diagnostics.CodeAnalysis.SuppressMessage("Major Code Smell", "S2589:Boolean expressions should not be gratuitous", Justification = "https://github.com/SonarSource/sonar-dotnet/issues/3123")] public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { return value is true diff --git a/src/tweetz.core/Converters/NotNullToVisibilityConverter.cs b/src/tweetz.core/Converters/NotNullToVisibilityConverter.cs index cb4c09d2..8677d8e8 100644 --- a/src/tweetz.core/Converters/NotNullToVisibilityConverter.cs +++ b/src/tweetz.core/Converters/NotNullToVisibilityConverter.cs @@ -7,11 +7,11 @@ namespace tweetz.core.Converters { public class NotNullToVisibilityConverter : IValueConverter { - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + public object Convert(object? value, Type targetType, object parameter, CultureInfo culture) { - return string.IsNullOrWhiteSpace(value as string) - ? Visibility.Collapsed - : Visibility.Visible; + return value is not null + ? Visibility.Visible + : Visibility.Collapsed; } [System.Diagnostics.CodeAnalysis.SuppressMessage("General", "RCS1079:Throwing of new NotImplementedException.")] diff --git a/src/tweetz.core/Converters/NullToVisibilityConverter.cs b/src/tweetz.core/Converters/NullToVisibilityConverter.cs index e1b8e623..e6a7491f 100644 --- a/src/tweetz.core/Converters/NullToVisibilityConverter.cs +++ b/src/tweetz.core/Converters/NullToVisibilityConverter.cs @@ -7,9 +7,9 @@ namespace tweetz.core.Converters { public class NullToVisibilityConverter : IValueConverter { - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + public object Convert(object? value, Type targetType, object parameter, CultureInfo culture) { - return string.IsNullOrWhiteSpace(value as string) + return value is null ? Visibility.Visible : Visibility.Collapsed; } diff --git a/src/tweetz.core/Models/VersionInfo.cs b/src/tweetz.core/Models/VersionInfo.cs index b5813a4b..4b94fa0e 100644 --- a/src/tweetz.core/Models/VersionInfo.cs +++ b/src/tweetz.core/Models/VersionInfo.cs @@ -2,7 +2,7 @@ { public static class VersionInfo { - public static string Version => "v2.9.5"; + public static string Version => "v2021.1"; public static string Copyright => "Copyright 2021, Mike Ward"; } } \ No newline at end of file diff --git a/src/tweetz.core/Views/MediaViewerBlock/MediaViewerBlock.xaml b/src/tweetz.core/Views/MediaViewerBlock/MediaViewerBlock.xaml index ec942382..fde362c8 100644 --- a/src/tweetz.core/Views/MediaViewerBlock/MediaViewerBlock.xaml +++ b/src/tweetz.core/Views/MediaViewerBlock/MediaViewerBlock.xaml @@ -17,7 +17,6 @@ KeyDown="Popup_KeyDown" MouseDown="Popup_MouseDown" MouseWheel="Popup_OnMouseWheel" - Opened="Popup_Opened" Placement="Center" PopupAnimation="Fade" SnapsToDevicePixels="True" @@ -40,6 +39,7 @@ IsIndeterminate="True" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + MediaOpened="MediaElement_MediaOpened"> + + + (MediaViewerBlockViewModel)DataContext; - private void UpdateDataContext(object _, System.Windows.DependencyPropertyChangedEventArgs e) + private void UpdateDataContext(object _, DependencyPropertyChangedEventArgs e) { MediaControls.DataContext = e.NewValue; ViewModel.PropertyChanged += (_, ea) => @@ -28,15 +29,31 @@ private void UpdateDataContext(object _, System.Windows.DependencyPropertyChange private void ShowLoadingIndicator() { MediaElement.Stop(); + MediaElement.Source = null; + MediaElement.Visibility = Visibility.Collapsed; + ImageElement.Visibility = Visibility.Collapsed; + MediaControls.Visibility = Visibility.Collapsed; + MediaControls.SetControlVisibilities(Visibility.Collapsed); ViewModel.ErrorMessage = null; - MediaControls.Visibility = System.Windows.Visibility.Collapsed; - LoadingIndicator.Visibility = System.Windows.Visibility.Visible; + LoadingIndicator.Visibility = Visibility.Collapsed; + + var uri = ((MediaViewerBlockViewModel)DataContext).Uri; + if (Services.ImageViewerService.IsMp4(uri?.ToString())) + { + MediaElement.Source = uri; + LoadingIndicator.Visibility = Visibility.Visible; + } + else + { + ImageElement.Visibility = Visibility.Visible; + MediaControls.Visibility = Visibility.Visible; + } } private void ShowMediaControls() { - LoadingIndicator.Visibility = System.Windows.Visibility.Collapsed; - MediaControls.Visibility = System.Windows.Visibility.Visible; + LoadingIndicator.Visibility = Visibility.Collapsed; + MediaControls.Visibility = Visibility.Visible; } private void Popup_MouseDown(object sender, MouseButtonEventArgs e) @@ -45,11 +62,6 @@ private void Popup_MouseDown(object sender, MouseButtonEventArgs e) e.Handled = true; } - private void Popup_Opened(object sender, EventArgs e) - { - ShowLoadingIndicator(); - } - private void Popup_Closed(object sender, EventArgs e) { Close(); @@ -61,22 +73,30 @@ private void Popup_KeyDown(object sender, KeyEventArgs e) e.Handled = true; } - private void MediaElement_MediaOpened(object sender, System.Windows.RoutedEventArgs e) + private void MediaElement_MediaOpened(object sender, RoutedEventArgs e) { ShowMediaControls(); MediaElement.Play(); + MediaElement.Visibility = Visibility.Visible; } - private void MediaElement_MediaFailed(object sender, System.Windows.ExceptionRoutedEventArgs e) + private void MediaElement_MediaFailed(object sender, ExceptionRoutedEventArgs e) { - LoadingIndicator.Visibility = System.Windows.Visibility.Collapsed; + LoadingIndicator.Visibility = Visibility.Collapsed; ViewModel.ErrorMessage = e.ErrorException.Message; } private void Close() { ViewModel.Uri = null; - MediaElement?.Close(); + if (MediaElement is not null) + { + MediaElement.Close(); + MediaElement.Source = null; + MediaElement.Visibility = Visibility.Collapsed; + } + + ImageElement.Visibility = Visibility.Collapsed; } private void Popup_OnMouseWheel(object sender, MouseWheelEventArgs e) diff --git a/src/tweetz.core/Views/MediaViewerBlock/MediaViewerBlockControls.xaml.cs b/src/tweetz.core/Views/MediaViewerBlock/MediaViewerBlockControls.xaml.cs index 24b78dba..0df09c89 100644 --- a/src/tweetz.core/Views/MediaViewerBlock/MediaViewerBlockControls.xaml.cs +++ b/src/tweetz.core/Views/MediaViewerBlock/MediaViewerBlockControls.xaml.cs @@ -43,6 +43,11 @@ private void OnMediaOpened(object _, RoutedEventArgs __) ? Visibility.Visible : Visibility.Collapsed; + SetControlVisibilities(visibility); + } + + public void SetControlVisibilities(Visibility visibility) + { RewindButton.Visibility = visibility; TenSecRewindButton.Visibility = visibility; PlayPauseButton.Visibility = visibility; diff --git a/src/tweetz.core/app.manifest b/src/tweetz.core/app.manifest index 4b368d00..d17a8765 100644 --- a/src/tweetz.core/app.manifest +++ b/src/tweetz.core/app.manifest @@ -1,6 +1,6 @@  - +