Skip to content

Commit

Permalink
Update command line tab for alpha 0.0.0.2 (#2)
Browse files Browse the repository at this point in the history
* Test hockey app

* Remove old code

* Remove old bindings

* Rebuild CommandLine View

* Update ReadMe

* Add color change effect for status indicator.

Color will change depending on progress of install/update/delete tasks. Current only yellow while downloading and green while unzipping.

* Only listen to output event when needed.

* Rebuild CommandLineTabView

* Add generic Run command for sdkmangaer (not used yet)

* Update for more colors

* Hook up basic Method to run generic commands.

Need to do somthing with the output...

* Update Platform and Tool Tab vies to use a grid layout

* Update ReadMe

* Update tab views

* Update Main View to grid system.

Alter width in tab views to match new main window view.

* Fix typos in ReadMe :/

* Signed for first alpha

* Add Command Output Window

* Udpate some doc comments

* Adjust size of command line tab
  • Loading branch information
GlassToeStudio authored Mar 17, 2019
1 parent 667afab commit 564ecf8
Show file tree
Hide file tree
Showing 10 changed files with 181 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public SdkToolsStructure() : base()
CreateItems();
}


// TODO: Fix This
protected override void CreateItems()
{
Expand All @@ -27,6 +26,7 @@ protected override void CreateItems()
{
return;
}

foreach (var p in Items)
{
p.CheckForUpdates();
Expand Down
10 changes: 8 additions & 2 deletions SdkManager.Core/SDKManager/SdkManagerBat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static class SdkManagerBat

/// <summary>
/// The path to sdkmanager.bat
/// </summary> TODO: Intentional Typeo!!!!!!!!!!!!!!!!!!!!!!
/// </summary>
public static string PathName { get => _pathName;
set
{
Expand All @@ -56,9 +56,14 @@ public static class SdkManagerBat
#region Events/Actions

/// <summary>
/// Listen for this event to get the output from the hidden console window.
/// Listen for this event to get the output from the hidden console window as it it received.
/// </summary>
public static event Action<string> CommandLineOutputReceived;

/// <summary>
/// Listen for this event to get the full output from the hidden console window.
/// </summary>
public static event Action<string> CommandLineOutputComplete;

#endregion

Expand Down Expand Up @@ -351,6 +356,7 @@ public async static Task<string> RunCommandAsync(params string[] args)
pro.StandardInput.WriteLine("y");
stdError = pro.StandardError.ReadToEnd();
pro.WaitForExit();
CommandLineOutputComplete(output.ToString());
}
catch (Exception e)
{
Expand Down
7 changes: 6 additions & 1 deletion SdkManager.Core/SDKManager/Utilities/LookUpTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public static class LookUpTable
{ "Android SDK Platform 26", "Android 8.0 (Oreo)"},
{ "Android SDK Platform 27", "Android 8.1 (Oreo)"},
{ "Android SDK Platform 28", "Android 28 (Pie)"},
{ "android-28", "Android SDK Platform 28"}
{ "Android SDK Platform Q", "Android SDK Platform Q"},
{ "android-28", "Android SDK Platform 28"},
};

/// <summary>
Expand All @@ -47,6 +48,10 @@ public static string GetDescription(string name)
{
string r = name;
Aliases.TryGetValue(name, out r);
if(string.IsNullOrEmpty(r))
{
r = name;
}
return r;
}
}
Expand Down
8 changes: 8 additions & 0 deletions SdkManager.UI/StandaloneSDKManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
<Compile Include="ViewModels\Core\SdkItems\SdkToolItemViewModel.cs" />
<Compile Include="ViewModels\TabViewModels\SdkPlatformsTabViewModel.cs" />
<Compile Include="ViewModels\TabViewModels\SdkToolsTabViewModel.cs" />
<Compile Include="ViewModels\Windows\ConsoleOutputWindowViewModel.cs" />
<Compile Include="ViewModels\Windows\ConfirmWindowViewModel.cs" />
<Compile Include="ViewModels\Core\SdkManagerBatViewModel.cs" />
<Compile Include="ViewModels\TabViewModels\CommandLineTabViewModel.cs" />
Expand All @@ -126,6 +127,9 @@
<Compile Include="Views\TabViews\CommandLineTabView.xaml.cs">
<DependentUpon>CommandLineTabView.xaml</DependentUpon>
</Compile>
<Compile Include="Windows\CommandLineOutputWindow.xaml.cs">
<DependentUpon>CommandLineOutputWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Windows\ConfirmChangeWindow.xaml.cs">
<DependentUpon>ConfirmChangeWindow.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -179,6 +183,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Windows\CommandLineOutputWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Windows\ConfirmChangeWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down
33 changes: 33 additions & 0 deletions SdkManager.UI/ViewModels/Core/SdkManagerBatViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ public class SdkManagerBatViewModel : BaseViewModel
/// </summary>
private string _consoleOutput = "Status";

/// <summary>
/// ConsoleOutput backing field.
/// </summary>
private string _consoleWindowOutput = "Status";

#endregion

#region Public Properties
Expand Down Expand Up @@ -48,6 +53,22 @@ public string ConsoleOutput
}
}
}

