change-界面优化

dev
liuwf 1 month ago
parent 75b44df7e9
commit c818cc56da

@ -30,7 +30,14 @@
<ColumnDefinition Width="2*"/> <ColumnDefinition Width="2*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<StackPanel Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center"> <StackPanel Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center">
<TextBlock Text="京源环保SCADA" FontSize="50" Foreground="White" FontWeight="Bold"/> <TextBlock Text="{Binding PageName}" FontSize="50" Foreground="White" FontWeight="Bold"/>
</StackPanel>
<StackPanel Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Right">
<TextBlock Grid.Column="0" Text="{Binding Date}" FontSize="25" Foreground="White" FontWeight="Bold" HorizontalAlignment="Right"/>
<TextBlock Grid.Column="0" Text="{Binding Time}" FontSize="25" Foreground="White" FontWeight="Bold" HorizontalAlignment="Right"/>
</StackPanel> </StackPanel>
<!--<StackPanel Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Right"> <!--<StackPanel Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Right">
@ -61,22 +68,22 @@
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Left" Orientation="Horizontal"> <StackPanel Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Left" Orientation="Horizontal">
<Button Content="首 页" x:Name="Index" Command="{Binding ControlOnClickCommand}" CommandParameter="{Binding Name,ElementName=Index}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="10,0,10,0"/> <Button Content="首 页" x:Name="Index" Command="{Binding ControlOnClickCommand}" CommandParameter="{Binding Name,ElementName=Index}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="40" Background="#009999" BorderBrush="#FF36B5C1" Margin="10,0,10,0"/>
<Button Content="设备监控" x:Name="DevMonitor" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=DevMonitor}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#0099FF" BorderBrush="#0099FF" Margin="0,0,10,0"/> <Button Content="设备监控" x:Name="DevMonitor" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=DevMonitor}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="40" Background="#0099FF" BorderBrush="#0099FF" Margin="0,0,10,0"/>
<Button Content="生产管理" Visibility="Collapsed" x:Name="ProdMgmt" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=ProdMgmt}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#0099FF" BorderBrush="#0099FF" Margin="0,0,10,0"/> <Button Content="生产管理" Visibility="Collapsed" x:Name="ProdMgmt" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=ProdMgmt}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="40" Background="#0099FF" BorderBrush="#0099FF" Margin="0,0,10,0"/>
<Button Content="手动叫料" x:Name="ManualDelivery" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=ManualDelivery}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#0099FF" BorderBrush="#0099FF" Margin="0,0,10,0"/> <Button Content="手动叫料" x:Name="ManualDelivery" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=ManualDelivery}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="40" Background="#0099FF" BorderBrush="#0099FF" Margin="0,0,10,0"/>
<Button Content="AGV监听" x:Name="AgvAndTaskPage" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=AgvAndTaskPage}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#0099FF" BorderBrush="#0099FF" Margin="0,0,10,0"/> <Button Content="AGV监听" x:Name="AgvAndTaskPage" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=AgvAndTaskPage}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="40" Background="#0099FF" BorderBrush="#0099FF" Margin="0,0,10,0"/>
<Button Content="生产统计" x:Name="ProdStatistics" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=ProdStatistics}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#0099FF" BorderBrush="#0099FF" Margin="0,0,10,0"/> <Button Content="生产统计" x:Name="ProdStatistics" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=ProdStatistics}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="40" Background="#0099FF" BorderBrush="#0099FF" Margin="0,0,10,0"/>
<Button Content="代码生成" Visibility="Collapsed" x:Name="Generate" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=Generate}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="0,0,10,0"/> <Button Content="代码生成" Visibility="Collapsed" x:Name="Generate" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=Generate}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="0,0,10,0"/>
<Button Content="参数配置" x:Name="ConfigInfo" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=ConfigInfo}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="0,0,10,0"/> <Button Content="参数配置" x:Name="ConfigInfo" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=ConfigInfo}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="40" Background="#009999" BorderBrush="#FF36B5C1" Margin="0,0,10,0"/>
<Button Content="配方管理" x:Name="RecipeManage" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=RecipeManage}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="0,0,10,0"/> <Button Content="配方管理" x:Name="RecipeManage" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=RecipeManage}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="40" Background="#009999" BorderBrush="#FF36B5C1" Margin="0,0,10,0"/>
<Button Content="键 盘" Command="{Binding OpenSystemKeyboardCommand}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="0,0,10,0" /> <Button Content="键 盘" Command="{Binding OpenSystemKeyboardCommand}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="40" Background="#009999" BorderBrush="#FF36B5C1" Margin="0,0,10,0" />
<Button Content="最小化" x:Name="Minimized" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=Minimized}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#FF9900" BorderBrush="#FF9900" Margin="0,0,10,0"/> <Button Content="最小化" x:Name="Minimized" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=Minimized}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="40" Background="#FF9900" BorderBrush="#FF9900" Margin="0,0,10,0"/>
<Button Content="退 出" x:Name="Exit" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=Exit}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#FF0033" BorderBrush="#FF0033" Margin="0,0,10,0"/> <Button Content="退 出" x:Name="Exit" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=Exit}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="40" Background="#FF0033" BorderBrush="#FF0033" Margin="0,0,10,0"/>
</StackPanel> </StackPanel>
<StackPanel Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Right" Orientation="Horizontal"> <StackPanel Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Right" Orientation="Horizontal">
@ -114,7 +121,7 @@
</Ellipse> </Ellipse>
</StackPanel> </StackPanel>
<StackPanel Grid.Column="1" VerticalAlignment="Center"> <StackPanel Grid.Column="1" VerticalAlignment="Center">
<TextBlock Text="PLC状态" FontSize="15" Foreground="#FFFFFF" Margin="2,0,10,0"/> <TextBlock Text="PLC状态" FontSize="25" Foreground="#FFFFFF" Margin="2,0,10,0"/>
</StackPanel> </StackPanel>
</Grid> </Grid>
</StackPanel> </StackPanel>
@ -145,7 +152,7 @@
</Ellipse> </Ellipse>
</StackPanel> </StackPanel>
<StackPanel Grid.Column="1" VerticalAlignment="Center"> <StackPanel Grid.Column="1" VerticalAlignment="Center">
<TextBlock Text="喷码机状态" FontSize="15" Foreground="#FFFFFF" Margin="2,0,10,0"/> <TextBlock Text="喷码机状态" FontSize="25" Foreground="#FFFFFF" Margin="2,0,10,0"/>
</StackPanel> </StackPanel>
</Grid> </Grid>
</StackPanel> </StackPanel>
@ -176,7 +183,7 @@
</Ellipse> </Ellipse>
</StackPanel> </StackPanel>
<StackPanel Grid.Column="1" VerticalAlignment="Center"> <StackPanel Grid.Column="1" VerticalAlignment="Center">
<TextBlock Text="小包出口RFID" FontSize="15" Foreground="#FFFFFF" Margin="2,0,10,0"/> <TextBlock Text="小包出口RFID" FontSize="25" Foreground="#FFFFFF" Margin="2,0,10,0"/>
</StackPanel> </StackPanel>
</Grid> </Grid>
</StackPanel> </StackPanel>

