public class AP : INotifyPropertyChanged\r
{\r
string iconDir = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "icon.png";\r
- string infoIconDir = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "icon.png";\r
private string essid;\r
private string state;\r
- private string stateText;\r
+\r
public event PropertyChangedEventHandler PropertyChanged;\r
\r
private void OnPropertyChanged(string propertyName)\r
public AP(string apEssid, string apState)\r
{\r
essid = apEssid;\r
- stateText = apState;\r
+ state = apState;\r
}\r
\r
public string Essid\r
OnPropertyChanged("State");\r
}\r
}\r
-\r
- public string StateText\r
- {\r
- get\r
- {\r
- return stateText;\r
- }\r
- set\r
- {\r
- stateText = value;\r
- OnPropertyChanged("StateText");\r
- }\r
- }\r
-\r
- public string Info\r
- {\r
- get\r
- {\r
- return infoIconDir;\r
- }\r
- }\r
};\r
\r
-\r
public class DeviceCollection : ObservableCollection<AP>\r
{\r
private string title;\r
\r
public void UpdateScanList(List<AP> apList)\r
{\r
- Log.Debug(Program.LogTag, "UpdateDevices");\r
if (apList == null)\r
{\r
Log.Debug(Program.LogTag, "apList is null");\r
\r
foreach (var item in apList)\r
{\r
- this.Add(new AP(item.Essid, item.StateText));\r
+ this.Add(new AP(item.Essid, item.State));\r
}\r
}\r
\r
this.Add(available);\r
Log.Debug(Program.LogTag, "Add DeviceCollection");\r
}\r
- public void UpdateDevices(List<AP> apList)\r
+ public void UpdateScanList(List<AP> apList)\r
{\r
available.UpdateScanList(apList);\r
}\r
foreach (var item in apList)\r
{\r
Log.Debug(Program.LogTag, "AP name: " + item.NetworkInformation.Essid);\r
- //Log.Debug(LogTag, "Connection state: " + item.NetworkInformation.ConnectionState);\r
- apInfoList.Add(new AP(item.NetworkInformation.Essid, item.NetworkInformation.ConnectionState.ToString()));\r
+ Log.Debug(Program.LogTag, "AP connection state: " + item.NetworkInformation.ConnectionState.ToString());\r
+\r
+ string connectionState = item.NetworkInformation.ConnectionState.ToString();\r
+ string securityType = item.SecurityInformation.SecurityType.ToString();\r
+ //bool isPassphraseRequired = item.SecurityInformation.IsPassphraseRequired;\r
+ bool isWpsSupported = item.SecurityInformation.IsWpsSupported;\r
+\r
+ if (item.NetworkInformation.ConnectionState.ToString().Equals("Connected"))\r
+ {\r
+ apInfoList.Add(new AP(item.NetworkInformation.Essid, "Connected"));\r
+ continue;\r
+ }\r
+ string text = "";\r
+\r
+ if (securityType.Equals("None"))\r
+ {\r
+ text = "Open";\r
+ }\r
+ else if (securityType.Equals("Eap"))\r
+ {\r
+ text = "Secured (Eap)";\r
+ }\r
+ else if (isWpsSupported)\r
+ {\r
+ text = "Secured (WPS available)";\r
+ }\r
+ else\r
+ {\r
+ text = "Secured";\r
+ }\r
+\r
+ apInfoList.Add(new AP(item.NetworkInformation.Essid, text));\r
}\r
\r
return apInfoList;\r
ItemsLayouter = new LinearLayouter(),\r
ItemTemplate = new DataTemplate(() =>\r
{\r
- DefaultLinearItem item = new DefaultLinearItem();\r
- item.WidthSpecification = LayoutParamPolicies.MatchParent;\r
+ DefaultLinearItem item = new DefaultLinearItem() //itemÀÌ °¢ AP\r
+ {\r
+ WidthSpecification = LayoutParamPolicies.MatchParent,\r
+ };\r
item.Label.SetBinding(TextLabel.TextProperty, "Essid");\r
-\r
item.Label.HorizontalAlignment = HorizontalAlignment.Begin;\r
- item.SubLabel.SetBinding(TextLabel.TextProperty, "StateText");\r
-\r
+ item.SubLabel.SetBinding(TextLabel.TextProperty, "State");\r
item.SubLabel.HorizontalAlignment = HorizontalAlignment.Begin;\r
item.Icon.SetBinding(ImageView.ResourceUrlProperty, "ImageUrl");\r
item.Icon.WidthSpecification = 40;\r
item.Icon.HeightSpecification = 40;\r
\r
+ var infoButton = new Button()\r
+ {\r
+ Text = "i",\r
+ WidthSpecification = 40,\r
+ HeightSpecification = 40,\r
+ };\r
+ //infoButton.Icon.SetBinding(ImageView.ResourceUrlProperty, "InfoImageUrl");\r
+ infoButton.Clicked += OnInfoButtonClicked;\r
+ item.Extra = infoButton;\r
+\r
return item;\r
}),\r
GroupHeaderTemplate = new DataTemplate(() =>\r
return page;\r
}\r
\r
- private ContentPage CreateInfoPage()\r
+ private ContentPage CreateInfoPage(AP ap)\r
{\r
var appBar = new AppBar()\r
{\r
WidthSpecification = 300,\r
HeightSpecification = 80,\r
};\r
- forgetButton.Clicked += OnforgetButtonClicked;\r
+\r
+ forgetButton.Clicked += (object source, ClickedEventArgs args) =>\r
+ {\r
+ Log.Debug(Program.LogTag, "Forget " + ap.Essid);\r
+ wifi.Forget(ap.Essid);\r
+ ScanAP();\r
+ };\r
\r
infoView.Add(forgetButton);\r
ContentPage page = new ContentPage()\r
apSource = new APSource();\r
\r
mainPage = CreateMainPage();\r
- infoPage = CreateInfoPage();\r
morePage = CreatemorePage();\r
\r
navigator.Push(mainPage);\r
ScanAP();\r
}\r
\r
- private void OnforgetButtonClicked(object sender, ClickedEventArgs e)\r
+ private void OnInfoButtonClicked(object sender, ClickedEventArgs e)\r
{\r
- Log.Debug(Program.LogTag, "OnforgetButtonClicked");\r
- //wifi.Forget(essid);\r
+ Log.Debug(Program.LogTag, "OnInfoButtonClicked");\r
+ Button button = (Button)sender;\r
+ infoPage = CreateInfoPage(button.BindingContext as AP);\r
+ navigator.Push(infoPage);\r
}\r
\r
private bool IsWiFiActive()\r
{\r
await wifi.Scan();\r
List<AP> apList = wifi.GetScanResult();\r
- apSource.UpdateDevices(apList);\r
+ apSource.UpdateScanList(apList);\r
}\r
}\r
\r
public async void OnScanListSelected(object sender, SelectionChangedEventArgs ev)\r
{\r
- /* TODO: disable to click the connected ap */\r
-\r
-\r
-\r
//SingleSelection Only have 1 or nil object in the list.\r
foreach (object item in ev.PreviousSelection)\r
{\r
if (item == null) break;\r
- if (item is AP device)\r
+ if (item is AP ap)\r
{\r
//Log.Debug(LogTag, "Disconnect ");\r
//await wifi.Disconnect(device.Essid);\r
foreach (object item in ev.CurrentSelection)\r
{\r
if (item == null) break;\r
- if (item is AP device)\r
+ if (item is AP ap)\r
{\r
- if (device.StateText.Equals("Connected"))\r
+ if (ap.State.Equals("Connected"))\r
{\r
Log.Debug(Program.LogTag, "already connected");\r
return;\r
}\r
\r
- Log.Debug(Program.LogTag, "new connect"); /* TODO: pop-up(password, cancel, connect) */\r
- device.StateText = "Connecting";\r
- await wifi.Connect(device.Essid, "datanetwork");\r
- if(wifi.GetConnectedAP().Equals(device.Essid))\r
+ /* TODO: pop-up (password, cancel, connect) */\r
+ ap.State = "Connecting";\r
+ await wifi.Connect(ap.Essid, "datanetwork");\r
+ if(wifi.GetConnectedAP().Equals(ap.Essid))\r
{\r
- device.StateText = "Connected";\r
-\r
+ ap.State = "Connected";\r
}\r
// device.Connected = true;\r
// device.Registered = true;\r