protected override void OnDomClick(DomMouseEventArgs e) { var elem = Document.ActiveElement; var uri = elem.HasAttribute("Href") ? elem.GetAttribute("Href") : elem.Parent.HasAttribute("Href") ? elem.Parent.GetAttribute("Href") : ""; const string scheme = "hybrid:"; if (!uri.StartsWith(scheme)) { base.OnDomClick(e); } e.Handled = true; var resources = uri.Substring(scheme.Length).Split('?'); var method = resources[0]; var parameters = resources.Length > 1? System.Web.HttpUtility.ParseQueryString(resources[1]): null; switch (method) { case "VowelChart": break; case "ConstChart": break; //case "DataCorpus": DisplayPages.DisplayData(); break; //case "Search": break; //case "Project": DisplayPages.DisplayOpenProject(); break; //case "Settings": break; //case "DistChart": break; //case "Steps": break; //case "Close": Program.DisplayMenu(); break; } }
protected void HandleDomClick(object sender, DomMouseEventArgs e) { if (sender == null || e == null || e.Target == null) { return; } GeckoElement elem = e.Target.CastToGeckoElement(); int hvo; if (TryGetHvo(elem, out hvo)) { JumpToToolBasedOnHvo(hvo); } if (elem.TagName.Equals("input", StringComparison.InvariantCultureIgnoreCase) && elem.GetAttribute("type").Equals("button", StringComparison.InvariantCultureIgnoreCase)) { switch (elem.GetAttribute("name")) { case "ShowWordGrammarDetail": ShowWordGrammarDetail(elem.GetAttribute("id")); break; case "TryWordGrammarAgain": TryWordGrammarAgain(elem.GetAttribute("id")); break; case "GoToPreviousWordGrammarPage": GoToPreviousWordGrammarPage(); break; } } }
private void wbElementRecorder_DomDoubleClick(object sender, DomMouseEventArgs e) { //mouse down has occured if (e != null) { try { if (_isRecording) { _lastSavedPoint = new Point(e.ClientX, e.ClientY); LoadSearchParameters(_lastSavedPoint); lblDescription.Text = _recordingMessage; } if (IsRecordingSequence && _isRecording) { //remove previous commands generated from two single clicks for (int i = 0; i < 4; i++) { _sequenceCommandList.RemoveAt(_sequenceCommandList.Count - 1); } BuildElementClickActionCommand("Double Left Click"); } } catch (Exception) { lblDescription.Text = _errorMessage; } } }
private void HandleClick(object sender, DomMouseEventArgs e) { GeckoElement geckoElement; if (m_blocksDisplayBrowser.Visible && GeckoUtilities.ParseDomEventTargetAsGeckoElement(e.Target, out geckoElement)) { int splitId; if (IsElementSelect(geckoElement)) { m_lblInvalidSplitLocation.Visible = false; } else if (IsElementSplitLine(geckoElement, out splitId)) { m_splitLocations.Remove(m_splitLocations.Single(s => s.Id == splitId)); SetHtml(); m_btnOk.Enabled = m_splitLocations.Any(); m_lblInvalidSplitLocation.Visible = false; } else if (DetermineSplitLocation(geckoElement)) { SetHtml(); m_btnOk.Enabled = true; m_lblInvalidSplitLocation.Visible = false; } else { m_lblInvalidSplitLocation.Visible = true; } } else { m_lblInvalidSplitLocation.Visible = true; } }
private void GeckoWebBrowser_DomContextMenu(object sender, DomMouseEventArgs e) { if (sender == null) { return; } if (e == null) { return; } if (e.Target == null) { return; } var element = e.Target.CastToGeckoElement(); GeckoHtmlElement clicked = element as GeckoHtmlElement; if (clicked == null) { return; } //MessageBox.Show(clicked.TagName); e.Handled = true; e.PreventDefault(); clicked.SetAttribute("style", "border: medium solid blue"); Browser_ContextMenu_RightClk.Tag = clicked; Browser_ContextMenu_RightClk.Show(Cursor.Position); //MessageBox.Show("right clicked"); }
private void geckoWebBrowser1_DomMouseDown(object sender, DomMouseEventArgs e) { if (e.Button == GeckoMouseButton.Right) { dataGridView1.Rows.Add(richTextBox1.Text, richTextBox2.Text, richTextBox3.Text); } }
private void geckoWebBrowser1_DomMouseDown(object sender, DomMouseEventArgs e) { GeckoHtmlElement elm = (GeckoHtmlElement)e.Target.CastToGeckoElement(); switch (elm.ClassName) { case "ytp-fullscreen-button ytp-button": this.SetWindowState(FormWindowState.Maximized, false); if (this.geckoWebBrowser1.Document.GetElementsByClassName("ytp-size-button ytp-button").FirstOrDefault() is GeckoHtmlElement theater) { if (this.TheaterClicked == false) { theater.Click(); this.TheaterClicked = true; } } break; case "ytp-size-button ytp-button": this.TheaterClicked = !this.TheaterClicked; break; default: break; } }
private void OnMouseClick(object sender, DomMouseEventArgs e) { if (!m_blocksDisplayBrowser.Window.Selection.IsCollapsed) { return; } GeckoElement geckoElement; if (GeckoUtilities.ParseDomEventTargetAsGeckoElement(e.Target, out geckoElement)) { var geckoDivElement = geckoElement as GeckoDivElement; while (geckoDivElement != null && !geckoDivElement.ClassName.Contains("block scripture")) { geckoDivElement = geckoDivElement.Parent as GeckoDivElement; } if (geckoDivElement == null) { return; } int blockIndexInBook; GeckoNode blockIndexInBookAttr = geckoDivElement.Attributes["data-block-index-in-book"]; if (blockIndexInBookAttr == null || !Int32.TryParse(blockIndexInBookAttr.NodeValue, out blockIndexInBook)) { return; } m_viewModel.CurrentBlockIndexInBook = blockIndexInBook; } }
public static DomUIEventArgs Create(nsIDOMUIEvent ev) { if (ev is nsIDOMMouseEvent) { return(DomMouseEventArgs.Create((nsIDOMMouseEvent)ev)); } return(new DomUIEventArgs(ev)); }
private void geckoWebBrowser1_DomMouseDown(object sender, DomMouseEventArgs e) { GeckoHtmlElement elm = (GeckoHtmlElement)e.Target.CastToGeckoElement(); if (elm.ClassName.Contains("fullscreen")) { this.SetWindowState(FormWindowState.Maximized, false); } }
private void HandleDomMouseOver(object sender, DomMouseEventArgs e) { EventHandler <DomMouseEventArgs> handler = OnMouseOver; if (handler != null) { handler(this, e); } }
private void HandleDomMouseClick(object sender, DomMouseEventArgs e) { EventHandler <DomMouseEventArgs> handler = OnMouseClick; if (handler != null) { handler(this, e); } e.Handled = true; // don't let the browser navigate itself }
void OpenGeckoLinksInNewWindow(object sender, DomMouseEventArgs e) { if (sender != null && e != null && e.Target != null) { GeckoElement clicked = e.Target.CastToGeckoElement(); if (clicked.TagName == "A") { e.Handled = true; System.Diagnostics.Process.Start(clicked.GetAttribute("href")); } } }
private void InsertSplitLocation(object sender, DomMouseEventArgs e) { if (DetermineSplitLocation(e.Target)) { SetHtml(); m_btnOk.Enabled = true; m_lblInvalidSplitLocation.Visible = false; } else { m_lblInvalidSplitLocation.Visible = true; } }
/// <summary> /// 鼠标移动到元素上执行的事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void On_MouseMove(object sender, DomMouseEventArgs e) { var ele = e.CurrentTarget.CastToGeckoElement(); ele = e.Target.CastToGeckoElement(); var cls = ele.GetAttribute("class"); if (!cls.Contains("focusHover")) { cls += " " + "focusHover"; ele.SetAttribute("class", cls); } }
/// <summary> /// Dom单击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void On_DomClick(object sender, DomMouseEventArgs e) { //屏蔽页面点击事件 e.PreventDefault(); e.StopPropagation(); var ele = e.CurrentTarget.CastToGeckoElement(); ele = e.Target.CastToGeckoElement(); GeckoHtmlElement geckoHtmlElement = (GeckoHtmlElement)ele; string searchElement = geckoHtmlElement.OuterHtml; if (!searchElement.Contains("firefinder-match-red")) { //在datagridview中显示选中行的内容 GeckoHtmlElement[] geckoHtmlEle = new GeckoHtmlElement[1]; geckoHtmlEle[0] = geckoHtmlElement; if (geckofxType.Equals(GeckofxWebbrowerType.General)) { InsertDataGridRow(dgv, geckoWebBrowser, geckoHtmlEle); } else if (geckofxType.Equals(GeckofxWebbrowerType.ListDetails)) { InsertDataGridRow(dgv, geckoWebBrowser, geckoHtmlEle); } else if (geckofxType.Equals(GeckofxWebbrowerType.UrlModel)) { try { GeckoAnchorElement d = (GeckoAnchorElement)geckoHtmlElement; string URL = d.Href; InsertDataGridRow(GeckofxWebbrowerType.UrlModel, dgv, geckoWebBrowser, geckoHtmlEle); } catch (Exception) { MessageBox.Show("请获取链接!"); return; } } ruleStyle.AddClass("firefinder-match-red", ele); } else { //在浏览器中标记红圈 ruleStyle.RemoveClass("firefinder-match-red", ele); } }
private void wbElementRecorder_DomClick(object sender, DomMouseEventArgs e) { //mouse down has occured if (e != null) { try { if (_isRecording) { _lastSavedPoint = new Point(e.ClientX, e.ClientY); LoadSearchParameters(_lastSavedPoint); lblDescription.Text = _recordingMessage; } string clickType; switch (e.Button) { case GeckoMouseButton.Left: clickType = "Invoke Click"; break; case GeckoMouseButton.Middle: clickType = "Middle Click"; break; case GeckoMouseButton.Right: clickType = "Right Click"; break; default: clickType = "Invoke Click"; break; } if (IsRecordingSequence && _isRecording) { BuildElementClickActionCommand(clickType); } } catch (Exception) { lblDescription.Text = _errorMessage; } } if (chkStopOnClick.Checked) { Close(); } }
/// <summary> /// 鼠标移走的事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void On_MouseOut(object sender, DomMouseEventArgs e) { var ele = e.CurrentTarget.CastToGeckoElement(); ele = e.Target.CastToGeckoElement(); var cls = ele.GetAttribute("class"); if (!string.IsNullOrWhiteSpace(cls)) { cls = cls.Replace("focusHover", "").Trim(); ele.SetAttribute("class", cls); } }
public static DomUIEventArgs Create(nsIDOMUIEvent ev) { if (ev is nsIDOMMouseEvent) { return(DomMouseEventArgs.Create((nsIDOMMouseEvent)ev)); } #if PORTFF60 else if (ev is nsIDOMKeyEvent) { return(DomKeyEventArgs.Create((nsIDOMKeyEvent)ev)); } #endif return(new DomUIEventArgs(ev)); }
private void geckoWebBrowser1_DomMouseOut(object sender, DomMouseEventArgs e) { try { if (this.elementStyles.ContainsKey(element)) { string style = this.elementStyles[element]; this.elementStyles.Remove(element); element.SetAttribute("style", style); } } catch (Exception ex) { } }
private void geckoWebBrowser1_DomMouseOver(object sender, DomMouseEventArgs e) { try { element = (GeckoHtmlElement)geckoWebBrowser1.Document.ElementFromPoint(e.ClientX, e.ClientY); if (!this.elementStyles.ContainsKey(element)) { string style = element.Style.CssText; elementStyles.Add(element, style); element.SetAttribute("style", style + ";border-style: solid;border-color: #FF0000;"); richTextBox1.Text = element.TextContent.Trim(); richTextBox2.Text = element.TagName.Trim(); richTextBox3.Text = element.OuterHtml.Trim(); } } catch (Exception ex) { } }
private void OnMouseOver(object sender, DomMouseEventArgs e) { if (e.Target == null || m_getCharacterIdForUi == null || !m_blocksDisplayBrowser.Visible) { HideToolTip(); return; } var geckoElement = e.Target.CastToGeckoElement(); var checkElement = geckoElement as GeckoHtmlElement; for (int i = 0; i < 10; i++) { if (checkElement == null) { HideToolTip(); return; } else if (checkElement.ClassName != BlockNavigatorViewModel.kCssClassContext) { checkElement = checkElement.Parent; } else { break; } } if (m_toolTip == null) { m_toolTip = new ToolTip { IsBalloon = true }; string toolTipText = m_getCharacterIdForUi(checkElement.GetAttribute(BlockNavigatorViewModel.kDataCharacter)); // 42 and 43 are the magic numbers which happens to make these display in the correct place // REVIEW: it would be nice to figure out a better way to place these which is more robust. These numbers have changed several times already int x = m_blocksDisplayBrowser.Location.X + m_blocksDisplayBrowser.Size.Width - 42; int y = m_blocksDisplayBrowser.Location.Y + e.ClientY - m_blocksDisplayBrowser.Margin.Top - 43; m_toolTip.Show(toolTipText, this, x, y); } }
private void _gecko_DomClick(object sender, DomMouseEventArgs e) { var ele = e.Target.CastToGeckoElement(); if (ele.GetAttribute("id") == "btnMethod") { string methodName = ele.GetAttribute("value"); string param = _gecko.Document.GetElementById("hidMethodParam").GetAttribute("value"); try { var method = this.GetType().GetMethod(methodName, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); method.Invoke(this, new object[] { param }); } catch (Exception ex) { MessageBox.Show(this.GetParentByName <Window>(null), ex.Message); } } }
private void m_browser_OnMouseClick(object sender, DomMouseEventArgs e) { if (this.DesignModeAtAll()) { return; } if (e.Target == null) { return; } var element = e.Target.CastToGeckoElement(); // handle if the user clicked on a hyperlink if (element.TagName == "A") { var url = element.GetAttribute("href"); if (url.StartsWith("file://")) { var path = url.Replace("file://", ""); var classAttr = element.GetAttribute("class"); if (classAttr != null && classAttr.Contains("showFileLocation")) { PathUtilities.SelectFileInExplorer(path); } else { Process.Start(path); } } else { // TODO: what if the hyperlink points to a web page? //Process.Start(url); } } }
/// <summary> /// Handle a mouse click in the web browser displaying the xhtml. /// </summary> private void OnDomClick(object sender, DomMouseEventArgs e) { XhtmlDocView.CloseContextMenuIfOpen(); var browser = m_mainView.NativeBrowser as GeckoWebBrowser; if (browser == null) { return; } var element = browser.DomDocument.ElementFromPoint(e.ClientX, e.ClientY); if (element == null || element.TagName == "html") { return; } if (e.Button == GeckoMouseButton.Left) { XhtmlDocView.HandleDomLeftClick(Clerk, m_propertyTable, e, element); } else if (e.Button == GeckoMouseButton.Right) { XhtmlDocView.HandleDomRightClick(browser, e, element, m_propertyTable, m_mediator); } }
/// <summary> /// Dom双击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void On_DomDoubleClick(object sender, DomMouseEventArgs e) { //屏蔽页面点击事件 e.PreventDefault(); e.StopPropagation(); var ele = e.CurrentTarget.CastToGeckoElement(); ele = e.Target.CastToGeckoElement(); GeckoHtmlElement geckoHtmlElement = (GeckoHtmlElement)ele; //短xpath var xpath1 = xpathHelper.GetSmallXpath(ele); //var xpath2 = xpathHelper.GetXpath(ele); if (xpath1.Contains("tr")) { string demo = xpath1.Substring(xpath1.IndexOf("tr")); try { demo = demo.Substring(0, demo.IndexOf("/")); } catch (Exception) { } xpath1 = xpath1.Replace(demo, "tr"); } else if (xpath1.Contains("li")) { string demo = xpath1.Substring(xpath1.IndexOf("li")); try { demo = demo.Substring(0, demo.IndexOf("/")); } catch (Exception) { } xpath1 = xpath1.Replace(demo, "li"); } if (string.IsNullOrWhiteSpace(xpath1)) { return; } var xresult = geckoWebBrowser.DomDocument.EvaluateXPath(xpath1); var nodes = xresult.GetNodes(); var elements = nodes.Select(x => x as GeckoElement).ToArray(); if (geckofxType.Equals(GeckofxWebbrowerType.General)) { } else if (geckofxType.Equals(GeckofxWebbrowerType.ListDetails)) { } else if (geckofxType.Equals(GeckofxWebbrowerType.UrlModel)) { foreach (var item in elements) { try { GeckoAnchorElement d = (GeckoAnchorElement)geckoHtmlElement; string URL = d.Href; } catch (Exception) { MessageBox.Show("链接列表有问题,请检查!"); return; } } } ruleStyle.AddClass("firefinder-match-red", elements); InsertDataGridRow(GeckofxWebbrowerType.UrlModel, dgv, geckoWebBrowser, elements); }
protected override void OnDomClick(object sender, DomMouseEventArgs e) { _browser.Focus(); }
protected virtual void OnDomClick(object sender, DomMouseEventArgs e) { }
private void GeckoWebBrowser1_DomClick(object sender, DomMouseEventArgs e) { e.Handled = true; }