本文整理汇总了C#中System.Windows.Controls.WebBrowser.NavigateToString方法的典型用法代码示例。如果您正苦于以下问题:C# WebBrowser.NavigateToString方法的具体用法?C# WebBrowser.NavigateToString怎么用?C# WebBrowser.NavigateToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.WebBrowser
的用法示例。
在下文中一共展示了WebBrowser.NavigateToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Show
private void Show(object obj)
{
RadFlowDocument document = this.CreateDocument();
HtmlFormatProvider formatProvider = new HtmlFormatProvider();
string html = formatProvider.Export(document);
WebBrowser browser = new WebBrowser();
browser.NavigateToString(html);
Window window = new Window() { Width = 1000, Height = 350 };
window.Content = browser;
window.Show();
}
示例2: SetVideo
/// <summary>
/// Create Video Player.
/// </summary>
/// <param name="video"></param>
private void SetVideo(string video)
{
var profile = Windows.Networking.Connectivity.NetworkInformation.GetInternetConnectionProfile();
if (profile != null)
{
var interfaceType = profile.NetworkAdapter.IanaInterfaceType;
if (interfaceType == 71)
{
//Wifi
_youTubeButton = new YouTubeButton {YouTubeID = _videoId};
_youTubeButton.Click += youTubeButton_Click;
LayoutRoot.Children.Clear();
LayoutRoot.Children.Add(_youTubeButton);
}
else
{
//Other
var web = new WebBrowser()
{
Height = 600,
IsScriptEnabled = true
};
web.NavigateToString(string.Format("<!doctype html>" +
"<html><head><title></title></head><body style=background-color:black;>" +
"<iframe height=\"600\" src=\"http://www.youtube.com/embed/{0}\" width=\"1000\"></iframe>" +
"</body></html>", video));
LayoutRoot.Children.Clear();
LayoutRoot.Children.Add(web);
}
}
}
示例3: MarkdownPreviewToolWindow
/// <summary>
/// Standard constructor for the tool window.
/// </summary>
public MarkdownPreviewToolWindow() : base(null)
{
this.Caption = MarkdownSharp.Language.Message("DocumentPreview");
this.BitmapResourceID = 301;
this.BitmapIndex = 1;
//force WebBrowser into IE9 mode
SetWebBrowserIE9DocMode();
browser = new WebBrowser();
browser.NavigateToString(MarkdownSharp.Language.Message("OpenUDNDocumentFileToSeePreview"));
browser.LoadCompleted += (sender, args) =>
{
if (scrollBackTo.HasValue)
{
var document = browser.Document as mshtml.IHTMLDocument2;
if (document != null)
{
var element = document.body as mshtml.IHTMLElement2;
if (element != null)
{
element.scrollTop = scrollBackTo.Value;
}
}
}
scrollBackTo = null;
isLoading = false;
};
browser.Navigating += new NavigatingCancelEventHandler(webBrowser_Navigating);
}
示例4: MyMapView_MapViewTapped
private async void MyMapView_MapViewTapped(object sender, Esri.ArcGISRuntime.Controls.MapViewInputEventArgs e)
{
MyMapView.Overlays.Items.Clear();
IEnumerable<KmlFeature> features = await (MyMapView.Map.Layers["kmlLayer"] as KmlLayer).HitTestAsync(MyMapView, e.Position);
if (features.Count() > 0)
{
if (!string.IsNullOrWhiteSpace(features.FirstOrDefault().BalloonStyle.FormattedText))
{
//Create WebBrowser to show the formatted text
var browser = new System.Windows.Controls.WebBrowser();
browser.NavigateToString(features.FirstOrDefault().BalloonStyle.FormattedText);
//Get the KmlPlacemark position
var featurePosition = (features.FirstOrDefault() as KmlPlacemark).Extent;
//Create ContentControl
var cControl = new ContentControl()
{
Content = browser,
MaxHeight = 500,
MaxWidth = 450
};
//Add the ContentControl to MapView.Overlays
MapView.SetViewOverlayAnchor(cControl, featurePosition.GetCenter());
MyMapView.Overlays.Items.Add(cControl);
}
}
}
示例5: MarkdownPreviewToolWindow
/// <summary>
/// Standard constructor for the tool window.
/// </summary>
public MarkdownPreviewToolWindow()
: base(null)
{
this.Caption = "Markdown Preview";
this.BitmapResourceID = 301;
this.BitmapIndex = 1;
browser = new WebBrowser();
browser.NavigateToString(EmptyWindowHtml);
browser.LoadCompleted += (sender, args) =>
{
if (scrollBackTo.HasValue)
{
var document = browser.Document as mshtml.IHTMLDocument2;
if (document != null)
{
var element = document.body as mshtml.IHTMLElement2;
if (element != null)
{
element.scrollTop = scrollBackTo.Value;
}
}
}
scrollBackTo = null;
};
}
示例6: MarkdownPreviewToolWindow
/// <summary>
/// Standard constructor for the tool window.
/// </summary>
public MarkdownPreviewToolWindow() : base(null)
{
this.Caption = "Markdown Preview";
this.BitmapResourceID = 301;
this.BitmapIndex = 1;
browser = new WebBrowser();
browser.NavigateToString(EmptyWindowHtml);
browser.LoadCompleted += (sender, args) =>
{
if (scrollBackTo.HasValue)
{
var document = browser.Document as mshtml.IHTMLDocument2;
if (document != null)
{
var element = document.body as mshtml.IHTMLElement2;
if (element != null)
{
element.scrollTop = scrollBackTo.Value;
}
}
}
scrollBackTo = null;
};
browser.IsVisibleChanged += HandleBrowserIsVisibleChanged;
browser.Navigating += (sender, args) =>
{
if (this.path == null)
{
return; // current context unknown
}
if (args.Uri == null || args.Uri.HostNameType != UriHostNameType.Unknown || string.IsNullOrEmpty(args.Uri.LocalPath))
{
return; // doesn't look like a relative uri
}
string documentName = new FileInfo(this.path).ResolveRelativePath(
args.Uri.LocalPath.Replace('/', Path.DirectorySeparatorChar));
// If there is a file name but it doesn't exist and doesn't have an extension, try adding
// ".md" (GitHub style target in a literal anchor link).
if(documentName != null && !File.Exists(documentName) && Path.GetExtension(documentName).Length == 0)
documentName += ".md";
if(documentName == null || !File.Exists(documentName))
{
return; // relative path could not be resolved, or does not exist
}
VsShellUtilities.OpenDocument(this, documentName);
args.Cancel = true; // open matching document
};
}
示例7: BindableSourcePropertyChanged
/// <summary>
///
/// </summary>
/// <param name="o"></param>
/// <param name="e"></param>
public static void BindableSourcePropertyChanged(DependencyObject o,
DependencyPropertyChangedEventArgs e)
{
_webBrowser = (WebBrowser)o;
_webBrowser.NavigateToString((string)e.NewValue);
// Object used for communication from JS -> WPF
_webBrowser.ObjectForScripting = new HtmlInterop();
// for testing with an html source file:
//webBrowser.Navigate(new Uri(@"file:///C:/Temp/test.html"));
}
示例8: HelpButton_Click
void HelpButton_Click(object sender, RoutedEventArgs e)
{
var vmdl = DataContext as ViewModel;
if (vmdl != null && vmdl.HasHelpText)
{
var html = new WebBrowser();
var header = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/></head><body style=\"background:#FFFFE0;font-family: Verdana, Arial; font-size: 0.8em;\">";
var footer = "</body></html>";
html.NavigateToString(header + vmdl.HelpText + footer);
var wnd = new Window();
wnd.Style = Application.Current.Resources["PopupWindow"] as Style;
wnd.Title = vmdl.HelpCommand.Label;
wnd.Content = html;
wnd.Show();
}
}
示例9: DownloadHTMLAsync
public static async Task DownloadHTMLAsync(SynchronizationContext sc, string url, WebBrowser toSet)
{
HttpClient client = new HttpClient();
HttpResponseMessage response = await client.GetAsync(url);
string content = await response.Content.ReadAsStringAsync();
sc.Post(rawState =>
{
string strToRemove = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">";
string parsedState = ((string)rawState).Replace(strToRemove, "").Trim();
HtmlDocument document = new HtmlDocument();
document.LoadHtml(parsedState);
HtmlNode collection = document.GetElementbyId("fw-mainColumn");
toSet.NavigateToString(collection.InnerHtml);
}, content);
}
示例10: newWb
public void newWb(string url)
{
if (webBrowser != null)
{
webBrowser.LoadCompleted -= completed;
webBrowser.Dispose();
gridwebBrowser.Children.Remove(webBrowser);
}
if (doc != null)
{
doc.clear();
}
webBrowser = new WebBrowser();
webBrowser.LoadCompleted += completed;
gridwebBrowser.Children.Add(webBrowser);
Script.HideScriptErrors(webBrowser, true);
if (url == "")
{
webBrowser.NavigateToString(Properties.Resources.New);
doc = webBrowser.Document as HTMLDocument;
doc.designMode = "On";
Format.doc = doc;
return;
}
else
{
webBrowser.Navigate(url);
}
doc = webBrowser.Document as HTMLDocument;
Format.doc = doc;
}
示例11: ParseLine
private void ParseLine(string line)
{
int lineCount = 0;
int maxLineCount = GetMaxLineCount();
string tempLine = line;
var sbLine = new StringBuilder();
while (lineCount < maxLineCount)
{
int charactersFitted = MeasureString(tempLine, (int) Width);
string leftSide = tempLine.Substring(0, charactersFitted);
sbLine.Append(leftSide);
tempLine = tempLine.Substring(charactersFitted, tempLine.Length - (charactersFitted));
lineCount++;
}
TextBlock textBlock = GetTextBlock();
textBlock.TextWrapping = TextWrapping.Wrap;
textBlock.Text = sbLine.ToString();
var wb = new WebBrowser {Height = 10*(textBlock.ActualWidth/320)};
wb.NavigateToString(WebBrowserHelper.WrapHtml(line, Application.Current.RootVisual.RenderSize.Width));
_stackPanel.Children.Add(wb);
if (tempLine.Length > 0)
ParseLine(tempLine);
}
示例12: generateRightCanvas
/// <summary>
/// Generate right page
/// </summary>
/// <param name="pageNumber"></param>
/// <returns>canvas, right canvas to renderBook()</returns>
private Canvas generateRightCanvas(int pageNumber)
{
SolidColorBrush whiteBrush = new SolidColorBrush();
whiteBrush.Color = Colors.White;
Canvas canvas = new Canvas();
canvas.Width = 520;
canvas.Height = 720;
canvas.Background = whiteBrush;
canvas.Margin = new Thickness(520, 0, 0, 0);
// Amu
WebBrowser wbRightPage = new WebBrowser();
// If there is odd number of pages last page in right will be empty (in future it will be filled with next chapter's first page)
if (!(parser.pageCount < (pageNumber + 1)))
{
wbRightPage.NavigateToString(splittedPages[pageNumber]);
}
wbRightPage.Width = 490;
wbRightPage.Height = 700;
wbRightPage.Margin = new Thickness(0, 8, 0, 0);
wbRightPage.Foreground = new SolidColorBrush(Colors.Magenta);
// set the padding area to top and to left
wbRightPage.SetValue(Canvas.LeftProperty, 20.00);
wbRightPage.SetValue(Canvas.TopProperty, 50.00);
canvas.Children.Add(wbRightPage);
Rectangle rectangle = new Rectangle();
rectangle.Width = 32;
rectangle.Height = 720;
rectangle.Fill = this.Resources["RightShadow"] as LinearGradientBrush;
rectangle.Margin = new Thickness(0, 0, 0, 0);
canvas.Children.Add(rectangle);
return canvas;
}
示例13: generateLeftCanvas
/// <summary>
/// Generate left page
/// </summary>
/// <param name="pageNumber"></param>
/// <returns>canvas, left canvas to renderBook()</returns>
private Canvas generateLeftCanvas(int pageNumber)
{
SolidColorBrush whiteBrush = new SolidColorBrush();
whiteBrush.Color = Colors.White;
Canvas canvas = new Canvas();
canvas.Width = 520;
canvas.Height = 720;
canvas.Background = whiteBrush;
canvas.Margin = new Thickness(0, 0, 0, 0);
WebBrowser wbLeftPage = new WebBrowser();
wbLeftPage.NavigateToString(splittedPages[pageNumber]);
wbLeftPage.Width = 490;
wbLeftPage.Height = 700;
wbLeftPage.Margin = new Thickness(8, 8, 0, 0);
wbLeftPage.Foreground = new SolidColorBrush(Colors.Magenta);
// set the padding area to top and to left
wbLeftPage.SetValue(Canvas.LeftProperty, 20.00);
wbLeftPage.SetValue(Canvas.TopProperty, 50.00);
canvas.Children.Add(wbLeftPage);
Rectangle rectangle = new Rectangle();
rectangle.Width = 32;
rectangle.Height = 720;
rectangle.Fill = this.Resources["LeftShadow"] as LinearGradientBrush;
rectangle.Margin = new Thickness(490, 0, 0, 0);
canvas.Children.Add(rectangle);
return canvas;
}
示例14: handleCompleted
private void handleCompleted(WebBrowser browser, /*ProgressBar progress,*/
object sender, DownloadStringCompletedEventArgs e, IScrapper scrapper)
{
if (e.Error != null)
{
browser.NavigateToString("Error occured: " + e.Error.ToString());
}
else
{
if (e.Cancelled)
{
browser.NavigateToString("Request was cancelled");
}
else
{
var searchResults = scrapper.Scrape(e.Result);
browser.NavigateToString(GetHtml(searchResults));
}
}
}
示例15: DisplayHTML
private void DisplayHTML(String html)
{
reportContent.Children.Clear();
WebBrowser browser = new WebBrowser();
browser.Navigating += new System.Windows.Navigation.NavigatingCancelEventHandler(browser_Navigating);
browser.NavigateToString(html);
reportContent.Children.Add(browser);
}