コード例 #1
0
ファイル: main.cs プロジェクト: dominikcebula/idotfm
        private void GetTracks_Click(object sender, EventArgs e)
        {
            try
            {
                SubmitTracks.Enabled = false;
                MyTunes myTunes = new MyTunes(this);
                myTunes.FillGrid(TrackGridView, pbGetTracks);

                if (TrackGridView.Rows.Count > 0)
                {
                    MessageBox.Show(TrackGridView.Rows.Count + " track(s) trasnferred from iTunes", "Information",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("No tracks with playcount greater than 0 found in iDotFm list.", "Information",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }
            }
            catch (Exception exp)
            {
                MessageBox.Show("Error getting tracks from iTunes: " + exp.Message, "Error",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
コード例 #2
0
        public void Submit(DataGridView tracks, ProgressBar bar)
        {
            if (user == "" || md5pass == "")
            {
                throw new Exception("Write down and save your login/password first");
            }

            String   artist, album, title;
            DateTime dateStarted;
            TimeSpan duration;
            Entry    entry;
            int      s = 0;

            Connection      conn   = new Connection(clientID, versionID, user, md5pass);
            ScrobbleManager scrobb = new ScrobbleManager(conn, Config.GetAppPath());

            File.Delete(scrobb.CacheDir + scrobb.cacheFileName);

            bar.Maximum = tracks.Rows.Count + 1;
            bar.Value   = 0;

            foreach (DataGridViewRow row in tracks.Rows)
            {
                bar.Value = bar.Value + 1;
                bar.Refresh();

                artist      = row.Cells[0].Value.ToString();
                album       = row.Cells[1].Value.ToString();
                title       = row.Cells[2].Value.ToString();
                dateStarted = DateTime.Parse(row.Cells[3].Value.ToString()).ToUniversalTime();
                duration    = TimeSpan.FromSeconds(Double.Parse(row.Cells[4].Value.ToString()));

                entry       = new Entry(artist, title, dateStarted, PlaybackSource.User, duration, ScrobbleMode.Played);
                entry.Album = album;
                scrobb.Queue(entry);
                s++;

                if (s > 25)
                {
                    scrobb.Submit();
                    s = 0;
                }
            }

            if (s > 0)
            {
                scrobb.Submit();
            }

            bar.Value = bar.Value + 1;

            MyTunes mytunes = new MyTunes(fmain);

            mytunes.Clear();

            fmain.SubmitTracks.Enabled = false;
        }