Merge "[MediaContent] Fixed wrong formats in the doc-comments."
[platform/core/csapi/tizenfx.git] / test / SampleTelephony / NetworkPage.cs
1 using System;
2 using Xamarin.Forms;
3 using Tizen;
4 using Tizen.Telephony;
5
6 namespace XamarinForTizen.Tizen
7 {
8     public class NetworkPage : ContentPage
9     {
10         private static Network _network = null;
11         public NetworkPage()
12         {
13             var cellBtn = new Button
14             {
15                 Text = "Get cell ID",
16                 VerticalOptions = LayoutOptions.Start,
17                 HorizontalOptions = LayoutOptions.FillAndExpand
18             };
19             cellBtn.Clicked += cellBtn_Clicked;
20
21             var lacBtn = new Button
22             {
23                 Text = "Get LAC",
24                 VerticalOptions = LayoutOptions.Start,
25                 HorizontalOptions = LayoutOptions.FillAndExpand
26             };
27             lacBtn.Clicked += lacBtn_Clicked;
28
29             var mccBtn = new Button
30             {
31                 Text = "Get Mcc",
32                 VerticalOptions = LayoutOptions.Start,
33                 HorizontalOptions = LayoutOptions.FillAndExpand
34             };
35             mccBtn.Clicked += mccBtn_Clicked;
36
37             var mncBtn = new Button
38             {
39                 Text = "Get Mnc",
40                 VerticalOptions = LayoutOptions.Start,
41                 HorizontalOptions = LayoutOptions.FillAndExpand
42             };
43             mncBtn.Clicked += mncBtn_Clicked;
44
45             Content = new StackLayout
46             {
47                 VerticalOptions = LayoutOptions.Center,
48                 Children = {
49                         cellBtn, lacBtn, mccBtn, mncBtn
50                     }
51             };
52
53             try
54             {
55                 if (Globals.slotHandle == null)
56                 {
57                     Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles");
58                     return;
59                 }
60
61                 _network = new Network(Globals.slotHandle);
62             }
63
64             catch (Exception ex)
65             {
66                 Log.Debug(Globals.LogTag, "Exception in network constructor: " + ex.ToString());
67             }
68         }
69
70         private void mncBtn_Clicked(object sender, EventArgs e)
71         {
72             if (_network == null)
73             {
74                 Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles");
75                 return;
76             }
77
78             Log.Debug(Globals.LogTag, "Mnc: " + _network.Mnc);
79         }
80
81         private void mccBtn_Clicked(object sender, EventArgs e)
82         {
83             if (_network == null)
84             {
85                 Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles");
86                 return;
87             }
88
89             Log.Debug(Globals.LogTag, "Mcc: " + _network.Mcc);
90         }
91
92         private void lacBtn_Clicked(object sender, EventArgs e)
93         {
94             if (_network == null)
95             {
96                 Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles");
97                 return;
98             }
99
100             Log.Debug(Globals.LogTag, "Lac: " + _network.Lac);
101         }
102
103         private void cellBtn_Clicked(object sender, EventArgs e)
104         {
105             if (_network == null)
106             {
107                 Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles");
108                 return;
109             }
110
111             Log.Debug(Globals.LogTag, "Cell ID: " + _network.CellId);
112         }
113     }
114 }