|
@ -1,8 +1,11 @@ |
|
|
using System; |
|
|
using ScottPlot.Colormaps; |
|
|
|
|
|
using SunlightCentralizedControlManagement_SCCM_.ViewModel; |
|
|
|
|
|
using System; |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
using System.Data; |
|
|
using System.Data; |
|
|
using System.Data.Entity.Core.Common.CommandTrees.ExpressionBuilder; |
|
|
using System.Data.Entity.Core.Common.CommandTrees.ExpressionBuilder; |
|
|
using System.Linq; |
|
|
using System.Linq; |
|
|
|
|
|
using System.Speech.Synthesis; |
|
|
using System.Text; |
|
|
using System.Text; |
|
|
using System.Threading.Tasks; |
|
|
using System.Threading.Tasks; |
|
|
using System.Windows; |
|
|
using System.Windows; |
|
@ -13,6 +16,8 @@ using System.Windows.Input; |
|
|
using System.Windows.Media; |
|
|
using System.Windows.Media; |
|
|
using System.Windows.Media.Imaging; |
|
|
using System.Windows.Media.Imaging; |
|
|
using System.Windows.Shapes; |
|
|
using System.Windows.Shapes; |
|
|
|
|
|
using System.Windows.Threading; |
|
|
|
|
|
using static SunlightCentralizedControlManagement_SCCM_.ViewModel.MainWindowViewModel; |
|
|
|
|
|
|
|
|
namespace SunlightCentralizedControlManagement_SCCM_.WindowsView |
|
|
namespace SunlightCentralizedControlManagement_SCCM_.WindowsView |
|
|
{ |
|
|
{ |
|
@ -21,37 +26,74 @@ namespace SunlightCentralizedControlManagement_SCCM_.WindowsView |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
public partial class UserInformation : Window |
|
|
public partial class UserInformation : Window |
|
|
{ |
|
|
{ |
|
|
DataTable dataTable = new DataTable(); |
|
|
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() |
|
|
public UserInformation() |
|
|
{ |
|
|
{ |
|
|
InitializeComponent(); |
|
|
InitializeComponent(); |
|
|
|
|
|
|
|
|
//DataTable dataTable = new DataTable();
|
|
|
MainWindowViewModel.InfData.Rows.Add(new object[] { "1", "a","423","12"}); |
|
|
dataTable.Columns.Add("Machine",Type.GetType("System.String")); |
|
|
MainWindowViewModel.InfData.Rows.Add(new object[] { "2", "b" ,"345","122"}); |
|
|
dataTable.Columns.Add("Information", Type.GetType("System.String")); |
|
|
MainWindowViewModel.InfData.Rows.Add(new object[] { "3", "c" ,"345","32"}); |
|
|
dataTable.Columns.Add("Code", Type.GetType("System.String")); |
|
|
MainWindowViewModel.InfData.Rows.Add(new object[] { "1", "a", "423", "1232" }); |
|
|
dataTable.Columns.Add("ID", Type.GetType("System.Int32")); |
|
|
MainWindowViewModel.InfData.Rows.Add(new object[] { "2", "b", "345", "1222" }); |
|
|
dataTable.Rows.Add(new object[] { "1", "a","423","12"}); |
|
|
MainWindowViewModel.InfData.Rows.Add(new object[] { "3", "c", "345", "325" }); |
|
|
dataTable.Rows.Add(new object[] { "2", "b" ,"345","122"}); |
|
|
|
|
|
dataTable.Rows.Add(new object[] { "3", "c" ,"345","32"}); |
|
|
Griddata.ItemsSource = MainWindowViewModel.InfData.DefaultView; |
|
|
dataTable.Rows.Add(new object[] { "1", "a", "423", "1232" }); |
|
|
|
|
|
dataTable.Rows.Add(new object[] { "2", "b", "345", "1222" }); |
|
|
synth.Rate = int.Parse( Configini.IniReadvalue("VOICE", "V1")); |
|
|
dataTable.Rows.Add(new object[] { "3", "c", "345", "325" }); |
|
|
synth.Volume = int.Parse( Configini.IniReadvalue("VOICE", "V2")); |
|
|
|
|
|
|
|
|
Griddata.ItemsSource = dataTable.DefaultView; |
|
|
Speak(); |
|
|
|
|
|
CountDown(); |
|
|
|
|
|
} |
|
|
|
|
|
public void CountDown() |
|
|
|
|
|
{ |
|
|
|
|
|
timers.Interval = TimeSpan.FromSeconds(10);//秒
|
|
|
|
|
|
timers.Tick += DisTimer_S; |
|
|
|
|
|
timers.Start(); |
|
|
|
|
|
}//时间周期初始化
|
|
|
|
|
|
void DisTimer_S(object sender, EventArgs e)//Tick_Event周期执行事件50MS
|
|
|
|
|
|
{ |
|
|
|
|
|
Speak(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void Speak() |
|
|
|
|
|
{ |
|
|
|
|
|
if (inf_cont < MainWindowViewModel.InfData.Rows.Count) |
|
|
|
|
|
{ |
|
|
|
|
|
synth.SpeakAsync(Properties.Resources.Machine + MainWindowViewModel.InfData.Rows[inf_cont][0].ToString() + |
|
|
|
|
|
Properties.Resources.Pequest + MainWindowViewModel.InfData.Rows[inf_cont][1].ToString());//播报
|
|
|
|
|
|
inf_cont++; |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
synth.SpeakAsync(Properties.Resources.Machine + MainWindowViewModel.InfData.Rows[0][0].ToString() + |
|
|
|
|
|
Properties.Resources.Pequest + MainWindowViewModel.InfData.Rows[0][1].ToString());//播报
|
|
|
|
|
|
inf_cont = 0; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void Button_Click(object sender, RoutedEventArgs e) |
|
|
private void Button_Click(object sender, RoutedEventArgs e) |
|
|
{ |
|
|
{ |
|
|
var button = sender as Button; |
|
|
var button = sender as Button; |
|
|
DataRowView datarow = (DataRowView)button.Tag; |
|
|
DataRowView datarow = (DataRowView)button.Tag; |
|
|
var y= datarow.Row.Field<int>("ID"); |
|
|
var id= datarow.Row.Field<int>("ID"); |
|
|
DataRow erwqer = dataTable.Select("ID='" + y + "'").First(); |
|
|
DataRow erwqer = MainWindowViewModel.InfData.Select("ID='" + id + "'").First(); |
|
|
|
|
|
|
|
|
erwqer.Delete(); |
|
|
erwqer.Delete(); |
|
|
Griddata.ItemsSource = dataTable.DefaultView; |
|
|
Griddata.ItemsSource = MainWindowViewModel.InfData.DefaultView; |
|
|
|
|
|
|
|
|
if (dataTable.Rows.Count == 0) { this.Close(); } |
|
|
if (MainWindowViewModel.InfData.Rows.Count == 0) { this.Close(); } |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) |
|
|
|
|
|
{ |
|
|
|
|
|
synth.Dispose(); |
|
|
|
|
|
timers.Stop(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|