@@ -46,6 +46,8 @@ public XamlRoot XamlRoot
4646 public bool BlockLoading ;
4747 public readonly TextBlock LoadingSthDalogText ;
4848 public readonly ContentDialog LoadingSthDalog ;
49+ private string _currentSubtitle = "" ;
50+ private int _currentSubtitlePxLength ;
4951
5052 public int LoadingDialogCount ;
5153
@@ -215,16 +217,19 @@ public static void ApplyProxyVariableToProcess()
215217
216218 private void AddToSubtitle ( string line )
217219 {
218- if ( subtitleBackup . Length > 0 )
219- subtitleBackup += " - " ;
220- subtitleBackup += line ;
221- Title = "UniGetUI - " + subtitleBackup ;
222- TitleBar . Subtitle = subtitleCollapsed is true ? "" : subtitleBackup ;
220+ if ( _currentSubtitle . Length > 0 )
221+ _currentSubtitle += " - " ;
222+ _currentSubtitle += line ;
223+ _currentSubtitlePxLength = _currentSubtitle . Length * 4 ;
224+ Title = "UniGetUI - " + _currentSubtitle ;
225+ TitleBar . Subtitle = subtitleCollapsed is true ? "" : _currentSubtitle ;
223226 }
224227
225228 private void ClearSubtitle ( )
226229 {
227230 TitleBar . Subtitle = "" ;
231+ _currentSubtitle = "" ;
232+ _currentSubtitlePxLength = 0 ;
228233 Title = "UniGetUI" ;
229234 }
230235
@@ -1005,39 +1010,40 @@ private void TitleBar_OnBackRequested(TitleBar sender, object args)
10051010
10061011 private bool ? subtitleCollapsed ;
10071012 private bool ? titleCollapsed ;
1008- private string subtitleBackup = "" ;
1013+ private const int DYNAMIC_SEARCHBOX_LIMIT = 750 ;
1014+ private const int HIDE_TITLE_LIMIT = 870 ;
1015+ private const int MIN_SEARCHBOX_W = 50 ;
1016+ private const int MAX_SEARCHBOX_W = 400 ;
10091017 private void TitleBar_SizeChanged ( object sender , SizeChangedEventArgs e )
10101018 {
1011- if ( TitleBar . ActualWidth <= 750 )
1019+ if ( TitleBar . ActualWidth <= DYNAMIC_SEARCHBOX_LIMIT )
10121020 {
1013- GlobalSearchBox . Width = Math . Max ( 50 , 400 - ( 750 - TitleBar . ActualWidth ) ) ;
1021+ GlobalSearchBox . Width = Math . Max ( MIN_SEARCHBOX_W , MAX_SEARCHBOX_W - ( DYNAMIC_SEARCHBOX_LIMIT - TitleBar . ActualWidth ) ) ;
10141022 }
10151023
1016- if ( TitleBar . ActualWidth < 870 && titleCollapsed is not true )
1024+ if ( titleCollapsed is not true && TitleBar . ActualWidth < HIDE_TITLE_LIMIT )
10171025 {
10181026 TitleBar . Title = "" ;
10191027 titleCollapsed = true ;
10201028 }
1021- else if ( TitleBar . ActualWidth > 870 && titleCollapsed is not false )
1029+ else if ( titleCollapsed is not false && TitleBar . ActualWidth > HIDE_TITLE_LIMIT )
10221030 {
10231031 TitleBar . Title = "UniGetUI" ;
1024- GlobalSearchBox . Width = 400 ;
1032+ GlobalSearchBox . Width = MAX_SEARCHBOX_W ;
10251033 titleCollapsed = false ;
10261034 }
10271035
1028- if ( TitleBar . ActualWidth < 1200 && subtitleCollapsed is not true )
1036+ if ( subtitleCollapsed is not true && TitleBar . ActualWidth < ( HIDE_TITLE_LIMIT + _currentSubtitlePxLength ) )
10291037 {
1030- subtitleBackup = TitleBar . Subtitle ;
10311038 TitleBar . Subtitle = "" ;
10321039 subtitleCollapsed = true ;
10331040 }
1034- else if ( TitleBar . ActualWidth > 1200 && subtitleCollapsed is not false )
1041+ else if ( subtitleCollapsed is not false && TitleBar . ActualWidth > ( HIDE_TITLE_LIMIT + _currentSubtitlePxLength ) )
10351042 {
1036- TitleBar . Subtitle = subtitleBackup ;
1037- GlobalSearchBox . Width = 400 ;
1043+ TitleBar . Subtitle = _currentSubtitle ;
1044+ GlobalSearchBox . Width = MAX_SEARCHBOX_W ;
10381045 subtitleCollapsed = false ;
10391046 }
1040- // Debug.WriteLine(TitleBar.ActualWidth);
10411047 }
10421048 }
10431049
0 commit comments