/// <summary>
/// Output recieved from console window.
/// </summary>
public string ConsoleWindowOutput
{
get => _consoleWindowOutput;
set
{
if(_consoleWindowOutput != value)
{
_consoleWindowOutput = value;
NotifyPropertyChanged();
}
}
}

#endregion

Expand Down Expand Up @@ -100,9 +121,12 @@ public async Task UninstallPackages(string args)
/// </summary>
public async Task RunCommands(string args)
{

SdkManagerBat.CommandLineOutputComplete += OnCommandLineOutputComplete;
SdkManagerBat.CommandLineOutputReceived += OnCommandLineOutputReceived;
var t = await Task.Run(() => SdkManagerBat.RunCommandAsync(args));
SdkManagerBat.CommandLineOutputReceived -= OnCommandLineOutputReceived;
SdkManagerBat.CommandLineOutputComplete -= OnCommandLineOutputComplete;
}

/// <summary>
Expand All @@ -125,6 +149,15 @@ private void OnCommandLineOutputReceived(string output)
{
// System.Console.WriteLine(output?.Trim());
ConsoleOutput = output?.Trim();
}
/// <summary>
/// Called when text is written tot he console window.
/// </summary>
/// <param name="output"></param>
private void OnCommandLineOutputComplete(string output)
{
// System.Console.WriteLine(output?.Trim());
ConsoleWindowOutput = output?.Trim();
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,19 @@ public CommandLineTabViewModel(MainWindowViewModel main, SdkManagerBatViewModel
ExecuteCommand = new RelayCommand(Execute);
}


/// <summary>
/// Do somethign with the output... Just outputs to the little Label on the MainWindow
/// </summary>
private void Execute()
{
var cmoWindow = new CommandLineOutputWindow(this._sdkManager);

var t = Task.Run(async () =>
{
await _sdkManager.RunCommands(argsList);
});
});
bool? result = cmoWindow.ShowDialog();
}
}
}
44 changes: 44 additions & 0 deletions SdkManager.UI/ViewModels/Windows/ConsoleOutputWindowViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System;
using System.Windows;
using System.Windows.Input;

namespace SdkManager.UI
{
/// <summary>
/// </summary>
public class ConsoleOutputWindowViewModel : BaseViewModel
{

private Window _win {get;set;}
private SdkManagerBatViewModel sdkManagerbatVM;

public SdkManagerBatViewModel SdkManagerBatVM
{
get => sdkManagerbatVM;
set
{
if(sdkManagerbatVM != value)
{
sdkManagerbatVM = value;
NotifyPropertyChanged();
}
}
}

public ICommand CancelCommand { get; set; }

public ConsoleOutputWindowViewModel(Window win, SdkManagerBatViewModel information)
{
_win = win;
SdkManagerBatVM = information;

CancelCommand = new RelayCommand(Cancel);
}

private void Cancel()
{
_win.DialogResult = false;
_win.Close();
}
}
}
23 changes: 12 additions & 11 deletions SdkManager.UI/Views/TabViews/CommandLineTabView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SdkManager.UI"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid Background="#3C3F41" Margin="-2,1,-2,-2">
d:DesignHeight="457.04" d:DesignWidth="766">

