private void toolsToolStripDropDownButton_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e) { ToolStripMenuItem menuItem = e.ClickedItem as ToolStripMenuItem; if (menuItem != null && menuItem.DropDownItems.Count == 0) { toolsToolStripDropDownButton.HideDropDown(); } WebBrowserTabPage webBrowserTabPage = mainTabControl.SelectedTab as WebBrowserTabPage; if (webBrowserTabPage != null) { if (e.ClickedItem == importExportToolStripMenuItem) { WinAPIHelper.InvokeCommandByMessage(1, WinAPIHelper.Messages.ID_IE_FILE_IMPORTEXPORT, webBrowserTabPage); } else if (e.ClickedItem == optionsToolStripMenuItem) { WinAPIHelper.InvokeCommandByMessage(2, WinAPIHelper.Messages.ID_IE_VIEW_OPTIONS, webBrowserTabPage); } else if (e.ClickedItem == aboutToolStripMenuItem) { using (AboutBox aboutBox = new AboutBox(webBrowserTabPage)) { aboutBox.ShowDialog(this); } } } }
private void favoritesToolStripSpiltButton_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e) { ToolStripMenuItem menuItem = e.ClickedItem as ToolStripMenuItem; if (menuItem != null && menuItem.DropDownItems.Count == 0) { favoritesToolStripSpiltButton.HideDropDown(); } WebBrowserTabPage webBrowserTabPage = mainTabControl.SelectedTab as WebBrowserTabPage; if (webBrowserTabPage != null) { if (e.ClickedItem == addToFavoritesToolStripMenuItem) { WinAPIHelper.InvokeCommandByMessage(2, WinAPIHelper.Messages.ID_IE_CONTEXTMENU_ADDFAV, webBrowserTabPage); } else if (e.ClickedItem == organizeFavoritesToolStripMenuItem) { Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.Favorites)); } else if (e.ClickedItem.Tag != null) { urlToolStripComboBox.Text = e.ClickedItem.Tag.ToString(); webBrowserTabPage.Navigate(urlToolStripComboBox.Text, true); } } }
private void openNewWebBrowserTabPage(Int32 index, String url) { WebBrowserTabPage webBrowserTabPage = new WebBrowserTabPage("Loading..."); webBrowserTabPage.Browser.Navigating += webBrowser_IsBusyDetection; webBrowserTabPage.Browser.DocumentCompleted += webBrowser_IsBusyDetection; webBrowserTabPage.Browser.NewWindow += webBrowser_NewWindow; webBrowserTabPage.Browser.Navigated += webBrowser_Navigated; webBrowserTabPage.Browser.ProgressChanged += webBrowser_ProgressChanged; webBrowserTabPage.Browser.StatusTextChanged += webBrowser_StatusTextChanged; webBrowserTabPage.Browser.DocumentTitleChanged += webBrowser_DocumentTitleChanged; mainTabControl.TabPages.Insert(index, webBrowserTabPage); mainTabControl.SelectedTab = webBrowserTabPage; urlToolStripComboBox.Text = url; if (!String.IsNullOrEmpty(url)) { webBrowserTabPage.Navigate(urlToolStripComboBox.Text, false); } else { urlToolStripComboBox.Focus(); } MainForm_SizeChanged(null, EventArgs.Empty); }
private void mainTabControl_MouseDoubleClick(object sender, MouseEventArgs e) { WebBrowserTabPage webBrowserTabPage = mainTabControl.SelectedTab as WebBrowserTabPage; if (webBrowserTabPage != null && mainTabControl.TabCount > 2) { closeWebBrowserTabPage(webBrowserTabPage); } }
private void webBrowser_IsBusyDetection(object sender, EventArgs e) { WebBrowserTabPage webBrowserTabPage = mainTabControl.SelectedTab as WebBrowserTabPage; if (webBrowserTabPage != null) { pageSwitchToolStripSpiltButton.Image = !webBrowserTabPage.IsBusy ? Resources.Forward : Resources.Stop; } }
private void pageSwitchToolStripSpiltButton_DropDownOpening(object sender, EventArgs e) { WebBrowserTabPage webBrowserTabPage = mainTabControl.SelectedTab as WebBrowserTabPage; if (webBrowserTabPage != null) { stopToolStripMenuItem.Enabled = webBrowserTabPage.IsBusy; } }
private void mainTabControl_SelectedIndexChanged(object sender, EventArgs e) { WebBrowserTabPage webBrowserTabPage = mainTabControl.SelectedTab as WebBrowserTabPage; if (webBrowserTabPage != null) { webBrowserTabPage.Browser.Focus(); } }
private void resizeWebBrowserTabPage(WebBrowserTabPage webBrowserTabPage) { Int32 width = mainTabControl.Size.Width; String title = webBrowserTabPage.Title; Int32 titleLength = (width / 100 - mainTabControl.TabCount) * ((width / 100)); titleLength = titleLength <= 0 ? 5 : titleLength; webBrowserTabPage.Text = title.Length > titleLength?title.Substring(0, titleLength) + "..." : title; }
private void webBrowser_DocumentTitleChanged(object sender, EventArgs e) { WebBrowserTabPage webBrowserTabPage = mainTabControl.SelectedTab as WebBrowserTabPage; if (webBrowserTabPage != null) { this.Text = String.Format("{0} - {1}", webBrowserTabPage.Title, this.ProductName); resizeWebBrowserTabPage(webBrowserTabPage); } }
private void webBrowser_StatusTextChanged(object sender, EventArgs e) { WebBrowserTabPage webBrowserTabPage = mainTabControl.SelectedTab as WebBrowserTabPage; if (webBrowserTabPage != null) { mainToolStripStatusLabel.Text = webBrowserTabPage.Browser.StatusText; mainStatusStrip.Visible = !String.IsNullOrEmpty(mainToolStripStatusLabel.Text); } }
internal static void InvokeCommandByMessage(Int32 wID, Int32 nID, WebBrowserTabPage webBrowserTabPage) { IntPtr webBrowserServerPtr = webBrowserTabPage.Browser.Handle; for (Int32 i = 0; i <= wID; i++) { webBrowserServerPtr = FindWindowEx(webBrowserServerPtr, IntPtr.Zero, handleWindowNames[i], null); } SendMessage(webBrowserServerPtr, WM_COMMAND, nID, (Int32)webBrowserTabPage.Parent.Handle); }
private void webBrowser_ProgressChanged(object sender, WebBrowserProgressChangedEventArgs e) { WebBrowserTabPage webBrowserTabPage = mainTabControl.SelectedTab as WebBrowserTabPage; if (webBrowserTabPage != null) { mainToolStripProgressBar.Visible = webBrowserTabPage.IsBusy; mainToolStripProgressBar.Maximum = (Int32)e.MaximumProgress; mainToolStripProgressBar.Value = (Int32)e.CurrentProgress; webBrowser_IsBusyDetection(sender, e); } }
private void mainTabControl_Selecting(object sender, TabControlCancelEventArgs e) { WebBrowserTabPage webBrowserTabPage = e.TabPage as WebBrowserTabPage; if (webBrowserTabPage != null) { checkWebBrowserTabPageStatus(webBrowserTabPage, false); } else { openNewWebBrowserTabPage(mainTabControl.TabCount - 1, null); } }
private void webBrowser_NewWindow(object sender, CancelEventArgs e) { WebBrowserTabPage webBrowserTabPage = mainTabControl.SelectedTab as WebBrowserTabPage; if (webBrowserTabPage != null && webBrowserTabPage.Browser.Document != null) { String url = !String.IsNullOrEmpty(webBrowserTabPage.Browser.Document.ActiveElement.GetAttribute("href")) ? webBrowserTabPage.Browser.Document.ActiveElement.GetAttribute("href") : webBrowserTabPage.Browser.Document.ActiveElement.GetElementsByTagName("a")[0].GetAttribute("href"); openNewWebBrowserTabPage(mainTabControl.SelectedIndex + 1, url); } e.Cancel = true; }
private void webBrowser_Navigated(object sender, WebBrowserNavigatedEventArgs e) { WebBrowserTabPage webBrowserTabPage = mainTabControl.SelectedTab as WebBrowserTabPage; if (webBrowserTabPage != null) { if (!urlToolStripComboBox.Focused) { urlToolStripComboBox.Text = webBrowserTabPage.Browser.Url.OriginalString; } checkWebBrowserTabPageStatus(webBrowserTabPage, true); } }
private void pageToolStripDropDownButton_DropDownOpening(object sender, EventArgs e) { WebBrowserTabPage webBrowserTabPage = mainTabControl.SelectedTab as WebBrowserTabPage; if (webBrowserTabPage != null) { findToolStripMenuItem.Enabled = (webBrowserTabPage.Browser.ReadyState != WebBrowserReadyState.Uninitialized); saveAsToolStripMenuItem.Enabled = (webBrowserTabPage.Browser.ReadyState != WebBrowserReadyState.Uninitialized); sendToToolStripMenuItem.Enabled = (webBrowserTabPage.Browser.ReadyState != WebBrowserReadyState.Uninitialized); printToolStripMenuItem.Enabled = (webBrowserTabPage.Browser.ReadyState != WebBrowserReadyState.Uninitialized); printPreviewToolStripMenuItem.Enabled = (webBrowserTabPage.Browser.ReadyState != WebBrowserReadyState.Uninitialized); pageSetupToolStripMenuItem.Enabled = (webBrowserTabPage.Browser.ReadyState != WebBrowserReadyState.Uninitialized); viewSourceToolStripMenuItem.Enabled = (webBrowserTabPage.Browser.ReadyState != WebBrowserReadyState.Uninitialized); } }
private void MainForm_SizeChanged(object sender, EventArgs e) { // AutoSize: urlToolStripComboBox Int32 leftX = mainToolStrip.Location.X; Int32 rightX = leftX + mainToolStrip.Size.Width; foreach (ToolStripItem item in mainToolStrip.Items) { if (item != urlToolStripComboBox) { leftX += item.Size.Width; } else { break; } } for (Int32 i = mainToolStrip.Items.Count - 1; i > 0; i--) { if (mainToolStrip.Items[i] != urlToolStripComboBox) { rightX -= mainToolStrip.Items[i].Size.Width; } else { break; } } urlToolStripComboBox.Size = new Size(rightX - leftX - 5, urlToolStripComboBox.Size.Height); //AutoSize: mainTabControl.TabPages foreach (TabPage page in mainTabControl.TabPages) { WebBrowserTabPage webBrowserTabPage = page as WebBrowserTabPage; if (webBrowserTabPage != null) { resizeWebBrowserTabPage(webBrowserTabPage); } } }
private void pageToolStripDropDownButton_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e) { ToolStripMenuItem menuItem = e.ClickedItem as ToolStripMenuItem; if (menuItem != null && menuItem.DropDownItems.Count == 0) { pageToolStripDropDownButton.HideDropDown(); } WebBrowserTabPage webBrowserTabPage = mainTabControl.SelectedTab as WebBrowserTabPage; if (webBrowserTabPage != null) { if (e.ClickedItem == findToolStripMenuItem) { WinAPIHelper.InvokeCommandByMessage(2, WinAPIHelper.Messages.ID_IE_EDIT_FIND, webBrowserTabPage); } else if (e.ClickedItem == saveAsToolStripMenuItem) { webBrowserTabPage.Browser.ShowSaveAsDialog(); } else if (e.ClickedItem == desktopShortcutToolStripMenuItem) { WinAPIHelper.InvokeCommandByMessage(1, WinAPIHelper.Messages.ID_IE_FILE_SENDDESKTOPSHORTCUT, webBrowserTabPage); MessageBox.Show(this, String.Format("The shortcut of the following page has been created on desktop:{0}{0}{1}", Environment.NewLine, webBrowserTabPage.Title), "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (e.ClickedItem == printToolStripMenuItem) { webBrowserTabPage.Browser.ShowPrintDialog(); } else if (e.ClickedItem == printPreviewToolStripMenuItem) { webBrowserTabPage.Browser.ShowPrintPreviewDialog(); } else if (e.ClickedItem == pageSetupToolStripMenuItem) { webBrowserTabPage.Browser.ShowPageSetupDialog(); } else if (e.ClickedItem == viewSourceToolStripMenuItem) { WinAPIHelper.InvokeCommandByMessage(2, WinAPIHelper.Messages.ID_IE_CONTEXTMENU_VIEWSOURCE, webBrowserTabPage); } } }
private void historyListToolStripDropDownButton_DropDownOpening(object sender, EventArgs e) { WebBrowserTabPage webBrowserTabPage = mainTabControl.SelectedTab as WebBrowserTabPage; if (webBrowserTabPage != null) { historyListToolStripDropDownButton.DropDownItems.Clear(); foreach (KeyValuePair <String, String> pair in webBrowserTabPage.HistoryList) { historyListToolStripDropDownButton.DropDownItems.Insert(0, createURLToolStripMenuItem(pair.Value, pair.Key, Resources.Link)); ToolStripMenuItem menuItem = historyListToolStripDropDownButton.DropDownItems[0] as ToolStripMenuItem; menuItem.Checked = (menuItem.Text == webBrowserTabPage.Title); } } }
private void pageSwitchToolStripSpiltButton_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e) { WebBrowserTabPage webBrowserTabPage = mainTabControl.SelectedTab as WebBrowserTabPage; if (webBrowserTabPage != null) { if (e.ClickedItem == openToolStripMenuItem) { if (!String.IsNullOrEmpty(urlToolStripComboBox.Text)) { if (!urlToolStripComboBox.Items.Contains(urlToolStripComboBox.Text)) { urlToolStripComboBox.Items.Add(urlToolStripComboBox.Text); } webBrowserTabPage.Navigate(urlToolStripComboBox.Text, true); } } else if (e.ClickedItem == openInNewTabToolStripMenuItem) { openNewWebBrowserTabPage(mainTabControl.SelectedIndex + 1, urlToolStripComboBox.Text); } else if (e.ClickedItem == searchToolStripMenuItem) { urlToolStripComboBox.Text = !String.IsNullOrEmpty(urlToolStripComboBox.Text) ? String.Format("? {0}", urlToolStripComboBox.Text) : "? "; if (urlToolStripComboBox.Text.Length > 2) { openToolStripMenuItem.PerformClick(); } else { urlToolStripComboBox.Focus(); urlToolStripComboBox.Select(urlToolStripComboBox.Text.Length, 0); } } else if (e.ClickedItem == stopToolStripMenuItem) { webBrowserTabPage.Browser.Stop(); } } }
private void MainForm_DragDrop(object sender, DragEventArgs e) { WebBrowserTabPage webBrowserTabPage = mainTabControl.SelectedTab as WebBrowserTabPage; if (webBrowserTabPage != null) { String[] files = e.Data.GetData(DataFormats.FileDrop) as String[]; if (files != null && files.Length > 0) { urlToolStripComboBox.Text = DataHelper.RegexCollection.UrlShortcutRegex.Match(File.ReadAllText(files[0])).Groups["URL"].Value; } else { urlToolStripComboBox.Text = e.Data.GetData(DataFormats.Text).ToString(); } webBrowserTabPage.Navigate(urlToolStripComboBox.Text, true); } }
private void checkWebBrowserTabPageStatus(WebBrowserTabPage webBrowserTabPage, Boolean isMainToolStripOnly) { WebBrowser webBrowser = webBrowserTabPage.Controls[0] as WebBrowser; if (webBrowser != null) { backToolStripButton.Enabled = webBrowser.CanGoBack; forwardToolStripButton.Enabled = webBrowser.CanGoForward; historyListToolStripDropDownButton.Enabled = webBrowser.CanGoBack || webBrowser.CanGoForward; if (!isMainToolStripOnly) { this.Text = String.Format("{0} - {1}", webBrowserTabPage.Title, this.ProductName); urlToolStripComboBox.Text = (webBrowser.Url != null) ? webBrowser.Url.OriginalString : String.Empty; mainToolStripStatusLabel.Text = webBrowser.StatusText; mainToolStripProgressBar.Visible = webBrowserTabPage.IsBusy; } } }
private void mainToolStrip_ButtonClick(object sender, EventArgs e) { WebBrowserTabPage webBrowserTabPage = mainTabControl.SelectedTab as WebBrowserTabPage; if (webBrowserTabPage != null) { if (sender == favoritesToolStripSpiltButton) { addToFavoritesToolStripMenuItem.PerformClick(); } else if (sender == pageSwitchToolStripSpiltButton) { if (!webBrowserTabPage.IsBusy) { openToolStripMenuItem.PerformClick(); } else { stopToolStripMenuItem.PerformClick(); } } } }
private void historyListToolStripDropDownButton_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e) { ToolStripMenuItem historyToolStripMenuItem = e.ClickedItem as ToolStripMenuItem; WebBrowserTabPage webBrowserTabPage = mainTabControl.SelectedTab as WebBrowserTabPage; if (historyToolStripMenuItem != null && webBrowserTabPage != null) { if (historyToolStripMenuItem.Checked) { refreshToolStripButton.PerformClick(); } else { foreach (ToolStripMenuItem item in historyListToolStripDropDownButton.DropDownItems) { item.Checked = (item == historyToolStripMenuItem); } urlToolStripComboBox.Text = historyToolStripMenuItem.Tag.ToString(); webBrowserTabPage.Navigate(urlToolStripComboBox.Text, false); } } }
private void mainToolStrip_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { WebBrowserTabPage webBrowserTabPage = mainTabControl.SelectedTab as WebBrowserTabPage; if (webBrowserTabPage != null) { if (e.ClickedItem == backToolStripButton) { webBrowserTabPage.Browser.GoBack(); } else if (e.ClickedItem == forwardToolStripButton) { webBrowserTabPage.Browser.GoForward(); } else if (e.ClickedItem == refreshToolStripButton) { webBrowserTabPage.Browser.Refresh(); } else if (e.ClickedItem == homeToolStripButton) { webBrowserTabPage.Browser.GoHome(); } } }
private void urlToolStripComboBox_KeyPress(object sender, KeyPressEventArgs e) { WebBrowserTabPage webBrowserTabPage = mainTabControl.SelectedTab as WebBrowserTabPage; if (webBrowserTabPage != null) { switch ((Int32)e.KeyChar) { case 13: { e.Handled = true; openToolStripMenuItem.PerformClick(); break; } default: { break; } } } }
public AboutBox(WebBrowserTabPage webBrowserTabPage) : this() { _webBrowserTabPage = webBrowserTabPage; }
private void tabControlContextMenuStrip_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { WebBrowserTabPage webBrowserTabPage = tabControlContextMenuStrip.Tag as WebBrowserTabPage; if (webBrowserTabPage != null) { if (e.ClickedItem == closeToolStripMenuItem) { closeWebBrowserTabPage(webBrowserTabPage); } else if (e.ClickedItem == closeTabsOnTheLeftToolStripMenuItem) { Int32 webBrowserTabPageIndex = mainTabControl.TabPages.IndexOf(webBrowserTabPage); for (Int32 i = 0; i < webBrowserTabPageIndex; i++) { closeWebBrowserTabPage(mainTabControl.TabPages[0]); } } else if (e.ClickedItem == closeTabsOnTheRightToolStripMenuItem) { Int32 webBrowserTabPageIndex = mainTabControl.TabPages.IndexOf(webBrowserTabPage); for (Int32 i = mainTabControl.TabCount - 2; i > webBrowserTabPageIndex; i--) { closeWebBrowserTabPage(mainTabControl.TabPages[i]); } } else if (e.ClickedItem == closeOtherTabsToolStripMenuItem) { closeTabsOnTheRightToolStripMenuItem.PerformClick(); closeTabsOnTheLeftToolStripMenuItem.PerformClick(); } else if (e.ClickedItem == refreshToolStripMenuItem) { webBrowserTabPage.Browser.Refresh(); } else if (e.ClickedItem == refreshAllToolStripMenuItem) { foreach (TabPage page in mainTabControl.TabPages) { WebBrowserTabPage tabPage = page as WebBrowserTabPage; if (tabPage != null) { tabPage.Browser.Refresh(); } } } else if (e.ClickedItem == newTabToolStripMenuItem) { openNewWebBrowserTabPage(mainTabControl.TabPages.IndexOf(webBrowserTabPage) + 1, null); urlToolStripComboBox.Focus(); } else if (e.ClickedItem == repeatTabToolStripMenuItem) { openNewWebBrowserTabPage(mainTabControl.TabPages.IndexOf(webBrowserTabPage) + 1, webBrowserTabPage.Browser.Url.OriginalString); } } }