当前位置: 首页> 娱乐> 明星 > 专业的企业宣传片制作企业_三门峡网站seo_怎么创建一个网页_广州营销优化

专业的企业宣传片制作企业_三门峡网站seo_怎么创建一个网页_广州营销优化

时间:2025/7/15 16:42:36来源:https://blog.csdn.net/2403_88923953/article/details/146914981 浏览次数:0次
专业的企业宣传片制作企业_三门峡网站seo_怎么创建一个网页_广州营销优化

首先我们要知道,跨线程使用让文本显示在文本框中,然后进行程序读取。这期间我们需要调用Speech。 所用到的控件是  button  textbox

效果展示


1.声明方法

void thread_control()
{List<string> list = new List<string>();list.Add("这是一段由线程修改的控件文本\r\n");list.Add("跨线程的操作,你很快就能理解了");for(int i = 0; i < 2; i++){txtbook.Text += list[i];Thread.Sleep(1500);}
} 

2.Appear 显示调用

 private void Appeartxt_Click(object sender, EventArgs e){new Thread(thread_control).Start();}

3.声明实例化Speech

 SpeechSynthesizer synthesizer=new SpeechSynthesizer();string word;

4.Speaking 按钮实现

 private void speaktxt_Click(object sender, EventArgs e){if(txtbook.Text!=""){word= txtbook.Text;}else{word = "请先输入文字";}synthesizer.SpeakAsync(word);}

5.textbox 回车代替按键

   private void txtbook_KeyDown(object sender, KeyEventArgs e){if (e.KeyCode == Keys.Enter){this.speaktxt.Focus();this.speaktxt_Click (sender, e);}}

6.跨线程调用

CheckForIllegalCrossThreadCalls=false;

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Speech;
using System.Speech.Synthesis;
using System.Threading;namespace _01.Speak
{public partial class Form1 : Form{public Form1(){InitializeComponent();CheckForIllegalCrossThreadCalls=false;}//右键添加引用 =>  引入System.Speech//synthesizer 综合器SpeechSynthesizer synthesizer=new SpeechSynthesizer();string word;private void speaktxt_Click(object sender, EventArgs e){if(txtbook.Text!=""){word= txtbook.Text;}else{word = "请先输入文字";}synthesizer.SpeakAsync(word);}void thread_control(){List<string> list = new List<string>();list.Add("这是一段由线程修改的控件文本\r\n");list.Add("跨线程的操作,你很快就能理解了");for(int i = 0; i < 2; i++){txtbook.Text += list[i];Thread.Sleep(1500);}}//按回车键,直接Speakingprivate void txtbook_KeyDown(object sender, KeyEventArgs e){if (e.KeyCode == Keys.Enter){this.speaktxt.Focus();this.speaktxt_Click (sender, e);}}//显示加载文字private void Appeartxt_Click(object sender, EventArgs e){new Thread(thread_control).Start();}}
}

关键字:专业的企业宣传片制作企业_三门峡网站seo_怎么创建一个网页_广州营销优化

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: