12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- 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();
- }
- }
- }
|