Beispiel #1
0
        private void LoadData()
        {
            // show status in textbox
            tbOutput.Text = "loading...";
            tbOutput.Update();

            try
            {
                NowPlaying np = LoadDataFromFreed();
                tbOutput.Text = JsonConvert.SerializeObject(np, Newtonsoft.Json.Formatting.Indented);
            }
            catch (Exception ex)
            {
                tbOutput.Text = ex.Message;
            }

            btRefresh.Focus();
        }
Beispiel #2
0
        private void notifyIcon1_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                try
                {
                    NowPlaying np = LoadDataFromFreed();

                    string artist = np.Results[0].songfile.artist;
                    string title  = np.Results[0].songfile.title;

                    notifyIcon1.BalloonTipText = String.Format("{0} - {1}", artist, title);
                    notifyIcon1.ShowBalloonTip(1000);
                }
                catch
                {
                    notifyIcon1.BalloonTipText = "fout bij inlezen data";
                    notifyIcon1.ShowBalloonTip(10);
                }
            }
        }
Beispiel #3
0
        private NowPlaying LoadDataFromFreed()
        {
            // in corporate environments, often a proxy-server is used
            IWebProxy proxy = WebRequest.GetSystemWebProxy();

            proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;

            WebClient wc = new WebClient();

            wc.Proxy = proxy;
            // we don't want any old (cached) data
            wc.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.NoCacheNoStore);

            string json = wc.DownloadString(_feedUrl);

            NowPlaying np = new NowPlaying();

            JsonConvert.PopulateObject(json, np);


            return(np);
        }