Skip to content

Commit

Permalink
Add remote control to simulator
Browse files Browse the repository at this point in the history
  • Loading branch information
wouterdevinck committed Nov 10, 2018
1 parent f325938 commit 3424959
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 19 deletions.
2 changes: 1 addition & 1 deletion test/simulator/Lamp.Simulator/IrReceiver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Lamp.Simulator {

internal class IrReceiver : AbstractIrReceiver {
public class IrReceiver : AbstractIrReceiver {

private IrHandlerWrapper _handler;

Expand Down
21 changes: 7 additions & 14 deletions test/simulator/Lamp.Simulator/Lamp.Simulator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,29 +74,22 @@
<Compile Include="HttpServer.cs" />
<Compile Include="HttpWebRequestExt.cs" />
<Compile Include="IrReceiver.cs" />
<Compile Include="Led.xaml.cs">
<DependentUpon>Led.xaml</DependentUpon>
</Compile>
<Compile Include="LedArray.cs" />
<Compile Include="LedDisplay.xaml.cs">
<DependentUpon>LedDisplay.xaml</DependentUpon>
</Compile>
<Compile Include="LedBoard.xaml.cs">
<DependentUpon>LedBoard.xaml</DependentUpon>
</Compile>
<Compile Include="LedGroup.xaml.cs">
<DependentUpon>LedGroup.xaml</DependentUpon>
</Compile>
<Compile Include="LedPanel.xaml.cs">
<DependentUpon>LedPanel.xaml</DependentUpon>
</Compile>
<Compile Include="Logger.cs" />
<Compile Include="RemoteControl.xaml.cs">
<DependentUpon>RemoteControl.xaml</DependentUpon>
</Compile>
<Compile Include="RgbLed.cs" />
<Compile Include="Updater.cs" />
<Page Include="Led.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="LedDisplay.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand All @@ -105,10 +98,6 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="LedGroup.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="LedPanel.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand All @@ -125,6 +114,10 @@
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="RemoteControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
Expand Down
4 changes: 4 additions & 0 deletions test/simulator/Lamp.Simulator/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Border Grid.Column="0" BorderBrush="Silver" BorderThickness="1" Margin="5">
<Grid>
Expand All @@ -51,6 +52,9 @@
<TextBlock x:Name="log" Text="{Binding Log}"></TextBlock>
</ScrollViewer>
</Border>
<Border Grid.Column="2" BorderBrush="Silver" BorderThickness="1" Margin="5">
<local:RemoteControl x:Name="remote" />
</Border>
</Grid>
</Grid>
</Window>
8 changes: 4 additions & 4 deletions test/simulator/Lamp.Simulator/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ public MainWindow() {
var led = new RgbLed(ellipse);
var leds = new LedArray(ledDisplay);

var lamp = new LampWrapper(updater, logger, ir, httpserver, httpclient, led, leds);
lamp.Start(Port);
var lamp = new LampWrapper(updater, logger, ir, httpserver, httpclient, led, leds);

remote.Ir = ir;

// ir.SendCode(0x0010);
lamp.Start(Port);

// Browser
browser.Navigated += (s, e) => {
Expand Down
29 changes: 29 additions & 0 deletions test/simulator/Lamp.Simulator/RemoteControl.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<UserControl x:Class="Lamp.Simulator.RemoteControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Lamp.Simulator"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Button Content="Red" x:Name="btnRed" Grid.Column="0" Grid.Row="1" Margin="5" />
<Button Content="Green" x:Name="btnGreen" Grid.Column="1" Grid.Row="1" Margin="5" />
<Button Content="Blue" x:Name="btnBlue" Grid.Column="2" Grid.Row="1" Margin="5" />
<Button Content="White" x:Name="btnWhite" Grid.Column="3" Grid.Row="1" Margin="5" />
</Grid>
</UserControl>
25 changes: 25 additions & 0 deletions test/simulator/Lamp.Simulator/RemoteControl.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.Windows.Controls;

namespace Lamp.Simulator {

public partial class RemoteControl : UserControl {

public IrReceiver Ir { get; set; }

public RemoteControl() {
InitializeComponent();
btnRed.Click += (s, e) => { Send(0x0090); };
btnGreen.Click += (s, e) => { Send(0x0010); };
btnBlue.Click += (s, e) => { Send(0x0050); };
btnWhite.Click += (s, e) => { Send(0x00D0); };
}

private void Send(short code) {
if (Ir != null) {
Ir.SendCode(code);
}
}

}

}

0 comments on commit 3424959

Please sign in to comment.