Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
PlatformSpecific.cs
2using System.Diagnostics;
4
6{
11 {
12 private bool isDisposed;
13
18 {
19 }
20
22 public void Dispose()
23 {
24 this.Dispose(true);
25 GC.SuppressFinalize(this);
26 }
27
32 protected virtual void Dispose(bool Disposing)
33 {
34 if (this.isDisposed)
35 return;
36
37 this.isDisposed = true;
38 }
39
41 public bool CanProhibitScreenCapture => false;
42
44 public bool ProhibitScreenCapture
45 {
46 get => false;
47 set => _ = value; // Not supported on Windows currently.
48 }
49
51 public string? GetDeviceId()
52 {
53 try
54 {
55 // Use SecureStorage if available (works on Windows). Persist generated GUID.
56 string? DeviceId = SecureStorage.GetAsync("DeviceIdentifier").Result;
57 if (!string.IsNullOrEmpty(DeviceId))
58 return DeviceId;
59
60 string NewId = Guid.NewGuid().ToString();
61 SecureStorage.SetAsync("DeviceIdentifier", NewId).Wait();
62 return NewId;
63 }
64 catch (Exception ex)
65 {
66 try
67 {
68 App.SendAlertAsync("Unable to get or store device ID: " + ex.Message, "text/plain").Wait();
69 this.CloseApplication().Wait();
70 }
71 catch (Exception)
72 {
73 Environment.Exit(0);
74 }
75 }
76
77 return null;
78 }
79
81 public Task CloseApplication()
82 {
83 try
84 {
85#if WINDOWS
86 Environment.Exit(0);
87#else
88 Environment.Exit(0);
89#endif
90 }
91 catch (Exception)
92 {
93 // Ignore.
94 }
95
96 return Task.CompletedTask;
97 }
98
100 public void ShareImage(byte[] PngFile, string Message, string Title, string FileName)
101 {
102 try
103 {
104 string CachePath = FileSystem.CacheDirectory;
105 if (!Directory.Exists(CachePath))
106 Directory.CreateDirectory(CachePath);
107
108 string FullPath = Path.Combine(CachePath, FileName);
109 File.WriteAllBytes(FullPath, PngFile);
110
111 ShareFileRequest Request = new()
112 {
113 Title = Title,
114 File = new ShareFile(FullPath, "image/png")
115 };
116
117 MainThread.BeginInvokeOnMainThread(async () => await Share.Default.RequestAsync(Request));
118 }
119 catch (Exception ex)
120 {
121 ServiceRef.LogService.LogException(ex);
122 }
123 }
124
126 public bool SupportsFingerprintAuthentication => false; // Windows Hello not integrated yet.
127
130
132 public Task<bool> AuthenticateUserFingerprint(string Title, string? Subtitle, string Description, string Cancel, CancellationToken? CancellationToken)
133 {
134 return Task.FromResult(false); // Not implemented.
135 }
136
138 public Task<TokenInformation> GetPushNotificationToken()
139 {
140 // No push implementation for Windows at this time. Return empty token.
142 {
143 Token = string.Empty,
144 ClientType = ClientType.Other,
145 Service = PushMessagingService.Firebase // Placeholder; value ignored if token empty.
146 };
147
148 return Task.FromResult(TokenInformation);
149 }
150
151 #region Keyboard (No-op on Windows desktop)
152 public event EventHandler<KeyboardSizeMessage>? KeyboardShown;
153 public event EventHandler<KeyboardSizeMessage>? KeyboardHidden;
154 public event EventHandler<KeyboardSizeMessage>? KeyboardSizeChanged;
155
157 public void HideKeyboard()
158 {
159 // No-op on Windows.
160 }
161 #endregion
162
163 #region Notifications (No-op placeholders)
164 public void ShowMessageNotification(string Title, string MessageBody, IDictionary<string, string> Data) { }
165 public void ShowIdentitiesNotification(string Title, string MessageBody, IDictionary<string, string> Data) { }
166 public void ShowPetitionNotification(string Title, string MessageBody, IDictionary<string, string> Data) { }
167 public void ShowContractsNotification(string Title, string MessageBody, IDictionary<string, string> Data) { }
168 public void ShowEDalerNotification(string Title, string MessageBody, IDictionary<string, string> Data) { }
169 public void ShowTokenNotification(string Title, string MessageBody, IDictionary<string, string> Data) { }
170 public void ShowProvisioningNotification(string Title, string MessageBody, IDictionary<string, string> Data) { }
171 #endregion
172
174 public Thickness GetInsets()
175 {
176 return new Thickness(0,16,0,0); // No safe area concept needed for desktop window.
177 }
178 }
179}
Represents an instance of the Neuro-Access app.
Definition: App.xaml.cs:125
Android implementation of platform-specific features.
EventHandler< KeyboardSizeMessage >? KeyboardShown
bool CanProhibitScreenCapture
If screen capture prohibition is supported
void ShareImage(byte[] PngFile, string Message, string Title, string FileName)
Shares an image in PNG format.
PlatformSpecific()
Windows implementation of platform-specific features.
void HideKeyboard()
Force hide the keyboard
bool SupportsFingerprintAuthentication
If the device supports authenticating the user using fingerprints.
Task< bool > AuthenticateUserFingerprint(string Title, string? Subtitle, string Description, string Cancel, CancellationToken? CancellationToken)
Authenticates the user using the fingerprint sensor. If the user has been successfully authenticated.
BiometricMethod GetBiometricMethod()
Gets the biometric method supported by the device. The BiometricMethod which is preferred/supported o...
virtual void Dispose(bool Disposing)
IDisposable.Dispose
EventHandler< KeyboardSizeMessage >? KeyboardSizeChanged
Fired when the keyboard size changes.
string? GetDeviceId()
Gets the ID of the device
EventHandler< KeyboardSizeMessage >? KeyboardHidden
bool ProhibitScreenCapture
If screen capture is prohibited or not.
Thickness GetInsets()
Gets the safe area insets for the device (top, bottom, left, right). Device safe insets as a Thicknes...
Task CloseApplication()
Closes the application
Task< TokenInformation > GetPushNotificationToken()
Gets a Push Notification token for the device. Token information.
Contains information about a push notification token.
Base class that references services in the app.
Definition: ServiceRef.cs:43
static ILogService LogService
Log service.
Definition: ServiceRef.cs:214
Interface for platform-specific functions.
Definition: ImplTypes.g.cs:58
BiometricMethod
Enum representing the device biometric method for authentication.
ClientType
Type of client requesting notification.
Definition: ClientType.cs:7