//加载 private void FormLogin_Load(object sender, EventArgs e) { //登录前Cookie: //pgv_pvi=3632438272; //Hm_lvt_204fcf6777f8efa834fe7c45a2336bf1=1421482609,1421483194; //mp_fbfbacb18f1ac527ede6ca993f5fbb18_mixpanel=%7B%22distinct_id%22%3A%20%2214b8710c26d147-0b66ecf27-464c0021-100200-14b8710c26e11a%22%2C%22%24initial_referrer%22%3A%20%22%24direct%22%2C%22%24initial_referring_domain%22%3A%20%22%24direct%22%7D; //PORTAL_SESSION=MTdKVkNXRzVTVVc3R1hZUFBBTVNEQlgwMU5NQ1pYN1IsMTQyNDE2NjY0ODIxNTI5MDc3MyxjNDc1NDMzNDljZTgwMTFkZDRhOGQ0MDNkZjMyNTkxMGM1YTkxMjRh; //_ga=GA1.2.1889280735.1414002006; //pgv_si=s1256732672; //PORTAL_FLASH= //登录后Cookie: //pgv_pvi=3632438272; //Hm_lvt_204fcf6777f8efa834fe7c45a2336bf1=1421482609,1421483194; //mp_fbfbacb18f1ac527ede6ca993f5fbb18_mixpanel=%7B%22distinct_id%22%3A%20%2214b8710c26d147-0b66ecf27-464c0021-100200-14b8710c26e11a%22%2C%22%24initial_referrer%22%3A%20%22%24direct%22%2C%22%24initial_referring_domain%22%3A%20%22%24direct%22%7D; //PORTAL_SESSION=MTdKVkNXRzVTVVc3R1hZUFBBTVNEQlgwMU5NQ1pYN1IsMTQyNDE2NjY0ODIxNTI5MDc3MyxjNDc1NDMzNDljZTgwMTFkZDRhOGQ0MDNkZjMyNTkxMGM1YTkxMjRh; //pgv_si=s1256732672; //_ga=GA1.2.1889280735.1414002006; //_utm_uidn=true; //PORTAL_FLASH=%00username%3A178910432%40qq.com%00 this.Opacity = 0.01; My.ResetWebbrowser(); webBrowser1.Navigate("http://portal.qiniu.com/signin"); timer1.Enabled = true; }
public CheckInternet1() { MyThread = new Thread(new ThreadStart(delegate { string Temp = ""; Temp = My.GetWebCodeByWebRequest("http://www.baidu.com/img/bdlogo.png"); if (Temp == "") { Temp = My.GetWebCodeByWebRequest("http://www.baidu.com/img/bdlogo.png"); } if (Temp == "") { Temp = My.GetWebCodeByWebRequest("http://www.baidu.com/img/bdlogo.png"); } if (Temp == "") { My.LoadingForm.TopMost = true; My.LoadingForm.TopMost = false; if (MessageBox.Show("网络连接错误,请检查网络设置。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) == DialogResult.OK) { Application.Exit(); } } //else { My.Show(Temp.Length); } //5KB try { My.LoadingForm.Invoke(new FormLoading.UIDelegate(DelegateMethod)); } catch (Exception) { } finally { MyThread.Abort(); } } )); MyThread.IsBackground = true; MyThread.Start(); }
private void PictureButton_MouseEnter(object sender, EventArgs e) { this.BackgroundImage = this.ImageMouseHower; this.Height += this.MouseHowerSize; this.Width += this.MouseHowerSize; this.Left -= this.MyHalfStretchSize1; this.Top -= this.MyHalfStretchSize1; try { (new SoundPlayer(My.ResourcesStream("hower.wav"))).Play(); } catch (Exception) { } }
private void PictureButton_MouseDown(object sender, MouseEventArgs e) { this.BackgroundImage = this.ImageMouseDown; this.Height -= this.MouseDownSize; this.Width -= this.MouseDownSize; this.Left += this.MyHalfStretchSize2; this.Top += this.MyHalfStretchSize2; try { (new SoundPlayer(My.ResourcesStream("down.wav"))).Play(); } catch (Exception) { } }
public static void WriteGBKString(string ResourceString, string NewFilePath) { try { StreamWriter SA = new StreamWriter(NewFilePath, false, System.Text.Encoding.GetEncoding("gbk")); SA.Write(ResourceString); SA.Dispose(); } catch (Exception EX) { My.Show(EX); } }
//删除选中的文件 private void toolStripMenuItem2_Click(object sender, EventArgs e) { System.Windows.Forms.DialogResult Temp = MessageBox.Show( "是否要在七牛云上永久删除选中的全部文件?删除后不可恢复,请谨慎操作。", "删除确认", MessageBoxButtons.OKCancel, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1 ); if (Temp == System.Windows.Forms.DialogResult.OK) { Int32 selectedRowCount = dataGridView1.Rows.GetRowCount(DataGridViewElementStates.Selected); if (selectedRowCount > 0) { Byte[] TempBytes = System.Text.Encoding.UTF8.GetBytes("bucket"); My.CombineArray(ref TempBytes, System.Text.Encoding.ASCII.GetBytes("=")); My.CombineArray(ref TempBytes, System.Text.Encoding.UTF8.GetBytes(My.LoginedBuckets[ChosenButtomIndex].Name)); Int32 Temp2 = selectedRowCount; for (int i = 0; i < Temp2; i++) { if (dataGridView1.SelectedRows[i].Cells[0].Value != null) { My.CombineArray(ref TempBytes, System.Text.Encoding.ASCII.GetBytes("&")); My.CombineArray(ref TempBytes, System.Text.Encoding.UTF8.GetBytes("keys[]")); My.CombineArray(ref TempBytes, System.Text.Encoding.ASCII.GetBytes("=")); My.CombineArray(ref TempBytes, System.Text.Encoding.UTF8.GetBytes(dataGridView1.SelectedRows[i].Cells[0].Value.ToString())); } else { selectedRowCount = selectedRowCount - 1;//选中了末尾的空行 } } if (selectedRowCount > 0) { My.MainForm.label2.Text = "正在删除共计" + selectedRowCount + "个文件……"; My.MainForm.Refresh(); My.LoginForm.webBrowser1.Navigate( "https://portal.qiniu.com/bucket/moonlord/files/0/delete?bucket=" + My.LoginedBuckets[ChosenButtomIndex].Name, null, TempBytes, "Content-Type:application/x-www-form-urlencoded; charset=UTF-8\r\nReferer:https://portal.qiniu.com/bucket/\r\n" ); } } } }
//删除文件 private void CheckDeleteFile() { if (webBrowser1.Url != null && webBrowser1.ReadyState == WebBrowserReadyState.Complete && webBrowser1.Url.ToString().Contains("https://portal.qiniu.com/bucket/moonlord/files/0/delete?bucket=")) { if (webBrowser1.DocumentText.Contains("\"failed_keys\":[]")) { My.Show("所有选中的文件都成功删除。"); } else { My.Show("选中的部分文件删除失败。"); } My.MainForm.FormMainButton_Click(My.MainForm.FormMainButton[My.MainForm.ChosenButtomIndex], new EventArgs()); } }
//设置IE浏览器的默认解析方法 public static void ResetWebbrowser() { //Show(MyProjectName); try//32位设置 { RegistryKey RK = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION", true); RK.SetValue(MyProjectName + ".exe", 10000);//默认IE10,然后按照网页上!DOCTYPE指令来显示网页 //RK.SetValue("YourApplication.exe", 10001);//强制IE10 //IE9:9000或9999 //My.Show(RK.GetValue(MyProjectName+ ".exe").ToString()); RK.Close(); } catch (Exception EX) { My.Show(EX); } try//64位设置 { RegistryKey RK = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION", true); RK.SetValue(MyProjectName + ".exe", 10000);//默认IE10,然后按照网页上!DOCTYPE指令来显示网页 //RK.SetValue("YourApplication.exe", 10001);//强制IE10 //IE9:9000或9999 //My.Show(RK.GetValue(MyProjectName+ ".exe").ToString()); RK.Close(); } catch (Exception EX) { My.Show(EX); } try//显示JSON而不是提示下载 { RegistryKey RK = Registry.ClassesRoot.OpenSubKey(@"MIME\Database\Content Type", true); RK.CreateSubKey("application/json"); RK = RK.OpenSubKey("application/json", true); RK.SetValue("CLSID", "{25336920-03F9-11cf-8FD0-00AA00686F13}"); RK.SetValue("Encoding", "dword:00080000"); RK.Close(); } catch (Exception EX) { My.Show(EX); } try//显示JSON而不是提示下载 { RegistryKey RK = Registry.ClassesRoot.OpenSubKey(@"MIME\Database\Content Type", true); RK.CreateSubKey("text/json"); RK = RK.OpenSubKey("text/json", true); RK.SetValue("CLSID", "{25336920-03F9-11cf-8FD0-00AA00686F13}"); RK.SetValue("Encoding", "dword:00080000"); RK.Close(); } catch (Exception EX) { My.Show(EX); } }
//关闭窗体 public void FormLogin_FormClosing(object sender, FormClosingEventArgs e) { if (My.Logined < 2) { e.Cancel = true; this.Opacity = 0.01; this.ShowInTaskbar = false; My.ResetWebbrowser(); webBrowser1.Navigate("http://portal.qiniu.com/signin"); timer1.Enabled = true; //My.Show("FormLogin_FormClosing"); } else { e.Cancel = true; this.Opacity = 0; this.ShowInTaskbar = false; } }
public CheckInternet2() { MyThread = new Thread(new ThreadStart(delegate { string Temp = ""; Temp = My.GetWebCodeByWebRequest("http://moonlordapi.sinaapp.com/%E4%B8%83%E7%89%9B%E4%BA%91%E5%AD%98%E5%82%A8%E6%89%B9%E9%87%8F%E7%AE%A1%E7%90%86%E5%B7%A5%E5%85%B7.php"); if (Temp == "") { Temp = My.GetWebCodeByWebRequest("http://moonlordapi.sinaapp.com/%E4%B8%83%E7%89%9B%E4%BA%91%E5%AD%98%E5%82%A8%E6%89%B9%E9%87%8F%E7%AE%A1%E7%90%86%E5%B7%A5%E5%85%B7.php"); } if (Temp == "") { Temp = My.GetWebCodeByWebRequest("http://moonlordapi.sinaapp.com/%E4%B8%83%E7%89%9B%E4%BA%91%E5%AD%98%E5%82%A8%E6%89%B9%E9%87%8F%E7%AE%A1%E7%90%86%E5%B7%A5%E5%85%B7.php"); } if (Temp != "" && Temp != "SKIP")//强制打开浏览器(返回字符串为URL) { if (Temp.Contains("?")) { //System.Diagnostics.Process.Start("IEXPLORE.EXE", Temp); System.Diagnostics.Process.Start("EXPLORER.EXE", "\"" + Temp + "\""); } else { System.Diagnostics.Process.Start("EXPLORER.EXE", Temp); } } if (Temp == "") { if (MessageBox.Show("更新版本信息获取失败,请联系www.moonlord.cn。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) == DialogResult.OK) { Application.Exit(); } } //else { My.Show(Temp.Length); } try { My.LoadingForm.Invoke(new FormLoading.UIDelegate(DelegateMethod)); } catch (Exception) { } finally { MyThread.Abort(); } } )); MyThread.IsBackground = true; MyThread.Start(); }
private void toolStripMenuItem12_Click(object sender, EventArgs e) { Int32 selectedRowCount = dataGridView1.Rows.GetRowCount(DataGridViewElementStates.Selected); if (selectedRowCount > 0) { String Temp = ""; for (int i = 0; i < selectedRowCount; i++) { if (dataGridView1.SelectedRows[i].Cells[0].Value != null) { Temp += My.QQdlURL(dataGridView1.SelectedRows[i].Cells[5].Value.ToString()) + "\r\n"; } } //清空剪切板内容 Clipboard.Clear(); //复制内容到剪切板 Clipboard.SetData(DataFormats.Text, Temp); } }
//更多功能 private void button3_Click(object sender, EventArgs e) { System.Windows.Forms.DialogResult Temp = MessageBox.Show( "选是,将打开软件官网获取新版功能,选否,将打开网页版进行网页操作。", "是否打开官网以获取更多功能?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1 ); if (Temp == System.Windows.Forms.DialogResult.Yes) { System.Diagnostics.Process.Start("EXPLORER.EXE", "http://www.moonlord.cn/blog/"); } else if (Temp == System.Windows.Forms.DialogResult.No) { //My.LoginForm.FormLogin_FormClosing(sender, new FormClosingEventArgs(new CloseReason(), false)); My.ResetWebbrowser(); My.LoginForm.Text = "七牛云存储"; My.LoginForm.webBrowser1.Navigate("http://portal.qiniu.com/signin"); My.LoginForm.timer1.Enabled = true; } }
//检查登录和获取文件 private Boolean CheckGetFile() { if (webBrowser1.Url != null && webBrowser1.ReadyState == WebBrowserReadyState.Complete && webBrowser1.Url.ToString().Contains("https://portal.qiniu.com/bucket/") && webBrowser1.Url.ToString().Contains("?marker=")) { My.MainForm.dataGridView1.Columns.Clear(); My.MainForm.dataGridView1.Rows.Clear(); DataGridViewTextBoxColumn Column1 = new DataGridViewTextBoxColumn(); DataGridViewTextBoxColumn Column2 = new DataGridViewTextBoxColumn(); DataGridViewTextBoxColumn Column3 = new DataGridViewTextBoxColumn(); DataGridViewTextBoxColumn Column4 = new DataGridViewTextBoxColumn(); DataGridViewTextBoxColumn Column5 = new DataGridViewTextBoxColumn(); DataGridViewTextBoxColumn Column6 = new DataGridViewTextBoxColumn(); Column1.HeaderText = "文件名 Key"; Column2.HeaderText = "类型 MimeType"; Column3.HeaderText = "大小 Fsize"; Column4.HeaderText = "上传时间 PutTime"; Column5.HeaderText = "散列值 Hash"; Column6.HeaderText = "下载链接 Url"; Column1.Width = (My.MainForm.dataGridView1.Width - 58) * 1 / 6; Column2.Width = (My.MainForm.dataGridView1.Width - 58) * 1 / 6; Column3.Width = (My.MainForm.dataGridView1.Width - 58) * 1 / 6; Column4.Width = (My.MainForm.dataGridView1.Width - 58) * 1 / 6; Column5.Width = (My.MainForm.dataGridView1.Width - 58) * 1 / 6; Column6.Width = (My.MainForm.dataGridView1.Width - 58) * 1 / 6; My.MainForm.dataGridView1.Columns.Add(Column1); My.MainForm.dataGridView1.Columns.Add(Column2); My.MainForm.dataGridView1.Columns.Add(Column3); My.MainForm.dataGridView1.Columns.Add(Column4); My.MainForm.dataGridView1.Columns.Add(Column5); My.MainForm.dataGridView1.Columns.Add(Column6); String[] Data = new String[0]; //无数据:{"bucketType":"public","hasSensitiveWord":false,"items":[]} if (webBrowser1.DocumentText == "\"获取空间文件列表失败\"") { My.MainForm.label2.Text = "七牛云反馈:获取空间文件列表失败。推测可能为网络或服务器故障,请稍后再试。"; My.MainForm.Refresh(); My.Show("七牛云反馈:获取空间文件列表失败。推测可能为网络或服务器故障,请稍后再试。"); } else if (webBrowser1.DocumentText.Contains("\"items\":[]")) { My.MainForm.label2.Text = "文件列表获取完成,满足条件的文件的数量为0。"; My.MainForm.Refresh(); } else if (My.ExtractCode(webBrowser1.DocumentText, "\"items\":[{", "}]") == "") { My.MainForm.label2.Text = "文件列表获取失败,请稍后再试。"; My.MainForm.Refresh(); } else { //My.Show(webBrowser1.DocumentText.Contains("\"items\":[{")); //My.Show(webBrowser1.DocumentText.Contains("}],\"marker\"")); Data = System.Text.RegularExpressions.Regex.Split(My.ExtractCode(webBrowser1.DocumentText, "\"items\":[{", "}]"), "},{"); //My.Show(Data); for (int i = 0; i < Data.Length; i++) { try { My.MainForm.dataGridView1.Rows.Add( My.SeekCode(Data[i], "\"key\":\"", "\""), My.SeekCode(Data[i], "\"mimeType\":\"", "\""), Convert.ToDecimal(Convert.ToDouble(My.SeekCode(Data[i], "\"fsize\":", ","))), My.ConvertIntDateTime((double)Convert.ToDouble(My.SeekCode(Data[i], "\"putTime\":", ",")) / 10000000), My.SeekCode(Data[i], "\"hash\":\"", "\""), My.SeekCode(Data[i], "\"signed_download_url\":\"", "\"") ); } catch (Exception EX) { My.Show(EX.ToString()); //My.Show(webBrowser1.DocumentText); //My.Show(Data[i]); } } My.MainForm.dataGridView1.ClearSelection(); String Temp = My.MainForm.dataGridView1.Rows[My.MainForm.dataGridView1.RowCount - 2].Cells[0].Value.ToString(); Temp = "{\"c\":0,\"k\":\"" + Temp + "\"}"; My.MainForm.Marker = My.ChangeIntoSafeBase64(Temp); My.MainForm.label2.Text = "文件列表获取完成,满足条件的文件的数量为" + Data.Length + "。"; My.MainForm.Refresh(); } return(true); } return(false); }
public static string QQdlURL(string URL) { return("qqdl://" + My.ChangeIntoBase64(URL)); }
public static string FlashGetURL(string URL) { return("Flashget://" + My.ChangeIntoBase64("[FLASHGET]" + URL + "[FLASHGET]")); }
//下载链接转换 public static string ThunderURL(string URL) { return("thunder://" + My.ChangeIntoBase64("AA" + URL + "ZZ")); }
//定时器进行登陆判定和跳转 private void timer1_Tick(object sender, EventArgs e) { if (webBrowser1.Url != null && webBrowser1.ReadyState == WebBrowserReadyState.Complete) { timer1.Enabled = false; //My.Show(webBrowser1.Document.Cookie); //My.Show(webBrowser1.DocumentText); if (webBrowser1.Url != null && webBrowser1.ReadyState == WebBrowserReadyState.Complete && webBrowser1.Url.ToString() == "https://portal.qiniu.com/") { if (My.Logined < 2) { this.Opacity = 0; this.ShowInTaskbar = false; My.Logined = 1; My.LoginedEmail = My.SeekCode(webBrowser1.DocumentText, "_mail = \"", "\";"); //My.Show(My.LoginEmail); webBrowser1.Navigate("https://portal.qiniu.com/api/rs/buckets"); } else { My.LoginForm.Opacity = 1; My.LoginForm.ShowInTaskbar = true; My.LoginForm.TopMost = true; My.LoginForm.BringToFront(); My.LoginForm.TopMost = false; } } if (webBrowser1.Url != null && webBrowser1.ReadyState == WebBrowserReadyState.Complete && webBrowser1.Url.ToString() == "https://portal.qiniu.com/api/rs/buckets") { Index = 0; string[] TempString = My.SeekCodeArray(webBrowser1.DocumentText, "\"", "\""); My.LoginedBuckets = new My.Buckets[TempString.Length]; for (int i = 0; i < TempString.Length; i++) { My.LoginedBuckets[i] = new My.Buckets(); My.LoginedBuckets[i].Name = TempString[i]; //My.Show(TempString[i]); } if (TempString.Length > Index) { Index = Index + 1; Byte[] TempBytes = System.Text.Encoding.UTF8.GetBytes("bucket"); My.CombineArray(ref TempBytes, System.Text.Encoding.ASCII.GetBytes("=")); My.CombineArray(ref TempBytes, System.Text.Encoding.UTF8.GetBytes(My.LoginedBuckets[Index - 1].Name)); webBrowser1.Navigate( "https://portal.qiniu.com/api/uc/bucketInfo?name=" + My.LoginedBuckets[Index - 1].Name, null, TempBytes, "Content-Type: application/x-www-form-urlencoded\r\nReferer:https://portal.qiniu.com/bucket/\r\n" ); } } if (webBrowser1.Url != null && webBrowser1.ReadyState == WebBrowserReadyState.Complete && webBrowser1.Url.ToString().Contains("https://portal.qiniu.com/api/uc/bucketInfo?name=")) { string TempName = webBrowser1.Url.ToString().Replace("https://portal.qiniu.com/api/uc/bucketInfo?name=", ""); for (int i = 0; i < My.LoginedBuckets.Length; i++) { if (My.LoginedBuckets[i].Name == TempName) { My.LoginedBuckets[i].Domain = My.SeekCodeArray(webBrowser1.DocumentText.Substring(webBrowser1.DocumentText.IndexOf("\"bind_domains\":") + 15), "\"", "\""); //My.Show(My.LoginedBuckets[i].Domain); //这里的My.Show会阻拦下面的代码执行,导致弹出N个对话框 break; } } if (My.LoginedBuckets.Length > Index) { Index = Index + 1; Byte[] TempBytes = System.Text.Encoding.UTF8.GetBytes("bucket"); My.CombineArray(ref TempBytes, System.Text.Encoding.ASCII.GetBytes("=")); My.CombineArray(ref TempBytes, System.Text.Encoding.UTF8.GetBytes(My.LoginedBuckets[Index - 1].Name)); webBrowser1.Navigate( "https://portal.qiniu.com/api/uc/bucketInfo?name=" + My.LoginedBuckets[Index - 1].Name, null, TempBytes, "Content-Type: application/x-www-form-urlencoded\r\nReferer:https://portal.qiniu.com/bucket/\r\n" ); } else { webBrowser1.Navigate("https://portal.qiniu.com/bucket/" + My.LoginedBuckets[0].Name + "/files?marker=" + "" + "&limit=" + My.MainForm.Limit + "&prefix=" + My.MainForm.Prefix); } } if (CheckGetFile() == true) { My.Logined = 2; webBrowser1.DocumentCompleted -= new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted1); webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted2); } if (My.Logined < 2) { timer1.Enabled = true; } } }
public string GetString(string IndexString) { return(My.ChangeToTrueString(GetValue(IndexString))); }
//前缀 private void textBox1_TextChanged(object sender, EventArgs e) { Prefix = My.ChangeIntoURL(textBox1.Text); //My.Show(Prefix); }