@ -25,7 +25,7 @@
<TextBlock Text="缓存区重量:" FontSize="25" VerticalAlignment="Center" Width="140" Foreground="White" HorizontalAlignment="Left" Margin="150 0 10 0" /> <TextBlock Text="缓存区重量:" FontSize="25" VerticalAlignment="Center" Width="140" Foreground="White" HorizontalAlignment="Left" Margin="150 0 10 0" />
<TextBlock x:Name="BufferWeightTxt" Text="0" Width="80" FontSize="25" VerticalAlignment="Center" Margin="0,0,20,0" Foreground="White"/> <TextBlock x:Name="BufferWeightTxt" Text="0" Width="80" FontSize="25" VerticalAlignment="Center" Margin="0,0,20,0" Foreground="White"/>
<Button x:Name="SetStopWeightButton" Style="{StaticResource BUTTON_AGREE}" Content="设置重量阈值" FontSize="30" Background="CadetBlue" Width="200" Height="60" Margin="0 0 20 0" HorizontalAlignment="Left" Click="SetStopWeightButton_Click" /> <Button x:Name="SetStopWeightButton" Content="设置重量阈值" FontSize="25" Foreground="White" Background="CadetBlue" Width="200" Height="60" Margin="0 0 20 0" HorizontalAlignment="Left" Click="SetStopWeightButton_Click" />
<TextBlock Text="包装袋余量:" FontSize="25" VerticalAlignment="Center" Width="140" Margin="50,0,20,0" Foreground="White" HorizontalAlignment="Left"/> <TextBlock Text="包装袋余量:" FontSize="25" VerticalAlignment="Center" Width="140" Margin="50,0,20,0" Foreground="White" HorizontalAlignment="Left"/>

