-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The basic terminal functionality works, now onto the cosmetics
This is for issue #100.
- Loading branch information
Showing
8 changed files
with
121 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,31 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Runtime.InteropServices.WindowsRuntime; | ||
using Windows.Foundation; | ||
using Windows.Foundation.Collections; | ||
using System.Threading; | ||
using Windows.UI.Core; | ||
using Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Controls; | ||
using Windows.UI.Xaml.Controls.Primitives; | ||
using Windows.UI.Xaml.Data; | ||
using Windows.UI.Xaml.Input; | ||
using Windows.UI.Xaml.Media; | ||
using Windows.UI.Xaml.Navigation; | ||
|
||
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238 | ||
|
||
namespace CTime2.Views.Terminal | ||
{ | ||
/// <summary> | ||
/// An empty page that can be used on its own or navigated to within a Frame. | ||
/// </summary> | ||
public sealed partial class TerminalView : Page | ||
{ | ||
private readonly Timer _focusTextBoxTimer; | ||
|
||
public TerminalViewModel ViewModel => this.DataContext as TerminalViewModel; | ||
|
||
public TerminalView() | ||
{ | ||
this.InitializeComponent(); | ||
|
||
this._focusTextBoxTimer = new Timer(this.TryFocusTextBox, null, TimeSpan.Zero, TimeSpan.FromSeconds(0.5)); | ||
} | ||
|
||
private void TryFocusTextBox(object state) | ||
{ | ||
this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => | ||
{ | ||
this.RfidReaderTextBox.Focus(FocusState.Programmatic); | ||
|
||
}).AsTask().Wait(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,60 @@ | ||
using Caliburn.Micro.ReactiveUI; | ||
using System; | ||
using System.Diagnostics; | ||
using System.Reactive; | ||
using System.Threading.Tasks; | ||
using Caliburn.Micro.ReactiveUI; | ||
using CTime2.Core.Data; | ||
using CTime2.Core.Services.ApplicationState; | ||
using CTime2.Core.Services.CTime; | ||
using ReactiveUI; | ||
using UwCore; | ||
using UwCore.Common; | ||
using UwCore.Services.ApplicationState; | ||
|
||
namespace CTime2.Views.Terminal | ||
{ | ||
public class TerminalViewModel : ReactiveScreen | ||
{ | ||
|
||
private readonly ICTimeService _cTimeService; | ||
private readonly IApplicationStateService _applicationStateService; | ||
|
||
private string _rfidKey; | ||
|
||
public string RfidKey | ||
{ | ||
get { return this._rfidKey; } | ||
set { this.RaiseAndSetIfChanged(ref this._rfidKey, value); } | ||
} | ||
|
||
public UwCoreCommand<Unit> Stamp { get; } | ||
|
||
public TerminalViewModel(ICTimeService cTimeService, IApplicationStateService applicationStateService) | ||
{ | ||
Guard.NotNull(cTimeService, nameof(cTimeService)); | ||
Guard.NotNull(applicationStateService, nameof(applicationStateService)); | ||
|
||
this._cTimeService = cTimeService; | ||
this._applicationStateService = applicationStateService; | ||
|
||
var canStamp = this.WhenAnyValue(f => f.RfidKey, (string rfidKey) => string.IsNullOrWhiteSpace(rfidKey) == false); | ||
this.Stamp = UwCoreCommand.Create(canStamp, this.StampImpl) | ||
.HandleExceptions() | ||
.ShowLoadingOverlay("Stempeln..."); | ||
} | ||
|
||
private async Task StampImpl() | ||
{ | ||
Debug.WriteLine(this.RfidKey); | ||
|
||
await this._cTimeService.SaveTimer( | ||
string.Empty, | ||
this.RfidKey, | ||
DateTime.Now, | ||
this._applicationStateService.GetCompanyId(), | ||
TimeState.Entered, | ||
true); | ||
|
||
this.RfidKey = string.Empty; | ||
} | ||
} | ||
} |