void HandleWebViewFinishedLoad(object sender, WebFrameEventArgs e) { if (match != null) { ShowNode(match); match = null; } if (navigationCells.SelectedSegment != -1) { navigationCells.SetSelected(false, navigationCells.SelectedSegment); } var dom = e.ForFrame.DomDocument; // Update the title of the current page var elements = dom.GetElementsByTagName("title"); if (elements.Count > 0 && !string.IsNullOrWhiteSpace(elements[0].TextContent)) { currentTitle = elements[0].TextContent.Length > 2 ? elements[0].TextContent.Substring(2) : elements[0].TextContent; } // Process embedded images coming from doc source // Because WebView doesn't let me answer a NSUrlRequest myself I have to resort to this piece of crap of a solution var imgs = dom.GetElementsByTagName("img").Where(node => node.Attributes["src"].NodeValue.StartsWith("source-id")); byte[] buffer = new byte[4096]; foreach (var img in imgs) { var src = img.Attributes["src"].NodeValue; var imgStream = AppDelegate.Root.GetImage(src); if (imgStream == null) { continue; } var length = imgStream.Read(buffer, 0, buffer.Length); var read = length; while (read != 0) { if (length == buffer.Length) { var oldBuffer = buffer; buffer = new byte[oldBuffer.Length * 2]; Buffer.BlockCopy(oldBuffer, 0, buffer, 0, oldBuffer.Length); } length += read = imgStream.Read(buffer, length, buffer.Length - length); } var data = Convert.ToBase64String(buffer, 0, length, Base64FormattingOptions.None); var uri = "data:image/" + src.Substring(src.LastIndexOf('.')) + ";base64," + data; ((DomElement)img).SetAttribute("src", uri); } }
void HandleStartedProvisionalLoad(object sender, WebFrameEventArgs e) { var url = String.Empty; if (e.ForFrame.ProvisionalDataSource.Request.MainDocumentURL != null) { url = e.ForFrame.ProvisionalDataSource.Request.MainDocumentURL.ToString(); } if (String.IsNullOrEmpty(url)) { return; } bool cancel = false; ApplicationContext.InvokeUserCode(delegate { cancel = EventSink.OnNavigateToUrl(url); }); if (cancel) { e.ForFrame.StopLoading(); } }
void HandleWebViewFinishedLoad (object sender, WebFrameEventArgs e) { if (match != null) { ShowNode (match); match = null; } if (navigationCells.SelectedSegment != -1) navigationCells.SetSelected (false, navigationCells.SelectedSegment); var dom = e.ForFrame.DomDocument; // Update the title of the current page var elements = dom.GetElementsByTagName ("title"); if (elements.Count > 0 && !string.IsNullOrWhiteSpace (elements[0].TextContent)) currentTitle = elements[0].TextContent.Length > 2 ? elements[0].TextContent.Substring (2) : elements[0].TextContent; // Process embedded images coming from doc source // Because WebView doesn't let me answer a NSUrlRequest myself I have to resort to this piece of crap of a solution var imgs = dom.GetElementsByTagName ("img").Where (node => node.Attributes["src"].Value.StartsWith ("source-id")); byte[] buffer = new byte[4096]; foreach (var img in imgs) { var src = img.Attributes["src"].Value; var imgStream = AppDelegate.Root.GetImage (src); if (imgStream == null) continue; var length = imgStream.Read (buffer, 0, buffer.Length); var read = length; while (read != 0) { if (length == buffer.Length) { var oldBuffer = buffer; buffer = new byte[oldBuffer.Length * 2]; Buffer.BlockCopy (oldBuffer, 0, buffer, 0, oldBuffer.Length); } length += read = imgStream.Read (buffer, length, buffer.Length - length); } var data = Convert.ToBase64String (buffer, 0, length, Base64FormattingOptions.None); var uri = "data:image/" + src.Substring (src.LastIndexOf ('.')) + ";base64," + data; ((DomElement)img).SetAttribute ("src", uri); } }
void HandleFinishedLoadForCss(object sender, WebFrameEventArgs e) { SetCustomCss(); }
private void WebViewWillCloseFrame(object sender, WebFrameEventArgs e) { }
private void WebViewFinishedLoad(object sender, WebFrameEventArgs e) { }
private void WebViewCommitedLoad(object sender, WebFrameEventArgs e) { }
private void WebViewStartedProvisionalLoad(object sender, WebFrameEventArgs e) { }
private void HandleFinishedLoad (object sender, WebFrameEventArgs e) { NoteTitle(currentNote.Title); // this needs to be here once the Window has loaded, otherwise the default window settings will override }
private void HandleFinishedLoad(object sender, WebFrameEventArgs e) { NoteTitle(currentNote.Title); // this needs to be here once the Window has loaded, otherwise the default window settings will override }