@ -35,8 +35,8 @@
<TextBox Text="{Binding RecipeMode}" FontSize="32" Foreground="White" IsReadOnly="True"/> <TextBox Text="{Binding RecipeMode}" FontSize="32" Foreground="White" IsReadOnly="True"/>
</StackPanel> </StackPanel>
<StackPanel Grid.Column="3" VerticalAlignment="Center" Orientation="Horizontal"> <StackPanel Grid.Column="3" VerticalAlignment="Center" Orientation="Horizontal">
<Button Command="{Binding ModeChangeCommand}" CommandParameter="auto" Style="{StaticResource BUTTON_AGREE}" Content="自动切换" FontSize="32" Background="ForestGreen" Width="200" Height="70" Margin="0 0 0 0" /> <Button Command="{Binding ModeChangeCommand}" CommandParameter="auto" Content="切换自动模式" FontSize="25" Background="ForestGreen" Width="200" Height="50" Margin="0 0 0 0" />
<Button Command="{Binding ModeChangeCommand}" CommandParameter="manual" Style="{StaticResource BUTTON_AGREE}" Content="手动切换" FontSize="32" Background="#C4D134" Width="200" Height="70" Margin="50 0 0 0" /> <Button Command="{Binding ModeChangeCommand}" CommandParameter="manual" Content="切换手动模式" FontSize="25" Background="#C4D134" Width="200" Height="50" Margin="50 0 0 0" />
</StackPanel> </StackPanel>
</Grid > </Grid >
</Border> </Border>

@ -131,10 +131,10 @@
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="Button"> <ControlTemplate TargetType="Button">
<Border Name="bdr" CornerRadius="5" Opacity="1" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1"> <Border Name="bdr" CornerRadius="5" Opacity="1" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1" Width="100" >
<!--可使用ContentPresenter代替--> <!--可使用ContentPresenter代替-->
<!--Foreground的值White可以替换为{TemplateBinding Foreground}--> <!--Foreground的值White可以替换为{TemplateBinding Foreground}-->
<Label VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Foreground="White" Content="{TemplateBinding Content}"/> <Label VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Foreground="White" FontSize="20" Content="{TemplateBinding Content}"/>
</Border> </Border>
<ControlTemplate.Triggers> <ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False"> <Trigger Property="IsEnabled" Value="False">

