Browse Source

添加图片资源

master
sc 7 months ago
parent
commit
ed94ddb180
  1. BIN
      LOGO/242w.png
  2. BIN
      LOGO/252-2t.png
  3. BIN
      LOGO/252RB.png
  4. BIN
      LOGO/252RMRD.png
  5. BIN
      LOGO/302.png
  6. BIN
      LOGO/303.png
  7. BIN
      LOGO/303pdw.png
  8. 22
      SunlightCentralizedControlManagement_SCCM_.csproj
  9. 87
      View/DispenseMachinesSet.xaml
  10. 218
      View/DispenseMachinesSet.xaml.cs
  11. 29
      View/DispenseView.xaml
  12. 49
      View/DispenseView.xaml.cs
  13. 8
      View/SYSSetView.xaml
  14. 5
      View/SYSSetView.xaml.cs

BIN
LOGO/242w.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

BIN
LOGO/252-2t.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 KiB

BIN
LOGO/252RB.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

BIN
LOGO/252RMRD.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB

BIN
LOGO/302.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

BIN
LOGO/303.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

BIN
LOGO/303pdw.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

22
SunlightCentralizedControlManagement_SCCM_.csproj

@ -137,6 +137,12 @@
<Compile Include="View\LogView.xaml.cs">
<DependentUpon>LogView.xaml</DependentUpon>
</Compile>
<Compile Include="View\DispenseView.xaml.cs">
<DependentUpon>DispenseView.xaml</DependentUpon>
</Compile>
<Compile Include="View\DispenseMachinesSet.xaml.cs">
<DependentUpon>DispenseMachinesSet.xaml</DependentUpon>
</Compile>
<Compile Include="View\MachinesView.xaml.cs">
<DependentUpon>MachinesView.xaml</DependentUpon>
</Compile>
@ -240,6 +246,14 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="View\DispenseView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="View\DispenseMachinesSet.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="View\MachinesView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@ -449,6 +463,14 @@
<Content Include="Fonts\font-awesome-4.7.0\css\font-awesome.css" />
<Content Include="Fonts\font-awesome-4.7.0\css\font-awesome.min.css" />
<Content Include="Fonts\font-awesome-4.7.0\fonts\fontawesome-webfont.svg" />
<Resource Include="LOGO\sunlight_logo.jpg" />
<Resource Include="LOGO\303pdw.png" />
<Resource Include="LOGO\303.png" />
<Resource Include="LOGO\302.png" />
<Resource Include="LOGO\252RMRD.png" />
<Resource Include="LOGO\252RB.png" />
<Resource Include="LOGO\252-2t.png" />
<Resource Include="LOGO\242w.png" />
<Resource Include="sunlight_logotext.jpg" />
<Resource Include="WindowsView\sunlight_logotext.jpg" />
<Resource Include="sunlightlogo.jpg" />

87
View/DispenseMachinesSet.xaml

