C#疑难问题?追分..在线等...

来源:百度知道 编辑:UC知道 时间:2024/06/19 12:40:52
1,在Panel里面,必须按下鼠标左键移动才能发出声音,如果鼠标在Panel里面按下左键,但一直不动的话,停止发出声音.(怎样判断??)
2.怎样获取鼠标的移动速度和声音的播放速度?
麻烦回答完整问题.写出详细代码.
如果鼠标在Panel里面按下左键,但一直不动的话,停止发出声音.没有达到效果..

2.如果要获取鼠标移动速度,可以定义一个Point变量,用于记录上一次移动前鼠标坐标,然后鼠标移动以后计算X,Y的偏移量大小,用于计算移动速度------(思路我也知道,不知道怎么写..麻烦你写下.)
代码测试后好像都没达到要求,好像需要用一个timer来做判断

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication2
{
public partial class Form7 : Form
{
System.Media.SoundPlayer s;
private Point p;
public Form7()
{
InitializeComponent();
s = new System.Media.SoundPlayer(@"C:\a.wav");
s.Load();
p = new Point(0, 0);
}

private void panel1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
s.Play();
}
else
{
s.Stop();
}
}
}
}

1.我这个只能播放wav格式的音频
2.如果要获取鼠标移动速