You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
97 lines
3.4 KiB
97 lines
3.4 KiB
using ScottPlot.Colormaps;
|
|
using SunlightCentralizedControlManagement_SCCM_.ViewModel;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.Entity.Core.Common.CommandTrees.ExpressionBuilder;
|
|
using System.Linq;
|
|
using System.Speech.Synthesis;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Data;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Shapes;
|
|
using System.Windows.Threading;
|
|
using static SunlightCentralizedControlManagement_SCCM_.ViewModel.MainWindowViewModel;
|
|
|
|
namespace SunlightCentralizedControlManagement_SCCM_.WindowsView
|
|
{
|
|
/// <summary>
|
|
/// UserInformation.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class UserInformation : Window
|
|
{
|
|
private static UserClass.IniFile.IniFiles Configini =
|
|
new UserClass.IniFile.IniFiles(Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "SCCM.ini");
|
|
DispatcherTimer timers = new DispatcherTimer(DispatcherPriority.Normal);//初始化循环,调用一次Tick
|
|
private SpeechSynthesizer synth = new SpeechSynthesizer();//语音
|
|
int inf_cont = 0;
|
|
public UserInformation()
|
|
{
|
|
InitializeComponent();
|
|
|
|
Griddata.ItemsSource = MainWindow.InfData.DefaultView;
|
|
|
|
synth.Rate = int.Parse( Configini.IniReadvalue("VOICE", "V1"));
|
|
synth.Volume = int.Parse( Configini.IniReadvalue("VOICE", "V2"));
|
|
|
|
Speak();
|
|
CountDown();
|
|
}
|
|
public void CountDown()
|
|
{
|
|
timers.Interval = TimeSpan.FromSeconds(5);//秒
|
|
timers.Tick += DisTimer_S;
|
|
timers.Start();
|
|
}//时间周期初始化
|
|
void DisTimer_S(object sender, EventArgs e)//Tick_Event周期执行事件50MS
|
|
{
|
|
Speak();
|
|
}
|
|
|
|
private void Speak()//语音
|
|
{
|
|
if (inf_cont < MainWindow.InfData.Rows.Count)
|
|
{
|
|
synth.SpeakAsync(Properties.Resources.Machine + MainWindow.InfData.Rows[inf_cont][0].ToString() +
|
|
MainWindow.InfData.Rows[inf_cont][1].ToString());//播报
|
|
inf_cont++;
|
|
}
|
|
else
|
|
{
|
|
synth.SpeakAsync(Properties.Resources.Machine + MainWindow.InfData.Rows[0][0].ToString() +
|
|
MainWindow.InfData.Rows[0][1].ToString());//播报
|
|
inf_cont = 0;
|
|
}
|
|
|
|
if (MainWindow.InfData.Rows.Count == 0) { this.Close(); }
|
|
}
|
|
|
|
private void Button_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
var button = sender as Button;
|
|
DataRowView datarow = (DataRowView)button.Tag;
|
|
var id = datarow.Row.Field<int>("ID");
|
|
MainWindow.InfData.Select("ID='" + id + "'").First().Delete();
|
|
|
|
Griddata.ItemsSource = MainWindow.InfData.DefaultView;
|
|
if (MainWindow.InfData.Rows.Count == 0) { this.Close(); }
|
|
}
|
|
catch (Exception) { }
|
|
|
|
}
|
|
|
|
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
|
{
|
|
synth.Dispose();
|
|
timers.Stop();
|
|
}
|
|
}
|
|
}
|
|
|