Exemplo n.º 1
0
        private void scrobbleOnThisDate_Click(object sender, EventArgs e)
        {
            if (files.Length > 50)
            {
                MessageBox.Show("Scrobbling more than 50 tracks - last.fm response may be lagged.", "Tracks, a lot!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            C5.ArrayList <TrackInfo> tracks = new C5.ArrayList <TrackInfo>();

            try
            {
                foreach (object file in this.files)
                {
                    UltraListViewItem item = (UltraListViewItem)file;

                    TrackInfo info = new TrackInfo(item.SubItems[1].Value.ToString(), item.SubItems[2].Value.ToString(), item.SubItems[0].Value.ToString());    //artist (!empty), album (may be empty), title (!empty)
                    info.Username     = this.username;
                    info.Duration     = (int)TimeSpan.Parse(item.SubItems[3].Value.ToString()).TotalSeconds;
                    info.SourceString = "P";

                    info.SetTimeStamp((long)UnixTime.GetUnixTimeOfDate(rTime).TotalSeconds);

                    rTime = rTime.AddSeconds(info.Duration + 10 * ((new Random()).NextDouble()));

                    for (int i = 0; i < (int)item.SubItems[4].Value; i++)
                    {
                        tracks.Add(info);
                    }
                }

                //for (int j = 0; j < files.Length; j++)
                //{
                tracks.Shuffle();
                //}

                ScrobblerCache cache = new ScrobblerCache(this.username);
                cache.Append(new List <TrackInfo>(tracks.ToArray()), true);

                sm.Scrobble(ref cache);

                if (MessageBox.Show("Scrobbled successfully! Close date scrobble dialog? ", "Oll Korrect", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    this.Close();
                }
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message, "Something happened!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 2
0
        private static string ReferenceRandomizer(string s)
        {
            if (string.IsNullOrEmpty(s))
            {
                return(s);
            }

            // use C5 shuffle to start
            var chars = new C5.ArrayList <char>(s.Length);

            chars.AddAll(s.ToCharArray());
            chars.Shuffle();

            return(new string(chars.ToArray()));
        }
            public override Explanation Explain(int doc)
            {
                string[] vals = _array.getTranslatedData(doc, _dataCache.valArray);

                C5.ArrayList<float> scoreList = new C5.ArrayList<float>(_dataCache.valArray.Count);
                List<Explanation> explList = new List<Explanation>(scoreList.Count);
                foreach (string val in vals)
                {
                    int idx = _dataCache.valArray.IndexOf(val);
                    if (idx >= 0)
                    {
                        scoreList.Add(Function.Score(_dataCache.freqs[idx], BoostList[idx]));
                        explList.Add(Function.Explain(_dataCache.freqs[idx], BoostList[idx]));
                    }
                }
                Explanation topLevel = Function.Explain(scoreList.ToArray());
                foreach (Explanation sub in explList)
                {
                    topLevel.AddDetail(sub);
                }
                return topLevel;
            }
Exemplo n.º 4
0
        private void scrobbleOnThisDate_Click(object sender, EventArgs e)
        {
            if (files.Length > 50)
            {
                MessageBox.Show("Scrobbling more than 50 tracks - last.fm response may be lagged.", "Tracks, a lot!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            C5.ArrayList<TrackInfo> tracks = new C5.ArrayList<TrackInfo>();

            try
            {
                foreach (object file in this.files)
                {
                    UltraListViewItem item = (UltraListViewItem)file;

                    TrackInfo info = new TrackInfo(item.SubItems[1].Value.ToString(), item.SubItems[2].Value.ToString(), item.SubItems[0].Value.ToString());    //artist (!empty), album (may be empty), title (!empty)
                    info.Username = this.username;
                    info.Duration = (int)TimeSpan.Parse(item.SubItems[3].Value.ToString()).TotalSeconds;
                    info.SourceString = "P";

                    info.SetTimeStamp((long) UnixTime.GetUnixTimeOfDate(rTime).TotalSeconds);

                    rTime = rTime.AddSeconds(info.Duration + 10 * ( (new Random() ).NextDouble() ) );

                    for (int i = 0; i < (int)item.SubItems[4].Value; i++)
                        tracks.Add(info);
                }

                //for (int j = 0; j < files.Length; j++)
                //{
                    tracks.Shuffle();
                //}

                ScrobblerCache cache = new ScrobblerCache(this.username);
                cache.Append(new List<TrackInfo>(tracks.ToArray()), true);

                sm.Scrobble(ref cache);

                if (MessageBox.Show("Scrobbled successfully! Close date scrobble dialog? ", "Oll Korrect", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    this.Close();
                }
            }
            catch(Exception exp)
            {
                MessageBox.Show(exp.Message, "Something happened!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }