Révision e4b899ed

Voir les différences:

TestXamConnections/TestXamConnections/Device/Barcode/Honeywell/HoneywellInternReader.cs
59 59

  
60 60
        /// <summary>
61 61
        /// Lance un scan de code barre avec le lecteur Honeywell interne.
62
        /// Important : Il faut d'abord 
62 63
        /// </summary>
63 64
        /// <returns>true si le scan s'est lancé correctement, false sinon.</returns>
64 65
        public async Task<bool> StartScanAsync()
TestXamConnections/TestXamConnections/ViewModels/InternServiceViewModel.cs
1 1
using System;
2 2
using System.Threading.Tasks;
3 3
using System.Windows.Input;
4
using TestXamConnections.Device.Barcode;
4 5
using TestXamConnections.Device.RFID;
5 6
using TestXamConnections.Device.RFID.Agrident;
6 7
using TestXamConnections.Models;
......
10 11
{
11 12
    public class InternServiceViewModel : ViewModelBase
12 13
    {
13
        private readonly IRFIDReader agridentReader;
14
        private IRFIDReader agridentReader;
15
        private IBarcodeReader honeyWellReader;
14 16

  
15 17
        private bool isScanning;
18

  
16 19
        private bool showRFID;
17
        private bool showError;
18 20
        private string rfidResult;
21
        private bool showBarcode;
22
        private string barcodeResult;
23

  
24
        private bool showError;
19 25
        private string errorMessage;
20 26

  
21 27
        public bool ShowRFID
......
24 30
            set => SetProperty(ref showRFID, value);
25 31
        }
26 32

  
33
        public bool ShowBarcode
34
        {
35
            get => showBarcode;
36
            set => SetProperty(ref showBarcode, value);
37
        }
38

  
27 39
        public bool ShowError
28 40
        {
29 41
            get => showError;
......
42 54
            set => SetProperty(ref rfidResult, value);
43 55
        }
44 56

  
57
        public string BarcodeResult
58
        {
59
            get => barcodeResult;
60
            set => SetProperty(ref barcodeResult, value);
61
        }
62

  
45 63
        public string ErrorMessage
46 64
        {
47 65
            get => errorMessage;
48 66
            set => SetProperty(ref errorMessage, value);
49 67
        }
50 68

  
51
        private async Task StartScan()
69
        private async Task StartScanRFID()
52 70
        {
53 71
            IsScanning = true;
54 72
            if (await agridentReader.StartScanAsync() == false)
......
58 76
            }
59 77
        }
60 78

  
61
        public ICommand StartScanCommand { private set; get; }
79
        public ICommand StartScanRFIDCommand { private set; get; }
62 80

  
63
        public InternServiceViewModel()
81
        private async Task StartScanBarcode()
82
        {
83
            IsScanning = true;
84
            if (await honeyWellReader.StartScanAsync() == false)
85
            {
86
                ShowError = true;
87
                ErrorMessage = "Service barcode non trouvé";
88
            }
89
        }
90

  
91
        public ICommand StartScanBarcodeCommand { private set; get; }
92

  
93
        public void Init()
64 94
        {
65 95
            ShowRFID = false;
66 96
            ShowError = false;
67 97
            RFIDResult = "";
68 98
            ErrorMessage = "";
69
            agridentReader = RFIDReaderProvider.GetRFIDReader(RFIDDevice.AgridentIntern, Connection.ConnectionType.Intern, new Device.DeviceInfo()) ;
99
            StartScanRFIDCommand = new Command(async () => await StartScanRFID());
100
            StartScanBarcodeCommand = new Command(async () => await StartScanBarcode());
101
            agridentReader = RFIDReaderProvider.GetRFIDReader(RFIDDevice.AgridentIntern, Connection.ConnectionType.Intern, new Device.DeviceInfo());
70 102
            agridentReader.RFIDDataReceivedEvent += OnRFIDResultReceived;
71
            bool err = agridentReader.EnableServiceAsync().Result;
72
            StartScanCommand = new Command(async () => await StartScan());
103
            honeyWellReader = BarcodeReaderProvider.GetBarcodeReader(BarcodeDevice.HoneywellIntern, Connection.ConnectionType.Intern, new Device.DeviceInfo());
104
            honeyWellReader.BarcodeDataReceivedEvent += OnBarcodeResultReceived;
105
            agridentReader.EnableServiceAsync().Wait();
106
            honeyWellReader.EnableServiceAsync().Wait();
107
        }
108

  
109
        public InternServiceViewModel()
110
        {
111
            Init();
73 112
        }
74 113

  
114
        
115

  
75 116
        private void ResetAffichage()
