[EflSharp] Update Circle and efl cs files (#995)
[platform/core/csapi/tizenfx.git] / test / SampleTelephony / ModemPage.cs
1 using System;
2 using Xamarin.Forms;
3 using Tizen;
4 using Tizen.Telephony;
5
6 namespace XamarinForTizen.Tizen
7 {
8     public class ModemPage : ContentPage
9     {
10         private static Modem _modem = null;
11         public ModemPage()
12         {
13             var imeiBtn = new Button
14             {
15                 Text = "Get IMEI",
16                 VerticalOptions = LayoutOptions.Start,
17                 HorizontalOptions = LayoutOptions.FillAndExpand
18             };
19             imeiBtn.Clicked += imeiBtn_Clicked;
20
21             var powerBtn = new Button
22             {
23                 Text = "Get power status",
24                 VerticalOptions = LayoutOptions.Start,
25                 HorizontalOptions = LayoutOptions.FillAndExpand
26             };
27             powerBtn.Clicked += powerBtn_Clicked;
28
29             var meidBtn = new Button
30             {
31                 Text = "Get MEID",
32                 VerticalOptions = LayoutOptions.Start,
33                 HorizontalOptions = LayoutOptions.FillAndExpand
34             };
35             meidBtn.Clicked += meidBtn_Clicked;
36
37             Content = new StackLayout
38             {
39                 VerticalOptions = LayoutOptions.Center,
40                 Children = {
41                         imeiBtn, powerBtn, meidBtn
42                     }
43             };
44
45             try
46             {
47                 if (Globals.slotHandle == null)
48                 {
49                     Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles");
50                     return;
51                 }
52
53                 _modem = new Modem(Globals.slotHandle);
54             }
55
56             catch (Exception ex)
57             {
58                 Log.Debug(Globals.LogTag, "Exception in modem constructor: " + ex.ToString());
59             }
60         }
61
62         private void meidBtn_Clicked(object sender, EventArgs e)
63         {
64             if (_modem == null)
65             {
66                 Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles");
67                 return;
68             }
69
70             Log.Debug(Globals.LogTag, "MEID: " + _modem.Meid);
71         }
72
73         private void powerBtn_Clicked(object sender, EventArgs e)
74         {
75             if (_modem == null)
76             {
77                 Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles");
78                 return;
79             }
80
81             Log.Debug(Globals.LogTag, "Power Status: " + _modem.CurrentPowerStatus);
82         }
83
84         private void imeiBtn_Clicked(object sender, EventArgs e)
85         {
86             if (_modem == null)
87             {
88                 Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles");
89                 return;
90             }
91
92             Log.Debug(Globals.LogTag, "IMEI: " + _modem.Imei);
93         }
94     }
95 }