@ -0,0 +1,87 @@
<UserControl x:Class="SunlightCentralizedControlManagement_SCCM_.View.DispenseMachinesSet"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SunlightCentralizedControlManagement_SCCM_.View"
xmlns:lang="clr-namespace:SunlightCentralizedControlManagement_SCCM_.Properties"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:ConvertMoels="clr-namespace:SunlightCentralizedControlManagement_SCCM_.ConvertMoels"
mc:Ignorable="d"
Loaded="UserControl_Loaded"
d:DesignHeight="900" d:DesignWidth="1200">
<UserControl.Resources>
<ConvertMoels:StateToColorConvert x:Key="StateToColorConvert"/>
</UserControl.Resources>
<Grid>
<DataGrid x:Name="Griddata" AlternationCount="2" IsReadOnly="True" d:ItemsSource="{d:SampleData ItemCount=999}"
Background="#FFC7C7C7" HorizontalGridLinesBrush="{x:Null}" VerticalGridLinesBrush="#FFC9C9C9"
GridLinesVisibility="All" ColumnHeaderHeight="40" HorizontalContentAlignment="Right" FontSize="15"
Grid.ColumnSpan="2" CanUserResizeRows="False" AutoGenerateColumns="False" MinColumnWidth="30"
CanUserAddRows="False" CanUserDeleteRows="False" HeadersVisibility ="Column" SelectionMode="Single"
HorizontalAlignment="Right" Width="500" MouseDoubleClick="Griddata_MouseDoubleClick">
<DataGrid.RowStyle >
<Style TargetType="{x:Type DataGridRow}">
<Setter Property="Height" Value="30" />
<Setter Property="FontSize" Value="25" />
<Style.Triggers>
<Trigger Property="ItemsControl.AlternationIndex" Value="0">
<Setter Property="Background" Value="#FFFFFFFF" />
</Trigger>
<Trigger Property="ItemsControl.AlternationIndex" Value="1">
<Setter Property="Background" Value="#FFF0F0F0" />
</Trigger>
<Trigger Property="IsMouseOver" Value="False"/>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
<DataGrid.CellStyle>
<Style TargetType="DataGridCell">
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="MinWidth" Value="20"/>
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="#FFC0C0C0"/>
<Setter Property="BorderBrush" Value="#FFC0C0C0"/>
<Setter Property="Foreground" Value="Black"/>
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.CellStyle>
<DataGrid.Columns>
<!--列信息绑定-->
<DataGridTemplateColumn Width="70" Header="{x:Static lang:Resources.State}">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<materialDesign:PackIcon Kind="StateMachine" Width="25" Height="30" VerticalAlignment="Center" HorizontalAlignment="Center"
Foreground="{Binding Path=State,Converter={StaticResource StateToColorConvert}}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Header="{x:Static lang:Resources.Machine}" Binding="{Binding Name}" Width="210" IsReadOnly="True"/>
<DataGridTextColumn Header="{x:Static lang:Resources.Group}" Binding="{Binding Groups}" Width="210" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding IP}" Width="0" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding PORT}" Width="0" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding Serial}" Width="0" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding Baud}" Width="0" IsReadOnly="True"/>
</DataGrid.Columns>
</DataGrid>
<Image HorizontalAlignment="Left" x:Name="IMAGE" VerticalAlignment="Top" Width="400" Height="400" Margin="10,200,0,0" />
<TextBox HorizontalAlignment="Left" Height="30" Margin="150,10,0,0" x:Name="comboBoxMachine" VerticalAlignment="Top" Width="270" FontSize="20" />
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,10,0,0" TextWrapping="Wrap" Text="{x:Static lang:Resources.Machine}" VerticalAlignment="Top" Width="120" FontSize="25"/>
<ComboBox HorizontalAlignment="Left" Height="30" Margin="150,50,0,0" x:Name="TextMachineGroup" VerticalAlignment="Top" Width="270" FontSize="20" DropDownClosed="TextMachineGroup_DropDownClosed"/>
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,50,0,0" TextWrapping="Wrap" Text="{x:Static lang:Resources.MachineGroup}" VerticalAlignment="Top" Width="120" FontSize="25"/>
<TextBox HorizontalAlignment="Left" Height="30" Margin="150,100,0,0" x:Name="IP" VerticalAlignment="Top" Width="200" FontSize="20" MaxLines="1"/>
<TextBlock HorizontalAlignment="Left" Height="40" Margin="350,100,0,0" TextWrapping="Wrap" Text=":" VerticalAlignment="Top" Width="20" FontSize="25"/>
<TextBox HorizontalAlignment="Left" Height="30" Margin="360,100,0,0" x:Name="PORT" VerticalAlignment="Top" Width="60" FontSize="20" MaxLines="1" Text="7789"/>
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,100,0,0" TextWrapping="Wrap" Text="IP/PORT" VerticalAlignment="Top" Width="120" FontSize="25"/>
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,600,0,0" x:Name="textlog" TextWrapping="Wrap" Text="------------" VerticalAlignment="Top" Width="140" FontSize="20"/>
<Button Content="{x:Static lang:Resources.Save}" HorizontalAlignment="Left" Height="35" Margin="250,600,0,5" VerticalAlignment="Top" Width="80" Click="Save_Click"/>
<Button Content="{x:Static lang:Resources.Delete}" HorizontalAlignment="Left" Height="35" Margin="340,600,0,5" VerticalAlignment="Top" Width="80" Click="Delete_Click"/>
<Button Content="{x:Static lang:Resources.Test}" HorizontalAlignment="Left" Height="35" Margin="160,600,50,5" VerticalAlignment="Top" Width="80" Click="Test_Click"/>
</Grid>
</UserControl>

