From 96fe20a20e7c107473cefeda3b06950955952bec Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Sun, 15 Mar 2020 01:55:42 +0200 Subject: Improved Console. Increased SignalR adapter connect timeout. Implemented Tango.FileSystem !!! --- .../Visual_Studio/Tango.Console/ConsoleTextBox.cs | 28 ++++++++++++---------- 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'Software/Visual_Studio/Tango.Console/ConsoleTextBox.cs') diff --git a/Software/Visual_Studio/Tango.Console/ConsoleTextBox.cs b/Software/Visual_Studio/Tango.Console/ConsoleTextBox.cs index 2802c0fe6..d2d20b629 100644 --- a/Software/Visual_Studio/Tango.Console/ConsoleTextBox.cs +++ b/Software/Visual_Studio/Tango.Console/ConsoleTextBox.cs @@ -22,6 +22,7 @@ namespace Tango.Console private Border _caret; private ListBox _listSuggestions; private Popup _popup; + private Popup _suggestionsPopup; static ConsoleTextBox() { @@ -44,13 +45,13 @@ namespace Tango.Console public static readonly DependencyProperty CaretPositionProperty = DependencyProperty.Register("CaretPosition", typeof(double), typeof(ConsoleTextBox), new PropertyMetadata(0.0)); - public Visibility SuggestionsVisibility + public bool IsSuggestionsOpened { - get { return (Visibility)GetValue(SuggestionsVisibilityProperty); } - set { SetValue(SuggestionsVisibilityProperty, value); } + get { return (bool)GetValue(IsSuggestionsOpenedProperty); } + set { SetValue(IsSuggestionsOpenedProperty, value); } } - public static readonly DependencyProperty SuggestionsVisibilityProperty = - DependencyProperty.Register("SuggestionsVisibility", typeof(Visibility), typeof(ConsoleTextBox), new PropertyMetadata(Visibility.Collapsed)); + public static readonly DependencyProperty IsSuggestionsOpenedProperty = + DependencyProperty.Register("IsSuggestionsOpened", typeof(bool), typeof(ConsoleTextBox), new PropertyMetadata(false)); public List FilteredSuggestions { @@ -125,7 +126,7 @@ namespace Tango.Console protected override void OnPreviewKeyDown(KeyEventArgs e) { - if (SuggestionsVisibility == Visibility.Visible) + if (IsSuggestionsOpened) { if (e.Key == Key.Down) { @@ -179,13 +180,13 @@ namespace Tango.Console Text = selectedItem.Name; } - SuggestionsVisibility = Visibility.Collapsed; + IsSuggestionsOpened = false; CaretIndex = Text.Length; e.Handled = true; return; } - SuggestionsVisibility = Visibility.Collapsed; + IsSuggestionsOpened = false; } } @@ -203,21 +204,21 @@ namespace Tango.Console if (Suggestions != null) { - FilteredSuggestions = Suggestions.Where(x => lastWord.IsNotNullOrEmpty() && x.Name.ToLower().StartsWith(lastWord.ToLower())).OrderBy(x => x.Name).Take(MaxSuggestions).ToList(); + FilteredSuggestions = Suggestions.Where(x => (lastWord.IsNotNullOrEmpty() && x.Name.ToLower().StartsWith(lastWord.ToLower())) || Text.EndsWith(" ")).OrderBy(x => x.Name).Take(MaxSuggestions).ToList(); if (Text.Contains(" ")) { FilteredSuggestions = FilteredSuggestions.Where(x => x.Type != ConsoleSuggestionType.Command).ToList(); } - SuggestionsVisibility = FilteredSuggestions.Count > 0 ? Visibility.Visible : Visibility.Collapsed; + IsSuggestionsOpened = FilteredSuggestions.Count > 0; _popup.IsOpen = false; _popup.IsOpen = FilteredSuggestions.Count > 0 && SelectedSuggestion != null; } } else { - SuggestionsVisibility = Visibility.Collapsed; + IsSuggestionsOpened = false; _popup.IsOpen = false; } } @@ -228,7 +229,7 @@ namespace Tango.Console if (CaretIndex < Text.Length) { - SuggestionsVisibility = Visibility.Collapsed; + IsSuggestionsOpened = false; _popup.IsOpen = false; } } @@ -240,6 +241,7 @@ namespace Tango.Console _caret = GetTemplateChild("PART_Caret") as Border; _listSuggestions = GetTemplateChild("PART_listSuggestions") as ListBox; _popup = GetTemplateChild("PART_popup") as Popup; + _suggestionsPopup = GetTemplateChild("PART_SuggestionsPopup") as Popup; } private void MoveCustomCaret() @@ -250,6 +252,8 @@ namespace Tango.Console { Canvas.SetLeft(_caret, caretLocation.X); CaretPosition = caretLocation.X; + + _suggestionsPopup.PlacementRectangle = new Rect(CaretPosition + 10, 20, 0, 0); } } } -- cgit v1.3.1