1
1
using System ;
2
2
using System . Globalization ;
3
+ using System . Windows . Controls ;
3
4
using System . Windows . Data ;
5
+ using System . Windows . Media ;
4
6
using Flow . Launcher . Infrastructure . Logger ;
5
7
using Flow . Launcher . ViewModel ;
6
8
@@ -10,13 +12,13 @@ public class QuerySuggestionBoxConverter : IMultiValueConverter
10
12
{
11
13
public object Convert ( object [ ] values , Type targetType , object parameter , CultureInfo culture )
12
14
{
13
- if ( values . Length != 2 )
15
+ if ( values . Length != 3 )
14
16
{
15
17
return string . Empty ;
16
18
}
19
+ var QueryTextBox = values [ 0 ] as TextBox ;
17
20
18
- // first prop is the current query string
19
- var queryText = ( string ) values [ 0 ] ;
21
+ var queryText = ( string ) values [ 2 ] ;
20
22
21
23
if ( string . IsNullOrEmpty ( queryText ) )
22
24
return string . Empty ;
@@ -43,10 +45,19 @@ public object Convert(object[] values, Type targetType, object parameter, Cultur
43
45
if ( ! selectedResultPossibleSuggestion . StartsWith ( queryText , StringComparison . CurrentCultureIgnoreCase ) )
44
46
return string . Empty ;
45
47
48
+
46
49
// For AutocompleteQueryCommand.
47
50
// When user typed lower case and result title is uppercase, we still want to display suggestion
48
51
selectedItem . QuerySuggestionText = queryText + selectedResultPossibleSuggestion . Substring ( queryText . Length ) ;
49
-
52
+
53
+ // Check if Text will be larger then our QueryTextBox
54
+ System . Windows . Media . Typeface typeface = new Typeface ( QueryTextBox . FontFamily , QueryTextBox . FontStyle , QueryTextBox . FontWeight , QueryTextBox . FontStretch ) ;
55
+ System . Windows . Media . FormattedText ft = new FormattedText ( QueryTextBox . Text , System . Globalization . CultureInfo . CurrentCulture , System . Windows . FlowDirection . LeftToRight , typeface , QueryTextBox . FontSize , Brushes . Black ) ;
56
+ if ( ft . Width > QueryTextBox . ActualWidth || QueryTextBox . HorizontalOffset != 0 )
57
+ {
58
+ return string . Empty ;
59
+ } ;
60
+
50
61
return selectedItem . QuerySuggestionText ;
51
62
}
52
63
catch ( Exception e )
0 commit comments