diff --git a/Drcom/MainWindow.xaml b/Drcom/MainWindow.xaml
index eab8ec9..529dbed 100644
--- a/Drcom/MainWindow.xaml
+++ b/Drcom/MainWindow.xaml
@@ -19,7 +19,7 @@
-
+
diff --git a/Drcom/MainWindow.xaml.cs b/Drcom/MainWindow.xaml.cs
index b98ce44..e0b1c02 100644
--- a/Drcom/MainWindow.xaml.cs
+++ b/Drcom/MainWindow.xaml.cs
@@ -13,9 +13,12 @@ public partial class MainWindow : Window
public MainWindow()
{
InitializeComponent();
- if (Setting.GetSetting("nip") != "")
+ if (Setting.GetSetting("nip") == "")
+ {
+ GetIp.IsChecked = true;
+ }
+ else
{
- SaveIp.IsChecked = true;
TextIp.Text = Setting.GetSetting("nip");
}
if (Setting.GetSetting("uid") != "")
@@ -38,11 +41,13 @@ private void LoginNet(object sender, RoutedEventArgs e)
string uid = TextUid.Text;
string pwd = TextPwd.Password;
- //保存ip账号密码
- if (SaveIp.IsChecked == true)
+ //获取登陆IP
+ if (GetIp.IsChecked == true)
{
- Setting.UpdateSetting("nip", nip);
+ TextIp.Text = CsuNet.LoginIP();
}
+ //保存IP,账号和密码
+ Setting.UpdateSetting("nip", nip);
if (SaveUid.IsChecked == true)
{
Setting.UpdateSetting("uid", uid);
@@ -60,6 +65,12 @@ private void LoginNet(object sender, RoutedEventArgs e)
//注销按钮
private void LogoutNet(object sender, RoutedEventArgs e)
{
+ //获取登陆IP
+ if (GetIp.IsChecked == true)
+ {
+ TextIp.Text = CsuNet.LoginIP();
+ }
+
string nip = TextIp.Text;
var relust = CsuNet.LogoutCsuNet(nip);
diff --git a/Drcom/Properties/AssemblyInfo.cs b/Drcom/Properties/AssemblyInfo.cs
index 0dce9aa..c74263e 100644
--- a/Drcom/Properties/AssemblyInfo.cs
+++ b/Drcom/Properties/AssemblyInfo.cs
@@ -51,5 +51,5 @@
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("0.0.1.0")]
-[assembly: AssemblyFileVersion("0.0.1.0")]
+[assembly: AssemblyVersion("0.1.0.0")]
+[assembly: AssemblyFileVersion("0.1.0.0")]
diff --git a/Drcom/net/CsuNet.cs b/Drcom/net/CsuNet.cs
index 879bc9b..6078925 100644
--- a/Drcom/net/CsuNet.cs
+++ b/Drcom/net/CsuNet.cs
@@ -9,6 +9,38 @@ namespace Drcom.net
{
public class CsuNet
{
+ //获取登陆IP
+ public static string LoginIP()
+ {
+ try
+ {
+ HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://www.qq.com/");
+ HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
+ Stream stream = resp.GetResponseStream();
+ //获取响应内容
+ using (StreamReader reader = new StreamReader(stream, Encoding.ASCII))
+ {
+ string result = reader.ReadToEnd();
+
+ if (result.Contains("v4serip"))
+ {
+ string[] Fnip = Regex.Split(result, "v4serip='", RegexOptions.IgnoreCase);
+ string[] nip = Regex.Split(Fnip[1], "'", RegexOptions.IgnoreCase);
+ return nip[0];
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ return null;
+ }
+ }
+
+
//登陆
public static string LoginCsuNet(string nip, string uid, string pwd)
{
@@ -62,7 +94,7 @@ public static string LogoutCsuNet(string nip)
//获取响应内容
using (StreamReader reader = new StreamReader(stream, Encoding.ASCII))
{
- var result = reader.ReadToEnd();
+ string result = reader.ReadToEnd();
return LoginCaes(result);
}
}