• Hello Guest! Welcome to ConsoleCrunch, to help support our site check out the premium upgrades HERE! to get exclusive access to our hidden content.
  • Unable to load portions of the website...
    If you use an ad blocker addon, you should disable it because it interferes with several elements of the site and blocks more than just adverts.
  • Read Rules Before Posting Post Virus Scans with every program.

[C#] Web Browser Source

Elite_Modz

Active Poster
Retired Staff
Active Member
Console ID Poster
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;

namespace Browser1
{
  public partial class UserControl1 : UserControl
  {
  public UserControl1()
  {
  InitializeComponent();
  }

  private void UserControl1_Load(object sender, EventArgs e)
  {

  }

  #region Design
  public void Design_1()
  {
  //Progressbar for Loading
  progressBar1.Visible = true;
  progressBar2.Visible = true;

  //Side Panels
  panel_1.Visible = true;
  panel_2.Visible = true;
  }

  public void Design_2()
  {

  }
  #endregion

  #region Search
  public void Search_1()
  {
  try
  {
  if (String.IsNullOrEmpty(textBox1.Text))
  {

  }
  else
  {
  if (textBox1.Text.Contains("https://"))
  {
  Load_1();
  webBrowser1.ScriptErrorsSuppressed = true;
  webBrowser1.Navigate(textBox1.Text);
  //BrowserTitle();
  }
  else if (textBox1.Text.Contains("http://"))
  {
  Load_1();
  webBrowser1.ScriptErrorsSuppressed = true;
  webBrowser1.Navigate(textBox1.Text);
  //BrowserTitle();
  }
  else if (!textBox1.Text.Contains("."))
  {
  Load_1();
  webBrowser1.ScriptErrorsSuppressed = true;
  webBrowser1.Navigate("https://www.google.com/search?q=" + textBox1.Text);
  //BrowserTitle();
  }
  else
  {
  Load_1();
  webBrowser1.ScriptErrorsSuppressed = true;
  webBrowser1.Navigate("https://" + textBox1.Text);
  //BrowserTitle();
  }
  }
  }
  catch (Exception ex)
  {
  MessageBox.Show(ex.Message);
  }
  }

  public void Search_2()
  {

  }

  public void Load_1()
  {
  panel1.Enabled = false;
  }

  public static void BrowserTitle()
  {
  UserControl1 userControl1 = new UserControl1();
  //userControl1.BrowserUrl();
  //Form1.TabTitle(BrowserUrl());
  //MessageBox.Show(BrowserUrl());

  Form1 form1 = new Form1();
  form1.tabControl1.TabPages[form1.tabControl1.SelectedIndex].Text = userControl1.webBrowser1.DocumentTitle.ToString();
  form1.tabControl1.SelectedTab.Text = userControl1.webBrowser1.DocumentTitle.ToString();
  form1.tabControl1.Refresh();
  }
  #endregion

  public string BrowserUrl()
  {
  if (!String.IsNullOrEmpty(webBrowser1.Url.ToString()))
  {
  return GetWebPageTitle(webBrowser1.Url.ToString());
  }
  else
  {
  return null;
  }
  }

  public static string GetWebPageTitle(string url)
  {
  // Create a request to the url

  HttpWebRequest request = HttpWebRequest.Create(url) as HttpWebRequest;

  // If the request wasn’t an HTTP request (like a file), ignore it

  if (request == null) return null;

  // Use the user’s credentials

  request.UseDefaultCredentials = true;

  // Obtain a response from the server, if there was an error, return nothing

  HttpWebResponse response = null;

  try { response = request.GetResponse() as HttpWebResponse; }

  catch (WebException) { return null; }

  // Regular expression for an HTML title

  string regex = @"(?<=<title.*>)([\s\S]*)(?=</title>)";

  // If the correct HTML header exists for HTML text, continue

  if (new List<string>(response.Headers.AllKeys).Contains("Content-Type"))

  if (response.Headers["Content-Type"].StartsWith("text/html"))
  {
  // Download the page

  WebClient web = new WebClient();

  web.UseDefaultCredentials = true;

  string page = web.DownloadString(url);

  // Extract the title

  Regex ex = new Regex(regex, RegexOptions.IgnoreCase);

  return ex.Match(page).Value.Trim();
  }

  // Not a valid HTML page

  return null;

  }


  private void label2_Click(object sender, EventArgs e)
  {
  progressBar1.Visible = true;
  progressBar2.Visible = true;
  progressBar1.Value = 100;
  progressBar2.Value = 100;
  Search_1();
  }

  private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
  {
  if (e.KeyChar == (char)ConsoleKey.Enter)
  {
  Search_1();
  }
  }

  private void webBrowser1_DocumentCompleted_1(object sender, WebBrowserDocumentCompletedEventArgs e)
  {
  panel1.Enabled = true;
  }

  private void label5_Click(object sender, EventArgs e)
  {
  progressBar1.Visible = true;
  progressBar2.Visible = true;
  progressBar1.Value = 0;
  progressBar2.Value = 0;
  //BrowserTitle();
  }

  private void webBrowser1_NewWindow(object sender, CancelEventArgs e)
  {

  }
  }
}
 
General chit-chat
Help Users
  • @ QM|T_JinX:
    for sure haha well lets hope right
  • @ QM|T_JinX:
    i still think if there was a jailbreak for ps4 this site would have been back for sure
  • @ God:
    That would be awesome I’m sure it will happen before long, technology now a days is crazy! If we can work out a deal and plans I’ll be spreading the word and doing a lot to make it better more attractive and helpful fourms tips giveaways and all
  • @ God:
    I’ve been messing and working with trying to make great CSS for the names. Like Staff Premium news writer etc..
  • @ QM|T_JinX:
    ok so hows that going /
  • @ God:
    It’s going good. So we will see what happens and if the site can come back like it was or better
  • @ QM|T_JinX:
    nice yea lets hope
  • @ QM|T_JinX:
    im going to play some red dead it was great to have spoken to you bro nice to see you back on here
  • @ QM|T_JinX:
    hope you have a great night bro
  • @ God:
    It was good talking with you as well, you have a great night! We will talk later bro
    +1
  • Chat Bot:
    QM|T_JinX has joined the room.
  • @ QM|T_JinX:
    have a great weekend everybody ill be back after the weekend
  • Chat Bot:
    OkBrruh is our newest member. Welcome!
  • Chat Bot:
    uncrtin is our newest member. Welcome!
  • Chat Bot:
    BigTechModz is our newest member. Welcome!
  • @ BigTechModz:
    Hey this is RexMods I don’t remember the login to my old account so I made a new one I am now known as BigTechModz
  • Chat Bot:
    QM|T_JinX has joined the room.
  • Chat Bot:
    QM|T_JinX has joined the room.
  • Chat Bot:
    iDior2K is our newest member. Welcome!
  • Chat Bot:
    QM|T_JinX has joined the room.
  • Chat Bot:
    KillerDino49 is our newest member. Welcome!
  • Chat Bot:
    Xiomber is our newest member. Welcome!
  • Chat Bot:
    QM|T_JinX has joined the room.
  • Chat Bot:
    QM|T_JinX has joined the room.
  • Chat Bot:
    QM|T_JinX has joined the room.
      Chat Bot: QM|T_JinX has joined the room.
      Back
      Top