change-界面优化

dev
liuwf 1 month ago
parent 75b44df7e9
commit c818cc56da

@ -30,9 +30,16 @@
<ColumnDefinition Width="2*"/>
</Grid.ColumnDefinitions>
<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 Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Right">
<Grid>
<Grid.ColumnDefinitions>
@ -61,22 +68,22 @@
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<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="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="生产管理" 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="手动叫料" 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="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="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="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="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="参数配置" 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="键 盘" Command="{Binding OpenSystemKeyboardCommand}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" 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="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="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="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="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="40" Background="#FF0033" BorderBrush="#FF0033" Margin="0,0,10,0"/>
</StackPanel>
<StackPanel Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Right" Orientation="Horizontal">
@ -114,7 +121,7 @@
</Ellipse>
</StackPanel>
<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>
</Grid>
</StackPanel>
@ -145,7 +152,7 @@
</Ellipse>
</StackPanel>
<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>
</Grid>
</StackPanel>
@ -176,7 +183,7 @@
</Ellipse>
</StackPanel>
<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>
</Grid>
</StackPanel>

@ -25,7 +25,7 @@
<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"/>
<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"/>

@ -35,8 +35,8 @@
<TextBox Text="{Binding RecipeMode}" FontSize="32" Foreground="White" IsReadOnly="True"/>
</StackPanel>
<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="manual" Style="{StaticResource BUTTON_AGREE}" Content="手动切换" FontSize="32" Background="#C4D134" Width="200" Height="70" Margin="50 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" Content="切换手动模式" FontSize="25" Background="#C4D134" Width="200" Height="50" Margin="50 0 0 0" />
</StackPanel>
</Grid >
</Border>

@ -131,10 +131,10 @@
<Setter Property="Template">
<Setter.Value>
<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代替-->
<!--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>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">

@ -18,6 +18,7 @@ using System.Threading;
using System.Threading.Tasks;
using System.Timers;
using System.Windows;
using System.Windows.Threading;
namespace SlnMesnac.WPF.ViewModel
{
@ -33,10 +34,46 @@ namespace SlnMesnac.WPF.ViewModel
private readonly BaseConfigInfoPage configInfoPage = new BaseConfigInfoPage();
private readonly RecipeManagePage recipeManagePage = new RecipeManagePage();
private readonly AgvAndTaskMonitorPage agvAndTaskMonitorPage = new AgvAndTaskMonitorPage();
private System.Timers.Timer timer = new System.Timers.Timer(1000*5);
private System.Timers.Timer timer = new System.Timers.Timer(1000 * 5);
PlcAbsractFactory? plc = null;
private BaseBusiness? baseBusiness = null;
#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>
/// PLC设备状态
/// </summary>
@ -104,16 +141,30 @@ namespace SlnMesnac.WPF.ViewModel
_logger = App.ServiceProvider.GetService<ILogger<MainWindowViewModel>>();
UserContent = prodMgmtPage;
PageName = "京源环保SCADA";
ControlOnClickCommand = new RelayCommand<object>(obj => ControlOnClick(obj));
FormControlCommand = new RelayCommand<object>(x => FormControl(x));
baseBusiness = App.ServiceProvider.GetService<BaseBusiness>();
plc = baseBusiness.GetPlcByKey("plc");
StartLiseningStatus();
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>
/// 监听外部设备状态:PLC、喷码机、RFID
/// </summary>
@ -126,16 +177,19 @@ namespace SlnMesnac.WPF.ViewModel
}
private void LiseningStatus(object?sender, ElapsedEventArgs e)
private void LiseningStatus(object? sender, ElapsedEventArgs e)
{
timer.Stop();
checkStatus();
timer.Start();
}
/// <summary>
/// 检查设备状态
/// </summary>
private void checkStatus()
{
try
{
#region PLC状态
@ -171,7 +225,7 @@ namespace SlnMesnac.WPF.ViewModel
#region RFID状态
var rfidEquip = baseBusiness.GetRfidByKey("secondFloorOut");
if(rfidEquip != null)
if (rfidEquip != null)
{
Out2FRfidStatus = 1;
}
@ -179,7 +233,7 @@ namespace SlnMesnac.WPF.ViewModel
{
Out2FRfidStatus = 2;
}
#endregion
@ -189,9 +243,11 @@ namespace SlnMesnac.WPF.ViewModel
{
_logger.LogError($"监听设备状态异常:{ex.Message}");
}
}
#endregion
/// <summary>
/// 窗体控制
/// </summary>
@ -204,11 +260,14 @@ namespace SlnMesnac.WPF.ViewModel
string controlType = obj as string;
switch (controlType)
{
case "DevMonitor":
UserContent = devMonitorPage;
PageName = "设备监控";
break;
case "ProdMgmt":
UserContent = prodMgmtPage;
PageName = "京源环保SCADA";
break;
case "ManualDelivery":
//UserContent = manualDelivery;
@ -217,6 +276,7 @@ namespace SlnMesnac.WPF.ViewModel
break;
case "ProdStatistics":
UserContent = prodStatisticsPage;
PageName = "生产统计";
break;
case "Exit":// 关闭当前窗口
//Environment.Exit(0);
@ -228,12 +288,15 @@ namespace SlnMesnac.WPF.ViewModel
case "ConfigInfo":
UserContent = configInfoPage;
PageName = "参数配置";
break;
case "RecipeManage":
UserContent = recipeManagePage;
PageName = "配方管理";
break;
case "AgvAndTaskPage":
UserContent = agvAndTaskMonitorPage;
PageName = "AGV监听";
break;
// 还原 或者 最大化当前窗口
case "Normal":
@ -271,6 +334,7 @@ namespace SlnMesnac.WPF.ViewModel
try
{
string info = obj as string;
PageName = "京源环保SCADA";
UserContent = prodMgmtPage;
}
catch (Exception ex)

Loading…
Cancel
Save