using System;
using System.Threading;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;
using System.Net;
namespace IReaper.Browser{
public partial class iReaperBrowserForm : iReaperDockContent
{
System.ComponentModel.ComponentResourceManager resources;
private TabContextMenu tabContextMenu = new TabContextMenu();
public iReaperBrowserForm()
{
InitializeComponent();
this.iReaperWebBrowser.DocumentTitleChanged += new EventHandler(UpdateTabTitle);
resources = new System.ComponentModel.ComponentResourceManager(typeof(iReaperBrowserForm));
this.TabPageContextMenu = tabContextMenu;
tabContextMenu.Context = this;
this.browserToolStrip1.WbForm = this;
this.browserToolStrip1.UrlCombo.KeyUp += new KeyEventHandler(UrlCombo_KeyUp);
}
void UrlCombo_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Return)
{
e.Handled = true;
GoNavigate();
}
}
/// <summary>
///
/// </summary>
public void LoadWelcomeWeb()
{
this.iReaperWebBrowser.Navigate("http://go.microsoft.com/fwlink/?LinkID=78110&clcid=0x804");
this.iReaperWebBrowser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(delegate(object obj,WebBrowserDocumentCompletedEventArgs e)
{
if (!this.IsDisposed)
{
this.Show();
this.Activate();
//msdn
this.browserToolStrip1.UrlCombo.Text = this.iReaperWebBrowser.Url.AbsoluteUri;
}
} );
this.iReaperWebBrowser.NavigationError += new EventHandler(delegate(object sender, EventArgs e)
{
this.Close();
});
}
protected override void OnLoad(EventArgs e)
{
//
BrowserManager.RegisterBrowser(this);
Core.CoreData[CoreDataType.ActiveWebBrowser] = this;
base.OnLoad(e);
}
/// <summary>
/// TabTextDocumentTitle
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void UpdateTabTitle(object sender, EventArgs e)
{
this.TabText = this.iReaperWebBrowser.DocumentTitle;
}
/// <summary>
/// Url
/// </summary>
public Uri Url
{
set
{
if (value == null || !value.IsAbsoluteUri)
{ return; }
this.TabText = value.AbsoluteUri;
this.iReaperWebBrowser.Url = value;
this.browserToolStrip1.UrlCombo.Text = value.AbsoluteUri;
}
get
{
return this.iReaperWebBrowser.Url;
}
}
/// <summary>
///
/// </summary>
/// <param name="icon"></param>
private void IconChanged(Icon icon)
{
this.Icon = icon;
}
/// <summary>
///
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void CheckQuit(object sender, EventArgs e)
{
this.Close();
}
/// <summary>
///
/// </summary>
public void GoBack()
{
this.iReaperWebBrowser.GoBack();
}
/// <summary>
///
/// </summary>
public void GoForward()
{
this.iReaperWebBrowser.GoForward();
}
/// <summary>
///
/// </summary>
public void RefreshBrowser()
{
this.iReaperWebBrowser.Refresh();
}
/// <summary>
///
/// </summary>
public void Stop()
{
this.iReaperWebBrowser.Stop();
}
/// <summary>
///
/// </summary>
public void GoNavigate()
{
string tempUrl = "";
if (this.browserToolStrip1.UrlCombo.Text.IndexOf("://") == -1)
{
tempUrl = "http://" + this.browserToolStrip1.UrlCombo.Text;
}
else
{
tempUrl = this.browserToolStrip1.UrlCombo.Text;
}
this.Url = new Uri(tempUrl, UriKind.Absolute);
}
/// <summary>
/// Windows Live ID
/// </summary>
/// <param name="url"></param>
/// <param name="postedData"></param>
public void NavigateWithPostedAuthenInfo(string url, byte[] postedData)
{
this.iReaperWebBrowser.Navigate(url, "_self", postedData, "Content-Type: application/x-www-form-urlencoded");
}
private void UpdateUrl(object sender, WebBrowserNavigatingEventArgs e)
{
this.browserToolStrip1.UrlCombo.Text = e.Url.AbsoluteUri;
}
}
}
|