public MainPage()
        {
            InitializeComponent();

            // Create WebClient and get first data
            m_WebClient = new WebClient();
            m_WebClient.BaseAddress = "http://api.forismatic.com/api/1.0/";

            m_WebClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(ReadAnswer);

            // Random to generate random key
            Random random = new Random();
            m_WebClient.DownloadStringAsync(new Uri(apiUrl + "&key=" + random.Next(999999) ));

            // Disable refresh button during get new data
            refreshButton.IsEnabled = false;

            m_Quote = new Quote();
        }
        private void ReadAnswer(Object sender, DownloadStringCompletedEventArgs e)
        {
            if (!e.Cancelled && e.Error == null)
            {
                m_Quote = Quote.Parse(e.Result.ToString());

                quoteText.Text = m_Quote.Text;
                if (m_Quote.Author != String.Empty)
                {
                    quoteAuthor.Text = m_Quote.Author;
                }

                // Set Twitter button Uri.
                string twitterUrl = String.Empty;
                if (quoteAuthor.Text != String.Empty)
                {
                    twitterUrl = String.Format("http://twitter.com/home?status={0}©{1}.{2}", HttpUtility.UrlEncode(quoteText.Text), HttpUtility.UrlEncode(quoteAuthor.Text), HttpUtility.UrlEncode("#forismatic") );
                    twitterUrl = twitterShareUrl + HttpUtility.UrlEncode(quoteText.Text + "©" + quoteAuthor.Text + " #forismatic");
                }
                else if (quoteText.Text != String.Empty)
                {
                    twitterUrl = twitterShareUrl + HttpUtility.UrlEncode(quoteText.Text + " #forismatic");
                }
                twitterButton.NavigateUri = new Uri(twitterUrl);

                // Set Facebook button Uri.
                string facebookUrl = String.Empty;
                if (m_Quote.Link != String.Empty)
                {
                    facebookUrl = m_FacebookShareUrl + m_Quote.Link;
                }
                facebookButton.NavigateUri = new Uri(facebookUrl);

                // Set Vkontakte button Uri
                string vkontakteUrl = String.Empty;
                if (m_Quote.Link != String.Empty)
                {
                    if (m_Quote.Author != String.Empty)
                    {
                        vkontakteUrl = m_VkontakteShareUrl + m_Quote.Link + "&title=" + HttpUtility.UrlEncode(m_Quote.Text) + "&description=" + HttpUtility.UrlEncode(m_Quote.Text + "©" + m_Quote.Author);
                    }
                    else
                    {
                        vkontakteUrl = m_VkontakteShareUrl + m_Quote.Link + "&title=" + HttpUtility.UrlEncode(m_Quote.Text) + "&description=" + HttpUtility.UrlEncode(m_Quote.Text);
                    }
                }
                vkontakteButton.NavigateUri = new Uri(vkontakteUrl);

                // Set Wiki button Uri.
                if (m_Quote.Author != String.Empty)
                {
                    wikiButton.NavigateUri = new Uri(String.Format("http://ru.wikipedia.org/wiki/{0}", quoteAuthor.Text));
                    wikiButton.IsEnabled = true;
                }
                else
                {
                    wikiButton.IsEnabled = false;
                }
            }

            // Enable Refresh button
            refreshButton.IsEnabled = true;
        }