1 Replies - 2981 Views - Last Post: 08 October 2009 - 06:07 AM Rate Topic: -----

#1 prince11  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 12-August 09

how to attach progress bar to a multi tabbed web browser in c#.net

Posted 08 October 2009 - 04:52 AM

how to attach progress bar to a multi tabbed web browser in c#.net
my code for web browser is as follows :-

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;

namespace my_browser
{
	public partial class Form1 : Form
	{
		public Form1()
		{
			InitializeComponent();
		}
		int i = 1;
		public WebBrowser Browser = new WebBrowser();
		private void Form1_Load(object sender, EventArgs e)
		{
			WebBrowser Browser = new WebBrowser();

			tabControl1.TabPages.Add("page" + i);
			tabControl1.SelectTab(i - 1);
			Browser.Name = "wb";
			Browser.Dock = DockStyle.Fill;
			tabControl1.SelectedTab.Controls.Add(Browser);
			i = i + 1;
			((WebBrowser)tabControl1.SelectedTab.Controls[0]).Navigate("http://www.google.com");
		}

		private void officeButtonTrial1_Click(object sender, EventArgs e)
		{
			WebBrowser Browser = new WebBrowser();

			tabControl1.TabPages.Add("page" + i);
			tabControl1.SelectTab(i - 1);
			Browser.Name = "wb";
			Browser.Dock = DockStyle.Fill;
			tabControl1.SelectedTab.Controls.Add(Browser);
			i = i + 1;
		}

		private void ηєωТαвToolStripMenuItem_Click(object sender, EventArgs e)
		{

			WebBrowser Browser = new WebBrowser();

			tabControl1.TabPages.Add("page" + i);
			tabControl1.SelectTab(i - 1);
			Browser.Name = "wb";
			Browser.Dock = DockStyle.Fill;
			tabControl1.SelectedTab.Controls.Add(Browser);
			i = i + 1;
		}

		private void officeButtonTrial2_Click(object sender, EventArgs e)
		{
			tabControl1.TabPages.RemoveAt(tabControl1.SelectedIndex);
			tabControl1.SelectTab(tabControl1.TabPages.Count - 1);
			i = i - 1;

		}

		private void ℓσѕєТαвToolStripMenuItem_Click(object sender, EventArgs e)
		{
			tabControl1.TabPages.RemoveAt(tabControl1.SelectedIndex);
			tabControl1.SelectTab(tabControl1.TabPages.Count - 1);
			i = i - 1;
		}
	
	   
	
	 

		private void officeButtonTrial3_Click(object sender, EventArgs e)
		{
			((WebBrowser)tabControl1.SelectedTab.Controls[0]).GoBack();
		}

		private void officeButtonTrial4_Click(object sender, EventArgs e)
		{
			((WebBrowser)tabControl1.SelectedTab.Controls[0]).GoForward();
		}

		private void officeButtonTrial5_Click(object sender, EventArgs e)
		{
			((WebBrowser)tabControl1.SelectedTab.Controls[0]).Refresh();
		}

		private void officeButtonTrial6_Click(object sender, EventArgs e)
		{
			((WebBrowser)tabControl1.SelectedTab.Controls[0]).Stop();
		}

		private void officeButtonTrial7_Click(object sender, EventArgs e)
		{
			((WebBrowser)tabControl1.SelectedTab.Controls[0]).Navigate("http://www.google.com");

		}

		private void officeButtonTrial8_Click(object sender, EventArgs e)
		{
			((WebBrowser)tabControl1.SelectedTab.Controls[0]).Navigate(textBox1.Text);
		}

		private void officeButtonTrial9_Click(object sender, EventArgs e)
		{
			MessageBox.Show("PageRank: " + GooglePageRank.GetPageRank(textBox1.Text), "∂αяк кηιgнт");

		}

		private void officeButtonTrial10_Click(object sender, EventArgs e)
		{
			string breaker = "";
			char[] delimiter = breaker.ToCharArray();
			string[] splitterArray = textBox2.Text.Trim().Split(delimiter);
			string queries = "";
			foreach (string s in splitterArray)
			{
				queries += s + "+";
			}
			queries.Substring(0, (queries.Length - 1));
			if (comboBox1.SelectedIndex == 0)
			{
				((WebBrowser)tabControl1.SelectedTab.Controls[0]).Navigate("http://www.youtube.com/results?search_type=search_video&search_query=" + queries);
			}
			if (comboBox1.SelectedIndex == 1)
			{
				((WebBrowser)tabControl1.SelectedTab.Controls[0]).Navigate("http://www.google.com/search?q=" + queries);
			}
			if (comboBox1.SelectedIndex == 2)
			{
				((WebBrowser)tabControl1.SelectedTab.Controls[0]).Navigate("http://search.yahoo.com/search?q=" + queries);
			}
			if (comboBox1.SelectedIndex == 3)
			{
				((WebBrowser)tabControl1.SelectedTab.Controls[0]).Navigate("http://www.answers.com/main/ntquery?s=" + queries);
			}
		}

