using System;
using System.Windows.Forms;

namespace GoogleSearch
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            richTextBox1.Clear();
            try
            {
                Google.API.Search.GwebSearchClient client =
                     new Google.API.Search.GwebSearchClient("");
                //--------------------------------------------------------------------------------------------------
                byte n = 10;
                var results = client.Search(textBox1.Text, n);
                //--------------------------------------------------------------------------------------------------
                for (int i = 0; i < n; i++)
                {
                    richTextBox1.Text +=
                                    "Title: " + results[i].Title + "\n";
                    richTextBox1.Text +=
                                    "Content: " + results[i].Content + "\n";
                    richTextBox1.Text +=
                                    "URL: " + results[i].Url + "\n";
                    richTextBox1.Text +=
                                    "--------------------------" + "\n";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void richTextBox1_LinkClicked(object sender, LinkClickedEventArgs e)
        {
            System.Diagnostics.Process.Start("IExplore.exe", e.LinkText);
        }
    }
}