Comm.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Speech.Synthesis;
  5. using System.Text;
  6. namespace Core.StlMes.Client.Mcp.Mch.Mcms
  7. {
  8. public static class Comm
  9. {
  10. public static void Speak(this string msg)
  11. {
  12. SpeechSynthesizer voice = new SpeechSynthesizer
  13. {
  14. Rate = 1,
  15. Volume = 100
  16. };
  17. voice.SpeakCompleted += (sender, args) => voice.Dispose();
  18. //设置语速,[-10,10]
  19. //设置音量,[0,100]
  20. voice.SpeakAsync(msg);
  21. }
  22. /// <summary>
  23. /// 安全刷新界面控件 当为子线程时委托刷新界面
  24. /// </summary>
  25. /// <param name="control"></param>
  26. /// <param name="action"></param>
  27. public static void SafeRefreshControl(this System.Windows.Forms.Control control, Action action)
  28. {
  29. if (control.InvokeRequired)
  30. control.Invoke(action);
  31. else
  32. action();
  33. }
  34. }
  35. }