Example #1
0
        private void SongQuery_DataGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (SongQuery_EditMode_CheckBox.Checked == false)
            {
                if (e.RowIndex < 0)
                {
                    return;
                }

                int i = e.RowIndex;

                string SongId       = SongQuery_DataGridView.Rows[i].Cells["Song_Id"].Value.ToString();
                string SongLang     = SongQuery_DataGridView.Rows[i].Cells["Song_Lang"].Value.ToString();
                string SongSinger   = SongQuery_DataGridView.Rows[i].Cells["Song_Singer"].Value.ToString();
                string SongSongName = SongQuery_DataGridView.Rows[i].Cells["Song_SongName"].Value.ToString();
                string SongTrack    = SongQuery_DataGridView.Rows[i].Cells["Song_Track"].Value.ToString();
                string SongFileName = SongQuery_DataGridView.Rows[i].Cells["Song_FileName"].Value.ToString();
                string SongPath     = SongQuery_DataGridView.Rows[i].Cells["Song_Path"].Value.ToString();
                string SongFilePath = Path.Combine(SongPath, SongFileName);

                List <string> PlayerSongInfoList = new List <string>()
                {
                    SongId, SongLang, SongSinger, SongSongName, SongTrack, SongFilePath, i.ToString(), "SongQuery"
                };

                Global.PlayerUpdateSongValueList = new List <string>();
                PlayerForm newPlayerForm = new PlayerForm(this, PlayerSongInfoList);
                newPlayerForm.Show();
                this.Hide();
            }
        }
