添加关机退出按钮
This commit is contained in:
commit
8db7de1d3c
4 files changed
+30
-9
No files matched your search
+1
-1
@@ -8,7 +8,7 @@
|
||||
xmlns:viewmodel="clr-namespace:DyeingComputer.ViewModel"
|
||||
d:DataContext="{d:DesignInstance Type=viewmodel:MainWindowViewModel}"
|
||||
mc:Ignorable="d"
|
||||
Title="SUNLIGHT 838 b0.0.1 (2024/08/10)"
|
||||
Title="SUNLIGHT838"
|
||||
Height="720" Width="1280"
|
||||
WindowState ="Maximized"
|
||||
WindowStyle="None">
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
<TextBlock Name="RX" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Bottom" Height="30" Width="100" Margin="5,0,0,0"/>
|
||||
<TextBlock Name="TX" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Bottom" Height="30" Width="100" Margin="200,0,0,0"/>
|
||||
|
||||
<DataGrid x:Name="_set" AutoGenerateColumns="False" FontSize="15"
|
||||
ColumnHeaderHeight="40" Width="400" HorizontalAlignment="Right" Margin="0,10,10,200" Background="{x:Null}" >
|
||||
<DataGrid x:Name="_set" AutoGenerateColumns="False" FontSize="15" ColumnHeaderHeight="40" Width="600"
|
||||
HorizontalAlignment="Right" Margin="0,10,10,200" Background="{x:Null}" >
|
||||
<DataGrid.RowStyle >
|
||||
<Style TargetType="{x:Type DataGridRow}">
|
||||
<Setter Property="Height" Value="30" />
|
||||
@@ -49,12 +49,14 @@
|
||||
</DataGrid.CellStyle>
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="Key" Binding="{Binding Key}" Width="*"/>
|
||||
<DataGridTextColumn Header="Type" Binding="{Binding Value}" Width="*"/>
|
||||
<DataGridTextColumn Header="Type" Binding="{Binding Value}" Width="200"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
<Button Content="{x:Static lang:Resources.Shutdown}" x:Name="Shutdown" FontSize="20" HorizontalAlignment="Right" Height="40" Margin="0,0,10,10"
|
||||
<Button Content="{x:Static lang:Resources.Shutdown}" x:Name="Shutdown" FontSize="20" HorizontalAlignment="Right" Height="40" Margin="0,0,20,20"
|
||||
VerticalAlignment="Bottom" Width="200" Background="White" Click="Shutdown_Click"/>
|
||||
<Button Content="{x:Static lang:Resources.Quit}" x:Name="Quit" FontSize="20" HorizontalAlignment="Right" Height="40" Margin="0,0,300,20"
|
||||
VerticalAlignment="Bottom" Width="200" Background="White" Click="Quit_Click"/>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -1,6 +1,7 @@
|
||||
using DyeingComputer.ViewModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -22,6 +23,7 @@ namespace DyeingComputer.View
|
||||
/// </summary>
|
||||
public partial class EngineerSetView : UserControl
|
||||
{
|
||||
int _S=0;
|
||||
public EngineerSetView()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -70,6 +72,10 @@ namespace DyeingComputer.View
|
||||
RX.Text = MainWindowViewModel.RX.ToString();
|
||||
TX.Text = MainWindowViewModel.TX.ToString();
|
||||
|
||||
_S++;
|
||||
if (_S > 60)
|
||||
{
|
||||
_S = 0;
|
||||
var displayData = MainWindowViewModel.Hardware.Select(kvp => new AdvancedDictionaryEntry
|
||||
{
|
||||
Key = kvp.Key,
|
||||
@@ -77,6 +83,18 @@ namespace DyeingComputer.View
|
||||
}).ToList();
|
||||
_set.ItemsSource = displayData;
|
||||
}
|
||||
}
|
||||
|
||||
private void Quit_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show(Properties.Resources.Quit, "800", MessageBoxButton.YesNo);
|
||||
if (messageBoxResult == MessageBoxResult.No) return;
|
||||
if (messageBoxResult == MessageBoxResult.Yes)
|
||||
{
|
||||
// Application.Current.Shutdown();
|
||||
System.Environment.Exit(0);//退出
|
||||
}
|
||||
}
|
||||
|
||||
private void Shutdown_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
@@ -85,7 +103,8 @@ namespace DyeingComputer.View
|
||||
if (messageBoxResult == MessageBoxResult.Yes)
|
||||
{
|
||||
// Application.Current.Shutdown();
|
||||
System.Environment.Exit(0);//退出
|
||||
//System.Environment.Exit(0);//退出
|
||||
Process.Start("shutdown", "/s /t 10");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -725,11 +725,11 @@ namespace DyeingComputer.ViewModel
|
||||
hardwareItem.Update(); // 更新硬件信息:cite[2]
|
||||
foreach (var sensor in hardwareItem.Sensors)
|
||||
{
|
||||
if (sensor.SensorType == SensorType.Temperature && sensor.Value.HasValue)
|
||||
// if (sensor.SensorType == SensorType.Temperature && sensor.Value.HasValue)
|
||||
{
|
||||
//Console.WriteLine($"{hardwareItem.Name} - {sensor.Name}: {sensor.Value.Value}°C");
|
||||
// 实际应用中,你可能需要将这里的数据绑定到UI控件或存储起来
|
||||
Hardware.Add(sensor.Name, sensor.Value.Value);
|
||||
Hardware.Add(sensor.Name+":"+sensor.SensorType, sensor.Value.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -752,7 +752,7 @@ namespace DyeingComputer.ViewModel
|
||||
|
||||
if (timer1s_ >= 2) { timer1s_ =0; Tick_Event_1S(); }
|
||||
if (timer5s_ >=10) { timer5s_ = 0; Tick_Event_5S(); }
|
||||
if (timer60s_ >= 20) { timer60s_ = 0; Tick_Event_60S(); }
|
||||
if (timer60s_ >= 120) { timer60s_ = 0; Tick_Event_60S(); }
|
||||
if (LINK_OK) IO_data();
|
||||
}
|
||||
void Chart()
|
||||
|
||||
Reference in new issue
Block a user