76 117
        {
77 118
            ShowError = false;
78 119
            ShowRFID = false;
120
            ShowBarcode = false;
79 121
        }
80 122

  
81 123
        private void OnRFIDResultReceived(object sender, ReponseRFID reponseRFID)
......
92 134
            }
93 135
            IsScanning = false;
94 136
        }
137

  
138
        private void OnBarcodeResultReceived(object sender, string reponseBarcode)
139
        {
140
            ResetAffichage();
141
            ShowBarcode = true;
142
            BarcodeResult = reponseBarcode;
143
            IsScanning = false;
144
        }
95 145
    }
96 146
}
TestXamConnections/TestXamConnections/Views/AccueilView.xaml
127 127
                            FontSize="18"
128 128
                            HorizontalOptions="CenterAndExpand"
129 129
                            HorizontalTextAlignment="Center"
130
                            Text="Connection Interne"
130
                            Text="Services internes"
131 131
                            TextColor="White"
132 132
                            VerticalOptions="CenterAndExpand" />
133 133

  
TestXamConnections/TestXamConnections/Views/InternServiceView.xaml
3 3
    x:Class="TestXamConnections.Views.InternServiceView"
4 4
    xmlns="http://xamarin.com/schemas/2014/forms"
5 5
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
6
    xmlns:xe="clr-namespace:XamEffects;assembly=XamEffects">
6
    xmlns:xe="clr-namespace:XamEffects;assembly=XamEffects"
7
    Title="Services internes">
7 8
    <ContentPage.Content>
8 9

  
9 10
        <StackLayout BackgroundColor="#001729" VerticalOptions="FillAndExpand">
10 11
            <Grid VerticalOptions="FillAndExpand">
11 12
                <StackLayout Spacing="15" VerticalOptions="CenterAndExpand">
12 13

  
14
                    <!--#region SCANRFID-->
13 15
                    <xe:BorderView
14 16
                        Margin="0,20,0,0"
15
                        xe:Commands.Tap="{Binding StartScanCommand}"
17
                        xe:Commands.Tap="{Binding StartScanRFIDCommand}"
16 18
                        xe:TouchEffect.Color="#0060a8"
17 19
                        BackgroundColor="#003266"
18 20
                        CornerRadius="65"
......
59 61
                                TextColor="White" />
60 62
                        </StackLayout>
61 63
                    </Frame>
64
                    <!--#endregion-->
62 65

  
66
                    <!--#region SCAN BARCODE-->
67
                    <xe:BorderView
68
                        Margin="0,20,0,0"
69
                        xe:Commands.Tap="{Binding StartScanBarcodeCommand}"
70
                        xe:TouchEffect.Color="#0060a8"
71
                        BackgroundColor="#003266"
72
                        CornerRadius="65"
73
                        HorizontalOptions="Center">
74
                        <StackLayout Padding="15,10">
75
                            <Label
76
                                FontSize="Medium"
77
                                HorizontalOptions="Center"
78
                                HorizontalTextAlignment="Center"
79
                                Text="Scan Barcode"
80
                                TextColor="#34a9ff" />
81
                        </StackLayout>
82
                    </xe:BorderView>
83

  
84
                    <Frame
85
                        Padding="0"
86
                        BackgroundColor="Transparent"
87
                        BorderColor="#4f5a64"
88
                        CornerRadius="5"
89
                        HasShadow="False"
90
                        HorizontalOptions="Center"
91
                        IsVisible="{Binding ShowBarcode}"
92
                        VerticalOptions="CenterAndExpand"
93
                        WidthRequest="200">
94
                        <StackLayout Spacing="0">
95
                            <Label
96
                                Margin="15"
97
                                FontSize="15"
98
                                HorizontalTextAlignment="Center"
99
                                Text="RFID Scanné"
100
                                TextColor="#34a9ff" />
101

  
102
                            <BoxView
103
                                HeightRequest="1"
104
                                HorizontalOptions="FillAndExpand"
105
                                Color="#4f5a64" />
106

  
107
                            <Label
108
                                Margin="0,10"
109
                                FontAttributes="Bold"
110
                                FontSize="17"
111
                                HorizontalTextAlignment="Center"
112
                                Text="{Binding BarcodeResult}"
113
                                TextColor="White" />
114
                        </StackLayout>
115
                    </Frame>
116
                    <!--#endregion-->
117

  
118
                    <!--#region ERROR-->
63 119
                    <Frame
64 120
                        Padding="0"
65 121
                        BackgroundColor="Transparent"
......
92 148
                                TextColor="RED" />
93 149
                        </StackLayout>
94 150
                    </Frame>
151
                    <!--#endregion-->
95 152

  
96 153
                </StackLayout>
97 154
                <Grid

Formats disponibles : Unified diff