diff options
| author | Roy <roy.mail.net@gmail.com> | 2018-02-10 02:13:37 +0200 |
|---|---|---|
| committer | Roy <roy.mail.net@gmail.com> | 2018-02-10 02:13:37 +0200 |
| commit | 07e686eb253ffd29f36dbe530b3a17633e02b353 (patch) | |
| tree | d9663f1c92a400349dffc743adb0114ee1a7f618 /Software/Visual_Studio/Utilities/Tango.MachineEM.UI | |
| parent | c8c9606e545f49aae3d9f0524775436adbdf27e9 (diff) | |
| download | Tango-07e686eb253ffd29f36dbe530b3a17633e02b353.tar.gz Tango-07e686eb253ffd29f36dbe530b3a17633e02b353.zip | |
Added support for motor controllers.
Diffstat (limited to 'Software/Visual_Studio/Utilities/Tango.MachineEM.UI')
7 files changed, 56 insertions, 40 deletions
diff --git a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Images/circuit.jpg b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Images/circuit.jpg Binary files differnew file mode 100644 index 000000000..589559bd4 --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Images/circuit.jpg diff --git a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Images/embedded-device.png b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Images/embedded-device.png Binary files differnew file mode 100644 index 000000000..2b3be3dfd --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Images/embedded-device.png diff --git a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/MainWindow.xaml b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/MainWindow.xaml index 318a4133e..0bedbb1fb 100644 --- a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/MainWindow.xaml +++ b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/MainWindow.xaml @@ -9,7 +9,7 @@ xmlns:local="clr-namespace:Tango.MachineEM.UI" xmlns:views="clr-namespace:Tango.MachineEM.UI.Views" mc:Ignorable="d" - Title="Tango Machine Emulator" Height="720" Width="1200" TitleCaps="False" BorderBrush="Gray" BorderThickness="1" WindowStartupLocation="CenterScreen" Background="#202020" Foreground="Gainsboro" DataContext="{Binding RelativeSource={RelativeSource Self}}"> + Title="Tango Embedded Emulator" Height="720" Width="1200" TitleCaps="False" BorderBrush="Gray" BorderThickness="1" WindowStartupLocation="CenterScreen" Background="#202020" Foreground="Gainsboro" DataContext="{Binding RelativeSource={RelativeSource Self}}"> <Grid> <views:MainView DataContext="{StaticResource MainViewVM}"></views:MainView> </Grid> diff --git a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Tango.MachineEM.UI.csproj b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Tango.MachineEM.UI.csproj index 8442cf3d6..e15e75bc5 100644 --- a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Tango.MachineEM.UI.csproj +++ b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Tango.MachineEM.UI.csproj @@ -162,6 +162,12 @@ <ItemGroup> <Resource Include="machine.ico" /> </ItemGroup> + <ItemGroup> + <Resource Include="Images\circuit.jpg" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\embedded-device.png" /> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <PropertyGroup> <PostBuildEvent>$(TargetDir)linkgen.exe -s "$(TargetPath)" -d "$(TargetDir)Utilities\Machine Emulator.lnk"</PostBuildEvent> diff --git a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/ViewModels/MainViewVM.cs index 0b1a10f13..99be80b29 100644 --- a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/ViewModels/MainViewVM.cs @@ -145,18 +145,21 @@ namespace Tango.MachineEM.UI.ViewModels /// </summary> public MainViewVM() { - MainViewLogger logger = new MainViewLogger(); - //logger.NewLog += (output) => - //{ - // Log += output + Environment.NewLine; - //}; + SimpleStringLogger logger = new SimpleStringLogger(LogCategory.Critical, LogCategory.Error, LogCategory.General, LogCategory.Warning); + logger.LogReceived += (sedner, log) => + { + Log += log.ToString() + Environment.NewLine; + }; LogManager.RegisterLogger(logger); + LogManager.Log("Embedded Emulator Started..."); + + Emulator = new MachineEmulator(new BasicTransporter()); StartCommand = new RelayCommand(Start, (x) => !Emulator.IsStarted); - StopCommand = new RelayCommand(Stop,(x) => Emulator.IsStarted); + StopCommand = new RelayCommand(Stop, (x) => Emulator.IsStarted); RunCommand = new RelayCommand(RunSelectedStub, (x) => !_running); CancelCommand = new RelayCommand(Cancel, (x) => _running); ClearCommand = new RelayCommand(() => Log = String.Empty); @@ -257,32 +260,5 @@ namespace Tango.MachineEM.UI.ViewModels } #endregion - - #region Custom Logger - - public class MainViewLogger : ILogger - { - public bool Enabled { get; set; } - public bool Immediate { get; set; } - public event Action<String> NewLog; - - public MainViewLogger() - { - Enabled = true; - Immediate = true; - } - - public void OnError(LogItemBase output) - { - NewLog?.Invoke(output.ToString()); - } - - public void OnTrace(LogItemBase output) - { - NewLog?.Invoke(output.ToString()); - } - } - - #endregion } } diff --git a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml index b48001a02..4e3c7bbc9 100644 --- a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml @@ -15,6 +15,9 @@ <converters:BooleanInverseConverter x:Key="BooleanInverseConverter"></converters:BooleanInverseConverter> </UserControl.Resources> <Grid> + <Grid.Background> + <ImageBrush ImageSource="../Images/circuit.jpg" Opacity="0.1" Stretch="UniformToFill"></ImageBrush> + </Grid.Background> <Grid> <Grid.RowDefinitions> <RowDefinition Height="100"/> @@ -22,16 +25,20 @@ </Grid.RowDefinitions> <Grid> + <Grid.Effect> + <DropShadowEffect BlurRadius="10"/> + </Grid.Effect> + <Grid.Background> + <SolidColorBrush Color="#151515" Opacity="0.8" /> + </Grid.Background> <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="20 15"> - <Image Source="/Images/machine-trans.png" RenderOptions.BitmapScalingMode="Fant"></Image> - <TextBlock Text="Tango Machine Emulator" VerticalAlignment="Center" Margin="20 0 0 0" FontSize="36" Foreground="Yellow"> + <Image Source="/Images/embedded-device.png" RenderOptions.BitmapScalingMode="Fant"></Image> + <TextBlock Text="Tango Embedded Emulator" VerticalAlignment="Center" Margin="20 0 0 0" FontSize="36" Foreground="Red"> <TextBlock.Effect> <DropShadowEffect/> </TextBlock.Effect> </TextBlock> </StackPanel> - - <Rectangle VerticalAlignment="Bottom" HorizontalAlignment="Stretch" Margin="20 0 50 0" Stroke="DimGray" StrokeThickness="1" StrokeDashArray="5"></Rectangle> </Grid> <Grid Grid.Row="1" Margin="20"> @@ -41,7 +48,13 @@ <RowDefinition Height="70"/> </Grid.RowDefinitions> - <Grid x:Name="gridContent" Background="#151515" Margin="5"> + <Grid> + <TextBox x:Name="txtLog" FontFamily="monospaced" TextChanged="txtLog_TextChanged" Text="{Binding Log}" Background="Transparent" Foreground="Red" FontSize="11" Padding="5" Style="{x:Null}" BorderThickness="0" IsReadOnly="True" AcceptsReturn="True" VerticalScrollBarVisibility="Auto" TextWrapping="Wrap"> + + </TextBox> + </Grid> + + <Grid x:Name="gridContent" Background="#151515" Margin="5" Visibility="Hidden"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="300" /> @@ -135,7 +148,13 @@ </Grid> </Grid> </Grid> - <Grid x:Name="gridActions" Grid.Row="1" Background="#151515" Margin="5"> + <Grid x:Name="gridActions" Grid.Row="1" Margin="5"> + <Grid.Effect> + <DropShadowEffect BlurRadius="10" /> + </Grid.Effect> + <Grid.Background> + <SolidColorBrush Color="#151515" Opacity="0.8" /> + </Grid.Background> <StackPanel HorizontalAlignment="Right" Orientation="Horizontal" Margin="5"> <ComboBox IsEnabled="{Binding Emulator.IsStarted,Converter={StaticResource BooleanInverseConverter}}" MinWidth="140" Margin="5" BorderThickness="0" ItemsSource="{Binding Ports}" SelectedItem="{Binding SelectedPort}"></ComboBox> <Button Margin="5" MinWidth="100" Style="{StaticResource AccentedSquareButtonStyle}" mahapps:ButtonHelper.PreserveTextCase="True" BorderThickness="0" Command="{Binding StopCommand}"> diff --git a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml.cs b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml.cs index 9112f28f4..358cd7927 100644 --- a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml.cs +++ b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; @@ -29,5 +30,19 @@ namespace Tango.MachineEM.UI.Views { //txtResponse.ScrollToEnd(); } + + private void txtLog_TextChanged(object sender, TextChangedEventArgs e) + { + Task.Factory.StartNew(() => + { + Thread.Sleep(50); + + this.Dispatcher.Invoke(() => + { + txtLog.SelectionStart = txtLog.Text.Length; + txtLog.ScrollToEnd(); + }); + }); + } } } |