<Grid Background="#3C3F41" Margin="-2,0.5,-2,-2">

<Grid.ColumnDefinitions>
<ColumnDefinition Width="10"/>
Expand Down Expand Up @@ -115,49 +116,49 @@
Width="50"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="20,2,2,10"></CheckBox>
Margin="2,2,2,10"></CheckBox>
<CheckBox Content="--verbose"
Width="75"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="10,2,2,10"></CheckBox>
Margin="2,2,2,10"></CheckBox>
<CheckBox Content="--include__obselete"
Width="125"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="10,2,2,10"></CheckBox>
Margin="2,2,2,10"></CheckBox>
</StackPanel>

<StackPanel Grid.Row="3" Grid.Column="4" Grid.ColumnSpan="1" Margin="2"
Orientation="Horizontal">
<CheckBox Content="--update"
Width="137"
Width="75"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="20,2,2,10"></CheckBox>
Margin="2,2,2,10"></CheckBox>

<CheckBox Content="--include__obselete"
Width="125"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="10,2,2,10"></CheckBox>
Margin="56,2,2,10"></CheckBox>
</StackPanel>

<CheckBox Content="--install"
Width="200"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="20,2,2,10"></CheckBox>
Margin="2,2,2,10"></CheckBox>
<CheckBox Content="--uninstall"
Width="200"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="20,2,2,10"></CheckBox>
Margin="2,2,2,10"></CheckBox>
<CheckBox Content="--version"
Width="200"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="20,2,2,10"></CheckBox>
Margin="2,2,2,10"></CheckBox>
</StackPanel>
</Grid>
</UserControl>
36 changes: 36 additions & 0 deletions SdkManager.UI/Windows/CommandLineOutputWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<Window x:Class="SdkManager.UI.CommandLineOutputWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SdkManager.UI"
mc:Ignorable="d"
Title="cmd output" Height="450" Width="800"
Background="#3C3F41">

<Grid DataContext="{Binding}">
<Grid.RowDefinitions>
<RowDefinition Height="10"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="10"/>
</Grid.RowDefinitions>

<Grid.ColumnDefinitions>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="10"/>
</Grid.ColumnDefinitions>

<Border Grid.Row="1" Grid.Column="1" BorderBrush="#292B2D" BorderThickness="1" CornerRadius="4,4,0,0" HorizontalAlignment="Stretch" Margin="2,0">
<ScrollViewer VerticalScrollBarVisibility="Auto" MaxWidth="2000" MinWidth="760" Height="370">
<TextBlock Text="{Binding SdkManagerBatVM.ConsoleWindowOutput}"></TextBlock>
</ScrollViewer>
</Border>

<StackPanel Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="3" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<Button HorizontalAlignment="Center" Content="Close" Width="60" Margin="10,5,10,5" Command="{Binding CancelCommand}"/>
</StackPanel>
</Grid>
</Window>
28 changes: 28 additions & 0 deletions SdkManager.UI/Windows/CommandLineOutputWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace SdkManager.UI
{
/// <summary>
/// Interaction logic for CommandLineOutputWindow.xaml
/// </summary>
public partial class CommandLineOutputWindow : Window
{
public CommandLineOutputWindow(SdkManagerBatViewModel dataContext)
{
this.DataContext = new ConsoleOutputWindowViewModel(this, dataContext);
InitializeComponent();
}
}
}

0 comments on commit 564ecf8

Please sign in to comment.