using System; using System.Collections.Generic; using System.Windows.Forms; using ShareWifi.Utils.Net; using ShareWifi.Views.Components; using ShareWifi.Model; using ShareWifi.Utils; namespace ShareWifi.Views { public partial class HomeControl : UserControl { WifiModel wifiModel; public HomeControl() { InitializeComponent(); } public static HomeControl getInstance() { return new HomeControl(); } private void btnGenerate_Click(object sender, EventArgs e) { if (showWifiinfo()) { //生成二维码 QRModel qRModel = QRUtils.genQR(wifiModel.getWifi()); picQR.Image = qRModel.QrData; } else { SimpleAlert simpleAlert = SimpleAlert.getInstance(); simpleAlert.Show("请链接 WIFI!"); lbPWD.Text = "null"; lbSSID.Text = "null"; picQR.Image = null; } } public bool showWifiinfo() { string ssid = WifiUtils.getSSID(); if (ssid != "" && ssid != null) { wifiModel = new WifiModel(); wifiModel.Ssid = ssid; //查找密码 wifiModel.Pwd = WifiUtils.getSSDIPassword(ssid); lbPWD.Text = wifiModel.Pwd; lbSSID.Text = wifiModel.Ssid; return true; } else { SimpleAlert simpleAlert = SimpleAlert.getInstance(); simpleAlert.Show("请链接 WIFI!"); return false; } } private void HomeControl_Load(object sender, EventArgs e) { showWifiinfo(); } } }