private void newTabButton_Click(object sender, EventArgs e) { WebTabPage newTabPage = new WebTabPage("http://www.google.co.jp/", addressBox); tabControlEx1.TabPages.Add(newTabPage); PageNum++; }
public Form1() { InitializeComponent(); WebTabPage newTabPage = new WebTabPage("http://www.google.co.jp/",addressBox); tabControlEx1.TabPages.Add(newTabPage); PageNum ++; }
public Form1() { InitializeComponent(); WebTabPage newTabPage = new WebTabPage("http://www.google.co.jp/", addressBox); tabControlEx1.TabPages.Add(newTabPage); PageNum++; }
protected override void OnDragOver(System.Windows.Forms.DragEventArgs e) { base.OnDragOver(e); Point pt = new Point(e.X, e.Y); //We need client coordinates. pt = PointToClient(pt); //Get the tab we are hovering over. WebTabPage hover_tab = (WebTabPage)GetTabPageByTab(pt); //Make sure we are on a tab. if (hover_tab != null) { //Make sure there is a TabPage being dragged. if (e.Data.GetDataPresent(typeof(WebTabPage))) { e.Effect = DragDropEffects.Move; WebTabPage drag_tab = (WebTabPage)e.Data.GetData(typeof(WebTabPage)); int item_drag_index = FindIndex(drag_tab); int drop_location_index = FindIndex(hover_tab); //Don't do anything if we are hovering over ourself. if (item_drag_index != drop_location_index) { ArrayList pages = new ArrayList(); //Put all tab pages into an array. for (int i = 0; i < TabPages.Count; i++) { //Except the one we are dragging. if (i != item_drag_index) { pages.Add(TabPages[i]); } } //Now put the one we are dragging it at the proper location. pages.Insert(drop_location_index, drag_tab); //Make them all go away for a nanosec. TabPages.Clear(); //Add them all back in. TabPages.AddRange((WebTabPage[])pages.ToArray(typeof(WebTabPage))); //Make sure the drag tab is selected. SelectedTab = drag_tab; } } } else { e.Effect = DragDropEffects.None; } }
/// <summary> /// Loops over all the TabPages to find the index of the given TabPage. /// </summary> /// <param name="page">The TabPage we want the index for.</param> /// <returns>The index of the given TabPage(-1 if it isn't found.)</returns> private int FindIndex(WebTabPage page) { for (int i = 0; i < TabPages.Count; i++) { if (TabPages[i] == page) { return(i); } } return(-1); }
/// <summary> /// Finds the TabPage whose tab is contains the given point. /// </summary> /// <param name="pt">The point (given in client coordinates) to look for a TabPage.</param> /// <returns>The TabPage whose tab is at the given point (null if there isn't one).</returns> private TabPage GetTabPageByTab(Point pt) { WebTabPage tp = null; for (int i = 0; i < TabPages.Count; i++) { if (GetTabRect(i).Contains(pt)) { tp = (WebTabPage)TabPages[i]; break; } } return(tp); }
private void goButton_Click(object sender, EventArgs e) { string address = this.addressBox.Text; if (address.StartsWith("http://") || address.StartsWith("https://") || address.StartsWith("ftp://")) { WebTabPage openTabPage = (WebTabPage)tabControlEx1.SelectedTab; openTabPage.TabWebBrowser.Navigate(address); } else { WebTabPage openTabPage = (WebTabPage)tabControlEx1.SelectedTab; openTabPage.TabWebBrowser.Navigate("http://www.google.co.jp/search?q=" + address); } }
private void addressBox_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { string address = this.addressBox.Text; if (address.StartsWith("http://") || address.StartsWith("https://") || address.StartsWith("ftp://")) { WebTabPage openTabPage = (WebTabPage)tabControlEx1.SelectedTab; openTabPage.TabWebBrowser.Navigate(address); } else { WebTabPage openTabPage = (WebTabPage)tabControlEx1.SelectedTab; openTabPage.TabWebBrowser.Navigate("http://www.google.co.jp/search?q=" + address); } } }
protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); if (dragBoxFromMouseDown != Rectangle.Empty && !dragBoxFromMouseDown.Contains(e.X, e.Y)) { if (this.TabCount <= 1) { return; } Point pt = new Point(mouseDownPointX, mouseDownPointY); WebTabPage tp = (WebTabPage)GetTabPageByTab(pt); if (tp != null) { DoDragDrop(tp, DragDropEffects.All); } } }
/// <summary> /// Loops over all the TabPages to find the index of the given TabPage. /// </summary> /// <param name="page">The TabPage we want the index for.</param> /// <returns>The index of the given TabPage(-1 if it isn't found.)</returns> private int FindIndex(WebTabPage page) { for (int i = 0; i < TabPages.Count; i++) { if (TabPages[i] == page) return i; } return -1; }
private void newTabButton_Click(object sender, EventArgs e) { WebTabPage newTabPage = new WebTabPage("http://www.google.co.jp/",addressBox); tabControlEx1.TabPages.Add(newTabPage); PageNum++; }
private void stopButton_Click(object sender, EventArgs e) { WebTabPage openTabPage = (WebTabPage)tabControlEx1.SelectedTab; openTabPage.TabWebBrowser.Stop(); }
private void reloadButton_Click(object sender, EventArgs e) { WebTabPage openTabPage = (WebTabPage)tabControlEx1.SelectedTab; openTabPage.TabWebBrowser.Refresh(); }
private void nextButton_Click(object sender, EventArgs e) { WebTabPage openTabPage = (WebTabPage)tabControlEx1.SelectedTab; openTabPage.TabWebBrowser.GoForward(); }