		private void єχιтToolStripMenuItem_Click(object sender, EventArgs e)
		{
			MessageBox.Show("тнαηкѕ σя υѕιηg ∂αяк кηιgнт ωєв вяσωѕєя", "∂αяк кηιgнт");

			Application.Exit();

		}

		private void αвσυтToolStripMenuItem_Click(object sender, EventArgs e)
		{
			Form2 f2 = new Form2();
			f2.Show();
		}

		private void statusStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
		{

		}
	}
	public static class GooglePageRank
	{
		private static void Mix(ref uint a, ref uint b, ref uint c)
		{
			a -= b;
			a -= c;
			a ^= c >> 13;
			b -= c;
			b -= a;
			b ^= a << 8;
			c -= a;
			c -= b;
			c ^= b >> 13;
			a -= b;
			a -= c;
			a ^= c >> 12;
			b -= c;
			b -= a;
			b ^= a << 16;
			c -= a;
			c -= b;
			c ^= b >> 5;
			a -= b;
			a -= c;
			a ^= c >> 3;
			b -= c;
			b -= a;
			b ^= a << 10;
			c -= a;
			c -= b;
			c ^= b >> 15;
		}

		private static string GoogleChecksum(string url)
		{
			uint GoogleMagic = 0xE6359A60;

			uint a, b;
			uint c = GoogleMagic;

			a = b = 0x9E3779B9;

			int k = 0;
			int length = url.Length;

			//Algorithm
			while (length >= 12)
			{
				a += (uint)(url[k + 0] + (url[k + 1] << 8) + (url[k + 2] << 16) + (url[k + 3] << 24));
				b += (uint)(url[k + 4] + (url[k + 5] << 8) + (url[k + 6] << 16) + (url[k + 7] << 24));
				c += (uint)(url[k + 8] + (url[k + 9] << 8) + (url[k + 10] << 16) + (url[k + 11] << 24));

				Mix(ref a, ref b, ref c);

				k += 12;
				length -= 12;
			}

			c += (uint)url.Length;

			//All cases fall through
			switch (length)
			{
				case 11:
					c += (uint)(url[k + 10] << 24);
					goto case 10; //fall through
				case 10:
					c += (uint)(url[k + 9] << 16);
					goto case 9;
				case 9:
					c += (uint)(url[k + 8] << 8);
					goto case 8;
				case 8:
					b += (uint)(url[k + 7] << 24);
					goto case 7;
				case 7:
					b += (uint)(url[k + 6] << 16);
					goto case 6;
				case 6:
					b += (uint)(url[k + 5] << 8);
					goto case 5;
				case 5:
					b += (uint)(url[k + 4]);
					goto case 4;
				case 4:
					a += (uint)(url[k + 3] << 24);
					goto case 3;
				case 3:
					a += (uint)(url[k + 2] << 16);
					goto case 2;
				case 2:
					a += (uint)(url[k + 1] << 8);
					goto case 1;
				case 1:
					a += (uint)(url[k + 0]);
					break;
				default:
					break;
			}

			Mix(ref a, ref b, ref c);

			return string.Format("6{0}", c);
		}

		public static int GetPageRank(string url)
		{
			//Calculate URL checksum
			string checkSum = GoogleChecksum("info:" + url);
			string file = "http://toolbarqueries.google.com/search?client=navclient-auto&ch=" + checkSum + "&features=Rank&q=info:" + url;

			try
			{
				//Request PR from Google
				WebRequest request = WebRequest.Create(file);
				WebResponse response = request.GetResponse();

				StreamReader reader = new StreamReader(response.GetResponseStream());
				string data = reader.ReadToEnd();

				reader.Close();
				response.Close();

				//Parse PR from string
				int pageRank = -1;
				if (data.IndexOf(':') != -1)
				{
					data = data.Substring(data.LastIndexOf(':') + 1);
				}

				int.TryParse(data, out pageRank);

				return pageRank;
			}
			catch (Exception)
			{
				return -1;
			}
		}
	}
}


Mod Edit: When you are posting code please use code tags like this. :code:

Is This A Good Question/Topic? 0
  • +

Replies To: how to attach progress bar to a multi tabbed web browser in c#.net

#2 Aeternalis  Icon User is offline

  • D.I.C Regular

Reputation: 28
  • View blog
  • Posts: 291
  • Joined: 13-July 09

Re: how to attach progress bar to a multi tabbed web browser in c#.net

Posted 08 October 2009 - 06:07 AM

What have you done to try to implement it? What errors are you getting?

What is the code not doing?

You have not provided enough information to help you. Also.. it works better if you try to implement it yourself and then tell us what errors you are getting.

Asking us to just implement a progress bar in this piece of code is not only vague.. but it shows no effort on your part to try to accomplish the task. Were not here to do it for you, we are here to help YOU do it.

Aet
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1