Example #2
0
        private void SongQuery_DataGridView_ContextMenuItem_RightClick(object sender, EventArgs e)
        {
            string SongPath     = SongQuery_DataGridView.Rows[SongQuery_DataGridView.CurrentCell.RowIndex].Cells["Song_Path"].Value.ToString();
            string SongFileName = SongQuery_DataGridView.Rows[SongQuery_DataGridView.CurrentCell.RowIndex].Cells["Song_FileName"].Value.ToString();
            string file         = Path.Combine(SongPath, SongFileName);

            switch (sender.ToString())
            {
            case "開啟資料夾":
                if (!Directory.Exists(SongPath) || !File.Exists(file))
                {
                    SongQuery_QueryStatus_Label.Text = "選取歌曲的資料夾或檔案不存在...";
                }
                else
                {
                    string arg = "/select, " + file;
                    Process.Start("explorer", arg);
                }
                break;

            case "播放檔案":
                if (!File.Exists(file))
                {
                    SongQuery_QueryStatus_Label.Text = "【" + SongFileName + "】檔案不存在...";
                }
                else
                {
                    int i = SongQuery_DataGridView.CurrentCell.RowIndex;

                    string SongId       = SongQuery_DataGridView.Rows[i].Cells["Song_Id"].Value.ToString();
                    string SongLang     = SongQuery_DataGridView.Rows[i].Cells["Song_Lang"].Value.ToString();
                    string SongSinger   = SongQuery_DataGridView.Rows[i].Cells["Song_Singer"].Value.ToString();
                    string SongSongName = SongQuery_DataGridView.Rows[i].Cells["Song_SongName"].Value.ToString();
                    string SongTrack    = SongQuery_DataGridView.Rows[i].Cells["Song_Track"].Value.ToString();
                    string SongFilePath = Path.Combine(SongPath, SongFileName);

                    List <string> PlayerSongInfoList = new List <string>()
                    {
                        SongId, SongLang, SongSinger, SongSongName, SongTrack, SongFilePath, i.ToString(), "SongQuery"
                    };

                    Global.PlayerUpdateSongValueList = new List <string>();
                    PlayerForm newPlayerForm = new PlayerForm(this, PlayerSongInfoList);
                    newPlayerForm.Show();
                    this.Hide();
                }
                break;

            case "刪除資料列":
                string MessageText = (Global.SongMgrSongAddMode != "3") ? "你確定要刪除歌曲資料及歌曲檔案嗎?" : "你確定要刪除歌曲資料嗎?";
                if (MessageBox.Show(MessageText, "刪除提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    List <string> SongIdlist       = new List <string>();
                    List <string> SongFilelist     = new List <string>();
                    List <string> RemoveSongIdlist = new List <string>();

                    foreach (DataGridViewRow row in SongQuery_DataGridView.SelectedRows)
                    {
                        SongIdlist.Add(row.Cells["Song_Id"].Value.ToString());
                        SongFilelist.Add(row.Cells["Song_FullPath"].Value.ToString());
                    }

                    SongQuery.CreateSongDataTable();
                    Common_SwitchSetUI(false);

                    var task = Task <List <string> > .Factory.StartNew(() => SongQuery_SongRemove(SongIdlist, SongFilelist));

                    RemoveSongIdlist = task.Result;

                    foreach (DataGridViewRow row in SongQuery_DataGridView.SelectedRows)
                    {
                        if (RemoveSongIdlist.IndexOf(row.Cells["Song_Id"].Value.ToString()) > -1)
                        {
                            SongQuery_DataGridView.Rows.Remove(row);
                        }
                    }

                    if (SongQuery_DataGridView.RowCount == 0)
                    {
                        SongQuery_DataGridView.DataSource = null;
                        if (SongQuery_DataGridView.Columns.Count > 0)
                        {
                            SongQuery_DataGridView.Columns.Remove("Song_FullPath");
                        }

                        SongQuery_InitializeEditControl();
                        SongQuery_QueryStatus_Label.Text = "已無歌曲可編輯!";
                    }
                    SongQuery.DisposeSongDataTable();
                    Common_SwitchSetUI(true);
                }
                break;

            case "從我的最愛移除":
                if (MessageBox.Show("你確定要從【" + SongQuery_FavoriteQuery_ComboBox.Text + "】移除我的最愛歌曲嗎?", "刪除提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    string UserId = "";
                    var    query  = from row in Global.FavoriteUserDT.AsEnumerable()
                                    where row.Field <string>("User_Name").Equals(SongQuery_FavoriteQuery_ComboBox.Text)
                                    select row;

                    if (query.Count <DataRow>() > 0)
                    {
                        foreach (DataRow row in query)
                        {
                            UserId = row["User_Id"].ToString();
                            break;
                        }
                    }

                    List <string> SongIdlist = new List <string>();
                    foreach (DataGridViewRow row in SongQuery_DataGridView.SelectedRows)
                    {
                        SongIdlist.Add(row.Cells["Song_Id"].Value.ToString());
                        SongQuery_DataGridView.Rows.Remove(row);
                    }
                    Task.Factory.StartNew(() => SongQuery_FavoriteRemove(SongIdlist, UserId));
                }
                break;
            }
        }
Example #3
0
        private void SongAdd_DataGridView_ContextMenuItem_RightClick(object sender, EventArgs e)
        {
            string file         = SongAdd_DataGridView.Rows[SongAdd_DataGridView.CurrentCell.RowIndex].Cells["Song_SrcPath"].Value.ToString();
            string SongPath     = Path.GetDirectoryName(file);
            string SongFileName = Path.GetFileName(file);

            switch (sender.ToString())
            {
            case "開啟資料夾":
                if (!Directory.Exists(SongPath) || !File.Exists(file))
                {
                    SongAdd_Tooltip_Label.Text = "選取歌曲的資料夾或檔案不存在...";
                }
                else
                {
                    string arg = "/select, " + file;
                    Process.Start("explorer", arg);
                }
                break;

            case "播放檔案":
                if (!File.Exists(file))
                {
                    SongAdd_Tooltip_Label.Text = "【" + SongFileName + "】檔案不存在...";
                }
                else
                {
                    int i = SongAdd_DataGridView.CurrentCell.RowIndex;

                    string SongId       = SongAdd_DataGridView.Rows[i].Cells["Song_Id"].Value.ToString();
                    string SongLang     = SongAdd_DataGridView.Rows[i].Cells["Song_Lang"].Value.ToString();
                    string SongSinger   = SongAdd_DataGridView.Rows[i].Cells["Song_Singer"].Value.ToString();
                    string SongSongName = SongAdd_DataGridView.Rows[i].Cells["Song_SongName"].Value.ToString();
                    string SongTrack    = SongAdd_DataGridView.Rows[i].Cells["Song_Track"].Value.ToString();
                    string SongFilePath = file;

                    List <string> PlayerSongInfoList = new List <string>()
                    {
                        SongId, SongLang, SongSinger, SongSongName, SongTrack, SongFilePath, i.ToString(), "SongAdd"
                    };

                    Global.PlayerUpdateSongValueList = new List <string>();
                    PlayerForm newPlayerForm = new PlayerForm(this, PlayerSongInfoList);
                    newPlayerForm.Show();
                    this.Hide();
                }
                break;

            case "刪除資料列":
                if (MessageBox.Show("你確定要刪除資料嗎?", "刪除提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    foreach (DataGridViewRow row in SongAdd_DataGridView.SelectedRows)
                    {
                        SongAdd_DataGridView.Rows.Remove(row);
                    }

                    if (SongAdd_DataGridView.RowCount == 0)
                    {
                        SongAdd_DataGridView.DataSource = null;
                        SongAdd_Add_Button.Enabled      = false;
                        SongAdd_InitializeEditControl();
                        SongAdd_Tooltip_Label.Text = "已無歌曲可加入!";
                    }
                }
                break;
            }
        }