218
View/DispenseMachinesSet.xaml.cs

@ -0,0 +1,218 @@
using SkiaSharp;
using SunlightCentralizedControlManagement_SCCM_.UserClass;
using SunlightCentralizedControlManagement_SCCM_.ViewModel;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Sockets;
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;
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper;
namespace SunlightCentralizedControlManagement_SCCM_.View
{
/// <summary>
/// MachinesSet.xaml 的交互逻辑
/// </summary>
public partial class DispenseMachinesSet : UserControl
{
public DispenseMachinesSet()
{
InitializeComponent();
//
string[] Machine_ = { "252", "252RB", "252-2T", "252RDRM", "242W", "302", "303", "303PDW" };
TextMachineGroup.ItemsSource = Machine_;
}
private SQLiteHelper SQLiteHelpers = null; //定义数据库
private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\SCCM.db"; //数据库路径
private readonly UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "SCCM.ini");
//private string SYS_machines = null;
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
Griddata.ItemsSource = MainWindowViewModel.Machines.DefaultView;
}
private void Griddata_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
int rownum = Griddata.SelectedIndex;//获取鼠标选中行并定义变量
if (rownum != -1)//判断鼠标定位是否有效
{
comboBoxMachine.Text = (Griddata.Columns[1].GetCellContent(Griddata.Items[rownum]) as TextBlock).Text;//定位第1列,
TextMachineGroup.Text = (Griddata.Columns[2].GetCellContent(Griddata.Items[rownum]) as TextBlock).Text;//定位第列,
IP.Text = (Griddata.Columns[3].GetCellContent(Griddata.Items[rownum]) as TextBlock).Text;//定位第列,
PORT.Text = (Griddata.Columns[4].GetCellContent(Griddata.Items[rownum]) as TextBlock).Text;//定位第列,
}
}
private void Save_Click(object sender, RoutedEventArgs e)
{
if (!string.IsNullOrEmpty(comboBoxMachine.Text))
{
Dictionary<string, object> dr_new = new Dictionary<string, object>();//缓存函数
dr_new.Add("Name", comboBoxMachine.Text);
dr_new.Add("Groups", TextMachineGroup.Text);
dr_new.Add("IP", IP.Text);
dr_new.Add("PORT", PORT.Text);
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
SQLiteHelpers.Open(); //打开数据库
if (SQLiteHelpers.ExecuteDataSet("select * from Machines where name ='" + comboBoxMachine.Text + "'", null).Tables[0].Rows.Count == 0)
{
SQLiteHelpers.InsertData("Machines", dr_new);
}
else
{
SQLiteHelpers.Update("Machines", dr_new, "name='" + comboBoxMachine.Text + "'", null);
}
MainWindowViewModel.Machines = SQLiteHelpers.ExecuteDataSet("select * from Machines Order by id", null).Tables[0]; //读取表写入缓存
SQLiteHelpers.Close();
Griddata.ItemsSource = MainWindowViewModel.Machines.DefaultView;
comboBoxMachine.Text = null;
TextMachineGroup.Text = null;
IP.Text = null;
PORT.Text = "7789";
}
else
{
}
}
private void Delete_Click(object sender, RoutedEventArgs e)
{
if (!string.IsNullOrEmpty(comboBoxMachine.Text))
{
MessageBoxResult vr = System.Windows.MessageBox.Show(Properties.Resources.Delete + comboBoxMachine.Text, "SCCM", MessageBoxButton.OKCancel, MessageBoxImage.Question);
if (vr == MessageBoxResult.OK) // 如果是确定,就执行下面代码
{
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
SQLiteHelpers.Open(); //打开数据库
SQLiteHelpers.Delete("Machines", "Name='" + comboBoxMachine.Text + "'", null);
MainWindowViewModel.Machines = SQLiteHelpers.ExecuteDataSet("select * from Machines Order by id", null).Tables[0]; //读取表写入缓存
SQLiteHelpers.Close();
Griddata.ItemsSource = MainWindowViewModel.Machines.DefaultView;
comboBoxMachine.Text = null;
}
}
else
{
textlog.Text = "Invalid";
textlog.Foreground = new SolidColorBrush(Color.FromRgb(255, 0, 0));
}
}
private void Test_Click(object sender, RoutedEventArgs e)//测试按钮
{
if (!string.IsNullOrEmpty(IP.Text) && !string.IsNullOrEmpty(PORT.Text))
{
textlog.Text = "TEST";
textlog.Foreground = new SolidColorBrush(Color.FromRgb(0, 0, 255));
//------------使用ping类------
string host = IP.Text;
Ping p1 = new Ping();
PingReply reply = p1.Send(host); //发送主机名或Ip地址
//StringBuilder sbuilder;
if (reply.Status == IPStatus.Success)
{
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
//连接服务器,绑定IP 与 端口
IPEndPoint iPEndPoint = new IPEndPoint(IPAddress.Parse(IP.Text), int.Parse(PORT.Text));
try
{
socket.Connect(iPEndPoint);
socket.Close();//离线
textlog.Text = "Link succeed";
textlog.Foreground = new SolidColorBrush(Color.FromRgb(0, 255, 0));
}
catch (Exception)
{
textlog.Text = "Link failed";
textlog.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 0));
}
}
else if (reply.Status == IPStatus.TimedOut)
{
textlog.Text = "Link timeout";
textlog.Foreground = new SolidColorBrush(Color.FromRgb(255, 0, 0));
}
else
{
textlog.Text = "No links";
textlog.Foreground = new SolidColorBrush(Color.FromRgb(255, 0, 0));
}
}
else
{
textlog.Text = "Invalid";
textlog.Foreground = new SolidColorBrush(Color.FromRgb(255, 0, 0));
}
}
private void TextMachineGroup_DropDownClosed(object sender, EventArgs e)
{
Uri uri;
BitmapImage bitmapImage;
switch (TextMachineGroup.Text)//步骤用时计算
{
case "252":
uri = new Uri("pack://application:,,,/ReferencedAssembly;component/LOGO/252-2t.png");
bitmapImage = new BitmapImage(uri);
IMAGE.Source = bitmapImage;
break;
case "252-2T":
uri = new Uri("pack://application:,,,/ReferencedAssembly;component/SunlightCentralizedControlManagement(SCCM)/LOGO/252-2t.png");
bitmapImage = new BitmapImage(uri);
IMAGE.Source = bitmapImage;
break;
case "252RB":
uri = new Uri("pack://application:,,,/ReferencedAssembly;component/SunlightCentralizedControlManagement(SCCM)/LOGO/252RB.png");
bitmapImage = new BitmapImage(uri);
IMAGE.Source = bitmapImage;
break;
case "252RDRM":
uri = new Uri("pack://application:,,,/ReferencedAssembly;component/SunlightCentralizedControlManagement(SCCM)/LOGO/252RDRM.png");
bitmapImage = new BitmapImage(uri);
IMAGE.Source = bitmapImage;
break;
case "242W":
uri = new Uri("pack://application:,,,/SunlightCentralizedControlManagement_SCCM_;component/242w.png");
bitmapImage = new BitmapImage(uri);
IMAGE.Source = bitmapImage;
break;
case "302":
uri = new Uri("pack://application:,,,/ReferencedAssembly;component/SunlightCentralizedControlManagement(SCCM)/LOGO/302.png");
bitmapImage = new BitmapImage(uri);
IMAGE.Source = bitmapImage;
break;
case "303":
uri = new Uri("pack://application:,,,/ReferencedAssembly;component/SunlightCentralizedControlManagement(SCCM)/LOGO/303.png");
bitmapImage = new BitmapImage(uri);
IMAGE.Source = bitmapImage;
break;
case "303PDW":
uri = new Uri("pack://application:,,,/ReferencedAssembly;component/SunlightCentralizedControlManagement(SCCM)/LOGO/303pdw.png");
bitmapImage = new BitmapImage(uri);
IMAGE.Source = bitmapImage;
break;
default:
break;
}
}
}
}

