aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Console
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-03-15 01:55:42 +0200
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-03-15 01:55:42 +0200
commit96fe20a20e7c107473cefeda3b06950955952bec (patch)
tree0c7efeb2a332eabdab4a551734eb94f4828aa381 /Software/Visual_Studio/Tango.Console
parentbb82e09c0080cacec65512805ac88f6b3416c3f2 (diff)
downloadTango-96fe20a20e7c107473cefeda3b06950955952bec.tar.gz
Tango-96fe20a20e7c107473cefeda3b06950955952bec.zip
Improved Console.
Increased SignalR adapter connect timeout. Implemented Tango.FileSystem !!!
Diffstat (limited to 'Software/Visual_Studio/Tango.Console')
-rw-r--r--Software/Visual_Studio/Tango.Console/ConsoleControlVM.cs7
-rw-r--r--Software/Visual_Studio/Tango.Console/ConsoleDictionary.cs2
-rw-r--r--Software/Visual_Studio/Tango.Console/ConsoleExecutionEngine.cs26
-rw-r--r--Software/Visual_Studio/Tango.Console/ConsoleTextBox.cs28
-rw-r--r--Software/Visual_Studio/Tango.Console/Network/GetCurrentDirectoryResponse.cs6
-rw-r--r--Software/Visual_Studio/Tango.Console/Themes/Generic.xaml72
6 files changed, 83 insertions, 58 deletions
diff --git a/Software/Visual_Studio/Tango.Console/ConsoleControlVM.cs b/Software/Visual_Studio/Tango.Console/ConsoleControlVM.cs
index ed32bd321..1cb4118b9 100644
--- a/Software/Visual_Studio/Tango.Console/ConsoleControlVM.cs
+++ b/Software/Visual_Studio/Tango.Console/ConsoleControlVM.cs
@@ -106,13 +106,18 @@ namespace Tango.Console
CreateNew(result.WorkingFolder, true);
- Suggestions = _knownSuggestions.Concat(result.Suggestions).OrderBy(x => x.Name).ToList();
+ AppendSuggestions(result.Suggestions);
});
CommandExecuting?.Invoke(this, args);
}
}
+ public void AppendSuggestions(List<ConsoleSuggestion> suggestions)
+ {
+ Suggestions = _knownSuggestions.Concat(suggestions).OrderBy(x => x.Name).ToList();
+ }
+
public void Clear()
{
Commands.Clear();
diff --git a/Software/Visual_Studio/Tango.Console/ConsoleDictionary.cs b/Software/Visual_Studio/Tango.Console/ConsoleDictionary.cs
index f0e1ab3f6..00e4a865d 100644
--- a/Software/Visual_Studio/Tango.Console/ConsoleDictionary.cs
+++ b/Software/Visual_Studio/Tango.Console/ConsoleDictionary.cs
@@ -25,7 +25,7 @@ namespace Tango.Console
{
ConsoleKnownCommand command = new ConsoleKnownCommand();
String[] args = line.Split('\t');
- command.Name = args[0];
+ command.Name = args[0].ToLower();
command.Description = args[1].Replace("\"", "");
_knownCommands.Add(command);
}
diff --git a/Software/Visual_Studio/Tango.Console/ConsoleExecutionEngine.cs b/Software/Visual_Studio/Tango.Console/ConsoleExecutionEngine.cs
index 42bc2ac00..02b58a658 100644
--- a/Software/Visual_Studio/Tango.Console/ConsoleExecutionEngine.cs
+++ b/Software/Visual_Studio/Tango.Console/ConsoleExecutionEngine.cs
@@ -61,7 +61,7 @@ namespace Tango.Console
}
//process.StartInfo.Verb = "runas";
- if (ConsoleDictionary.GetKnownCommands().Exists(x => x.Name.ToLower() == parsedCommand.Command))
+ if (ConsoleDictionary.GetKnownCommands().Exists(x => x.Name.ToLower() == parsedCommand.Command.ToLower()))
{
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.Arguments = "/C " + request.Command;
@@ -93,30 +93,38 @@ namespace Tango.Console
});
}
- private ConsoleCommandExecutionResult CreateResult(String workingFolder, String output)
+ public static List<ConsoleSuggestion> GetSuggestions(String folder)
{
- ConsoleCommandExecutionResult result = new ConsoleCommandExecutionResult();
- result.WorkingFolder = workingFolder;
- result.Output = output;
+ List<ConsoleSuggestion> suggestions = new List<ConsoleSuggestion>();
- foreach (var dir in Directory.GetDirectories(Path.GetFullPath(workingFolder)))
+ foreach (var dir in Directory.GetDirectories(Path.GetFullPath(folder)))
{
- result.Suggestions.Add(new ConsoleSuggestion()
+ suggestions.Add(new ConsoleSuggestion()
{
Type = ConsoleSuggestionType.Folder,
Name = Path.GetFileName(dir)
});
}
- foreach (var file in Directory.GetFiles(Path.GetFullPath(workingFolder)))
+ foreach (var file in Directory.GetFiles(Path.GetFullPath(folder)))
{
- result.Suggestions.Add(new ConsoleSuggestion()
+ suggestions.Add(new ConsoleSuggestion()
{
Type = ConsoleSuggestionType.File,
Name = Path.GetFileName(file),
});
}
+ return suggestions;
+ }
+
+ private ConsoleCommandExecutionResult CreateResult(String workingFolder, String output)
+ {
+ ConsoleCommandExecutionResult result = new ConsoleCommandExecutionResult();
+ result.WorkingFolder = workingFolder;
+ result.Output = output;
+ result.Suggestions.AddRange(GetSuggestions(workingFolder));
+
return result;
}
}
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<ConsoleSuggestion> 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);
}
}
}
diff --git a/Software/Visual_Studio/Tango.Console/Network/GetCurrentDirectoryResponse.cs b/Software/Visual_Studio/Tango.Console/Network/GetCurrentDirectoryResponse.cs
index 30a24e461..7b6eedda0 100644
--- a/Software/Visual_Studio/Tango.Console/Network/GetCurrentDirectoryResponse.cs
+++ b/Software/Visual_Studio/Tango.Console/Network/GetCurrentDirectoryResponse.cs
@@ -9,5 +9,11 @@ namespace Tango.Console.Network
public class GetCurrentDirectoryResponse
{
public String CurrentDirectory { get; set; }
+ public List<ConsoleSuggestion> Suggestions { get; set; }
+
+ public GetCurrentDirectoryResponse()
+ {
+ Suggestions = new List<ConsoleSuggestion>();
+ }
}
}
diff --git a/Software/Visual_Studio/Tango.Console/Themes/Generic.xaml b/Software/Visual_Studio/Tango.Console/Themes/Generic.xaml
index e2a9e2b8f..cc62cbbf5 100644
--- a/Software/Visual_Studio/Tango.Console/Themes/Generic.xaml
+++ b/Software/Visual_Studio/Tango.Console/Themes/Generic.xaml
@@ -47,41 +47,43 @@
</EventTrigger>
</Border.Triggers>
</Border>
- <Border x:Name="PART_borderSuggestions" BorderThickness="1" BorderBrush="{TemplateBinding SuggestionsBorderBrush}" Background="{TemplateBinding SuggestionsBackground}" MinWidth="200" MaxHeight="300" Canvas.Left="{TemplateBinding CaretPosition}" Canvas.Top="20" Visibility="{TemplateBinding SuggestionsVisibility}">
- <Grid>
- <ListBox Foreground="{TemplateBinding SuggestionsForeground}" x:Name="PART_listSuggestions" FocusVisualStyle="{x:Null}" Background="Transparent" ItemsSource="{TemplateBinding FilteredSuggestions}" SelectedItem="{Binding RelativeSource={RelativeSource AncestorType=local:ConsoleTextBox},Path=SelectedSuggestion,Mode=TwoWay}">
- <ListBox.ItemTemplate>
- <DataTemplate>
- <StackPanel Orientation="Horizontal">
- <Image Stretch="Uniform" Width="16" Height="16" VerticalAlignment="Center">
- <Image.Style>
- <Style TargetType="Image">
- <Setter Property="Source" Value="pack://application:,,,/Tango.Console;component/Images/thunder.png"></Setter>
- <Style.Triggers>
- <DataTrigger Binding="{Binding Type}" Value="Folder">
- <Setter Property="Source" Value="pack://application:,,,/Tango.Console;component/Images/folder.png"></Setter>
- </DataTrigger>
- <DataTrigger Binding="{Binding Type}" Value="File">
- <Setter Property="Source" Value="pack://application:,,,/Tango.Console;component/Images/file.png"></Setter>
- </DataTrigger>
- </Style.Triggers>
- </Style>
- </Image.Style>
- </Image>
- <TextBlock Margin="5 0 0 0" VerticalAlignment="Center" FontSize="11" Text="{Binding Name}"></TextBlock>
- </StackPanel>
- </DataTemplate>
- </ListBox.ItemTemplate>
- </ListBox>
- <Canvas HorizontalAlignment="Right" VerticalAlignment="Top">
- <Popup x:Name="PART_popup" IsOpen="False" Placement="Right" HorizontalOffset="10">
- <Border Padding="5" CornerRadius="3" MaxWidth="500" BorderThickness="1" BorderBrush="{TemplateBinding SuggestionsBorderBrush}" Background="{TemplateBinding SuggestionsBackground}">
- <TextBlock FontSize="11" Foreground="{TemplateBinding SuggestionsForeground}" TextWrapping="Wrap" Text="{Binding ElementName=PART_listSuggestions,Path=SelectedItem.Description}"></TextBlock>
- </Border>
- </Popup>
- </Canvas>
- </Grid>
- </Border>
+ <Popup x:Name="PART_SuggestionsPopup" MinWidth="200" MaxHeight="300" Placement="RelativePoint" StaysOpen="False" IsOpen="{TemplateBinding IsSuggestionsOpened}">
+ <Border BorderThickness="1" BorderBrush="{TemplateBinding SuggestionsBorderBrush}" Background="{TemplateBinding SuggestionsBackground}" MinWidth="200" MaxHeight="300">
+ <Grid>
+ <ListBox Foreground="{TemplateBinding SuggestionsForeground}" x:Name="PART_listSuggestions" FocusVisualStyle="{x:Null}" Background="Transparent" ItemsSource="{TemplateBinding FilteredSuggestions}" SelectedItem="{Binding RelativeSource={RelativeSource AncestorType=local:ConsoleTextBox},Path=SelectedSuggestion,Mode=TwoWay}">
+ <ListBox.ItemTemplate>
+ <DataTemplate>
+ <StackPanel Orientation="Horizontal">
+ <Image Stretch="Uniform" Width="16" Height="16" VerticalAlignment="Center">
+ <Image.Style>
+ <Style TargetType="Image">
+ <Setter Property="Source" Value="pack://application:,,,/Tango.Console;component/Images/thunder.png"></Setter>
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding Type}" Value="Folder">
+ <Setter Property="Source" Value="pack://application:,,,/Tango.Console;component/Images/folder.png"></Setter>
+ </DataTrigger>
+ <DataTrigger Binding="{Binding Type}" Value="File">
+ <Setter Property="Source" Value="pack://application:,,,/Tango.Console;component/Images/file.png"></Setter>
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </Image.Style>
+ </Image>
+ <TextBlock Margin="5 0 0 0" VerticalAlignment="Center" FontSize="11" Text="{Binding Name}"></TextBlock>
+ </StackPanel>
+ </DataTemplate>
+ </ListBox.ItemTemplate>
+ </ListBox>
+ <Canvas HorizontalAlignment="Right" VerticalAlignment="Top">
+ <Popup x:Name="PART_popup" IsOpen="False" Placement="Right" HorizontalOffset="10">
+ <Border Padding="5" CornerRadius="3" MaxWidth="500" BorderThickness="1" BorderBrush="{TemplateBinding SuggestionsBorderBrush}" Background="{TemplateBinding SuggestionsBackground}">
+ <TextBlock FontSize="11" Foreground="{TemplateBinding SuggestionsForeground}" TextWrapping="Wrap" Text="{Binding ElementName=PART_listSuggestions,Path=SelectedItem.Description}"></TextBlock>
+ </Border>
+ </Popup>
+ </Canvas>
+ </Grid>
+ </Border>
+ </Popup>
</Canvas>
</Grid>
<ControlTemplate.Triggers>