Browse Source

播报信息页面逻辑

master
sc 3 months ago
parent
commit
9bcffdc6df
  1. 2
      MainWindow.xaml.cs
  2. 9
      Properties/Resources.Designer.cs
  3. 3
      Properties/Resources.en-US.resx
  4. 3
      Properties/Resources.resx
  5. 3
      Properties/Resources.zh-CN.resx
  6. 3
      Properties/Resources.zh-TW.resx
  7. 2
      View/MonitorView.xaml.cs
  8. 16
      ViewModel/MainWindowViewModel.cs
  9. 36
      WindowsView/UserInformation.xaml
  10. 82
      WindowsView/UserInformation.xaml.cs

2
MainWindow.xaml.cs

@ -44,7 +44,7 @@ namespace SunlightCentralizedControlManagement_SCCM_
AsEnumerable().Select(rowdata => rowdata.Field<string>("Name")).ToList(); AsEnumerable().Select(rowdata => rowdata.Field<string>("Name")).ToList();
} }
user_ = App.USER_Purview; user_ = App.USER_Purview;
username.Text = user_; username.Text = user_;
} }
private void ButtonPopUpLogout_Click(object sender, RoutedEventArgs e) private void ButtonPopUpLogout_Click(object sender, RoutedEventArgs e)

9
Properties/Resources.Designer.cs