29
View/DispenseView.xaml

@ -0,0 +1,29 @@
<UserControl x:Class="SunlightCentralizedControlManagement_SCCM_.View.DispenseView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SunlightCentralizedControlManagement_SCCM_.View"
xmlns:lang="clr-namespace:SunlightCentralizedControlManagement_SCCM_.Properties"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:ConvertMoels="clr-namespace:SunlightCentralizedControlManagement_SCCM_.ConvertMoels"
mc:Ignorable="d"
Loaded="UserControl_Loaded"
d:DesignHeight="900" d:DesignWidth="1200">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="60"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
</Grid>
<StackPanel Grid.Row="1" Height="60" Background="#FF00204E" Orientation="Horizontal">
</StackPanel>
</Grid>
</UserControl>

49
View/DispenseView.xaml.cs

@ -0,0 +1,49 @@
using SkiaSharp;
using SunlightCentralizedControlManagement_SCCM_.UserClass;
using SunlightCentralizedControlManagement_SCCM_.ViewModel;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Sockets;
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;
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper;
namespace SunlightCentralizedControlManagement_SCCM_.View
{
/// <summary>
/// MachinesSet.xaml 的交互逻辑
/// </summary>
public partial class DispenseView : UserControl
{
public DispenseView()
{
InitializeComponent();
}
private SQLiteHelper SQLiteHelpers = null; //定义数据库
private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\SCCM.db"; //数据库路径
private readonly UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "SCCM.ini");
//private string SYS_machines = null;
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
}
}
}

