Merge "[Multimedia] Fixed errors in the doc-comments of Player and AudioIO."
[platform/core/csapi/tizenfx.git] / test / SampleTelephony / SimPage.cs
1 using System;
2 using System.Threading.Tasks;
3 using System.Collections.Generic;
4 using System.Linq;
5 using Xamarin.Forms;
6 using Tizen;
7 using Tizen.Telephony;
8
9 namespace XamarinForTizen.Tizen
10 {
11     public class SimPage : ContentPage
12     {
13         private static Sim _sim = null;
14         public SimPage()
15         {
16             var changedBtn = new Button
17             {
18                 Text = "Is sim changed",
19                 VerticalOptions = LayoutOptions.Start,
20                 HorizontalOptions = LayoutOptions.FillAndExpand
21             };
22             changedBtn.Clicked += changedBtn_Clicked;
23
24             var operatorBtn = new Button
25             {
26                 Text = "Get operator",
27                 VerticalOptions = LayoutOptions.Start,
28                 HorizontalOptions = LayoutOptions.FillAndExpand
29             };
30             operatorBtn.Clicked += operatorBtn_Clicked;
31
32             var iccIdBtn = new Button
33             {
34                 Text = "Get Icc id",
35                 VerticalOptions = LayoutOptions.Start,
36                 HorizontalOptions = LayoutOptions.FillAndExpand
37             };
38             iccIdBtn.Clicked += iccIdBtn_Clicked;
39
40             var msinBtn = new Button
41             {
42                 Text = "Get Msin",
43                 VerticalOptions = LayoutOptions.Start,
44                 HorizontalOptions = LayoutOptions.FillAndExpand
45             };
46             msinBtn.Clicked += msinBtn_Clicked;
47
48             Content = new StackLayout
49             {
50                 VerticalOptions = LayoutOptions.Center,
51                 Children = {
52                         changedBtn, operatorBtn, iccIdBtn, msinBtn
53                     }
54             };
55
56             try
57             {
58                 if (Globals.slotHandle == null)
59                 {
60                     Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles");
61                     return;
62                 }
63
64                 _sim = new Sim(Globals.slotHandle);
65             }
66
67             catch (Exception ex)
68             {
69                 Log.Debug(Globals.LogTag, "Exception in Sim constructor: " + ex.ToString());
70             }
71         }
72
73         private void msinBtn_Clicked(object sender, EventArgs e)
74         {
75             if (_sim == 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, "Msin: " + _sim.Msin);
82         }
83
84         private void iccIdBtn_Clicked(object sender, EventArgs e)
85         {
86             if (_sim == 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, "Icc id: " + _sim.IccId);
93         }
94
95         private void operatorBtn_Clicked(object sender, EventArgs e)
96         {
97             if (_sim == null)
98             {
99                 Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles");
100                 return;
101             }
102
103             Log.Debug(Globals.LogTag, "Operator: " + _sim.Operator);
104         }
105
106         private void changedBtn_Clicked(object sender, EventArgs e)
107         {
108             if (_sim == null)
109             {
110                 Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles");
111                 return;
112             }
113
114             Log.Debug(Globals.LogTag, "Is sim changed: " + _sim.IsChanged);
115         }
116     }
117 }