コード例 #1
0
ファイル: BrowserPage.xaml.cs プロジェクト: netcharm/PixivWPF
        private void WebBrowser_DocumentCompleted(object sender, System.Windows.Forms.WebBrowserDocumentCompletedEventArgs e)
        {
            try
            {
                if (sender == webHtml)
                {
                    ((System.Windows.Forms.WebBrowser)sender).Document.Window.Error += new System.Windows.Forms.HtmlElementErrorEventHandler(Window_Error);

                    var browser = sender as System.Windows.Forms.WebBrowser;
                    foreach (System.Windows.Forms.HtmlElement link in browser.Document.Links)
                    {
                        try
                        {
                            if (string.IsNullOrEmpty(link.GetAttribute("href")))
                            {
                                continue;
                            }
                            link.Click += WebBrowser_LinkClick;
                        }
                        catch (Exception ex) { ex.ERROR(); continue; }
                    }
                    WebBrowserReplaceImageSource(browser);
                }
            }
#if DEBUG
            catch (Exception ex)
            {
                if (ParentWindow is ContentWindow)
                {
                    (ParentWindow as ContentWindow).SetPrefetchingProgress(-1, state: TaskStatus.Faulted);
                }
                //BrowserWait.Fail();
                ex.Message.DEBUG();
            }
#else
            catch (Exception ex) { ex.ERROR(); BrowserWait.Fail(); }
#endif
            finally
            {
                if (ParentWindow is ContentWindow)
                {
                    (ParentWindow as ContentWindow).SetPrefetchingProgress(-1, state: TaskStatus.RanToCompletion);
                }
                //BrowserWait.Hide();
            }
        }