開発環境 |
Microsoft Visual Studio Express 2013 for Windows Desktop |
実行環境 |
Windows 8.1 (64bit) |
プロジェクト |
Visual C#/Windows フォーム アプリケーション |
名前 |
LogBrowser |
プロジェクト/参照の追加
C:\etc\FiddlerCoreAPI\DotNet4\FiddlerCore4.dll
プロジェクト/プロパティ
設定タブ
名前 |
型 |
スコープ |
値 |
Bounds |
System.Drawing.Rectangle |
ユーザー |
100, 100, 800, 600 |
SplitterDistance |
int |
ユーザー |
480 |
URL |
string |
ユーザー |
https://www.google.co.jp/ |
※型は参照...で追加できる。
参考
Program.cs
using System;
using System.Windows.Forms;
namespace LogBrowser
{
static class Program
{
/// <summary>
/// アプリケーションのメイン エントリ ポイントです。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
Form1.cs
using System;
using System.Windows.Forms;
namespace LogBrowser
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void toolStripButton1_Click(object sender, EventArgs e)
{
webBrowser1.Navigate(toolStripTextBox1.Text);
}
private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
{
toolStripTextBox1.Text = webBrowser1.Url.ToString();
}
private void Form1_Load(object sender, EventArgs e)
{
Properties.Settings psd = Properties.Settings.Default;
Bounds = psd.Bounds;
splitContainer1.SplitterDistance = psd.SplitterDistance;
toolStripTextBox1.Text = psd.URL;
Fiddler.FiddlerApplication.AfterSessionComplete += FiddlerApplication_AfterSessionComplete;
Fiddler.FiddlerApplication.Startup(0,
Fiddler.FiddlerCoreStartupFlags.ChainToUpstreamGateway);
Fiddler.URLMonInterop.SetProxyInProcess(string.Format("127.0.0.1:{0}",
Fiddler.FiddlerApplication.oProxy.ListenPort), "<local>");
}
void FiddlerApplication_AfterSessionComplete(Fiddler.Session oSession)
{
string text = oSession.fullUrl + "[" + oSession.oResponse.MIMEType + "]\n";
textBox1.Invoke(new D_AppendLog(AppendLog), text);
}
private delegate void D_AppendLog(string text);
private void AppendLog(string text)
{
textBox1.AppendText(text);
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
Properties.Settings psd = Properties.Settings.Default;
psd.Bounds = (WindowState == FormWindowState.Normal) ? Bounds : RestoreBounds;
psd.SplitterDistance = splitContainer1.SplitterDistance;
psd.URL = toolStripTextBox1.Text;
psd.Save();
Fiddler.URLMonInterop.ResetProxyInProcessToDefault();
Fiddler.FiddlerApplication.Shutdown();
}
private void toolStripButton2_Click(object sender, EventArgs e)
{
webBrowser1.Document.Window.ScrollTo(70, 76);
}
}
}
Form1.Designer.cs
namespace LogBrowser
{
partial class Form1
{
/// <summary>
/// 必要なデザイナー変数です。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 使用中のリソースをすべてクリーンアップします。
/// </summary>
/// <param name="disposing">マネージ リソースが破棄される場合 true、破棄されない場合は false です。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows フォーム デザイナーで生成されたコード
/// <summary>
/// デザイナー サポートに必要なメソッドです。このメソッドの内容を
/// コード エディターで変更しないでください。
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.toolStrip1 = new System.Windows.Forms.ToolStrip();
this.toolStripTextBox1 = new System.Windows.Forms.ToolStripTextBox();
this.toolStripButton1 = new System.Windows.Forms.ToolStripButton();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.webBrowser1 = new System.Windows.Forms.WebBrowser();
this.textBox1 = new System.Windows.Forms.TextBox();
this.toolStripButton2 = new System.Windows.Forms.ToolStripButton();
this.toolStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.SuspendLayout();
//
// toolStrip1
//
this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripTextBox1,
this.toolStripButton1,
this.toolStripButton2});
this.toolStrip1.Location = new System.Drawing.Point(0, 0);
this.toolStrip1.Name = "toolStrip1";
this.toolStrip1.Size = new System.Drawing.Size(774, 25);
this.toolStrip1.TabIndex = 0;
this.toolStrip1.Text = "toolStrip1";
//
// toolStripTextBox1
//
this.toolStripTextBox1.Name = "toolStripTextBox1";
this.toolStripTextBox1.Size = new System.Drawing.Size(400, 25);
this.toolStripTextBox1.Text = "https://www.google.co.jp/";
//
// toolStripButton1
//
this.toolStripButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.toolStripButton1.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton1.Image")));
this.toolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripButton1.Name = "toolStripButton1";
this.toolStripButton1.Size = new System.Drawing.Size(23, 22);
this.toolStripButton1.Text = "toolStripButton1";
this.toolStripButton1.Click += new System.EventHandler(this.toolStripButton1_Click);
//
// splitContainer1
//
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
this.splitContainer1.Location = new System.Drawing.Point(0, 25);
this.splitContainer1.Name = "splitContainer1";
this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.webBrowser1);
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.textBox1);
this.splitContainer1.Size = new System.Drawing.Size(774, 725);
this.splitContainer1.SplitterDistance = 587;
this.splitContainer1.TabIndex = 1;
//
// webBrowser1
//
this.webBrowser1.Dock = System.Windows.Forms.DockStyle.Fill;
this.webBrowser1.Location = new System.Drawing.Point(0, 0);
this.webBrowser1.MinimumSize = new System.Drawing.Size(20, 20);
this.webBrowser1.Name = "webBrowser1";
this.webBrowser1.Size = new System.Drawing.Size(774, 587);
this.webBrowser1.TabIndex = 0;
this.webBrowser1.Navigated += new System.Windows.Forms.WebBrowserNavigatedEventHandler(this.webBrowser1_Navigated);
//
// textBox1
//
this.textBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.textBox1.Location = new System.Drawing.Point(0, 0);
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.textBox1.Size = new System.Drawing.Size(774, 134);
this.textBox1.TabIndex = 0;
//
// toolStripButton2
//
this.toolStripButton2.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.toolStripButton2.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton2.Image")));
this.toolStripButton2.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripButton2.Name = "toolStripButton2";
this.toolStripButton2.Size = new System.Drawing.Size(23, 22);
this.toolStripButton2.Text = "toolStripButton2";
this.toolStripButton2.Click += new System.EventHandler(this.toolStripButton2_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(774, 750);
this.Controls.Add(this.splitContainer1);
this.Controls.Add(this.toolStrip1);
this.Name = "Form1";
this.Text = "LogBrowser";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
this.Load += new System.EventHandler(this.Form1_Load);
this.toolStrip1.ResumeLayout(false);
this.toolStrip1.PerformLayout();
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel2.ResumeLayout(false);
this.splitContainer1.Panel2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.ToolStrip toolStrip1;
private System.Windows.Forms.ToolStripTextBox toolStripTextBox1;
private System.Windows.Forms.ToolStripButton toolStripButton1;
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.WebBrowser webBrowser1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.ToolStripButton toolStripButton2;
}
}
最終更新:2014年09月18日 10:33