@ -1698,6 +1698,15 @@ namespace SunlightCentralizedControlManagement_SCCM_.Properties {
} }
} }
/// <summary>
/// 查找类似 Pequest 的本地化字符串。
/// </summary>
public static string Pequest {
get {
return ResourceManager.GetString("Pequest", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Permit 的本地化字符串。 /// 查找类似 Permit 的本地化字符串。
/// </summary> /// </summary>

3
Properties/Resources.en-US.resx

@ -1068,4 +1068,7 @@
<data name="Vol" xml:space="preserve"> <data name="Vol" xml:space="preserve">
<value>Vol</value> <value>Vol</value>
</data> </data>
<data name="Pequest" xml:space="preserve">
<value>Pequest</value>
</data>
</root> </root>

3
Properties/Resources.resx

@ -1068,4 +1068,7 @@
<data name="Vol" xml:space="preserve"> <data name="Vol" xml:space="preserve">
<value>Vol</value> <value>Vol</value>
</data> </data>
<data name="Pequest" xml:space="preserve">
<value>Pequest</value>
</data>
</root> </root>

3
Properties/Resources.zh-CN.resx

@ -1068,4 +1068,7 @@
<data name="Vol" xml:space="preserve"> <data name="Vol" xml:space="preserve">
<value>音量</value> <value>音量</value>
</data> </data>
<data name="Pequest" xml:space="preserve">
<value>请求</value>
</data>
</root> </root>

3
Properties/Resources.zh-TW.resx

@ -1068,4 +1068,7 @@
<data name="Vol" xml:space="preserve"> <data name="Vol" xml:space="preserve">
<value>音量</value> <value>音量</value>
</data> </data>
<data name="Pequest" xml:space="preserve">
<value />
</data>
</root> </root>

2
View/MonitorView.xaml.cs

@ -70,7 +70,9 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
DATA_view(); DATA_view();
UserInformation userInformation = new UserInformation(); UserInformation userInformation = new UserInformation();
userInformation.Topmost = true;
userInformation.Show(); userInformation.Show();
userInformation.Activate();
} }
private string machine; private string machine;

16
ViewModel/MainWindowViewModel.cs

@ -71,12 +71,12 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
private SQLiteHelper SQLiteHelpers = null; //定义数据库 private SQLiteHelper SQLiteHelpers = null; //定义数据库
private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\SCCM.db"; //数据库路径 private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\SCCM.db"; //数据库路径
public static DataTable Machines = new DataTable(); //设备表缓存 public static DataTable Machines = new DataTable(); //设备表缓存
public static DataTable InfData = new DataTable();
// public static DataRow MachinesROW; // public static DataRow MachinesROW;
public static DataTable USER_data = new DataTable(); public static DataTable USER_data = new DataTable();
public static UserControls.info[] inf = new UserControls.info[999]; //定义总览信息卡 public static UserControls.info[] inf = new UserControls.info[999]; //定义总览信息卡
public static int ERR_c = 0;//错误计数器 public static int ERR_c = 0;//错误计数器
public static bool[] USER_Capacity { set; get; } = new bool[99]; public static bool[] USER_Capacity { set; get; } = new bool[99];
// private SpeechSynthesizer synth = new SpeechSynthesizer();//语音
public MainWindowViewModel() public MainWindowViewModel()
{ {
@ -90,10 +90,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
SN_ID = Configini.IniReadvalue("SN", "SN2"); SN_ID = Configini.IniReadvalue("SN", "SN2");
SN_KEY = Configini.IniReadvalue("SN", "SN1"); SN_KEY = Configini.IniReadvalue("SN", "SN1");
DyelotsDispenser = Convert.ToBoolean(Configini.IniReadvalue("SYS", "DyelotsDispenser")); DyelotsDispenser = Convert.ToBoolean(Configini.IniReadvalue("SYS", "DyelotsDispenser"));
// synth.Rate = int.Parse( Configini.IniReadvalue("VOICE", "V1"));
// synth.Volume = int.Parse( Configini.IniReadvalue("VOICE", "V2"));
} }
catch (Exception ex) { LogGing.ERRDATA(ex); } catch (Exception ex) { LogGing.ERRDATA(ex); }
@ -103,13 +99,17 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
USER_data = SQLiteHelpers.ExecuteDataSet("select * from USER order by Name desc", null).Tables[0]; USER_data = SQLiteHelpers.ExecuteDataSet("select * from USER order by Name desc", null).Tables[0];
SQLiteHelpers.Close(); SQLiteHelpers.Close();
// MachinesROW = Machines.NewRow();
USERCapacity(App.USER_Purview);//App.USER_Purview); USERCapacity(App.USER_Purview);//App.USER_Purview);
CountDown(); CountDown();
TcpClientNEW(); TcpClientNEW();
SQL_LINK(); SQL_LINK();
/**添加提示信息栏**/
InfData.Columns.Add("Machine", Type.GetType("System.String"));
InfData.Columns.Add("Information", Type.GetType("System.String"));
InfData.Columns.Add("Code", Type.GetType("System.String"));
InfData.Columns.Add("ID", Type.GetType("System.Int32"));
} }
public static void USERCapacity(string user) //权限 public static void USERCapacity(string user) //权限
{ {

36
WindowsView/UserInformation.xaml

@ -6,26 +6,20 @@
xmlns:local="clr-namespace:SunlightCentralizedControlManagement_SCCM_" xmlns:local="clr-namespace:SunlightCentralizedControlManagement_SCCM_"
xmlns:lang="clr-namespace:SunlightCentralizedControlManagement_SCCM_.Properties" xmlns:lang="clr-namespace:SunlightCentralizedControlManagement_SCCM_.Properties"
mc:Ignorable="d" mc:Ignorable="d"
Closing="Window_Closing"
Title="UserInformation" Height="450" Width="800"> Title="UserInformation" Height="450" Width="800">
<Grid> <Grid>
<DataGrid x:Name="Griddata" AlternationCount="2" IsReadOnly="True" <DataGrid x:Name="Griddata" AlternationCount="2" IsReadOnly="True" d:ItemsSource="{d:SampleData ItemCount=99}"
d:ItemsSource="{d:SampleData ItemCount=30}" AutoGenerateColumns="False" MinColumnWidth="30" AutoGenerateColumns="False" MinColumnWidth="30" Background="White" GridLinesVisibility="All"
Background="White" GridLinesVisibility="All" ColumnHeaderHeight="40" HorizontalContentAlignment="Right" ColumnHeaderHeight="50" HorizontalContentAlignment="Right" CanUserReorderColumns="False"
CanUserReorderColumns="False" CanUserSortColumns="False" CanUserResizeRows="False" CanUserResizeColumns="False" CanUserSortColumns="False" CanUserResizeRows="False" CanUserResizeColumns="False"
CanUserDeleteRows="False" SelectionMode="Single" FontSize="15" Focusable="True" > CanUserDeleteRows="False" SelectionMode="Single" FontSize="25" Focusable="True" >
<DataGrid.RowStyle > <DataGrid.RowStyle >
<Style TargetType="{x:Type DataGridRow}"> <Style TargetType="{x:Type DataGridRow}">
<Setter Property="Height" Value="30" /> <Setter Property="Height" Value="60" />
<Setter Property="FontSize" Value="25" /> <Setter Property="FontSize" Value="50" />
<Setter Property="VerticalAlignment" Value="Center"/> <Setter Property="VerticalAlignment" Value="Stretch"/>
<Style.Triggers> <Setter Property="HorizontalAlignment" Value="Right"/>
<Trigger Property="ItemsControl.AlternationIndex" Value="0">
<Setter Property="Background" Value="#FFFFFFFF" />
</Trigger>
<Trigger Property="ItemsControl.AlternationIndex" Value="1">
<Setter Property="Background" Value="#FFF0F0F0" />
</Trigger>
</Style.Triggers>
</Style> </Style>
</DataGrid.RowStyle> </DataGrid.RowStyle>
<DataGrid.CellStyle> <DataGrid.CellStyle>
@ -51,16 +45,16 @@ CanUserDeleteRows="False" SelectionMode="Single" FontSize="15" Focusable="True"
</Style> </Style>
<DataTemplate x:Key="btnCell"> <DataTemplate x:Key="btnCell">
<!--注意此处的设置方式--> <!--注意此处的设置方式-->
<Button Content="{x:Static lang:Resources.Confirm}" Click="Button_Click" Tag="{Binding}"/> <Button Content="{x:Static lang:Resources.Confirm}" Click="Button_Click" Tag="{Binding}" FontSize="20"/>
</DataTemplate> </DataTemplate>
</DataGrid.Resources> </DataGrid.Resources>
<DataGrid.Columns> <DataGrid.Columns>
<!--列信息绑定--> <!--列信息绑定-->
<DataGridTextColumn Header="{x:Static lang:Resources.Machine}" Binding="{Binding Machine}" Width="150" IsReadOnly="True"/> <DataGridTextColumn Header="{x:Static lang:Resources.Machine}" Binding="{Binding Machine}" Width="150" IsReadOnly="True"/>
<DataGridTextColumn Header="{x:Static lang:Resources.Information}" Binding="{Binding Code}" MaxWidth="0" IsReadOnly="True"/> <DataGridTextColumn Binding="{Binding Code}" MaxWidth="0" IsReadOnly="True"/>
<DataGridTextColumn Header="{x:Static lang:Resources.Information}" Binding="{Binding ID}" MaxWidth="0" IsReadOnly="True"/> <DataGridTextColumn Binding="{Binding ID}" MaxWidth="0" IsReadOnly="True"/>
<DataGridTextColumn Header="{x:Static lang:Resources.Information}" Binding="{Binding inf}" Width="*" IsReadOnly="True"/> <DataGridTextColumn Header="{x:Static lang:Resources.Information}" Binding="{Binding Information}" Width="*" IsReadOnly="True"/>
<DataGridTemplateColumn Width="100" CellTemplate="{StaticResource btnCell}" /> <DataGridTemplateColumn Width="100" CellTemplate="{StaticResource btnCell}"/>
</DataGrid.Columns> </DataGrid.Columns>
</DataGrid> </DataGrid>

82
WindowsView/UserInformation.xaml.cs

@ -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();
} }
} }
} }

Loading…
Cancel
Save