Esempio n. 1
2
 private void mnuOpenUrl_Click(object sender, RoutedEventArgs e)
 {
     var dialog = new UrlDialog();
     if (dialog.ShowDialog() != true) return;
     try
     {
         Cursor = Cursors.Wait;
         //var req = (HttpWebRequest) WebRequest.Create(dialog.Url);
         //using (var resp = req.GetResponse().GetResponseStream())
         //using (var read = new StreamReader(resp))
         //{
         //    var txt = read.ReadToEnd();
         //    txtHtml.Text = txt;
         //}
         var hw = new HtmlWeb();
         _html = hw.Load(dialog.Url);
         hapTree.BaseNode = _html.DocumentNode;
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error loading file: " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error,
                         MessageBoxResult.OK);
     }
     finally
     {
         Cursor = Cursors.Arrow;
     }
 }
        private void mnuOpenUrl_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new UrlDialog();

            if (dialog.ShowDialog() != true)
            {
                return;
            }
            try
            {
                Cursor = Cursors.Wait;
                var req = (HttpWebRequest)WebRequest.Create(dialog.Url);
                using (var resp = req.GetResponse().GetResponseStream())
                {
                    using (var read = new StreamReader(resp))
                    {
                        var txt = read.ReadToEnd();
                        txtHtml.Text = txt;
                        _html.LoadHtml(txt);
                        hapTree.BaseNode = _html.DocumentNode;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error loading file: " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error,
                                MessageBoxResult.OK);
            }
            finally
            {
                Cursor = Cursors.Arrow;
            }
        }
Esempio n. 3
0
        private void mnuOpenUrl_Click(object sender, RoutedEventArgs e)
        {
            UrlDialog dialog = new UrlDialog();

            if (dialog.ShowDialog() == true)
            {
                try
                {
                    base.Cursor           = Cursors.Wait;
                    this._html            = new HtmlWeb().Load(dialog.Url);
                    this.hapTree.BaseNode = this._html.DocumentNode;
                }
                catch (Exception exception)
                {
                    MessageBox.Show("Error loading file: " + exception.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Hand, MessageBoxResult.OK);
                }
                finally
                {
                    base.Cursor = Cursors.Arrow;
                }
            }
        }
Esempio n. 4
0
 private void mnuOpenUrl_Click(object sender, RoutedEventArgs e)
 {
     var dialog = new UrlDialog();
     if (dialog.ShowDialog() != true) return;
     try
     {
         Cursor = Cursors.Wait;
         var req = (HttpWebRequest)HttpWebRequest.Create(dialog.Url);
         using (var resp = req.GetResponse().GetResponseStream())
         using (var read = new StreamReader(resp))
         {
             var txt = read.ReadToEnd();
             txtHtml.Text = txt;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error loading file: " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
     }
     finally
     {
         Cursor = Cursors.Arrow;
     }
 }