|
| 1 | +--- |
| 2 | +layout: default-layout |
| 3 | +title: Migrate from Xamarin Forms to MAUI - Dynamsoft Barcode Reader for MAUI |
| 4 | +description: This is the migration guide from Xamarin Forms to MAUI |
| 5 | +keywords: user guide, maui, xamarin forms |
| 6 | +needAutoGenerateSidebar: true |
| 7 | +needGenerateH3Content: true |
| 8 | +noTitleIndex: true |
| 9 | +--- |
| 10 | + |
| 11 | +# How to migrate from Xamarin Forms to MAUI |
| 12 | + |
| 13 | +The Dynamsoft Barcode Reader SDK has been refactored to align with the [DynamsoftCaptureVision (DCV)]({{ site.dcvb_architecture }}) architecture. To upgrade to version 10.x, we recommend following the [User Guide](user-guide.md) and re-writing your code accordingly. |
| 14 | + |
| 15 | +## Update the Project |
| 16 | + |
| 17 | +Previously, you created a Mobile App (Xamarin.Forms) project. Now, you’ll need to create a standalone .NET MAUI App project. |
| 18 | + |
| 19 | +## Update the Library |
| 20 | + |
| 21 | +In your Xamarin.Forms project, you referenced the **Dynamsoft.CaptureVision.Xamarin.Forms** library. Now, in your MAUI project, you’ll need to reference the **Dynamsoft.BarcodeReaderBundle.Maui** library. Please refer to the [User Guide](user-guide.md#installation) for further instructions. |
| 22 | + |
| 23 | +## Update the License Activation Code |
| 24 | + |
| 25 | +Starting from 10.0, we have unified the API for setting licenses across different Dynamsoft products. |
| 26 | + |
| 27 | +| Old APIs | New APIs | |
| 28 | +| :----------- | :------- | |
| 29 | +| `BarcodeReader.initLicense` | `LicenseManager.initLicense` | |
| 30 | + |
| 31 | +- code in Xamarin.Forms |
| 32 | + |
| 33 | +```c# |
| 34 | +public partial class App : Application, ILicenseVerificationListener |
| 35 | +{ |
| 36 | + public App(IDCVCameraEnhancer dce, IDCVBarcodeReader dbr) |
| 37 | + { |
| 38 | + ... |
| 39 | + // Initialize the license of barcode reader module. Please note that the following license is a public trial. |
| 40 | + barcodeReader.InitLicense("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9", this); |
| 41 | + } |
| 42 | + |
| 43 | + // Implement LicenseVerificationCallback to get message from the license server. |
| 44 | + public void LicenseVerificationCallback(bool isSuccess, string msg) |
| 45 | + { |
| 46 | + if (!isSuccess) |
| 47 | + { |
| 48 | + System.Console.WriteLine(msg); |
| 49 | + } |
| 50 | + } |
| 51 | +} |
| 52 | +``` |
| 53 | + |
| 54 | +- code in MAUI |
| 55 | + |
| 56 | +```c# |
| 57 | +public partial class MainPage : ContentPage, ILicenseVerificationListener |
| 58 | +{ |
| 59 | + public MainPage() |
| 60 | + { |
| 61 | + InitializeComponent(); |
| 62 | + LicenseManager.InitLicense("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9", this); |
| 63 | + } |
| 64 | + public void OnLicenseVerified(bool isSuccess, string message) |
| 65 | + { |
| 66 | + if (!isSuccess) |
| 67 | + { |
| 68 | + Debug.WriteLine(message); |
| 69 | + } |
| 70 | + } |
| 71 | +} |
| 72 | +``` |
| 73 | + |
| 74 | +## Update Video Streaming Decoding APIs |
| 75 | + |
| 76 | +The APIs for decoding video frames has been adjusted as follows: |
| 77 | + |
| 78 | +| Old APIs | New APIs | |
| 79 | +| :----------- | :------- | |
| 80 | +| `BarcodeReader.SetCameraEnhancer` | `CaptureVisionRouter.SetInput` | |
| 81 | +| `BarcodeReader.StartScanning` | `CaptureVisionRouter.StartCapturing` | |
| 82 | +| `BarcodeReader.StopScanning` | `CaptureVisionRouter.StopCapturing` | |
| 83 | +| `BarcodeReader.AddResultReceiver` | `CaptureVisionRouter.addResultReceiver` | |
| 84 | +| `BarcodeReader.Set/GetMinImageReadingInterval` | `SimplifiedCaptureVisionSettings.MinImageCaptureInterval` | |
| 85 | +| `BarcodeReader.EnableResultVerification` | `MultiFrameResultCrossFilter.EnableResultCrossVerification` | |
| 86 | +| `BarcodeReader.EnableDuplicateFilter` | `MultiFrameResultCrossFilter.EnableResultDeduplication` | |
| 87 | +| `interface IBarcodeResultListener` | `interface ICapturedResultReceiver` | |
| 88 | +| `class BarcodeResult` | `class BarcodeResultItem` | |
| 89 | + |
| 90 | +## Migrate Your Templates |
| 91 | + |
| 92 | +The template system is upgraded. The template you used for the previous version can't be directly recognized by the new version. Please <a href="https://download2.dynamsoft.com/dcv/TemplateConverter.zip" target="_blank">download the TemplateConverter tool</a> or <a href="https://www.dynamsoft.com/company/customer-service/#contact" target="_blank">contact us</a> to upgrade your template. |
| 93 | + |
| 94 | +The template-based APIs have been updated as follows: |
| 95 | + |
| 96 | +| Old APIs | New APIs | |
| 97 | +| :----------- | :------- | |
| 98 | +| `BarcodeReader.UpdateRuntimeSettings` | `CaptureVisionRouter.InitSettings` | |
| 99 | +| `BarcodeReader.ResetRuntimeSettings` | `CaptureVisionRouter.ResetRuntimeSettings` | |
| 100 | +| `BarcodeReader.OutputRuntimeSettingsToString` | `CaptureVisionRouter.OutputSettings` | |
| 101 | + |
| 102 | +## Migrate Your DBRPublicRuntimeSettings |
| 103 | + |
| 104 | +The class `DBRPublicRuntimeSettings` has been refactored. The APIs for accessing and updating `DBRPublicRuntimeSettings` has been adjusted as follows: |
| 105 | + |
| 106 | +| Old APIs | New APIs | |
| 107 | +| :----------- | :------- | |
| 108 | +| `BarcodeReader.GetRuntimeSettings` | `CaptureVisionRouter.GetSimplifiedSettings` | |
| 109 | +| `BarcodeReader.UpdateRuntimeSettings` | `CaptureVisionRouter.UpdateSettings` | |
| 110 | + |
| 111 | +### Migrate to SimplifiedCaptureVisionSettings |
| 112 | + |
| 113 | +The following properties are replaced by similar properties under `SimplifiedCaptureVisionSettings`. They can also be set via a template file(String). |
| 114 | + |
| 115 | +| PublicRuntimeSettings Property | SimplifiedCaptureVisionSettings Property | Template File Parameter | |
| 116 | +| ------------------------------- | ----------------------------------------- | ----------------------- | |
| 117 | +| `Timeout` | [`Timeout`]({{ site.dcv_maui_api }}capture-vision-router/auxiliary-classes/simplified-capture-vision-settings.html#timeout) | [`CaptureVisionTemplates.Timeout`]({{ site.dcvb_parameters_reference }}capture-vision-template/timeout.html?product=dbr) | |
| 118 | + |
| 119 | +### Migrate to SimplifiedBarcodeReaderSettings |
| 120 | + |
| 121 | +The following properties are replaced by similar properties under `SimplifiedBarcodeReaderSettings`. The majority of them can also be set via a template file(String). |
| 122 | + |
| 123 | +| PublicRuntimeSettings Property | SimplifiedBarcodeReaderSettings Property | Template File Parameter | |
| 124 | +| ------------------------------- | ----------------------------------------- | ----------------------- | |
| 125 | +| `MinBarcodeTextLength` | [`MinBarcodeTextLength`]({{ site.dbr_maui_api }}simplified-barcode-reader-settings.html#minbarcodetextlength) | [`BarcodeFormatSpecification.BarcodeTextLengthRangeArray`]({{ site.dcvb_parameters_reference }}barcode-format-specification/barcode-text-length-range-array.html?product=dbr) | |
| 126 | +| `MinResultConfidence` | [`MinResultConfidence`]({{ site.dbr_maui_api }}simplified-barcode-reader-settings.html#minresultconfidence) | [`BarcodeFormatSpecification.MinResultConfidence`]({{ site.dcvb_parameters_reference }}barcode-format-specification/min-result-confidence.html?product=dbr) | |
| 127 | +| `ExpectedBarcodesCount` | [`ExpectedBarcodesCount`]({{ site.dbr_maui_api }}simplified-barcode-reader-settings.html#expectedbarcodescount) | [`BarcodeReaderTaskSetting.ExpectedBarcodesCount`]({{ site.dcvb_parameters_reference }}barcode-reader-task-settings/expected-barcodes-count.html?product=dbr) | |
| 128 | +| `BarcodeFormatIds` | [`BarcodeFormatIds`]({{ site.dbr_maui_api }}simplified-barcode-reader-settings.html#barcodeformatids) | [`BarcodeReaderTaskSetting.BarcodeFormatIds`]({{ site.dcvb_parameters_reference }}barcode-reader-task-settings/barcode-format-ids.html?product=dbr) | |
| 129 | +| `BarcodeFormatIds_2` | [`BarcodeFormatIds`]({{ site.dbr_maui_api }}simplified-barcode-reader-settings.html#barcodeformatids) | [`BarcodeReaderTaskSetting.BarcodeFormatIds`]({{ site.dcvb_parameters_reference }}barcode-reader-task-settings/barcode-format-ids.html?product=dbr) | |
| 130 | + |
| 131 | +> Remarks: |
| 132 | +> |
| 133 | +> * The 2 groups of barcode formats are merged. |
0 commit comments