1- using System . ComponentModel ;
2- using System . Text ;
3- using System . Windows ;
1+ using System . Windows ;
42using System . Windows . Controls ;
5- using System . Windows . Threading ;
3+ using System . Windows . Input ;
64
7- using LiveCaptionsTranslator . utils ;
5+ using LiveCaptionsTranslator . Utils ;
86
97namespace LiveCaptionsTranslator
108{
@@ -25,15 +23,14 @@ public CaptionPage()
2523 {
2624 AutoHeight ( ) ;
2725 ( App . Current . MainWindow as MainWindow ) . CaptionLogButton . Visibility = Visibility . Visible ;
28- Translator . Caption . PropertyChanged += TranslatedChanged ;
2926 } ;
3027 Unloaded += ( s , e ) =>
3128 {
3229 ( App . Current . MainWindow as MainWindow ) . CaptionLogButton . Visibility = Visibility . Collapsed ;
33- Translator . Caption . PropertyChanged -= TranslatedChanged ;
3430 } ;
3531
3632 CollapseTranslatedCaption ( Translator . Setting . MainWindow . CaptionLogEnabled ) ;
33+ ApplyFontSizes ( ) ;
3734 }
3835
3936 private async void TextBlock_MouseLeftButtonDown ( object sender , RoutedEventArgs e )
@@ -53,25 +50,36 @@ private async void TextBlock_MouseLeftButtonDown(object sender, RoutedEventArgs
5350 }
5451 }
5552
56- private void TranslatedChanged ( object sender , PropertyChangedEventArgs e )
53+ private void ApplyFontSizes ( )
5754 {
58- if ( e . PropertyName == nameof ( Translator . Caption . DisplayTranslatedCaption ) )
59- {
60- if ( Encoding . UTF8 . GetByteCount ( Translator . Caption . DisplayTranslatedCaption ) >= TextUtil . LONG_THRESHOLD )
61- {
62- Dispatcher . BeginInvoke ( new Action ( ( ) =>
63- {
64- this . TranslatedCaption . FontSize = 15 ;
65- } ) , DispatcherPriority . Background ) ;
66- }
67- else
68- {
69- Dispatcher . BeginInvoke ( new Action ( ( ) =>
70- {
71- this . TranslatedCaption . FontSize = 18 ;
72- } ) , DispatcherPriority . Background ) ;
73- }
74- }
55+ OriginalCaption . FontSize = Translator . Setting . MainWindow . OriginalFontSize ;
56+ TranslatedCaption . FontSize = Translator . Setting . MainWindow . TranslatedFontSize ;
57+ }
58+
59+ private void OriginalCard_PreviewMouseWheel ( object sender , MouseWheelEventArgs e )
60+ {
61+ if ( Keyboard . Modifiers != ModifierKeys . Control )
62+ return ;
63+ Translator . Setting . MainWindow . OriginalFontSize =
64+ AdjustFontSize ( Translator . Setting . MainWindow . OriginalFontSize , e . Delta ) ;
65+ ApplyFontSizes ( ) ;
66+ e . Handled = true ;
67+ }
68+
69+ private void TranslatedCard_PreviewMouseWheel ( object sender , MouseWheelEventArgs e )
70+ {
71+ if ( Keyboard . Modifiers != ModifierKeys . Control )
72+ return ;
73+ Translator . Setting . MainWindow . TranslatedFontSize =
74+ AdjustFontSize ( Translator . Setting . MainWindow . TranslatedFontSize , e . Delta ) ;
75+ ApplyFontSizes ( ) ;
76+ e . Handled = true ;
77+ }
78+
79+ private static int AdjustFontSize ( int current , int wheelDelta )
80+ {
81+ int next = current + ( wheelDelta > 0 ? StyleConsts . DELTA_FONT_SIZE : - StyleConsts . DELTA_FONT_SIZE ) ;
82+ return Math . Clamp ( next , StyleConsts . MIN_FONT_SIZE , StyleConsts . MAX_FONT_SIZE ) ;
7583 }
7684
7785 public void CollapseTranslatedCaption ( bool isCollapsed )
0 commit comments