@ -18,6 +18,7 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Timers; using System.Timers;
using System.Windows; using System.Windows;
using System.Windows.Threading;
namespace SlnMesnac.WPF.ViewModel namespace SlnMesnac.WPF.ViewModel
{ {
@ -37,6 +38,42 @@ namespace SlnMesnac.WPF.ViewModel
PlcAbsractFactory? plc = null; PlcAbsractFactory? plc = null;
private BaseBusiness? baseBusiness = null; private BaseBusiness? baseBusiness = null;
#region 参数定义 #region 参数定义
private string _time;
public string Time
{
get { return _time; }
set
{
_time = value;
RaisePropertyChanged(nameof(Time));
}
}
private string _Date;
public string Date
{
get { return _Date; }
set
{
_Date = value;
RaisePropertyChanged(nameof(Date));
}
}
private string _PageName;
public string PageName
{
get { return _PageName; }
set
{
_PageName = value;
RaisePropertyChanged(nameof(PageName));
}
}
/// <summary> /// <summary>
/// PLC设备状态 /// PLC设备状态
/// </summary> /// </summary>
@ -104,16 +141,30 @@ namespace SlnMesnac.WPF.ViewModel
_logger = App.ServiceProvider.GetService<ILogger<MainWindowViewModel>>(); _logger = App.ServiceProvider.GetService<ILogger<MainWindowViewModel>>();
UserContent = prodMgmtPage; UserContent = prodMgmtPage;
PageName = "京源环保SCADA";
ControlOnClickCommand = new RelayCommand<object>(obj => ControlOnClick(obj)); ControlOnClickCommand = new RelayCommand<object>(obj => ControlOnClick(obj));
FormControlCommand = new RelayCommand<object>(x => FormControl(x)); FormControlCommand = new RelayCommand<object>(x => FormControl(x));
baseBusiness = App.ServiceProvider.GetService<BaseBusiness>(); baseBusiness = App.ServiceProvider.GetService<BaseBusiness>();
plc = baseBusiness.GetPlcByKey("plc"); plc = baseBusiness.GetPlcByKey("plc");
StartLiseningStatus(); StartLiseningStatus();
checkStatus(); checkStatus();
RefreshTime();
} }
private void RefreshTime()
{
DispatcherTimer _timer = new DispatcherTimer();
_timer.Interval = TimeSpan.FromSeconds(1);
_timer.Tick += Timer_Tick;
_timer.Start();
}
private void Timer_Tick(object sender, EventArgs e)
{
Date = DateTime.Now.ToString("yyyy年MM月dd日");
Time = DateTime.Now.ToString("HH:mm:ss");
}
#region 监听外部设备状态:PLC、喷码机、RFID
/// <summary> /// <summary>
/// 监听外部设备状态:PLC、喷码机、RFID /// 监听外部设备状态:PLC、喷码机、RFID
/// </summary> /// </summary>
@ -133,6 +184,9 @@ namespace SlnMesnac.WPF.ViewModel
timer.Start(); timer.Start();
} }
/// <summary>
/// 检查设备状态
/// </summary>
private void checkStatus() private void checkStatus()
{ {
@ -192,6 +246,8 @@ namespace SlnMesnac.WPF.ViewModel
} }
#endregion
/// <summary> /// <summary>
/// 窗体控制 /// 窗体控制
/// </summary> /// </summary>
@ -204,11 +260,14 @@ namespace SlnMesnac.WPF.ViewModel
string controlType = obj as string; string controlType = obj as string;
switch (controlType) switch (controlType)
{ {
case "DevMonitor": case "DevMonitor":
UserContent = devMonitorPage; UserContent = devMonitorPage;
PageName = "设备监控";
break; break;
case "ProdMgmt": case "ProdMgmt":
UserContent = prodMgmtPage; UserContent = prodMgmtPage;
PageName = "京源环保SCADA";
break; break;
case "ManualDelivery": case "ManualDelivery":
//UserContent = manualDelivery; //UserContent = manualDelivery;
@ -217,6 +276,7 @@ namespace SlnMesnac.WPF.ViewModel
break; break;
case "ProdStatistics": case "ProdStatistics":
UserContent = prodStatisticsPage; UserContent = prodStatisticsPage;
PageName = "生产统计";
break; break;
case "Exit":// 关闭当前窗口 case "Exit":// 关闭当前窗口
//Environment.Exit(0); //Environment.Exit(0);
@ -228,12 +288,15 @@ namespace SlnMesnac.WPF.ViewModel
case "ConfigInfo": case "ConfigInfo":
UserContent = configInfoPage; UserContent = configInfoPage;
PageName = "参数配置";
break; break;
case "RecipeManage": case "RecipeManage":
UserContent = recipeManagePage; UserContent = recipeManagePage;
PageName = "配方管理";
break; break;
case "AgvAndTaskPage": case "AgvAndTaskPage":
UserContent = agvAndTaskMonitorPage; UserContent = agvAndTaskMonitorPage;
PageName = "AGV监听";
break; break;
// 还原 或者 最大化当前窗口 // 还原 或者 最大化当前窗口
case "Normal": case "Normal":
@ -271,6 +334,7 @@ namespace SlnMesnac.WPF.ViewModel
try try
{ {
string info = obj as string; string info = obj as string;
PageName = "京源环保SCADA";
UserContent = prodMgmtPage; UserContent = prodMgmtPage;
} }
catch (Exception ex) catch (Exception ex)

Loading…
Cancel
Save