@@ -63,6 +63,7 @@ | |||
<None Remove="Image\tittle.png" /> | |||
<None Remove="Image\topImage.png" /> | |||
<None Remove="Image\topTitle.png" /> | |||
<None Remove="Image\WindowImages.png" /> | |||
<None Remove="Image\上箭头.png" /> | |||
<None Remove="Image\不规则矩形.png" /> | |||
<None Remove="Image\个人信息.png" /> | |||
@@ -103,6 +104,7 @@ | |||
<None Remove="Image\环形切图\占位.png" /> | |||
<None Remove="Image\环形切图\外圈\未选中.png" /> | |||
<None Remove="Image\环形切图\外圈\选中.png" /> | |||
<None Remove="Image\界面2.png" /> | |||
<None Remove="Image\矩形.png" /> | |||
<None Remove="Image\矩形1.png" /> | |||
<None Remove="Image\矩形样式.png" /> | |||
@@ -187,6 +189,7 @@ | |||
<Resource Include="Image\Exp.png" /> | |||
<Resource Include="Image\leftback.png" /> | |||
<Resource Include="Image\leftImage.png" /> | |||
<Resource Include="Image\WindowImages.png" /> | |||
<Resource Include="Image\上箭头.png" /> | |||
<Resource Include="Image\临时模板.png" /> | |||
<Resource Include="Image\产品制作.png" /> | |||
@@ -197,6 +200,9 @@ | |||
<Resource Include="Image\告警\无告警.png" /> | |||
<Resource Include="Image\告警\无告警1.png" /> | |||
<Resource Include="Image\告警\轻微告警.png" /> | |||
<Resource Include="Image\界面2.png"> | |||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | |||
</Resource> | |||
<Resource Include="Image\背景2.png" /> | |||
<Resource Include="Image\边角.png" /> | |||
</ItemGroup> | |||
@@ -177,4 +177,43 @@ | |||
</Style> | |||
<!--#endregion--> | |||
<!--#region 长方形左侧按钮--> | |||
<Style x:Key="MenuRadioButtonStyle" TargetType="{x:Type RadioButton}"> | |||
<Setter Property="FontFamily" Value="楷体" /> | |||
<Setter Property="Width" Value="130" /> | |||
<Setter Property="IsChecked" Value="False" /> | |||
<Setter Property="FontSize" Value="18" /> | |||
<Setter Property="Foreground" Value="White" /> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="{x:Type RadioButton}"> | |||
<Grid SnapsToDevicePixels="True"> | |||
<Image x:Name="im" /> | |||
<ContentPresenter | |||
x:Name="contentPresenter" | |||
Margin="10" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Content="{TemplateBinding Content}" | |||
ContentStringFormat="{TemplateBinding ContentStringFormat}" | |||
ContentTemplate="{TemplateBinding ContentTemplate}" | |||
Focusable="False" | |||
RecognizesAccessKey="True" | |||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" /> | |||
</Grid> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsChecked" Value="True"> | |||
<Setter TargetName="im" Property="Source" Value="../Image/窗体样式/Tab/Tab4_Select.png" /> | |||
</Trigger> | |||
<Trigger Property="IsChecked" Value="False"> | |||
<Setter TargetName="im" Property="Source" Value="../Image/窗体样式/Tab/Tab4_No.png" /> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
<!--#endregion--> | |||
</ResourceDictionary> |
@@ -42,4 +42,14 @@ | |||
<Setter Property="EnterBackground" Value="#2219b7ec" /> | |||
</Style> | |||
<Style x:Key="IcoTitleBarStyle" TargetType="local:IcoButton"> | |||
<Setter Property="FontFamily" Value="../Fonts/#iconfont" /> | |||
<Setter Property="FontSize" Value="24" /> | |||
<Setter Property="Background" Value="Transparent" /> | |||
<Setter Property="BorderThickness" Value="0" /> | |||
<Setter Property="EnterBackground" Value="#33ffffff" /> | |||
</Style> | |||
</ResourceDictionary> |
@@ -24,7 +24,13 @@ namespace BPASmartClient.Modbus | |||
private string IPAdress; | |||
private int Port; | |||
//public Action ConnectOk { get; set; } | |||
public Action ConnectOk { get; set; } | |||
public Action ConnectFail { get; set; } | |||
public Action Disconnect { get; set; } | |||
public bool IsReconnect { get; set; } = true; //true=启用重连,false=禁用重连 | |||
/// <summary> | |||
/// 判断是否连接成功 | |||
@@ -46,7 +52,16 @@ namespace BPASmartClient.Modbus | |||
master.Transport.ReadTimeout = 2000;//读取超时时间 | |||
master.Transport.WriteTimeout = 2000;//写入超时时间 | |||
master.Transport.Retries = 10;//重试次数 | |||
MessageLog.GetInstance.Show($"设备【{ip}:{port}】连接成功"); | |||
if (Connected) | |||
{ | |||
ConnectOk?.Invoke(); | |||
MessageLog.GetInstance.Show($"设备【{ip}:{port}】连接成功"); | |||
} | |||
else | |||
{ | |||
ConnectFail?.Invoke(); | |||
} | |||
} | |||
private void Connect() | |||
@@ -67,10 +82,11 @@ namespace BPASmartClient.Modbus | |||
MessageLog.GetInstance.ShowEx(ex.ToString()); | |||
ErrorFlag = true; | |||
} | |||
if (!IsReconnect) break; | |||
Thread.Sleep(3000); | |||
} | |||
} | |||
MessageLog.GetInstance.Show("ModbusTcp 连接成功!"); | |||
if (ErrorFlag) MessageLog.GetInstance.Show("ModbusTcp 重连成功!"); | |||
} | |||
/// <summary> | |||
@@ -109,6 +125,19 @@ namespace BPASmartClient.Modbus | |||
return -1; | |||
} | |||
private void ExceptionHandling(Exception ex) | |||
{ | |||
if (ex.InnerException is SocketException) | |||
{ | |||
if (IsReconnect) | |||
{ | |||
tcpClient = null; | |||
Connect(); | |||
} | |||
Disconnect?.Invoke(); | |||
} | |||
} | |||
public object Read(string address, ushort len = 1, byte slaveAddress = 1) | |||
{ | |||
if (address == null || tcpClient == null) return default(object); | |||
@@ -135,11 +164,7 @@ namespace BPASmartClient.Modbus | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.ShowEx($"读取地址:【{address}:= {startAddress}】,读取类型:【{commandType.ToString()}】出错,{ex.ToString()}"); | |||
if (ex.InnerException is SocketException) | |||
{ | |||
tcpClient = null; | |||
Connect(); | |||
} | |||
ExceptionHandling(ex); | |||
} | |||
return default(object); | |||
} | |||
@@ -199,12 +224,8 @@ namespace BPASmartClient.Modbus | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.ShowEx($"读写入地址:【{address}:= {startAddress}】,写入类型:【{commandType.ToString()}】出错,{ex.ToString()}"); | |||
if (ex.InnerException is SocketException) | |||
{ | |||
tcpClient = null; | |||
Connect(); | |||
} | |||
MessageLog.GetInstance.ShowEx($"写入地址:【{address}:= {startAddress}】,写入类型:【{commandType.ToString()}】出错,{ex.ToString()}"); | |||
ExceptionHandling(ex); | |||
} | |||
} | |||
@@ -15,8 +15,8 @@ | |||
Background="{x:Null}" | |||
Topmost="False" | |||
WindowStartupLocation="CenterScreen" | |||
WindowStyle="None" | |||
WindowState="Maximized" | |||
WindowStyle="None" | |||
mc:Ignorable="d"> | |||
<Window.Resources> | |||
<ResourceDictionary> | |||
@@ -52,24 +52,33 @@ | |||
Style="{DynamicResource imagetop_Title}" /> | |||
<Grid Grid.Column="1"> | |||
<!--#region 用户菜单界面--> | |||
<StackPanel x:Name="myPanel" Orientation="Horizontal" Visibility="Collapsed" > | |||
<Button Height="40" Width="120" | |||
Content="日志监视" | |||
Margin="50,0,20,0" | |||
Click="MenuItem_Click" | |||
Tag ="LogView" | |||
/> | |||
<Button Height="40" Width="120" | |||
Content="设备监控" | |||
Margin="20,0" Cursor="Hand" | |||
Click="DeviceMonitor_Click" | |||
Tag =""/> | |||
<Button Height="40" Width="120" | |||
Margin="20,0" | |||
Content="订单监视" | |||
Click="MenuItem_Click" | |||
Tag ="OrderStatusView" Cursor="Hand"/> | |||
<StackPanel | |||
x:Name="myPanel" | |||
Orientation="Horizontal" | |||
Visibility="Collapsed"> | |||
<Button | |||
Width="120" | |||
Height="40" | |||
Margin="50,0,20,0" | |||
Click="MenuItem_Click" | |||
Content="日志监视" | |||
Tag="LogView" /> | |||
<Button | |||
Width="120" | |||
Height="40" | |||
Margin="20,0" | |||
Click="DeviceMonitor_Click" | |||
Content="设备监控" | |||
Cursor="Hand" | |||
Tag="" /> | |||
<Button | |||
Width="120" | |||
Height="40" | |||
Margin="20,0" | |||
Click="MenuItem_Click" | |||
Content="订单监视" | |||
Cursor="Hand" | |||
Tag="OrderStatusView" /> | |||
</StackPanel> | |||
<!--#endregion--> | |||
<Menu x:Name="myMenu" Visibility="Visible"> | |||
@@ -14,6 +14,7 @@ | |||
<ItemGroup> | |||
<ProjectReference Include="..\BPASmartClient.CustomResource\BPASmartClient.CustomResource.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.Helper\BPASmartClient.Helper.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.Modbus\BPASmartClient.Modbus.csproj" /> | |||
</ItemGroup> | |||
</Project> |
@@ -0,0 +1,117 @@ | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.Modbus; | |||
using DosingSystem.ViewModel; | |||
using System; | |||
using System.Collections.Concurrent; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Net.NetworkInformation; | |||
using System.Text; | |||
using System.Threading; | |||
using System.Threading.Tasks; | |||
namespace DosingSystem.Model | |||
{ | |||
public class DeviceInquire | |||
{ | |||
private volatile static DeviceInquire _Instance; | |||
public static DeviceInquire GetInstance => _Instance ?? (_Instance = new DeviceInquire()); | |||
private DeviceInquire() { } | |||
string IPSegment = "192.168.1."; | |||
string NameAddress = "VW5000"; | |||
int count = 0; | |||
private static readonly object _lock = new object(); | |||
ConcurrentDictionary<string, ModbusTcp> modbusTcps = new ConcurrentDictionary<string, ModbusTcp>(); | |||
List<string> InvalidIP = new List<string>(); | |||
public void Init() | |||
{ | |||
IpAddressLines(); | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
if (count >= 255) IpAddressLines(); | |||
Thread.Sleep(5000); | |||
}), "配料机设备上线监听", true); | |||
} | |||
public ModbusTcp GetModbusTcp(string ip) | |||
{ | |||
if (modbusTcps.ContainsKey(ip)) return modbusTcps[ip]; | |||
else return default; | |||
} | |||
private void IpAddressLines() | |||
{ | |||
for (int i = 1; i <= 255; i++) | |||
{ | |||
if (!InvalidIP.Contains($"{IPSegment}{i}")) | |||
{ | |||
Ping myPing; | |||
myPing = new Ping(); | |||
myPing.PingCompleted += new PingCompletedEventHandler(_myPing_PingCompleted); | |||
string pingIP = $"{IPSegment}{i}"; | |||
myPing.SendAsync(pingIP, 1000, null); | |||
} | |||
} | |||
count = 0; | |||
} | |||
private void CompleteCount() | |||
{ | |||
lock (_lock) | |||
count++; | |||
} | |||
private void _myPing_PingCompleted(object sender, PingCompletedEventArgs e) | |||
{ | |||
if (e.Reply.Status == IPStatus.Success) | |||
{ | |||
string ip = e.Reply.Address.ToString(); | |||
if (!modbusTcps.ContainsKey(ip)) | |||
{ | |||
modbusTcps.TryAdd(ip, new ModbusTcp()); | |||
modbusTcps[ip].IsReconnect = false; | |||
Task.Run(new Action(() => { modbusTcps[ip].ModbusTcpConnect(ip); })); | |||
modbusTcps[ip].ConnectOk = new Action(() => | |||
{ | |||
string DeviceName = modbusTcps[ip].GetString(NameAddress, 10); | |||
if (DeviceName.Length > 0) | |||
{ | |||
App.Current.Dispatcher.Invoke(new Action(() => | |||
{ | |||
DeviceListViewModel.devices.Add(new Devices() | |||
{ | |||
DeviceName = DeviceName, | |||
IpAddress = ip | |||
}); | |||
})); | |||
} | |||
else | |||
{ | |||
if (!InvalidIP.Contains(ip)) InvalidIP.Add(ip); | |||
} | |||
}); | |||
modbusTcps[ip].ConnectFail = new Action(() => | |||
{ | |||
if (!InvalidIP.Contains(ip)) InvalidIP.Add(ip); | |||
}); | |||
modbusTcps[ip].Disconnect = new Action(() => | |||
{ | |||
if (InvalidIP.Contains(ip)) InvalidIP.Remove(ip); | |||
var res = DeviceListViewModel.devices.FirstOrDefault(P => P.IpAddress == ip); | |||
if (res != null && DeviceListViewModel.devices.Contains(res)) | |||
App.Current.Dispatcher.Invoke(new Action(() => { DeviceListViewModel.devices.Remove(res); })); | |||
}); | |||
} | |||
} | |||
CompleteCount(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,27 @@ | |||
<UserControl | |||
x:Class="DosingSystem.View.AlarmRecordView" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:control="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:DosingSystem.View" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||
xmlns:vm="clr-namespace:DosingSystem.ViewModel" | |||
d:DesignHeight="450" | |||
d:DesignWidth="800" | |||
mc:Ignorable="d"> | |||
<UserControl.DataContext> | |||
<vm:AlarmRecordViewModel/> | |||
</UserControl.DataContext> | |||
<Grid> | |||
<TextBlock | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="40" | |||
Foreground="Wheat" | |||
Text="报警记录" /> | |||
</Grid> | |||
</UserControl> |
@@ -0,0 +1,28 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Windows; | |||
using System.Windows.Controls; | |||
using System.Windows.Data; | |||
using System.Windows.Documents; | |||
using System.Windows.Input; | |||
using System.Windows.Media; | |||
using System.Windows.Media.Imaging; | |||
using System.Windows.Navigation; | |||
using System.Windows.Shapes; | |||
namespace DosingSystem.View | |||
{ | |||
/// <summary> | |||
/// AlarmRecordView.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class AlarmRecordView : UserControl | |||
{ | |||
public AlarmRecordView() | |||
{ | |||
InitializeComponent(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,74 @@ | |||
<UserControl | |||
x:Class="DosingSystem.View.DeviceListView" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:control="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:DosingSystem.View" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||
xmlns:vm="clr-namespace:DosingSystem.ViewModel" | |||
d:DesignHeight="450" | |||
d:DesignWidth="800" | |||
mc:Ignorable="d"> | |||
<UserControl.DataContext> | |||
<vm:DeviceListViewModel /> | |||
</UserControl.DataContext> | |||
<Grid> | |||
<ItemsControl | |||
Width="300" | |||
HorizontalAlignment="Left" | |||
ItemsSource="{Binding devices}"> | |||
<ItemsControl.ItemTemplate> | |||
<DataTemplate> | |||
<Border | |||
Margin="0,0,0,15" | |||
BorderBrush="Aqua" | |||
BorderThickness="1"> | |||
<Grid> | |||
<Grid.RowDefinitions> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
HorizontalAlignment="Right" | |||
FontSize="16" | |||
Foreground="Aqua" | |||
Text="IP地址:" /> | |||
<TextBlock | |||
Grid.Column="1" | |||
HorizontalAlignment="Left" | |||
FontSize="16" | |||
Foreground="Aqua" | |||
Text="{Binding IpAddress}" /> | |||
<TextBlock | |||
Grid.Row="1" | |||
HorizontalAlignment="Right" | |||
FontSize="16" | |||
Foreground="Aqua" | |||
Text="设备名称:" /> | |||
<TextBlock | |||
Grid.Row="1" | |||
Grid.Column="1" | |||
FontSize="16" | |||
Foreground="Aqua" | |||
Text="{Binding DeviceName}" /> | |||
</Grid> | |||
</Border> | |||
</DataTemplate> | |||
</ItemsControl.ItemTemplate> | |||
</ItemsControl> | |||
</Grid> | |||
</UserControl> |
@@ -0,0 +1,28 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Windows; | |||
using System.Windows.Controls; | |||
using System.Windows.Data; | |||
using System.Windows.Documents; | |||
using System.Windows.Input; | |||
using System.Windows.Media; | |||
using System.Windows.Media.Imaging; | |||
using System.Windows.Navigation; | |||
using System.Windows.Shapes; | |||
namespace DosingSystem.View | |||
{ | |||
/// <summary> | |||
/// DeviceListView.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class DeviceListView : UserControl | |||
{ | |||
public DeviceListView() | |||
{ | |||
InitializeComponent(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,27 @@ | |||
<UserControl | |||
x:Class="DosingSystem.View.HardwareStatusView" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:control="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:DosingSystem.View" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||
xmlns:vm="clr-namespace:DosingSystem.ViewModel" | |||
d:DesignHeight="450" | |||
d:DesignWidth="800" | |||
mc:Ignorable="d"> | |||
<UserControl.DataContext> | |||
<vm:HardwareStatusViewModel /> | |||
</UserControl.DataContext> | |||
<Grid> | |||
<TextBlock | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="40" | |||
Foreground="Wheat" | |||
Text="硬件状态" /> | |||
</Grid> | |||
</UserControl> |
@@ -0,0 +1,28 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Windows; | |||
using System.Windows.Controls; | |||
using System.Windows.Data; | |||
using System.Windows.Documents; | |||
using System.Windows.Input; | |||
using System.Windows.Media; | |||
using System.Windows.Media.Imaging; | |||
using System.Windows.Navigation; | |||
using System.Windows.Shapes; | |||
namespace DosingSystem.View | |||
{ | |||
/// <summary> | |||
/// HardwareStatusView.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class HardwareStatusView : UserControl | |||
{ | |||
public HardwareStatusView() | |||
{ | |||
InitializeComponent(); | |||
} | |||
} | |||
} |
@@ -7,24 +7,249 @@ | |||
xmlns:local="clr-namespace:DosingSystem" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||
xmlns:vm="clr-namespace:DosingSystem.ViewModel" | |||
Title="MainWindow" | |||
Width="800" | |||
Height="450" | |||
Width="1300" | |||
Height="800" | |||
AllowsTransparency="True" | |||
Background="{x:Null}" | |||
Opacity="0.8" | |||
Topmost="False" | |||
Topmost="True" | |||
WindowStartupLocation="CenterScreen" | |||
WindowStyle="None" | |||
mc:Ignorable="d"> | |||
<Grid> | |||
<Window.Resources> | |||
<ResourceDictionary> | |||
<ResourceDictionary.MergedDictionaries> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/GenricStyle.xaml" /> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/MyStyle.xaml" /> | |||
</ResourceDictionary.MergedDictionaries> | |||
</ResourceDictionary> | |||
</Window.Resources> | |||
<Window.DataContext> | |||
<vm:MainViewModel /> | |||
</Window.DataContext> | |||
<Border x:Name="br" Style="{DynamicResource border主窗体背景}"> | |||
<Grid> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="60" /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<!-- 标题 --> | |||
<Grid Grid.Row="0"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="300" /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<Border | |||
Grid.ColumnSpan="2" | |||
Height="52" | |||
VerticalAlignment="Top" | |||
Style="{DynamicResource bordertop矩形}" /> | |||
<Border Style="{DynamicResource bordertopL}" /> | |||
<Image | |||
Margin="20,0,0,0" | |||
VerticalAlignment="Center" | |||
Style="{DynamicResource imagetop_Title}" /> | |||
<Grid Grid.Column="1"> | |||
<StackPanel Orientation="Horizontal"> | |||
<RadioButton | |||
Command="{Binding TogglePag}" | |||
CommandParameter="RecipeSettingsView.配方设置" | |||
Content="配方设置" | |||
Style="{StaticResource MenuRadioButtonStyle}" /> | |||
<RadioButton | |||
Command="{Binding TogglePag}" | |||
CommandParameter="DeviceListView.设备列表" | |||
Content="设备列表" | |||
Style="{StaticResource MenuRadioButtonStyle}" /> | |||
<RadioButton | |||
Command="{Binding TogglePag}" | |||
CommandParameter="HardwareStatusView.硬件状态" | |||
Content="硬件状态" | |||
Style="{StaticResource MenuRadioButtonStyle}" /> | |||
<RadioButton | |||
Command="{Binding TogglePag}" | |||
CommandParameter="AlarmRecordView.报警记录" | |||
Content="报警记录" | |||
Style="{StaticResource MenuRadioButtonStyle}" /> | |||
<RadioButton | |||
Command="{Binding TogglePag}" | |||
CommandParameter="RecipeControlView.配方控制" | |||
Content="配方控制" | |||
Style="{StaticResource MenuRadioButtonStyle}" /> | |||
</StackPanel> | |||
</Grid> | |||
<StackPanel | |||
Grid.Column="4" | |||
Height="50" | |||
HorizontalAlignment="Right" | |||
VerticalAlignment="Top" | |||
Orientation="Horizontal"> | |||
<Border Style="{DynamicResource border竖线}" /> | |||
<StackPanel | |||
Margin="5" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center"> | |||
<TextBlock FontSize="12">网</TextBlock> | |||
<TextBlock FontSize="12">络</TextBlock> | |||
</StackPanel> | |||
<ToggleButton | |||
Margin="5" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Cursor="Hand" | |||
IsChecked="{Binding NetworkConnectState}" | |||
Style="{DynamicResource StatusBtnStyle网络连接状态}" | |||
ToolTip="网络连接状态" /> | |||
<Border Style="{DynamicResource border竖线}" /> | |||
<ToggleButton | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Cursor="Hand" | |||
DataContext="{Binding IsAlarm}" | |||
Style="{DynamicResource StatusBtnStyle告警}" | |||
ToolTip="告警消息" /> | |||
<Border Style="{DynamicResource border竖线}" /> | |||
<control:DateTimeUI Margin="10,0,10,0" VerticalAlignment="Center" /> | |||
<Border Style="{DynamicResource border竖线}" /> | |||
<Button | |||
x:Name="ButClose" | |||
Grid.Column="4" | |||
Margin="10,0,20,0" | |||
VerticalAlignment="Center" | |||
Content="退出" | |||
Cursor="Hand" | |||
Style="{DynamicResource CommonBtn_返回}" | |||
ToolTip="退出程序" /> | |||
</StackPanel> | |||
</Grid> | |||
<!-- 底部窗体 --> | |||
<Grid Grid.Row="1" Margin="10"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="45" /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<!-- 顶部装饰 --> | |||
<Border | |||
Grid.Row="0" | |||
Grid.RowSpan="2" | |||
Style="{DynamicResource border右下}" /> | |||
<Border | |||
Grid.Row="0" | |||
Grid.RowSpan="2" | |||
Style="{DynamicResource border左下}" /> | |||
<Border | |||
Grid.Row="0" | |||
Grid.RowSpan="2" | |||
Style="{DynamicResource border右上}" /> | |||
<Border | |||
Grid.Row="0" | |||
Grid.RowSpan="2" | |||
Style="{DynamicResource border左上}" /> | |||
<Grid Margin="10"> | |||
<Border Width="600" Style="{DynamicResource borderFromTitle}" /> | |||
<StackPanel Orientation="Horizontal"> | |||
<CheckBox | |||
Margin="5,0,5,0" | |||
Content="开机启动" | |||
IsChecked="{Binding AutoStart}" /> | |||
</StackPanel> | |||
<TextBlock | |||
x:Name="Title" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Top" | |||
FontSize="16" | |||
Foreground="#feffff" | |||
Text="{Binding WindowTitleName}" /> | |||
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal"> | |||
<Button | |||
Name="login" | |||
Grid.Row="0" | |||
Width="45" | |||
Margin="5,0,5,0" | |||
HorizontalAlignment="Right" | |||
VerticalAlignment="Top" | |||
Click="Button_Login" | |||
Content="登录" | |||
Cursor="Hand" /> | |||
<Button | |||
Name="logout" | |||
Grid.Row="0" | |||
Width="45" | |||
HorizontalAlignment="Right" | |||
VerticalAlignment="Top" | |||
Click="Button_LogOut" | |||
Command="{Binding LogoutCommand}" | |||
Content="注销" | |||
Cursor="Hand" /> | |||
</StackPanel> | |||
</Grid> | |||
<!--#region 底部窗体栏--> | |||
<ContentControl | |||
x:Name="contentRegion" | |||
Grid.Row="1" | |||
Content="{Binding MyWindow}" /> | |||
<!--#endregion--> | |||
</Grid> | |||
</Grid> | |||
</Border> | |||
<!--<Grid> | |||
--> | |||
<!--<Grid.Background> | |||
<ImageBrush ImageSource="pack://application:,,,/BPASmartClient.CustomResource;component/Image/界面2.png" /> | |||
</Grid.Background>--> | |||
<!-- | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="50" /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<!--#region 标题栏设置--> | |||
--> | |||
<!--#region 标题栏设置--> | |||
<!--<Border | |||
x:Name="MoveBorder" | |||
Height="50" | |||
VerticalAlignment="Top" | |||
BorderBrush="#55ffffff" | |||
BorderThickness="0,0,0,0"> | |||
<StackPanel Orientation="Horizontal"> | |||
<Image Margin="25 5 0 0" Source="pack://application:,,,/BPASmartClient.CustomResource;component/Image/HBL.png" /> | |||
<TextBlock | |||
Name="tbTitle" | |||
Margin="20,0" | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Center" | |||
FontSize="18" | |||
Foreground="White" | |||
Text="配料控制系统" /> | |||
</StackPanel> | |||
</Border>--> | |||
<!-- | |||
<Border | |||
x:Name="MoveBorder" | |||
Height="50" | |||
@@ -34,7 +259,7 @@ | |||
BorderThickness="0,0,0,1"> | |||
<StackPanel Orientation="Horizontal"> | |||
<Image Margin="15,5,0,5" Source="pack://application:,,,/BPASmartClient.CustomResource;component/Image/HBL.png" /> | |||
<Image Margin="25,5,0,0" Source="pack://application:,,,/BPASmartClient.CustomResource;component/Image/HBL.png" /> | |||
<TextBlock | |||
Name="tbTitle" | |||
Margin="20,0" | |||
@@ -42,10 +267,8 @@ | |||
VerticalAlignment="Center" | |||
FontSize="18" | |||
Foreground="White" | |||
Text="配料演示系统" /> | |||
Text="配料控制系统" /> | |||
</StackPanel> | |||
</Border> | |||
<UniformGrid | |||
@@ -53,22 +276,90 @@ | |||
Height="50" | |||
HorizontalAlignment="Right" | |||
Columns="3"> | |||
<Button | |||
<pry:IcoButton | |||
Name="ButMin" | |||
Content="" | |||
Style="{StaticResource TitleBarStyle}" /> | |||
<Button | |||
Style="{StaticResource IcoTitleBarStyle}" /> | |||
<pry:IcoButton | |||
Name="ButMax" | |||
Content="" | |||
Style="{StaticResource TitleBarStyle}" /> | |||
<Button | |||
Style="{StaticResource IcoTitleBarStyle}" /> | |||
<pry:IcoButton | |||
Name="ButClose" | |||
Content="" | |||
Style="{StaticResource TitleBarStyle}" /> | |||
Style="{StaticResource IcoTitleBarStyle}" /> | |||
</UniformGrid> | |||
<!--#endregion--> | |||
--> | |||
<!--#endregion--> | |||
<!--#region 内容区域--> | |||
<!-- | |||
<Grid Grid.Row="1"> | |||
--> | |||
<!--<Grid.Background> | |||
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/WindowImages.png" /> | |||
</Grid.Background>--> | |||
<!-- | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="0.15*" /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<Grid> | |||
<Grid.Background> | |||
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/leftback.png" Opacity="0.8" /> | |||
</Grid.Background> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="0.1*"/> | |||
<RowDefinition Height="0.1*"/> | |||
<RowDefinition Height="0.1*"/> | |||
<RowDefinition Height="0.1*"/> | |||
<RowDefinition Height="0.1*"/> | |||
<RowDefinition/> | |||
</Grid.RowDefinitions> | |||
<RadioButton Grid.Row="0" Content="配方设置" Style="{StaticResource RectangleLeftRadioButtonStyle}" /> | |||
<RadioButton Grid.Row="1" Content="设备列表" Style="{StaticResource RectangleLeftRadioButtonStyle}" /> | |||
<RadioButton Grid.Row="2" Content="硬件状态" Style="{StaticResource RectangleLeftRadioButtonStyle}" /> | |||
<RadioButton Grid.Row="3" Content="报警记录" Style="{StaticResource RectangleLeftRadioButtonStyle}" /> | |||
<RadioButton Grid.Row="4" Content="配方控制" Style="{StaticResource RectangleLeftRadioButtonStyle}" /> | |||
</Grid> | |||
--> | |||
<!--<StackPanel> | |||
<StackPanel.Background> | |||
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/leftback.png" Opacity="0.8" /> | |||
</StackPanel.Background> | |||
<RadioButton Content="配方设置" Style="{StaticResource RectangleLeftRadioButtonStyle}" /> | |||
<RadioButton Content="设备列表" Style="{StaticResource RectangleLeftRadioButtonStyle}" /> | |||
<RadioButton Content="硬件状态" Style="{StaticResource RectangleLeftRadioButtonStyle}" /> | |||
<RadioButton Content="报警记录" Style="{StaticResource RectangleLeftRadioButtonStyle}" /> | |||
<RadioButton Content="配方控制" Style="{StaticResource RectangleLeftRadioButtonStyle}" /> | |||
</StackPanel>--> | |||
<!-- | |||
<Grid Grid.Column="1"> | |||
<Grid.Background> | |||
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/WindowImages.png" /> | |||
</Grid.Background> | |||
<TextBlock | |||
Margin="0,10,0,0" | |||
HorizontalAlignment="Center" | |||
FontSize="16" | |||
Foreground="#1A8ADE" | |||
Text="配方设置" /> | |||
</Grid> | |||
</Grid> | |||
--> | |||
<!--#endregion--> | |||
<!-- | |||
</Grid> | |||
</Grid>--> | |||
</Window> |
@@ -23,12 +23,35 @@ namespace DosingSystem.View | |||
public MainWindow() | |||
{ | |||
InitializeComponent(); | |||
this.MoveBorder.MouseLeftButtonDown += (o, e) => { this.DragMove(); }; | |||
this.ButMin.Click += (o, e) => { this.WindowState = WindowState.Minimized; }; | |||
this.ButMax.Click += (o, e) => { this.WindowState = this.WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized; }; | |||
this.ButClose.Click += (o, e) => { this.Close(); }; | |||
this.MaxWidth = SystemParameters.WorkArea.Width; | |||
this.MaxHeight = SystemParameters.WorkArea.Height; | |||
this.br.MouseLeftButtonDown += (o, e) => | |||
{ | |||
if (e.ClickCount > 1) | |||
{ | |||
if (this.WindowState == WindowState.Maximized) | |||
this.WindowState = WindowState.Normal; | |||
else if (this.WindowState == WindowState.Normal) | |||
this.WindowState = WindowState.Maximized; | |||
} | |||
if (e.LeftButton == MouseButtonState.Pressed) this.DragMove(); | |||
}; | |||
} | |||
private void Button_Login(object sender, RoutedEventArgs e) | |||
{ | |||
} | |||
private void Button_LogOut(object sender, RoutedEventArgs e) | |||
{ | |||
} | |||
} | |||
} |
@@ -0,0 +1,27 @@ | |||
<UserControl | |||
x:Class="DosingSystem.View.RecipeControlView" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:control="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||
xmlns:vm="clr-namespace:DosingSystem.ViewModel" | |||
xmlns:local="clr-namespace:DosingSystem.View" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
d:DesignHeight="450" | |||
d:DesignWidth="800" | |||
mc:Ignorable="d"> | |||
<UserControl.DataContext> | |||
<vm:RecipeControlViewModel/> | |||
</UserControl.DataContext> | |||
<Grid> | |||
<TextBlock | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="40" | |||
Foreground="Wheat" | |||
Text="配方控制" /> | |||
</Grid> | |||
</UserControl> |
@@ -0,0 +1,28 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Windows; | |||
using System.Windows.Controls; | |||
using System.Windows.Data; | |||
using System.Windows.Documents; | |||
using System.Windows.Input; | |||
using System.Windows.Media; | |||
using System.Windows.Media.Imaging; | |||
using System.Windows.Navigation; | |||
using System.Windows.Shapes; | |||
namespace DosingSystem.View | |||
{ | |||
/// <summary> | |||
/// RecipeControlView.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class RecipeControlView : UserControl | |||
{ | |||
public RecipeControlView() | |||
{ | |||
InitializeComponent(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,27 @@ | |||
<UserControl | |||
x:Class="DosingSystem.View.RecipeSettingsView" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:control="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:DosingSystem.View" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||
xmlns:vm="clr-namespace:DosingSystem.ViewModel" | |||
d:DesignHeight="450" | |||
d:DesignWidth="800" | |||
mc:Ignorable="d"> | |||
<UserControl.DataContext> | |||
<vm:RecipeSettingsViewModel /> | |||
</UserControl.DataContext> | |||
<Grid> | |||
<TextBlock | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="40" | |||
Foreground="Wheat" | |||
Text="配方设置" /> | |||
</Grid> | |||
</UserControl> |
@@ -0,0 +1,28 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Windows; | |||
using System.Windows.Controls; | |||
using System.Windows.Data; | |||
using System.Windows.Documents; | |||
using System.Windows.Input; | |||
using System.Windows.Media; | |||
using System.Windows.Media.Imaging; | |||
using System.Windows.Navigation; | |||
using System.Windows.Shapes; | |||
namespace DosingSystem.View | |||
{ | |||
/// <summary> | |||
/// RecipeSettingsView.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class RecipeSettingsView : UserControl | |||
{ | |||
public RecipeSettingsView() | |||
{ | |||
InitializeComponent(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,18 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using System.Collections.Concurrent; | |||
using System.Collections.ObjectModel; | |||
using System.Windows; | |||
using BPASmartClient.Helper; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
namespace DosingSystem.ViewModel | |||
{ | |||
public class AlarmRecordViewModel : ObservableObject | |||
{ | |||
} | |||
} |
@@ -0,0 +1,37 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using System.Collections.Concurrent; | |||
using System.Collections.ObjectModel; | |||
using System.Windows; | |||
using BPASmartClient.Helper; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
namespace DosingSystem.ViewModel | |||
{ | |||
public class DeviceListViewModel : ObservableObject | |||
{ | |||
public DeviceListViewModel() | |||
{ | |||
for (int i = 0; i < 10; i++) | |||
{ | |||
devices.Add(new Devices() { IpAddress = $"192.168.1.{i + 10}", DeviceName = $"Device_{i}" }); | |||
} | |||
} | |||
public static ObservableCollection<Devices> devices { get; set; } = new ObservableCollection<Devices>(); | |||
} | |||
public class Devices : ObservableObject | |||
{ | |||
public string IpAddress { get { return _mIpAddress; } set { _mIpAddress = value; OnPropertyChanged(); } } | |||
private string _mIpAddress; | |||
public string DeviceName { get { return _mDeviceName; } set { _mDeviceName = value; OnPropertyChanged(); } } | |||
private string _mDeviceName; | |||
} | |||
} |
@@ -0,0 +1,18 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using System.Collections.Concurrent; | |||
using System.Collections.ObjectModel; | |||
using System.Windows; | |||
using BPASmartClient.Helper; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
namespace DosingSystem.ViewModel | |||
{ | |||
public class HardwareStatusViewModel : ObservableObject | |||
{ | |||
} | |||
} |
@@ -7,7 +7,8 @@ using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using System.Collections.Concurrent; | |||
using System.Collections.ObjectModel; | |||
using System.Windows; | |||
using BPASmartClient.Helper; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
namespace DosingSystem.ViewModel | |||
{ | |||
@@ -15,7 +16,32 @@ namespace DosingSystem.ViewModel | |||
{ | |||
public MainViewModel() | |||
{ | |||
DoNavChanged("HardwareStatusView.硬件状态"); | |||
TogglePag = new RelayCommand<object>(DoNavChanged); | |||
} | |||
public void DoNavChanged(object obj) | |||
{ | |||
if (obj != null && obj is string stobj) | |||
{ | |||
var strs = stobj.Split('.'); | |||
if (strs != null && strs.Length == 2) | |||
{ | |||
Type type = Type.GetType($"DosingSystem.View.{strs[0]}"); | |||
var res = type?.GetConstructor(System.Type.EmptyTypes)?.Invoke(null); | |||
if (res != null && res is FrameworkElement fe) MyWindow = fe; | |||
WindowTitleName = strs[1]; | |||
} | |||
} | |||
} | |||
public RelayCommand<object> TogglePag { get; set; } | |||
public FrameworkElement MyWindow { get { return _mMyWindow; } set { _mMyWindow = value; OnPropertyChanged(); } } | |||
private FrameworkElement _mMyWindow; | |||
public string WindowTitleName { get { return _mWindowTitleName; } set { _mWindowTitleName = value; OnPropertyChanged(); } } | |||
private string _mWindowTitleName; | |||
public bool AutoStart { get { return SystemHelper.GetInstance.IsAutoStart(); } set { SystemHelper.GetInstance.AutoStart(value); OnPropertyChanged(); } } | |||
} | |||
} |
@@ -0,0 +1,18 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using System.Collections.Concurrent; | |||
using System.Collections.ObjectModel; | |||
using System.Windows; | |||
using BPASmartClient.Helper; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
namespace DosingSystem.ViewModel | |||
{ | |||
public class RecipeControlViewModel : ObservableObject | |||
{ | |||
} | |||
} |
@@ -0,0 +1,17 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using System.Collections.Concurrent; | |||
using System.Collections.ObjectModel; | |||
using System.Windows; | |||
using BPASmartClient.Helper; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
namespace DosingSystem.ViewModel | |||
{ | |||
public class RecipeSettingsViewModel : ObservableObject | |||
{ | |||
} | |||
} |