diff --git a/Akari.Provider.WaveshareUART.csproj b/Akari.Provider.WaveshareUART.csproj index 0de7bce..cfe66d5 100644 --- a/Akari.Provider.WaveshareUART.csproj +++ b/Akari.Provider.WaveshareUART.csproj @@ -94,7 +94,6 @@ - @@ -103,7 +102,6 @@ - diff --git a/Views/DataDisplay.cs b/Views/DataDisplay.cs deleted file mode 100644 index 9451c0f..0000000 --- a/Views/DataDisplay.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System.IO; -using Terminal.Gui; - -namespace Akari.Provider.WaveshareUART.Views -{ - public class DataDisplay : Toplevel - { - private string _title; - private byte[] _data; - - public DataDisplay(string title, byte[] data) - { - _title = title; - _data = data; - - Init(); - } - - private void Init() - { - ColorScheme = Colors.TopLevel; - - // Creates the top-level window to show - var win = new Window(_title) - { - X = 0, - Y = 0, - - // By using Dim.Fill(), it will automatically resize without manual intervention - Width = Dim.Fill(), - Height = Dim.Fill() - }; - - win.ColorScheme = Colors.ColorSchemes["Dialog"]; - - Add(win); - - var quitButton = new Button("_Ok") - { - X = Pos.Right(this) - 9, - Y = Pos.Bottom(this) - 2 - }; - quitButton.Clicked += () => Application.RequestStop(); - - var stream = new MemoryStream(_data); - var text = new HexView(stream) - { - X = Pos.Center(), - Y = Pos.Center(), - Height = Dim.Fill() - 5, - Width = Dim.Fill() - 2, - AllowEdits = false - }; - - Add(text, quitButton); - } - } -} diff --git a/Views/SleepDisplay.cs b/Views/SleepDisplay.cs deleted file mode 100644 index 726a04c..0000000 --- a/Views/SleepDisplay.cs +++ /dev/null @@ -1,100 +0,0 @@ -using Terminal.Gui; -using WaveshareUARTFingerprintSensor; - -namespace Akari.Provider.WaveshareUART.Views -{ - public class SleepDisplay : Toplevel - { - private FingerprintSensor _fingerprintSensor; - private int _count; - private int _lastID; - private Label _sleepModeLabel; - private Label _readCountLabel; - private Label _lastReadLabel; - - public SleepDisplay(FingerprintSensor fingerprintSensor) - { - _fingerprintSensor = fingerprintSensor; - _count = 0; - _lastID = -1; - - Init(); - } - - private void Init() - { - ColorScheme = Colors.Error; - - // Creates the top-level window to show - var win = new Window("Sleep") - { - X = 0, - Y = 0, - - // By using Dim.Fill(), it will automatically resize without manual intervention - Width = Dim.Fill(), - Height = Dim.Fill() - }; - - win.ColorScheme = Colors.ColorSchemes["Dialog"]; - - Add(win); - - // Window Content - _sleepModeLabel = new Label("Sleep mode is on, waiting for fingerprints...") - { - X = 2, - Y = 1, - Width = Dim.Fill() - }; - _readCountLabel = new Label("Read: 0") - { - X = Pos.Left(_sleepModeLabel), - Y = Pos.Bottom(_sleepModeLabel) + 1, - Width = Dim.Fill() - }; - _lastReadLabel = new Label("Last User: - 1") - { - X = Pos.Left(_readCountLabel), - Y = Pos.Bottom(_readCountLabel), - Width = Dim.Fill() - }; - - var stopButton = new Button("_Stop") - { - X = Pos.Right(this) - 11, - Y = Pos.Bottom(this) - 2 - }; - stopButton.Clicked += () => { _fingerprintSensor.Waked -= FingerprintSensor_Waked; Application.RequestStop(); }; - - win.Add(_sleepModeLabel, _readCountLabel, _lastReadLabel); - - Add(stopButton); - - _fingerprintSensor.Waked += FingerprintSensor_Waked; - - _fingerprintSensor.Sleep(); - } - - private void UpdateInfo() - { - _readCountLabel.Text = $"Read: {_count}"; - _lastReadLabel.Text = $"Last User: {_lastID}"; - } - - private void FingerprintSensor_Waked(FingerprintSensor sender) - { - _fingerprintSensor.Wake(); - - if (_fingerprintSensor.TryComparison1N(out var userInfo)) - { - _count += 1; - _lastID = userInfo.userID; - - Application.MainLoop.Invoke(UpdateInfo); - } - - _fingerprintSensor.Sleep(); - } - } -}