private void btnClear_Click(object sender, EventArgs e) { LoadHelper.ClearAll(); this.Invoke(new Action <ListView>(p => { p.BeginUpdate(); p.Items.Clear(); p.EndUpdate(); }), this.listView1); }
private void requestHandler_NotifyResult(string guid, string url, NameValueCollection request, NameValueCollection response, byte[] data) { if (isCapture) { LoadHelper.AddInfo(new LoadInfo() { Key = guid, Url = url, RequestHeader = request, ResponseHeader = response, Data = data }); } }
private void listView1_SelectedIndexChanged(object sender, EventArgs e) { if (this.listView1.SelectedItems != null && this.listView1.SelectedItems.Count > 0) { string guid = this.listView1.SelectedItems[0].Tag as string; currentModel = LoadHelper.GetInfo(guid); if (currentModel != null) { this.listView2.Items.Clear(); this.listView3.Items.Clear(); if (currentModel.RequestHeader != null && currentModel.RequestHeader.Count > 0) { InitHeader(currentModel.RequestHeader, this.listView2); } if (currentModel.ResponseHeader != null && currentModel.ResponseHeader.Count > 0) { InitHeader(currentModel.ResponseHeader, this.listView3); } try { this.richTextBox1.Clear(); if (currentModel.ResponseHeader["Content-Type"].Contains("image")) { Bitmap bmp = null; using (MemoryStream ms = new MemoryStream(currentModel.Data)) { bmp = (Bitmap)Image.FromStream(ms); } Clipboard.SetDataObject(bmp, false);//将图片放在剪贴板中 if (richTextBox1.CanPaste(DataFormats.GetFormat(DataFormats.Bitmap))) { richTextBox1.Paste();//粘贴数据 } } else { this.richTextBox1.Text = defaultEncode.GetString(currentModel.Data); } } catch { } } } }
private void ExecuteThread() { var list = LoadHelper.GetAll(); this.AddList(list); int maxId = 0; if (list.Count > 0) { maxId = list.Max(p => p.Index); } while (true) { try { while (isStart) { try { var newList = LoadHelper.GetNew(maxId); if (newList.Count > 0) { maxId = newList.Max(p => p.Index); maxId = (newList.Max(p => p.Index) > maxId ? newList.Max(p => p.Index) : maxId); } this.AddList(newList); } finally { Thread.Sleep(200); } } } catch { } finally { Thread.Sleep(300); } } }