From 084ae8dc3558fb5e28fe5e3f6935da501d39dff2 Mon Sep 17 00:00:00 2001 From: liuwf Date: Wed, 27 Mar 2024 17:18:23 +0800 Subject: [PATCH] =?UTF-8?q?change-=E6=9C=97=E8=AF=BB=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Aucma.Core.Palletiz/Common/SpeechStr.cs | 36 +++++++++++++++++++ .../ViewModels/MainWindowViewModel.cs | 6 ++-- .../ViewModels/SetRangeWindowViewModel.cs | 3 ++ 3 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 Aucma.Core.Palletiz/Common/SpeechStr.cs diff --git a/Aucma.Core.Palletiz/Common/SpeechStr.cs b/Aucma.Core.Palletiz/Common/SpeechStr.cs new file mode 100644 index 00000000..37e9f865 --- /dev/null +++ b/Aucma.Core.Palletiz/Common/SpeechStr.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Speech.Synthesis; +using System.Text; +using System.Threading.Tasks; + +namespace Aucma.Core.Palletiz.Common +{ + public class SpeechStr + { + private static readonly Lazy lazy = new Lazy(() => new SpeechStr()); + + public static SpeechStr Instance { + get + { + return lazy.Value; + } + } + + public void speech(string str) { + + SpeechSynthesizer speech = new SpeechSynthesizer(); + speech.Rate = 3;//设置语速 + speech.Volume = 100;//设置音量 + speech.SelectVoice("Microsoft Huihui Desktop");//设置播音员(中文) + speech.SpeakAsync(str); + + } + + + } + + + +} diff --git a/Aucma.Core.Palletiz/ViewModels/MainWindowViewModel.cs b/Aucma.Core.Palletiz/ViewModels/MainWindowViewModel.cs index bd88bbea..434acf02 100644 --- a/Aucma.Core.Palletiz/ViewModels/MainWindowViewModel.cs +++ b/Aucma.Core.Palletiz/ViewModels/MainWindowViewModel.cs @@ -16,6 +16,7 @@ using Admin.Core.IService; using Microsoft.Extensions.DependencyInjection; using Aucma.Core.Palletiz.Business; using Aucma.Core.HwPLc; +using Aucma.Core.Palletiz.Common; namespace Aucma.Core.Palletiz.ViewModels { @@ -25,7 +26,7 @@ namespace Aucma.Core.Palletiz.ViewModels private IndexPageView firstPage = new IndexPageView();//首页 private StatisticsPageView recordPage = new StatisticsPageView(); private PalletizPageView palletizPage = new PalletizPageView(); - + private SpeechStr speech = SpeechStr.Instance; ISysUserInfoServices _sysUserInfoServices; public MainWindowViewModel() { @@ -39,7 +40,8 @@ namespace Aucma.Core.Palletiz.ViewModels //测试开启 //InstoreBusiness instore=new InstoreBusiness(); //instore.test(); - + + } public void init() diff --git a/Aucma.Core.Palletiz/ViewModels/SetRangeWindowViewModel.cs b/Aucma.Core.Palletiz/ViewModels/SetRangeWindowViewModel.cs index f95e2903..5e5acdc1 100644 --- a/Aucma.Core.Palletiz/ViewModels/SetRangeWindowViewModel.cs +++ b/Aucma.Core.Palletiz/ViewModels/SetRangeWindowViewModel.cs @@ -10,6 +10,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; +using System.Speech.Synthesis; namespace Aucma.Core.Palletiz.ViewModels { @@ -140,6 +141,8 @@ namespace Aucma.Core.Palletiz.ViewModels { config.RangeConfig = config.RangeConfig + $"[{MinModel}-{MaxModel}-{SelectedOddNumber}-{SelectedEvenNumber}]"; MessageBox.Show("保存成功"); + + InitDataGrid(); } }