这是我用来演讲richTextBox 的代码。我的问题是播放文本时无法单击任何内容。我什至无法停止播放。我该如何解决这个问题?有什么方法可以通过单击按钮停止播放?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Speech.Synthesis;
namespace Merger
{
public partial class Form1 : Form
{
SpeechSynthesizer tell = new SpeechSynthesizer();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
richTextBox1.SelectionAlignment = HorizontalAlignment.Center;
tell.Rate = trackBar1.Value;
}
private void Form1_Resize(object sender, EventArgs e)
{
this.Refresh();
}
private void pictureBox2_Click(object sender, EventArgs e)
{
tell.Volume = 100;
tell.Speak(richTextBox1.SelectedText);
}
private void trackBar1_ValueChanged(object sender, EventArgs e)
{
tell.Rate = trackBar1.Value;
}
private void button1_Click(object sender, EventArgs e)
{
tell.SpeakAsyncCancelAll();
}
}
}