You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
using System.Reflection; using CDPShared; using Syncfusion.Maui.PdfViewer;
namespace CircleViewerMaui;
public partial class MainPage : ContentPage { int count = 0; // private CDPWorker _cdp;
Timer _timer; Boolean _bConnected = false;
public MainPage() { using (LogMethod.Log(MethodBase.GetCurrentMethod().ReflectedType.Name)) { InitializeComponent(); _timer = new Timer(IsReady, null, 250, 250); } }
void IsReady(object state) { if (_bConnected != App.CDP.Ready) { _bConnected = App.CDP.Ready; OnReady(); _timer = null; } }
void OnReady() { // Device.InvokeOnMainThreadAsync(() => { lblConnected.Text = "Connected"; });
}
public async Task<string> OpenCirFileAsync() { var fileTypes = new FilePickerFileType(new Dictionary<DevicePlatform, IEnumerable<string>> { { DevicePlatform.iOS, new[] { "public.cir" } }, { DevicePlatform.Android, new[] { "application/cir" } }, { DevicePlatform.WinUI, new[] { ".cir" } }, { DevicePlatform.macOS, new[] { ".cir" } } });
var options = new PickOptions { FileTypes = fileTypes, PickerTitle = "Open .cir File" };
var result = await FilePicker.PickAsync(options);
if (result != null) { return result.FullPath; }
return null; }
private async void onOpenClicked(object sender, EventArgs e) { var filePath = await OpenCirFileAsync(); if (filePath != null) { ViewFileAsync(filePath); } }
async void ViewFileAsync(string fileToLoad) { using (LogMethod.Log(MethodBase.GetCurrentMethod().ReflectedType.Name)) { var result = await App.CDP.Decrypt(fileToLoad); if (result.Status.Result.GetValueOrDefault(false)) { byte[] buf = Convert.FromBase64String(result.DecryptedData); string ext = Path.GetExtension(result.FileName); PdfViewer.DocumentSource = new MemoryStream(buf); } } } }
|