FrmBoFang.cs
资源名称:KTV.rar [点击查看]
上传用户:fzwcsgshou
上传日期:2022-07-30
资源大小:28414k
文件大小:7k
源码类别:
行业应用
开发平台:
Visual C++
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- namespace KTV
- {
- public partial class FrmBoFang : Form
- {
- public FrmBoFang()
- {
- InitializeComponent();
- }
- private bool tag = false;
- public static DataSet ds = new DataSet();
- private void FrmBoFang_Load(object sender, EventArgs e)
- {
- listBox1.DisplayMember = "歌曲名称";
- listBox1.ValueMember = "存放位置";
- ds.Tables.Add();
- ds.Tables[0].Columns.Add("存放位置");
- ds.Tables[0].Columns.Add("歌曲名称");
- listBox1.DataSource = ds.Tables[0];
- }
- public int i = 0;
- private int YouXianID = -1;
- private void button9_Click(object sender, EventArgs e)
- {
- tag = false;
- if (listBox1.Items.Count < 1)
- {
- MessageBox.Show("请选择您要播放的歌曲!", "温馨提示", MessageBoxButtons.OK,
- MessageBoxIcon.Asterisk);
- return;
- }
- if (listBox1.SelectedValue.ToString() != "")
- {
- axWindowsMediaPlayer1.URL = listBox1.SelectedValue.ToString();
- i = listBox1.SelectedIndex;
- }
- else
- {
- MessageBox.Show("请选择您要播放的歌曲!", "温馨提示", MessageBoxButtons.OK,
- MessageBoxIcon.Asterisk);
- }
- }
- private void btnBoFang_Click(object sender, EventArgs e)
- {
- if (listBox1.Items.Count < 1)
- {
- MessageBox.Show("请选择您要播放的歌曲!", "温馨提示", MessageBoxButtons.OK,
- MessageBoxIcon.Asterisk);
- return;
- }
- axWindowsMediaPlayer1.Ctlcontrols.play();
- tag = false;
- }
- private void btnZanTing_Click(object sender, EventArgs e)
- {
- axWindowsMediaPlayer1.Ctlcontrols.pause();
- }
- private void btnTingZhi_Click(object sender, EventArgs e)
- {
- axWindowsMediaPlayer1.Ctlcontrols.stop();
- tag = true;
- }
- private void btnUp_Click(object sender, EventArgs e)
- {
- if (listBox1.Items.Count < 1)
- {
- MessageBox.Show("请选择您要播放的歌曲!", "温馨提示", MessageBoxButtons.OK,
- MessageBoxIcon.Asterisk);
- return;
- }
- axWindowsMediaPlayer1.Ctlcontrols.previous();
- listBox1.ClearSelected();
- if (i == 0)
- {
- i = listBox1.Items.Count - 1;
- }
- else
- {
- i=i-1;
- }
- listBox1.SetSelected(i, true);
- axWindowsMediaPlayer1.URL = ds.Tables[0].Rows[i]["存放位置"].ToString();
- }
- private void btnNext_Click(object sender, EventArgs e)
- {
- if (listBox1.Items.Count < 1)
- {
- MessageBox.Show("请选择您要播放的歌曲!", "温馨提示", MessageBoxButtons.OK,
- MessageBoxIcon.Asterisk);
- return;
- }
- axWindowsMediaPlayer1.Ctlcontrols.next();
- listBox1.ClearSelected();
- if (i == listBox1.Items.Count - 1)
- {
- i = 0;
- }
- else
- {
- i = i + 1;
- }
- listBox1.SetSelected(i, true);
- axWindowsMediaPlayer1.URL = ds.Tables[0].Rows[i]["存放位置"].ToString();
- }
- private void button8_Click(object sender, EventArgs e)
- {
- ds.Tables[0].Rows.RemoveAt(listBox1.SelectedIndex);
- }
- private void button10_Click(object sender, EventArgs e)
- {
- ds.Tables[0].Rows.InsertAt(ds.Tables[0].Rows[0],listBox1.SelectedIndex - 1);
- ds.Tables[0].Rows.RemoveAt(listBox1.SelectedIndex+1);
- }
- private void button7_Click(object sender, EventArgs e)
- {
- FrmXuanZe FrmXuanZe1 = new FrmXuanZe();
- FrmXuanZe1.Show();
- }
- private void FrmBoFang_Shown(object sender, EventArgs e)
- {
- FrmXuanZe FrmXuanZe1 = new FrmXuanZe();
- FrmXuanZe1.Show();
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- if (axWindowsMediaPlayer1.playState == WMPLib.WMPPlayState.wmppsStopped && tag==false)
- {
- if (YouXianID == -1)
- {
- listBox1.ClearSelected();
- if (comboBox1.Text.Trim() == "顺序播放")
- {
- if (i <= listBox1.Items.Count - 1)
- {
- i = -1;
- }
- i = i + 1;
- }
- else if (comboBox1.Text.Trim() == "倒叙播放")
- {
- if (i <= 0)
- {
- i = listBox1.Items.Count;
- }
- i = i - 1;
- }
- else if (comboBox1.Text.Trim() == "随机播放")
- {
- System.Random r = new Random();
- i=r.Next(listBox1.Items.Count);
- }
- listBox1.SetSelected(i, true);
- axWindowsMediaPlayer1.URL = ds.Tables[0].Rows[i]["存放位置"].ToString();
- }
- else
- {
- axWindowsMediaPlayer1.URL = ds.Tables[0].Rows[YouXianID]["存放位置"].ToString();
- }
- }
- }
- private void btnQuanPing_Click(object sender, EventArgs e)
- {
- if (axWindowsMediaPlayer1.playState == WMPLib.WMPPlayState.wmppsPlaying)
- {
- axWindowsMediaPlayer1.fullScreen = true;
- }
- else
- {
- MessageBox.Show("请先播放,再点全屏!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- }
- }
- private void btnYouXianBoFang_Click(object sender, EventArgs e)
- {
- YouXianID = listBox1.SelectedIndex;
- }
- private void pictureBox1_Click(object sender, EventArgs e)
- {
- MessageBox.Show("需要硬件设备支持!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- }
- private void button1_Click(object sender, EventArgs e)
- {
- if (MessageBox.Show("这里退出将关闭KTV点歌系统,您真的要退出吗?", "系统提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- {
- return;
- }
- Application.Exit();
- }
- private void FrmBoFang_FormClosing(object sender, FormClosingEventArgs e)
- {
- if (MessageBox.Show("这里退出将关闭KTV点歌系统,您真的要退出吗?", "系统提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- {
- return;
- }
- Application.Exit();
- }
- }
- }