8
View/SYSSetView.xaml

@ -22,6 +22,14 @@
</StackPanel>
</ListViewItem>
</ListView>
<ListView ScrollViewer.HorizontalScrollBarVisibility="Disabled" Foreground="#FF1368BD">
<ListViewItem Height="60" MouseLeftButtonUp="ListViewItem_ConveyorCenters" VerticalAlignment="Center">
<StackPanel Orientation="Horizontal" >
<materialDesign:PackIcon Kind="Material" Width="40" Height="30" Margin="10" VerticalAlignment="Center"/>
<TextBlock Text="{x:Static lang:Resources.ConveyorCenters}" VerticalAlignment="Center" Margin="20 10" Foreground="White"/>
</StackPanel>
</ListViewItem>
</ListView>
<ListView ScrollViewer.HorizontalScrollBarVisibility="Disabled" Foreground="#FF1368BD">
<ListViewItem Height="60" MouseLeftButtonUp="ListViewItem_EngineerSet" VerticalAlignment="Center">
<StackPanel Orientation="Horizontal" >

5
View/SYSSetView.xaml.cs

@ -51,5 +51,10 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
{
Picture.Content = new View.LogView();
}
private void ListViewItem_ConveyorCenters(object sender, MouseButtonEventArgs e)
{
Picture.Content = new View.DispenseMachinesSet();
}
}
}

Loading…
Cancel
Save