コード例 #1
0
ファイル: DisplayWindow.cs プロジェクト: fahslaj/maestro_2014
        private void showCurrentPlayQueueToolStripMenuItem_Click(object sender, EventArgs e)
        {
            String[] playlist = Manager.streamer.GetInternalPlaylist();
            if (playlist == null)
            {
                return;
            }
            String attributes = "";

            for (int i = 0; i < playlist.Length; i++)
            {
                attributes += "Filepath='" + playlist[i] + "'";
                if (i < playlist.Length - 1)
                {
                    attributes += " OR ";
                }
            }

            DataTable table = DBAccessor.selectCurrentPlaylist(attributes);

            table.Columns.Add("Order");
            //table.PrimaryKey = new DataColumn[]{table.Columns[0]};
            int ind = -1;

            for (int i = 0; i < playlist.Length; i++)
            {
                for (int j = 0; j < table.Rows.Count; j++)
                {
                    System.Console.WriteLine(table.Rows[j].Field <String>(0));
                    if (table.Rows[j].Field <String>(0) == playlist[i])
                    {
                        ind = j;
                        break;
                    }
                }
                //int ind = table.Rows.IndexOf(table.Rows.Find(playlist[i]));
                table.Rows[ind].SetField <int>(table.Columns[table.Columns.Count - 1], i + 1);
            }
            table.Columns.Remove("Filepath");
            dataGridView1.DataSource = new BindingSource(table, null);
        }