Skip to content

Commit

Permalink
Started implementing a UI for the terminal
Browse files Browse the repository at this point in the history
This is for issue #100.
  • Loading branch information
haefele committed Oct 19, 2016
1 parent 4f975d7 commit 0862c05
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 4 deletions.
57 changes: 55 additions & 2 deletions src/CTime2/Views/Terminal/TerminalView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,70 @@
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:behaviors="using:UwCore.Behaviors"
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
xmlns:converter="using:UwCore.Converter"

xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
mc:Ignorable="d"
>
<Page.Resources>
<converter:FormatStringConverter x:Key="TimeToStringConverter"
FormatString="hh\:mm\:ss" />
</Page.Resources>

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>

<TextBlock Grid.Row="0"
Margin="0, 50, 0, 0"
Style="{StaticResource TitleTextBlockStyle}"
Foreground="{ThemeResource SystemControlHighlightAccentBrush}"
Text="Aktuelle Uhrzeit:"
HorizontalAlignment="Center" />

<TextBlock HorizontalAlignment="Center"
Text="{x:Bind ViewModel.CurrentTime, Converter={StaticResource TimeToStringConverter}, Mode=OneWay}"
Margin="0, -12, 0, 0"
FontSize="40"
Grid.Row="1"/>

<Grid Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>

<ToggleButton Grid.Column="0"
Content="Normal Stempeln"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Margin="20" />

<ToggleButton Grid.Column="1"
Content="Trip"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Margin="20" />

<ToggleButton Grid.Column="2"
Content="Homeoffice"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Margin="20" />

</Grid>

<TextBox x:Name="RfidReaderTextBox"
Text="{Binding RfidKey, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Opacity="0"
IsHitTestVisible="False">
IsHitTestVisible="False"
Grid.Row="0">
<interactivity:Interaction.Behaviors>
<behaviors:KeyTriggerBehavior Key="Enter">
<core:InvokeCommandAction Command="{x:Bind ViewModel.Stamp}" />
Expand Down
25 changes: 23 additions & 2 deletions src/CTime2/Views/Terminal/TerminalViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System;
using System.Diagnostics;
using System.Reactive;
using System.Threading;
using System.Threading.Tasks;
using Caliburn.Micro;
using Caliburn.Micro.ReactiveUI;
using CTime2.Core.Data;
using CTime2.Core.Services.ApplicationState;
Expand All @@ -18,8 +20,17 @@ public class TerminalViewModel : ReactiveScreen
private readonly ICTimeService _cTimeService;
private readonly IApplicationStateService _applicationStateService;

private readonly Timer _timer;

private TimeSpan _currentTime;
private string _rfidKey;

public TimeSpan CurrentTime
{
get { return this._currentTime; }
set { this.RaiseAndSetIfChanged(ref this._currentTime, value); }
}

public string RfidKey
{
get { return this._rfidKey; }
Expand All @@ -40,12 +51,22 @@ public TerminalViewModel(ICTimeService cTimeService, IApplicationStateService ap
this.Stamp = UwCoreCommand.Create(canStamp, this.StampImpl)
.HandleExceptions()
.ShowLoadingOverlay("Stempeln...");

this._timer = new Timer(this.Tick, null, TimeSpan.Zero, TimeSpan.FromMilliseconds(100));

this.DisplayName = "Terminal";
}

private void Tick(object state)
{
Execute.OnUIThread(() =>
{
this.CurrentTime = DateTimeOffset.Now.TimeOfDay;
});
}

private async Task StampImpl()
{
Debug.WriteLine(this.RfidKey);

await this._cTimeService.SaveTimer(
string.Empty,
this.RfidKey,
Expand Down

0 comments on commit 0862c05

Please sign in to comment.