📄 withe.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WiThe
{
public partial class WiThe : Form
{
Timer Clock;
public WiThe()
{
InitializeComponent();
}
private void btnScan_Click(object sender, EventArgs e)
{
Clock = new Timer();
//Every second
Clock.Interval = 1000;
Clock.Enabled = true;
//贩贩贩贩贩贩贩贩贩贩贩贩贩贩贩贩贩
// This secction is only to develop with emulator, It's will delete in the final version
//贩贩贩贩贩贩贩贩贩贩贩贩贩贩贩贩贩
if (OpenNETCF.Net.Networking.GetAdapters().Count != 0)
//If try WiThe in PDA
Clock.Tick += new System.EventHandler(scanInPDA);
else
//If try WiThe in Emulator WM5
Clock.Tick += new System.EventHandler(scanInEmulator);
//贩贩贩贩贩贩贩贩贩贩贩贩贩贩贩贩贩
}
/// <summary>
/// This is the function to try in the PDA. It's scan the ESSID and it send to ListView
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void scanInPDA(object sender, System.EventArgs e)
{
OpenNETCF.Net.Adapter wlan;
OpenNETCF.Net.AccessPointCollection aps;
//OpenNETCF.Net.AccessPoint ap;
txtInterface.Text = "";
lstNetworks.Items.Clear();
try
{
foreach (OpenNETCF.Net.Adapter wlanTemp in OpenNETCF.Net.Networking.GetAdapters())
{
if (wlanTemp.IsWireless)
{
wlan = wlanTemp;
txtInterface.Text = "INTERFACE: " + wlanTemp.Name;
//Se llama TIACXWLN1
aps = wlan.NearbyAccessPoints;
for (int i = 0; i < 15; i++)
{
if (aps.Count > 0)
{
break; //We found one AP !!
}
aps = wlan.NearbyAccessPoints; //If not found , we scan again
}
foreach (OpenNETCF.Net.AccessPoint AP in aps)
{
// ListViewItem essid =new ListViewItem(AP.Name.ToString());
//ListViewItem signal = new ListViewItem(AP.SignalStrengthInDecibels.ToString());
ListViewItem nodo = new ListViewItem(AP.Name.ToString());
nodo.SubItems.Add(AP.Privacy.ToString());
nodo.SubItems.Add((100 + AP.SignalStrengthInDecibels).ToString());
nodo.SubItems.Add(BitConverter.ToString(AP.MacAddress).Replace("-", ""));
//Add the network to the list
lstNetworks.Items.Add(nodo);
}
}//End if ifaces detection
else
txtInterface.Text = "NO WIFI INTERFACE";
}//end forech
}
catch (Exception ex)
{
Console.WriteLine("{0} Exception caught.", ex) ;
}
}//End funtion scanInPDA()
/// <summary>
/// This funcion only work in the emulator, this function will delete in the final version
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void scanInEmulator(object sender, System.EventArgs e)
{
txtInterface.Text = "IFace simlated (scanning ...)";
lstNetworks.Items.Clear();
for (int i = 0; i < 10; i++)
{
Random rand = new Random();
ListViewItem nodo = new ListViewItem("Node"+i.ToString ());
nodo.SubItems.Add(rand.Next (0,2).ToString ());
nodo.SubItems.Add(rand.Next(0, 11).ToString() + rand.Next(0, 10).ToString());
nodo.SubItems.Add("00:00:00:00:00:"+rand.Next (0,10).ToString ()+rand.Next (0,10).ToString ());
//Add the network to the list
lstNetworks.Items.Add(nodo);
rand = null;
}
}//End funtion scanInEmulator()
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -