Exemplo n.º 1
0
 private void chkRetriever_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (chkRetriever.CheckedItems.Count > 0)
     {
         AlbumArtRetrieverManager.SelectRetriever(chkRetriever.CheckedItems[0].ToString());
     }
     lblSelectedRetriever.Text = AlbumArtRetrieverManager.getSelectedRetriever().getName();
 }
Exemplo n.º 2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // Start the proxy http server
            AlbumArtServer.getInstance().Start();

            // Register retrievers and fill UI.
            AlbumArtRetrieverManager.registerRetriever(new DefaultAlbumArtRetriever());
            foreach (string r in AlbumArtRetrieverManager.getRetrieverList())
            {
                chkRetriever.Items.Add(r);
            }

            chkRetriever.SetItemChecked(0, true);
            chkRetriever_SelectedIndexChanged(null, null);

            // Register Remoting object which MXiTunes will access when it starts up.
            TcpServerChannel servChannel = new TcpServerChannel(7898);

            ChannelServices.RegisterChannel(servChannel, false);
            RemotingConfiguration.RegisterWellKnownServiceType(
                typeof(MXiTunesRemote), "MXiTunes",
                WellKnownObjectMode.SingleCall);
        }
Exemplo n.º 3
0
        private static void Process(Object param)
        {
            HttpListenerContext context = (HttpListenerContext)param;
            Encoding            encoder = new UTF8Encoding();

            string url = context.Request.Url.AbsolutePath;

            Match url_match = Regex.Match(url, SearchUrlMatcher);

            if (!url_match.Success)
            {
                Form1.LogInfo("Unknown URL: " + url);
                return;
            }
            String AlbumName  = HttpUtility.UrlDecode(url_match.Groups["Album"].ToString());
            String ArtistName = HttpUtility.UrlDecode(url_match.Groups["Artist"].ToString());

            AlbumArtRetriever retriever = AlbumArtRetrieverManager.getSelectedRetriever();

            int    album_count = 0;
            String result_line = "";

            foreach (AlbumInfo album in retriever.retrieve(ArtistName, AlbumName))
            {
                album_count++;
                result_line += String.Format(PicRegexGenerator, album.AlbumArtURL, album.AlbumName, album.Artist);
            }
            Match  m = Regex.Match(result_line, PicRegex);
            String s = m.Groups["Artist"].Value;

            byte[] result_bytes = encoder.GetBytes(result_line);
            context.Response.OutputStream.Write(result_bytes, 0, result_bytes.Length);
            Form1.LogInfo(String.Format("Search of {0} {1} via {2} returned {3} albums.",
                                        new object[] { ArtistName, AlbumName, retriever.getName(), album_count }));

            context.Response.OutputStream.Close();
        }