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()));
        }
Exemplo n.º 3
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);
            }
        }