首次上传代码
BIN
.vs/AnQing/v17/.suo
Normal file
86
.vs/AnQing/v17/DocumentLayout.backup.json
Normal file
@ -0,0 +1,86 @@
|
||||
{
|
||||
"Version": 1,
|
||||
"WorkspaceRootPath": "E:\\Work\\\u5B89\u5E86\u53BB\u529F\u80FD\u5316\\AnQing\\",
|
||||
"Documents": [
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{BB127311-91B1-4F6A-BC1C-23682B667D16}|AnQing\\AnQing.csproj|E:\\Work\\\u5B89\u5E86\u53BB\u529F\u80FD\u5316\\AnQing\\anqing\\mainwindow.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}",
|
||||
"RelativeMoniker": "D:0:0:{BB127311-91B1-4F6A-BC1C-23682B667D16}|AnQing\\AnQing.csproj|solutionrelative:anqing\\mainwindow.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{BB127311-91B1-4F6A-BC1C-23682B667D16}|AnQing\\AnQing.csproj|e:\\work\\\u5B89\u5E86\u53BB\u529F\u80FD\u5316\\anqing\\anqing\\viewmodel\\windowqueryviewmodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{BB127311-91B1-4F6A-BC1C-23682B667D16}|AnQing\\AnQing.csproj|solutionrelative:anqing\\viewmodel\\windowqueryviewmodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{BB127311-91B1-4F6A-BC1C-23682B667D16}|AnQing\\AnQing.csproj|E:\\Work\\\u5B89\u5E86\u53BB\u529F\u80FD\u5316\\AnQing\\anqing\\viewmodel\\mianwindowviewmodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{BB127311-91B1-4F6A-BC1C-23682B667D16}|AnQing\\AnQing.csproj|solutionrelative:anqing\\viewmodel\\mianwindowviewmodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{BB127311-91B1-4F6A-BC1C-23682B667D16}|AnQing\\AnQing.csproj|E:\\Work\\\u5B89\u5E86\u53BB\u529F\u80FD\u5316\\AnQing\\anqing\\commons\\common.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{BB127311-91B1-4F6A-BC1C-23682B667D16}|AnQing\\AnQing.csproj|solutionrelative:anqing\\commons\\common.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
}
|
||||
],
|
||||
"DocumentGroupContainers": [
|
||||
{
|
||||
"Orientation": 0,
|
||||
"VerticalTabListWidth": 256,
|
||||
"DocumentGroups": [
|
||||
{
|
||||
"DockedWidth": 200,
|
||||
"SelectedChildIndex": 3,
|
||||
"Children": [
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 3,
|
||||
"Title": "Common.cs",
|
||||
"DocumentMoniker": "E:\\Work\\\u5B89\u5E86\u53BB\u529F\u80FD\u5316\\AnQing\\AnQing\\Commons\\Common.cs",
|
||||
"RelativeDocumentMoniker": "AnQing\\Commons\\Common.cs",
|
||||
"ToolTip": "E:\\Work\\\u5B89\u5E86\u53BB\u529F\u80FD\u5316\\AnQing\\AnQing\\Commons\\Common.cs",
|
||||
"RelativeToolTip": "AnQing\\Commons\\Common.cs",
|
||||
"ViewState": "AgIAACIAAAAAAAAAAAArwJwAAAARAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-03-23T23:57:05.4Z"
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 2,
|
||||
"Title": "MianWindowViewModel.cs",
|
||||
"DocumentMoniker": "E:\\Work\\\u5B89\u5E86\u53BB\u529F\u80FD\u5316\\AnQing\\AnQing\\ViewModel\\MianWindowViewModel.cs",
|
||||
"RelativeDocumentMoniker": "AnQing\\ViewModel\\MianWindowViewModel.cs",
|
||||
"ToolTip": "E:\\Work\\\u5B89\u5E86\u53BB\u529F\u80FD\u5316\\AnQing\\AnQing\\ViewModel\\MianWindowViewModel.cs",
|
||||
"RelativeToolTip": "AnQing\\ViewModel\\MianWindowViewModel.cs",
|
||||
"ViewState": "AgIAAOgBAAAAAAAAAAA2wDwCAAAWAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-03-23T23:53:49.48Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 1,
|
||||
"Title": "WindowQueryViewModel.cs",
|
||||
"DocumentMoniker": "E:\\Work\\\u5B89\u5E86\u53BB\u529F\u80FD\u5316\\AnQing\\AnQing\\ViewModel\\WindowQueryViewModel.cs",
|
||||
"RelativeDocumentMoniker": "AnQing\\ViewModel\\WindowQueryViewModel.cs",
|
||||
"ToolTip": "E:\\Work\\\u5B89\u5E86\u53BB\u529F\u80FD\u5316\\AnQing\\AnQing\\ViewModel\\WindowQueryViewModel.cs",
|
||||
"RelativeToolTip": "AnQing\\ViewModel\\WindowQueryViewModel.cs",
|
||||
"ViewState": "AgIAAIQBAAAAAAAAAAAQwDoAAAAmAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-03-23T08:38:06.209Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 0,
|
||||
"Title": "MainWindow.xaml",
|
||||
"DocumentMoniker": "E:\\Work\\\u5B89\u5E86\u53BB\u529F\u80FD\u5316\\AnQing\\AnQing\\MainWindow.xaml",
|
||||
"RelativeDocumentMoniker": "AnQing\\MainWindow.xaml",
|
||||
"ToolTip": "E:\\Work\\\u5B89\u5E86\u53BB\u529F\u80FD\u5316\\AnQing\\AnQing\\MainWindow.xaml",
|
||||
"RelativeToolTip": "AnQing\\MainWindow.xaml",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003549|",
|
||||
"WhenOpened": "2025-03-17T05:53:34.154Z",
|
||||
"EditorCaption": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
86
.vs/AnQing/v17/DocumentLayout.json
Normal file
@ -0,0 +1,86 @@
|
||||
{
|
||||
"Version": 1,
|
||||
"WorkspaceRootPath": "E:\\Work\\\u5B89\u5E86\u53BB\u529F\u80FD\u5316\\AnQing\\",
|
||||
"Documents": [
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{BB127311-91B1-4F6A-BC1C-23682B667D16}|AnQing\\AnQing.csproj|E:\\Work\\\u5B89\u5E86\u53BB\u529F\u80FD\u5316\\AnQing\\anqing\\viewmodel\\mianwindowviewmodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{BB127311-91B1-4F6A-BC1C-23682B667D16}|AnQing\\AnQing.csproj|solutionrelative:anqing\\viewmodel\\mianwindowviewmodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{BB127311-91B1-4F6A-BC1C-23682B667D16}|AnQing\\AnQing.csproj|E:\\Work\\\u5B89\u5E86\u53BB\u529F\u80FD\u5316\\AnQing\\anqing\\mainwindow.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}",
|
||||
"RelativeMoniker": "D:0:0:{BB127311-91B1-4F6A-BC1C-23682B667D16}|AnQing\\AnQing.csproj|solutionrelative:anqing\\mainwindow.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{BB127311-91B1-4F6A-BC1C-23682B667D16}|AnQing\\AnQing.csproj|e:\\work\\\u5B89\u5E86\u53BB\u529F\u80FD\u5316\\anqing\\anqing\\viewmodel\\windowqueryviewmodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{BB127311-91B1-4F6A-BC1C-23682B667D16}|AnQing\\AnQing.csproj|solutionrelative:anqing\\viewmodel\\windowqueryviewmodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{BB127311-91B1-4F6A-BC1C-23682B667D16}|AnQing\\AnQing.csproj|E:\\Work\\\u5B89\u5E86\u53BB\u529F\u80FD\u5316\\AnQing\\anqing\\commons\\common.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{BB127311-91B1-4F6A-BC1C-23682B667D16}|AnQing\\AnQing.csproj|solutionrelative:anqing\\commons\\common.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
}
|
||||
],
|
||||
"DocumentGroupContainers": [
|
||||
{
|
||||
"Orientation": 0,
|
||||
"VerticalTabListWidth": 256,
|
||||
"DocumentGroups": [
|
||||
{
|
||||
"DockedWidth": 200,
|
||||
"SelectedChildIndex": 1,
|
||||
"Children": [
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 3,
|
||||
"Title": "Common.cs",
|
||||
"DocumentMoniker": "E:\\Work\\\u5B89\u5E86\u53BB\u529F\u80FD\u5316\\AnQing\\AnQing\\Commons\\Common.cs",
|
||||
"RelativeDocumentMoniker": "AnQing\\Commons\\Common.cs",
|
||||
"ToolTip": "E:\\Work\\\u5B89\u5E86\u53BB\u529F\u80FD\u5316\\AnQing\\AnQing\\Commons\\Common.cs",
|
||||
"RelativeToolTip": "AnQing\\Commons\\Common.cs",
|
||||
"ViewState": "AgIAACIAAAAAAAAAAAArwJwAAAARAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-03-23T23:57:05.4Z"
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 0,
|
||||
"Title": "MianWindowViewModel.cs",
|
||||
"DocumentMoniker": "E:\\Work\\\u5B89\u5E86\u53BB\u529F\u80FD\u5316\\AnQing\\AnQing\\ViewModel\\MianWindowViewModel.cs",
|
||||
"RelativeDocumentMoniker": "AnQing\\ViewModel\\MianWindowViewModel.cs",
|
||||
"ToolTip": "E:\\Work\\\u5B89\u5E86\u53BB\u529F\u80FD\u5316\\AnQing\\AnQing\\ViewModel\\MianWindowViewModel.cs*",
|
||||
"RelativeToolTip": "AnQing\\ViewModel\\MianWindowViewModel.cs*",
|
||||
"ViewState": "AgIAAMMAAAAAAAAAAIA9wHYBAAAAAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-03-23T23:53:49.48Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 2,
|
||||
"Title": "WindowQueryViewModel.cs",
|
||||
"DocumentMoniker": "E:\\Work\\\u5B89\u5E86\u53BB\u529F\u80FD\u5316\\AnQing\\AnQing\\ViewModel\\WindowQueryViewModel.cs",
|
||||
"RelativeDocumentMoniker": "AnQing\\ViewModel\\WindowQueryViewModel.cs",
|
||||
"ToolTip": "E:\\Work\\\u5B89\u5E86\u53BB\u529F\u80FD\u5316\\AnQing\\AnQing\\ViewModel\\WindowQueryViewModel.cs",
|
||||
"RelativeToolTip": "AnQing\\ViewModel\\WindowQueryViewModel.cs",
|
||||
"ViewState": "AgIAAIQBAAAAAAAAAAAQwDoAAAAmAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-03-23T08:38:06.209Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 1,
|
||||
"Title": "MainWindow.xaml",
|
||||
"DocumentMoniker": "E:\\Work\\\u5B89\u5E86\u53BB\u529F\u80FD\u5316\\AnQing\\AnQing\\MainWindow.xaml",
|
||||
"RelativeDocumentMoniker": "AnQing\\MainWindow.xaml",
|
||||
"ToolTip": "E:\\Work\\\u5B89\u5E86\u53BB\u529F\u80FD\u5316\\AnQing\\AnQing\\MainWindow.xaml",
|
||||
"RelativeToolTip": "AnQing\\MainWindow.xaml",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003549|",
|
||||
"WhenOpened": "2025-03-17T05:53:34.154Z",
|
||||
"EditorCaption": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
22
AnQing.sln
Normal file
@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.12.35527.113 d17.12
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AnQing", "AnQing\AnQing.csproj", "{BB127311-91B1-4F6A-BC1C-23682B667D16}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{BB127311-91B1-4F6A-BC1C-23682B667D16}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BB127311-91B1-4F6A-BC1C-23682B667D16}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BB127311-91B1-4F6A-BC1C-23682B667D16}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BB127311-91B1-4F6A-BC1C-23682B667D16}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
1
AnQing/.vs/AnQing.csproj.dtbcache.json
Normal file
@ -0,0 +1 @@
|
||||
{"RootPath":"E:\\Work\\安庆去功能化\\AnQing\\AnQing","ProjectFileName":"AnQing.csproj","Configuration":"Debug|AnyCPU","FrameworkPath":"","Sources":[{"SourceFile":"App.xaml.cs"},{"SourceFile":"MainWindow.xaml.cs"},{"SourceFile":"Properties\\AssemblyInfo.cs"},{"SourceFile":"Properties\\Resources.Designer.cs"},{"SourceFile":"Properties\\Settings.Designer.cs"},{"SourceFile":"obj\\Debug\\.NETFramework,Version=v4.8.AssemblyAttributes.cs"},{"SourceFile":"E:\\Work\\安庆去功能化\\AnQing\\AnQing\\obj\\Debug\\MainWindow.g.cs"},{"SourceFile":"E:\\Work\\安庆去功能化\\AnQing\\AnQing\\obj\\Debug\\App.g.cs"}],"References":[{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\Microsoft.CSharp.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\mscorlib.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\PresentationCore.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\PresentationFramework.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Core.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Data.DataSetExtensions.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Data.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Net.Http.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Xaml.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Xml.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Xml.Linq.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\WindowsBase.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""}],"Analyzers":[],"Outputs":[{"OutputItemFullPath":"E:\\Work\\安庆去功能化\\AnQing\\AnQing\\bin\\Debug\\AnQing.exe","OutputItemRelativePath":"AnQing.exe"},{"OutputItemFullPath":"","OutputItemRelativePath":""}],"CopyToOutputEntries":[]}
|
219
AnQing/AnQing.csproj
Normal file
@ -0,0 +1,219 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\packages\EntityFramework.6.4.4\build\EntityFramework.props" Condition="Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.props')" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{BB127311-91B1-4F6A-BC1C-23682B667D16}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>AnQing</RootNamespace>
|
||||
<AssemblyName>AnQing</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
<LangVersion>10.0</LangVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.SqlServer.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="EPPlus, Version=7.7.0.0, Culture=neutral, PublicKeyToken=ea159fdaa78159a1, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\EPPlus.7.7.0\lib\net462\EPPlus.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="EPPlus.Interfaces, Version=7.7.0.0, Culture=neutral, PublicKeyToken=a694d7f3b0907a61, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\EPPlus.Interfaces.7.7.0\lib\net462\EPPlus.Interfaces.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="EPPlus.System.Drawing, Version=7.7.0.0, Culture=neutral, PublicKeyToken=2308d35469c9bac0, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\EPPlus.System.Drawing.7.7.0\lib\net462\EPPlus.System.Drawing.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="HandyControl, Version=3.5.1.0, Culture=neutral, PublicKeyToken=45be8712787a1e5b, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\HandyControl.3.5.1\lib\net48\HandyControl.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.IO.RecyclableMemoryStream, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.IO.RecyclableMemoryStream.3.0.1\lib\netstandard2.0\Microsoft.IO.RecyclableMemoryStream.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.WindowsAPICodePack, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\WindowsAPICodePack-Core.1.1.1\lib\Microsoft.WindowsAPICodePack.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.WindowsAPICodePack.Shell, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\WindowsAPICodePack-Shell.1.1.1\lib\Microsoft.WindowsAPICodePack.Shell.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Xaml.Behaviors, Version=1.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Xaml.Behaviors.Wpf.1.1.135\lib\net462\Microsoft.Xaml.Behaviors.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NModbus4, Version=2.1.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NModbus4.2.1.0\lib\net40\NModbus4.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.ComponentModel.Annotations, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.ComponentModel.Annotations.5.0.0\lib\net461\System.ComponentModel.Annotations.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Security" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xaml">
|
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="zxing, Version=0.16.10.0, Culture=neutral, PublicKeyToken=4e88037ac681fe60, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\ZXing.Net.0.16.10\lib\net48\zxing.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="zxing.presentation, Version=0.16.10.0, Culture=neutral, PublicKeyToken=4e88037ac681fe60, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\ZXing.Net.0.16.10\lib\net48\zxing.presentation.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Compile Include="Commons\CommandInfo.cs" />
|
||||
<Compile Include="Commons\Common.cs" />
|
||||
<Compile Include="Commons\DbHelperSQL.cs" />
|
||||
<Compile Include="Commons\IndexToSerialNumberConverter.cs" />
|
||||
<Compile Include="Commons\ModbusClient.cs" />
|
||||
<Compile Include="Commons\MVCamera.cs" />
|
||||
<Compile Include="Commons\ParamInfo.cs" />
|
||||
<Compile Include="Commons\RelayCommand.cs" />
|
||||
<Compile Include="Model\IMAGEINFO.cs" />
|
||||
<Compile Include="Model\SCAN_DETAIL.cs" />
|
||||
<Compile Include="Model\SCAN_MAIN.cs" />
|
||||
<Compile Include="ViewModel\MianWindowViewModel.cs" />
|
||||
<Compile Include="ViewModel\SetUpViewModel.cs" />
|
||||
<Compile Include="ViewModel\WindowQueryViewModel.cs" />
|
||||
<Compile Include="View\History.xaml.cs">
|
||||
<DependentUpon>History.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="View\ImageSetUp.xaml.cs">
|
||||
<DependentUpon>ImageSetUp.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="View\SetUpView.xaml.cs">
|
||||
<DependentUpon>SetUpView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Page Include="MainWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MainWindow.xaml.cs">
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Page Include="Style.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="View\History.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="View\ImageSetUp.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="View\SetUpView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<None Include="config.json" />
|
||||
<None Include="packages.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Resources\Image\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Resources\Dll\MvCameraControl.Net.dll" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\EntityFramework.6.4.4\build\EntityFramework.props'))" />
|
||||
<Error Condition="!Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\EntityFramework.6.4.4\build\EntityFramework.targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\packages\EntityFramework.6.4.4\build\EntityFramework.targets" Condition="Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.targets')" />
|
||||
</Project>
|
25
AnQing/App.config
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
|
||||
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
||||
</configSections>
|
||||
<connectionStrings>
|
||||
<add name="ConnectionString" connectionString="server=.;uid=sa;pwd=rgd.123;database=AnQing;"/>
|
||||
</connectionStrings>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
|
||||
</startup>
|
||||
<appSettings>
|
||||
<add key="VideoIP1" value="192.168.0.202" />
|
||||
<add key="VideoIP2" value="192.168.0.202" />
|
||||
<add key="ImagePath" value="192.168.0.202" />
|
||||
</appSettings>
|
||||
<entityFramework>
|
||||
<providers>
|
||||
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
|
||||
<provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
|
||||
</providers>
|
||||
</entityFramework>
|
||||
|
||||
</configuration>
|
15
AnQing/App.xaml
Normal file
@ -0,0 +1,15 @@
|
||||
<Application x:Class="AnQing.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:AnQing"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/SkinDefault.xaml"/>
|
||||
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Theme.xaml"/>
|
||||
<ResourceDictionary Source="pack://application:,,,/AnQing;component/Style.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
</Application>
|
61
AnQing/App.xaml.cs
Normal file
@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace AnQing
|
||||
{
|
||||
/// <summary>
|
||||
/// App.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
private static Mutex _mutex;
|
||||
private const string AppName = "AnQing";
|
||||
public static bool IsDuplicateInstance { get; private set; } = false; // 标记重复运行
|
||||
|
||||
protected override void OnStartup(StartupEventArgs e)
|
||||
{
|
||||
bool createdNew;
|
||||
_mutex = new Mutex(true, "Global\\" + AppName, out createdNew);
|
||||
|
||||
if (!createdNew)
|
||||
{
|
||||
// 标记为重复运行
|
||||
IsDuplicateInstance = true;
|
||||
|
||||
// 显示提示
|
||||
MessageBox.Show("程序已在运行中!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
|
||||
// 直接关闭应用
|
||||
Application.Current.Shutdown();
|
||||
return;
|
||||
}
|
||||
|
||||
base.OnStartup(e);
|
||||
}
|
||||
|
||||
protected override void OnExit(ExitEventArgs e)
|
||||
{
|
||||
_mutex?.ReleaseMutex();
|
||||
_mutex?.Dispose();
|
||||
base.OnExit(e);
|
||||
}
|
||||
|
||||
public static void Restart()
|
||||
{
|
||||
// 释放互斥锁
|
||||
_mutex.ReleaseMutex();
|
||||
|
||||
string executablePath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "AnQing.exe");
|
||||
System.Diagnostics.Process.Start(executablePath);
|
||||
//System.Diagnostics.Process.Start(Application.ResourceAssembly.Location);
|
||||
|
||||
Application.Current.Shutdown();
|
||||
}
|
||||
}
|
||||
}
|
82
AnQing/Commons/CommandInfo.cs
Normal file
@ -0,0 +1,82 @@
|
||||
using System;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace RGD.DBUtility
|
||||
{
|
||||
public enum EffentNextType
|
||||
{
|
||||
/// <summary>
|
||||
/// 对其他语句无任何影响
|
||||
/// </summary>
|
||||
None,
|
||||
|
||||
/// <summary>
|
||||
/// 当前语句必须为"select count(1) from .."格式,如果存在则继续执行,不存在回滚事务
|
||||
/// </summary>
|
||||
WhenHaveContine,
|
||||
|
||||
/// <summary>
|
||||
/// 当前语句必须为"select count(1) from .."格式,如果不存在则继续执行,存在回滚事务
|
||||
/// </summary>
|
||||
WhenNoHaveContine,
|
||||
|
||||
/// <summary>
|
||||
/// 当前语句影响到的行数必须大于0,否则回滚事务
|
||||
/// </summary>
|
||||
ExcuteEffectRows,
|
||||
|
||||
/// <summary>
|
||||
/// 引发事件-当前语句必须为"select count(1) from .."格式,如果不存在则继续执行,存在回滚事务
|
||||
/// </summary>
|
||||
SolicitationEvent
|
||||
}
|
||||
|
||||
public class CommandInfo
|
||||
{
|
||||
public object ShareObject = null;
|
||||
public object OriginalData = null;
|
||||
|
||||
private event EventHandler _solicitationEvent;
|
||||
|
||||
public event EventHandler SolicitationEvent
|
||||
{
|
||||
add
|
||||
{
|
||||
_solicitationEvent += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_solicitationEvent -= value;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnSolicitationEvent()
|
||||
{
|
||||
if (_solicitationEvent != null)
|
||||
{
|
||||
_solicitationEvent(this, new EventArgs());
|
||||
}
|
||||
}
|
||||
|
||||
public string CommandText;
|
||||
public System.Data.Common.DbParameter[] Parameters;
|
||||
public EffentNextType EffentNextType = EffentNextType.None;
|
||||
|
||||
public CommandInfo()
|
||||
{
|
||||
}
|
||||
|
||||
public CommandInfo(string sqlText, SqlParameter[] para)
|
||||
{
|
||||
this.CommandText = sqlText;
|
||||
this.Parameters = para;
|
||||
}
|
||||
|
||||
public CommandInfo(string sqlText, SqlParameter[] para, EffentNextType type)
|
||||
{
|
||||
this.CommandText = sqlText;
|
||||
this.Parameters = para;
|
||||
this.EffentNextType = type;
|
||||
}
|
||||
}
|
||||
}
|
273
AnQing/Commons/Common.cs
Normal file
@ -0,0 +1,273 @@
|
||||
using AnQing.View;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.ComponentModel;
|
||||
using AnQing.Models;
|
||||
using OfficeOpenXml;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace AnQing.Commons
|
||||
{
|
||||
public class Common
|
||||
{
|
||||
|
||||
public static MainWindow main;
|
||||
/// <summary>
|
||||
/// 查询页面
|
||||
/// </summary>
|
||||
public static History historycontrol;
|
||||
/// <summary>
|
||||
/// 设置页面
|
||||
/// </summary>
|
||||
public static SetUpView setupview;
|
||||
|
||||
|
||||
public static string ConnectionString
|
||||
{
|
||||
get
|
||||
{
|
||||
var conn = ConfigurationManager.ConnectionStrings["ConnectionString"];
|
||||
if (conn == null)
|
||||
{
|
||||
throw new Exception("未找到数据库连接字符串,请检查 App.config 是否正确!");
|
||||
}
|
||||
return conn.ConnectionString;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// DataView 转 ObservableCollection
|
||||
/// </summary>
|
||||
public static ObservableCollection<T> ConvertDataViewToObservableCollection<T>(DataView view) where T : class, new()
|
||||
{
|
||||
ObservableCollection<T> collection = new ObservableCollection<T>();
|
||||
|
||||
if (view == null || view.Count == 0)
|
||||
{
|
||||
return collection; // 返回空集合
|
||||
}
|
||||
|
||||
// 获取 DataTable 结构(从 DataView 取出)
|
||||
DataTable table = view.Table;
|
||||
|
||||
// 缓存属性信息
|
||||
PropertyInfo[] properties = typeof(T).GetProperties();
|
||||
|
||||
foreach (DataRowView rowView in view)
|
||||
{
|
||||
DataRow row = rowView.Row;
|
||||
T obj = new T();
|
||||
|
||||
foreach (PropertyInfo info in properties)
|
||||
{
|
||||
if (table.Columns.Contains(info.Name))
|
||||
{
|
||||
if (row[info.Name] != DBNull.Value)
|
||||
{
|
||||
// 获取属性类型
|
||||
Type propertyType = info.PropertyType;
|
||||
|
||||
// 获取DataRow中的值
|
||||
object value = row[info.Name];
|
||||
|
||||
// 进行类型转换
|
||||
if (propertyType.IsEnum)
|
||||
{
|
||||
value = Enum.ToObject(propertyType, value);
|
||||
}
|
||||
else if (propertyType == typeof(int) && value is long)
|
||||
{
|
||||
value = Convert.ToInt32(value);
|
||||
}
|
||||
else if (propertyType.IsGenericType && propertyType.GetGenericTypeDefinition() == typeof(Nullable<>))
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
propertyType = Nullable.GetUnderlyingType(propertyType);
|
||||
value = Convert.ChangeType(value, propertyType);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
value = Convert.ChangeType(value, propertyType);
|
||||
}
|
||||
|
||||
// 设置属性值
|
||||
info.SetValue(obj, value, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
collection.Add(obj);
|
||||
}
|
||||
return collection;
|
||||
}
|
||||
public static void MenuViewQuit()
|
||||
{
|
||||
main.MenuView.Children.Clear();
|
||||
main.MenuView.Visibility = System.Windows.Visibility.Collapsed;
|
||||
}
|
||||
public static void SaveImage(Bitmap bitmap)
|
||||
{
|
||||
try
|
||||
{
|
||||
string directory = @"E:\Images";
|
||||
if (!Directory.Exists(directory))
|
||||
{
|
||||
Directory.CreateDirectory(directory);
|
||||
}
|
||||
|
||||
string filePath = Path.Combine(directory, $"Image_{DateTime.Now:yyyyMMdd_HHmmss}.bmp");
|
||||
|
||||
bitmap.Save(filePath, ImageFormat.Bmp); // 直接保存 BMP,避免二次转换
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show($"保存图片失败: {e.Message}");
|
||||
}
|
||||
}
|
||||
public static BitmapSource BitmapToBitmapSource2(Bitmap bitmap)
|
||||
{
|
||||
IntPtr hBitmap = IntPtr.Zero;
|
||||
BitmapSource bitmapSource = null;
|
||||
|
||||
try
|
||||
{
|
||||
// 使用 GetThumbnailImage 进行快速缩放
|
||||
using (Bitmap resizedBitmap = (Bitmap)bitmap.GetThumbnailImage(760, 600, null, IntPtr.Zero))
|
||||
{
|
||||
hBitmap = resizedBitmap.GetHbitmap();
|
||||
bitmapSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
|
||||
hBitmap,
|
||||
IntPtr.Zero,
|
||||
Int32Rect.Empty,
|
||||
BitmapSizeOptions.FromEmptyOptions());
|
||||
|
||||
bitmapSource.Freeze(); // 让 BitmapSource 可跨线程使用
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (hBitmap != IntPtr.Zero)
|
||||
{
|
||||
DeleteObject(hBitmap); // 避免 GDI 资源泄漏
|
||||
}
|
||||
}
|
||||
|
||||
return bitmapSource;
|
||||
}
|
||||
public static BitmapSource BitmapToBitmapSource(Bitmap bitmap)
|
||||
{
|
||||
IntPtr hBitmap = IntPtr.Zero;
|
||||
BitmapSource bitmapSource = null;
|
||||
|
||||
try
|
||||
{
|
||||
hBitmap = bitmap.GetHbitmap();
|
||||
bitmapSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
|
||||
hBitmap,
|
||||
IntPtr.Zero,
|
||||
Int32Rect.Empty,
|
||||
BitmapSizeOptions.FromEmptyOptions());
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (hBitmap != IntPtr.Zero)
|
||||
{
|
||||
DeleteObject(hBitmap); // 避免 GDI 资源泄漏
|
||||
}
|
||||
}
|
||||
|
||||
return bitmapSource;
|
||||
}
|
||||
[System.Runtime.InteropServices.DllImport("gdi32.dll")]
|
||||
private static extern bool DeleteObject(IntPtr hObject);
|
||||
|
||||
/// <summary>
|
||||
/// 保存ObservableCollection数据为excel
|
||||
/// </summary>
|
||||
/// <param name="tagInfos"></param>
|
||||
/// <param name="filePath"></param>
|
||||
public static void SaveToExcel(ObservableCollection<SCAN_MAIN> tagInfos, string filePath)
|
||||
{
|
||||
ExcelPackage.LicenseContext = OfficeOpenXml.LicenseContext.NonCommercial;
|
||||
|
||||
using (var package = new ExcelPackage())
|
||||
{
|
||||
var worksheet = package.Workbook.Worksheets.Add("历史报废数据");
|
||||
|
||||
// 添加标题行
|
||||
worksheet.Cells[1, 1].Value = "时间";
|
||||
worksheet.Cells[1, 2].Value = "资产编号";
|
||||
worksheet.Cells[1, 3].Value = "报废前图片路径";
|
||||
worksheet.Cells[1, 4].Value = "报废后图片路径";
|
||||
// 设置第一列(时间列)为文本格式,防止Excel自动转换日期
|
||||
worksheet.Column(1).Style.Numberformat.Format = "@";
|
||||
worksheet.Column(2).Style.Numberformat.Format = "@";
|
||||
worksheet.Column(3).Style.Numberformat.Format = "@";
|
||||
worksheet.Column(4).Style.Numberformat.Format = "@";
|
||||
|
||||
// 添加数据行
|
||||
for (int i = 0; i < tagInfos.Count; i++)
|
||||
{
|
||||
|
||||
worksheet.Cells[i + 2, 1].Value = tagInfos[i].time.ToString("yyyy-MM-dd HH:mm:ss"); // 添加单引号,强制 Excel 识别为文本
|
||||
worksheet.Cells[i + 2, 2].Value = tagInfos[i].goodcode;
|
||||
worksheet.Cells[i + 2, 3].Value = tagInfos[i].img;
|
||||
worksheet.Cells[i + 2, 4].Value = tagInfos[i].img_after;
|
||||
}
|
||||
// 保存到文件
|
||||
var fileInfo = new FileInfo(filePath);
|
||||
package.SaveAs(fileInfo);
|
||||
System.Windows.MessageBox.Show("数据导出成功!");
|
||||
}
|
||||
}
|
||||
public static void EnsureFolderExists(string folderName)
|
||||
{
|
||||
string projectRoot = AppDomain.CurrentDomain.BaseDirectory;
|
||||
string folderPath = Path.Combine(projectRoot, folderName);
|
||||
|
||||
if (!Directory.Exists(folderPath))
|
||||
{
|
||||
Directory.CreateDirectory(folderPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
string todayFolderName = DateTime.Now.ToString("yyyy-MM-dd");
|
||||
string todayFolderPath = Path.Combine(folderPath, todayFolderName);
|
||||
|
||||
// 如果今天日期的文件夹不存在,则创建
|
||||
if (!Directory.Exists(todayFolderPath))
|
||||
{
|
||||
Directory.CreateDirectory(todayFolderPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static string configPath = "config.json";
|
||||
|
||||
public static string GetSetting(string key)
|
||||
{
|
||||
var json = JObject.Parse(File.ReadAllText(configPath));
|
||||
return json["Settings"]?[key]?.ToString();
|
||||
}
|
||||
|
||||
public static void SetSetting(string key, string value)
|
||||
{
|
||||
var json = JObject.Parse(File.ReadAllText(configPath));
|
||||
json["Settings"][key] = value;
|
||||
File.WriteAllText(configPath, json.ToString());
|
||||
}
|
||||
}
|
||||
}
|
1304
AnQing/Commons/DbHelperSQL.cs
Normal file
96
AnQing/Commons/IndexToSerialNumberConverter.cs
Normal file
@ -0,0 +1,96 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace AnQing.Commons
|
||||
{
|
||||
public class IndexConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
ListViewItem item = (ListViewItem)value;
|
||||
ListView listView = ItemsControl.ItemsControlFromItemContainer(item) as ListView;
|
||||
int index = listView.ItemContainerGenerator.IndexFromContainer(item) + 1;
|
||||
return index.ToString();
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
public class EllipseFillConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is bool isOK)
|
||||
{
|
||||
return isOK ? Brushes.Green : Brushes.Red;
|
||||
}
|
||||
return Brushes.Gray; // 默认颜色
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
public class RunTextConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is bool isOK)
|
||||
{
|
||||
return isOK ? "连接成功" : "连接失败";
|
||||
}
|
||||
return "未知状态"; // 默认文本
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public class ReadRunTextConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is bool isOK)
|
||||
{
|
||||
return isOK ? "采集中" : "空闲";
|
||||
}
|
||||
return "未知状态"; // 默认文本
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public class StringToDateTimeConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
// 如果 StartTime 是空字符串,转换为 null
|
||||
if (value is string str && string.IsNullOrEmpty(str))
|
||||
{
|
||||
return null; // 返回 null,清空 DateTimePicker
|
||||
}
|
||||
return value; // 否则,返回原始值
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
// 将 DateTime? 转换回字符串(如果为 null 则为空字符串)
|
||||
return value == null ? "" : value.ToString();
|
||||
}
|
||||
}
|
||||
}
|
9345
AnQing/Commons/MVCamera.cs
Normal file
89
AnQing/Commons/ModbusClient.cs
Normal file
@ -0,0 +1,89 @@
|
||||
using Modbus.Device;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AnQing.Commons
|
||||
{
|
||||
public class ModbusClient
|
||||
{
|
||||
private TcpClient tcpClient;
|
||||
private ModbusIpMaster modbusMaster;
|
||||
|
||||
public ModbusClient(string ipAddress, int port)
|
||||
{
|
||||
tcpClient = new TcpClient(ipAddress, port);
|
||||
modbusMaster = ModbusIpMaster.CreateIp(tcpClient);
|
||||
}
|
||||
|
||||
// 发送:写单个寄存器
|
||||
public void WriteSingleRegister(ushort address, ushort value)
|
||||
{
|
||||
try
|
||||
{
|
||||
modbusMaster.WriteSingleRegister(address, value);
|
||||
Console.WriteLine($"成功写入寄存器地址 {address},值为 {value}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"写寄存器时发生错误: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
// 发送:写多个寄存器
|
||||
public void WriteMultipleRegisters(ushort startAddress, ushort[] values)
|
||||
{
|
||||
try
|
||||
{
|
||||
modbusMaster.WriteMultipleRegisters(startAddress, values);
|
||||
Console.WriteLine($"成功写入多个寄存器,从地址 {startAddress} 开始");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"写多个寄存器时发生错误: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
// 接收:读取多个保持寄存器
|
||||
public ushort[] ReadHoldingRegisters(ushort startAddress, ushort numRegisters)
|
||||
{
|
||||
try
|
||||
{
|
||||
ushort[] registers = modbusMaster.ReadHoldingRegisters(startAddress, numRegisters);
|
||||
Console.WriteLine($"成功读取 {numRegisters} 个保持寄存器,从地址 {startAddress} 开始");
|
||||
return registers;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"读取寄存器时发生错误: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// 接收:读取单个保持寄存器
|
||||
public ushort ReadHoldingRegister(ushort address)
|
||||
{
|
||||
try
|
||||
{
|
||||
ushort registerValue = modbusMaster.ReadHoldingRegisters(address, 1)[0];
|
||||
Console.WriteLine($"成功读取寄存器地址 {address} 的值:{registerValue}");
|
||||
return registerValue;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"读取寄存器时发生错误: {ex.Message}");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// 关闭连接
|
||||
public void Close()
|
||||
{
|
||||
modbusMaster?.Dispose();
|
||||
tcpClient.Close();
|
||||
}
|
||||
}
|
||||
}
|
73
AnQing/Commons/ParamInfo.cs
Normal file
@ -0,0 +1,73 @@
|
||||
using System.Data;
|
||||
|
||||
namespace RGD.DBUtility
|
||||
{
|
||||
public class ParamInfo
|
||||
{
|
||||
public ParamInfo(string name, object value, SqlDbType dbtype)
|
||||
{
|
||||
this.Name = name;
|
||||
this.Value = value;
|
||||
this.DbType = dbtype;
|
||||
//this.Size = size;
|
||||
//this.Direction = ParameterDirection.Input;
|
||||
}
|
||||
|
||||
public ParamInfo(string name, object value, SqlDbType dbtype, int size)
|
||||
{
|
||||
this.Name = name;
|
||||
this.Value = value;
|
||||
this.DbType = dbtype;
|
||||
this.Size = size;
|
||||
//this.Direction = ParameterDirection.Input;
|
||||
}
|
||||
|
||||
public ParamInfo(string name, object value, SqlDbType dbtype, int size, ParameterDirection direction)
|
||||
{
|
||||
this.Name = name;
|
||||
this.Value = value;
|
||||
this.DbType = dbtype;
|
||||
this.Size = size;
|
||||
this.Direction = direction;
|
||||
}
|
||||
|
||||
public ParamInfo(string name, SqlDbType dbtype, int size)
|
||||
{
|
||||
this.Name = name;
|
||||
this.Value = string.Empty;
|
||||
this.DbType = dbtype;
|
||||
this.Size = size;
|
||||
this.Direction = ParameterDirection.Output;
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public object Value
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public SqlDbType DbType
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public int Size
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public ParameterDirection Direction
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
}
|
46
AnQing/Commons/RelayCommand.cs
Normal file
@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace AnQing.Commons
|
||||
{
|
||||
public class RelayCommand : ICommand
|
||||
{
|
||||
private readonly Action _execute;
|
||||
private readonly Func<bool> _canExecute;
|
||||
|
||||
public RelayCommand(Action execute)
|
||||
: this(execute, null) { }
|
||||
|
||||
public RelayCommand(Action execute, Func<bool> canExecute)
|
||||
{
|
||||
_execute = execute ?? throw new ArgumentNullException(nameof(execute));
|
||||
_canExecute = canExecute;
|
||||
}
|
||||
|
||||
public bool CanExecute(object parameter)
|
||||
{
|
||||
return _canExecute?.Invoke() ?? true;
|
||||
}
|
||||
|
||||
public void Execute(object parameter)
|
||||
{
|
||||
_execute();
|
||||
}
|
||||
|
||||
public event EventHandler CanExecuteChanged
|
||||
{
|
||||
add => CommandManager.RequerySuggested += value;
|
||||
remove => CommandManager.RequerySuggested -= value;
|
||||
}
|
||||
|
||||
// 手动调用来通知命令的状态改变
|
||||
public void RaiseCanExecuteChanged()
|
||||
{
|
||||
CommandManager.InvalidateRequerySuggested();
|
||||
}
|
||||
}
|
||||
}
|
156
AnQing/MainWindow.xaml
Normal file
@ -0,0 +1,156 @@
|
||||
<Window x:Class="AnQing.MainWindow"
|
||||
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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:viewmodel="clr-namespace:AnQing.ViewModel"
|
||||
xmlns:local_index="clr-namespace:AnQing.Commons"
|
||||
xmlns:local="clr-namespace:AnQing"
|
||||
mc:Ignorable="d" Loaded="Window_Loaded" Closing="Window_Closing"
|
||||
Title="MainWindow" Height="800
|
||||
" Width="1100">
|
||||
<Window.Resources>
|
||||
<Style TargetType="Thumb" x:Key="CustomThumbStyle">
|
||||
<!-- 设置Thumb的背景 -->
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<!-- 设置Thumb的边框 -->
|
||||
<Setter Property="BorderBrush" Value="Transparent"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<!-- 设置Thumb的宽度 -->
|
||||
<Setter Property="Height" Value="20"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||||
<Setter Property="VerticalAlignment" Value="Bottom"/>
|
||||
<Setter Property="Cursor" Value="SizeNS"/>
|
||||
|
||||
<!-- 自定义控件模板 -->
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Thumb">
|
||||
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
|
||||
<Grid>
|
||||
<!-- 这里可以定义Thumb的内容 -->
|
||||
<Rectangle Fill="Transparent" />
|
||||
</Grid>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<local_index:IndexConverter x:Key="IndexToSerialNumberConverter" />
|
||||
<local_index:RunTextConverter x:Key="RunTextConverter" />
|
||||
<local_index:ReadRunTextConverter x:Key="ReadRunTextConverter" />
|
||||
<local_index:EllipseFillConverter x:Key="EllipseFillConverter" />
|
||||
<BooleanToVisibilityConverter x:Key="BoolToVisibilityConverter" />
|
||||
</Window.Resources>
|
||||
<!--<Window.DataContext>
|
||||
<viewmodel:MianWindowViewModel></viewmodel:MianWindowViewModel>
|
||||
</Window.DataContext>-->
|
||||
<Grid Background="#EFF1F3">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="1*"></RowDefinition>
|
||||
<RowDefinition Height="100"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid x:Name="Main">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="1*"></RowDefinition>
|
||||
<RowDefinition Height="4*"></RowDefinition>
|
||||
<RowDefinition Height="1*"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1*"></ColumnDefinition>
|
||||
<ColumnDefinition Width="1*"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Border Grid.Column="0" Margin="20,30,20,20" CornerRadius="15" Background="White">
|
||||
<TextBlock FontSize="20" FontWeight="Bold" Foreground="#999" VerticalAlignment="Center" HorizontalAlignment="Center">视 觉 摄 像 画 面 ( 一 )</TextBlock>
|
||||
</Border>
|
||||
<Border Grid.Column="1" Margin="20,30,20,20" CornerRadius="15" Background="White">
|
||||
<TextBlock FontSize="20" FontWeight="Bold" Foreground="#999" VerticalAlignment="Center" HorizontalAlignment="Center">视 觉 摄 像 画 面 ( 二 )</TextBlock>
|
||||
</Border>
|
||||
<Border Grid.Row="1" Grid.Column="0" Margin="20" CornerRadius="15">
|
||||
<Border.Style>
|
||||
<Style TargetType="Border">
|
||||
<Setter Property="Background">
|
||||
<Setter.Value>
|
||||
<ImageBrush ImageSource="{Binding ImageSource}" />
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding ImageSource}" Value="{x:Null}">
|
||||
<Setter Property="Background" Value="White"/>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Border.Style>
|
||||
</Border>
|
||||
<Border Grid.Row="1" Grid.Column="1" Margin="20" CornerRadius="15" Background="White">
|
||||
<Border.Style>
|
||||
<Style TargetType="Border">
|
||||
<Setter Property="Background">
|
||||
<Setter.Value>
|
||||
<ImageBrush ImageSource="{Binding ImageSource}" />
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding ImageSource}" Value="{x:Null}">
|
||||
<Setter Property="Background" Value="White"/>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Border.Style>
|
||||
<!--<Image Name="Image_2"></Image>-->
|
||||
</Border>
|
||||
<Border Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Margin="20" Background="White" CornerRadius="15">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="3*"></ColumnDefinition>
|
||||
<ColumnDefinition Width="2*"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<WrapPanel VerticalAlignment="Center">
|
||||
<TextBlock Margin="20,0">资产信息:<Run Text="{Binding ReaderText}"></Run></TextBlock>
|
||||
<TextBlock Margin="20,0">识别时间:<Run Text="{Binding ReaderTextTime}"></Run></TextBlock>
|
||||
</WrapPanel>
|
||||
<WrapPanel VerticalAlignment="Center" HorizontalAlignment="Right" Grid.Column="1">
|
||||
<Button Width="100" Height="35" Margin="0,0,30,0" Style="{StaticResource BtnCornerRadius2}" Command="{Binding ButtonGatherCommand}" >触发</Button>
|
||||
<Button Width="100" Height="35" Margin="0,0,30,0" Style="{StaticResource BtnCornerRadius2}" Click="Button_Click_2" Visibility="{Binding ReaderState, Converter={StaticResource BoolToVisibilityConverter}}">区域选值</Button>
|
||||
</WrapPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
<Grid Name="ToolBar" Grid.Row="1">
|
||||
<Border Grid.Row="2" Margin="20,5,20,5" Height="60" Background="White" CornerRadius="15">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="3*"></ColumnDefinition>
|
||||
<ColumnDefinition Width="2*"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<WrapPanel VerticalAlignment="Center" Grid.Column="0" Margin="20,0">
|
||||
<Ellipse Width="20" Height="20" Fill="{Binding Video1State, Converter={StaticResource EllipseFillConverter}}" />
|
||||
<TextBlock Margin="10,0,0,0" VerticalAlignment="Center">
|
||||
相机1连接状态:
|
||||
<Run Foreground="{Binding Video1State, Converter={StaticResource EllipseFillConverter}}" Text="{Binding Video1State, Converter={StaticResource RunTextConverter}}"/>
|
||||
</TextBlock>
|
||||
<Ellipse Width="20" Margin="30,0,0,0" Height="20" Fill="{Binding Video2State, Converter={StaticResource EllipseFillConverter}}" />
|
||||
<TextBlock Margin="10,0,0,0" VerticalAlignment="Center">
|
||||
相机2连接状态:
|
||||
<Run Foreground="{Binding Video2State, Converter={StaticResource EllipseFillConverter}}" Text="{Binding Video2State, Converter={StaticResource RunTextConverter}}"/>
|
||||
</TextBlock>
|
||||
</WrapPanel>
|
||||
|
||||
<WrapPanel Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center">
|
||||
<Button Width="100" Height="35" Margin="0,0,30,0" Style="{StaticResource BtnCornerRadius2}" Command="{Binding ButtonGatherCommand}">触发</Button>
|
||||
<!--<Button Width="100" Height="35" Margin="0,0,30,0" Style="{StaticResource BtnCornerRadius2}" Command="{Binding ButtonCloseCommand}">释放</Button>-->
|
||||
<Button Width="100" Height="35" Style="{StaticResource BtnCornerRadius}" Click="Button_Click">历史</Button>
|
||||
<Button Width="100" Height="35" Margin="30,0,0,0" Style="{StaticResource BtnCornerRadius2}" Click="Button_Click_1">设置</Button>
|
||||
</WrapPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
<Grid x:Name="MenuView" Grid.Row="0" Grid.RowSpan="2" Visibility="Collapsed" Background="#EFF1F3">
|
||||
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
81
AnQing/MainWindow.xaml.cs
Normal file
@ -0,0 +1,81 @@
|
||||
using AnQing.Commons;
|
||||
using AnQing.View;
|
||||
using AnQing.ViewModel;
|
||||
using MvCamCtrl.NET;
|
||||
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 AnQing
|
||||
{
|
||||
/// <summary>
|
||||
/// MainWindow.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public MianWindowViewModel mianWindowViewModel;
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
mianWindowViewModel = new MianWindowViewModel();
|
||||
this.DataContext = mianWindowViewModel;
|
||||
Common.EnsureFolderExists("ImageList");
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Common.main = this;
|
||||
}
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (Common.historycontrol == null)
|
||||
Common.historycontrol = new History();
|
||||
|
||||
MenuView.Children.Add(Common.historycontrol);
|
||||
MenuView.Visibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
private void Button_Click_1(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (Common.setupview == null)
|
||||
Common.setupview = new SetUpView();
|
||||
|
||||
MenuView.Children.Add(Common.setupview);
|
||||
MenuView.Visibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
// 如果是重复运行导致的关闭,则不执行任何关闭逻辑
|
||||
if (App.IsDuplicateInstance)
|
||||
{
|
||||
e.Cancel = true; // 取消关闭事件
|
||||
return;
|
||||
}
|
||||
|
||||
//// ch:关闭设备 | en:Close Device
|
||||
mianWindowViewModel.m_MyCamera.MV_CC_CloseDevice_NET();
|
||||
mianWindowViewModel.m_MyCamera.MV_CC_DestroyDevice_NET();
|
||||
}
|
||||
|
||||
private void Button_Click_2(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ImageSetUp ImageSetUp = new ImageSetUp(mianWindowViewModel.ReaderImagePath_Temp);
|
||||
|
||||
MenuView.Children.Add(ImageSetUp);
|
||||
MenuView.Visibility = Visibility.Visible;
|
||||
}
|
||||
}
|
||||
}
|
17
AnQing/Model/IMAGEINFO.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AnQing.Model
|
||||
{
|
||||
public class IMAGEINFO
|
||||
{
|
||||
public int x { get; set; }
|
||||
public int y { get; set; }
|
||||
public int width { get; set; }
|
||||
public int height { get; set; }
|
||||
public int index { get; set; }
|
||||
}
|
||||
}
|
18
AnQing/Model/SCAN_DETAIL.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AnQing.Models
|
||||
{
|
||||
public class SCAN_DETAIL
|
||||
{
|
||||
public int ScanDetailId { get; set; }
|
||||
|
||||
public int ScanId { get; set; }
|
||||
|
||||
public string Tag { get; set; }
|
||||
}
|
||||
}
|
29
AnQing/Model/SCAN_MAIN.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace AnQing.Models
|
||||
{
|
||||
public partial class SCAN_MAIN
|
||||
{
|
||||
public int id { get; set; }
|
||||
public DateTime time { get; set; }
|
||||
public string goodcode { get; set; }
|
||||
public string img { get; set; }
|
||||
public string img_after { get; set; }
|
||||
public string ex { get; set; }
|
||||
}
|
||||
public partial class SCAN_MAIN_IMG
|
||||
{
|
||||
public int id { get; set; }
|
||||
public DateTime time { get; set; }
|
||||
public string goodcode { get; set; }
|
||||
public BitmapImage img { get; set; }
|
||||
public BitmapImage img_after { get; set; }
|
||||
public string ex { get; set; }
|
||||
}
|
||||
}
|
52
AnQing/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,52 @@
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
|
||||
// 有关程序集的一般信息由以下
|
||||
// 控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("AnQing")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("AnQing")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2025")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// 将 ComVisible 设置为 false 会使此程序集中的类型
|
||||
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
|
||||
//请将此类型的 ComVisible 特性设置为 true。
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
//若要开始生成可本地化的应用程序,请设置
|
||||
//.csproj 文件中的 <UICulture>CultureYouAreCodingWith</UICulture>
|
||||
//在 <PropertyGroup> 中。例如,如果你使用的是美国英语。
|
||||
//使用的是美国英语,请将 <UICulture> 设置为 en-US。 然后取消
|
||||
//对以下 NeutralResourceLanguage 特性的注释。 更新
|
||||
//以下行中的“en-US”以匹配项目文件中的 UICulture 设置。
|
||||
|
||||
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
||||
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //主题特定资源词典所处位置
|
||||
//(未在页面中找到资源时使用,
|
||||
//或应用程序资源字典中找到时使用)
|
||||
ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置
|
||||
//(未在页面中找到资源时使用,
|
||||
//、应用程序或任何主题专用资源字典中找到时使用)
|
||||
)]
|
||||
|
||||
|
||||
// 程序集的版本信息由下列四个值组成:
|
||||
//
|
||||
// 主版本
|
||||
// 次版本
|
||||
// 生成号
|
||||
// 修订号
|
||||
//
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
71
AnQing/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,71 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 此代码由工具生成。
|
||||
// 运行时版本: 4.0.30319.42000
|
||||
//
|
||||
// 对此文件的更改可能导致不正确的行为,如果
|
||||
// 重新生成代码,则所做更改将丢失。
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace AnQing.Properties
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 强类型资源类,用于查找本地化字符串等。
|
||||
/// </summary>
|
||||
// 此类是由 StronglyTypedResourceBuilder
|
||||
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
|
||||
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
|
||||
// (以 /str 作为命令选项),或重新生成 VS 项目。
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources
|
||||
{
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 返回此类使用的缓存 ResourceManager 实例。
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((resourceMan == null))
|
||||
{
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AnQing.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写当前线程的 CurrentUICulture 属性,对
|
||||
/// 使用此强类型资源类的所有资源查找执行重写。
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
return resourceCulture;
|
||||
}
|
||||
set
|
||||
{
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
117
AnQing/Properties/Resources.resx
Normal file
@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
30
AnQing/Properties/Settings.Designer.cs
generated
Normal file
@ -0,0 +1,30 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace AnQing.Properties
|
||||
{
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
|
||||
{
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default
|
||||
{
|
||||
get
|
||||
{
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
7
AnQing/Properties/Settings.settings
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
BIN
AnQing/Resources/Dll/MvCameraControl.Net.dll
Normal file
BIN
AnQing/Resources/Image/back3_1.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
AnQing/Resources/Image/back4_1.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
370
AnQing/Style.xaml
Normal file
@ -0,0 +1,370 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<Style x:Key="dgButton" TargetType="Button" >
|
||||
<Setter Property="FontSize" Value="40"/>
|
||||
<Setter Property="Content" Value="按钮"/>
|
||||
<Setter Property="Foreground" Value="White"/>
|
||||
<Setter Property="Background">
|
||||
<Setter.Value>
|
||||
<!--<RadialGradientBrush>
|
||||
<GradientStop Color="#FFC564B8" Offset="0"/>
|
||||
<GradientStop Color="#FFF57A7A" Offset="1"/>
|
||||
</RadialGradientBrush>-->
|
||||
<LinearGradientBrush EndPoint="1,1" StartPoint="0,0">
|
||||
<GradientStop Color="#FFC564B8" Offset="0"/>
|
||||
<GradientStop Color="#FFF57A7A" Offset="1"/>
|
||||
</LinearGradientBrush>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style >
|
||||
<ControlTemplate x:Key="buttonTemplate" TargetType="Button" >
|
||||
<Border BorderThickness="1" CornerRadius="30" Background="{TemplateBinding Background}">
|
||||
<ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
</Border>
|
||||
<!--<Grid >
|
||||
<Ellipse Name="faceEllipse" Height="50" Width="100" Fill="{TemplateBinding Button.Background}"/>
|
||||
<TextBlock Name="txtBlock" />
|
||||
</Grid >-->
|
||||
<ControlTemplate.Triggers >
|
||||
<Trigger Property="Button.IsMouseOver" Value="True">
|
||||
<Setter Property="Button.Background" Value="blue"/>
|
||||
</Trigger >
|
||||
</ControlTemplate.Triggers >
|
||||
</ControlTemplate >
|
||||
|
||||
<!--文本框圆角效果-->
|
||||
<ControlTemplate x:Key="FilletTextBox" TargetType="{x:Type TextBox}">
|
||||
<Border Background="#EBEBEB" CornerRadius="8">
|
||||
<ScrollViewer x:Name="PART_ContentHost" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
<!--禁用button的悬浮效果-->
|
||||
<Style x:Key="ButtonStyle" TargetType="Button">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Button}">
|
||||
<Border Background="{TemplateBinding Background}">
|
||||
<ContentPresenter HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="False">
|
||||
<Setter Property="Background" Value="{x:Null}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Cursor" Value="No"/>
|
||||
<Setter Property="Opacity" Value="0.2"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="True">
|
||||
<Setter Property="Opacity" Value="1"/>
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<!--禁用button的悬浮效果 加 圆角 带描边的-->
|
||||
<Style x:Key="BtnCornerRadius" TargetType="{x:Type Button}">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Button}">
|
||||
<Border BorderThickness="1" BorderBrush="#2048EC" CornerRadius="5" Background="Transparent">
|
||||
<ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
<Setter Property="Foreground" Value="#2048EC"/>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="BtnCornerRadius_1" TargetType="{x:Type Button}">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Button}">
|
||||
<Border CornerRadius="10">
|
||||
<Border.Background>
|
||||
<ImageBrush ImageSource="/Resources/Image/back3_1.png"></ImageBrush>
|
||||
</Border.Background>
|
||||
<ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
<Setter Property="FontSize" Value="20"/>
|
||||
<Setter Property="FontWeight" Value="Bold"/>
|
||||
<Setter Property="Foreground" Value="White"/>
|
||||
</Style>
|
||||
<Style x:Key="BtnCornerRadius_2" TargetType="{x:Type Button}">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Button}">
|
||||
<Border CornerRadius="10">
|
||||
<Border.Background>
|
||||
<ImageBrush ImageSource="/Resources/Image/back4_1.png"></ImageBrush>
|
||||
</Border.Background>
|
||||
<ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
<Setter Property="FontSize" Value="20"/>
|
||||
<Setter Property="FontWeight" Value="Bold"/>
|
||||
<Setter Property="Foreground" Value="White"/>
|
||||
</Style>
|
||||
<Style x:Key="BtnCornerRadius_3" TargetType="{x:Type Button}">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Button}">
|
||||
<Border CornerRadius="10">
|
||||
<Border.Background>
|
||||
<ImageBrush ImageSource="/Resources/Image/back1.png"></ImageBrush>
|
||||
</Border.Background>
|
||||
<ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
<Setter Property="FontSize" Value="20"/>
|
||||
<Setter Property="FontWeight" Value="Bold"/>
|
||||
<Setter Property="Foreground" Value="White"/>
|
||||
</Style>
|
||||
<!--禁用button的悬浮效果 加 圆角 实色-->
|
||||
<Style x:Key="BtnCornerRadius2" TargetType="{x:Type Button}">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Button}">
|
||||
<Border CornerRadius="5" Background="#2048EC">
|
||||
<ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
<Setter Property="Foreground" Value="White"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Cursor" Value="No"/>
|
||||
<Setter Property="Opacity" Value="0.2"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="True">
|
||||
<Setter Property="Opacity" Value="1"/>
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<!--禁用button的悬浮效果-->
|
||||
<Style x:Key="ButtonStyleBold" TargetType="Button">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Button}">
|
||||
<Border Background="{TemplateBinding Background}">
|
||||
<ContentPresenter HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
<Setter Property="Foreground" Value="White"/>
|
||||
<Setter Property="FontSize" Value="24"/>
|
||||
<Setter Property="FontWeight" Value="Bold"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="False">
|
||||
<Setter Property="Background" Value="{x:Null}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<!--禁用button的悬浮效果 + 禁止状态-->
|
||||
<Style x:Key="ButtonStyleBoldProhibition" TargetType="Button">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Button}">
|
||||
<Border Background="{TemplateBinding Background}">
|
||||
<ContentPresenter HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
<Setter Property="Foreground" Value="White"/>
|
||||
<Setter Property="FontSize" Value="24"/>
|
||||
<Setter Property="FontWeight" Value="Bold"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="False">
|
||||
<Setter Property="Background" Value="{x:Null}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Cursor" Value="No"/>
|
||||
<Setter Property="Opacity" Value="0.2"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="True">
|
||||
<Setter Property="Opacity" Value="1"/>
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<!--禁用button的悬浮效果 + 禁止状态-->
|
||||
<Style x:Key="ButtonStyleBoldProhibition2" TargetType="Button">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Button}">
|
||||
<Border Background="{TemplateBinding Background}">
|
||||
<ContentPresenter HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
<Setter Property="Foreground" Value="White"/>
|
||||
<Setter Property="FontSize" Value="24"/>
|
||||
<Setter Property="FontWeight" Value="Bold"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="False">
|
||||
<Setter Property="Background" Value="{x:Null}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Cursor" Value="No"/>
|
||||
<Setter Property="Opacity" Value="0.2"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="True">
|
||||
<Setter Property="Opacity" Value="1"/>
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<!--滚动条样式-->
|
||||
<ControlTemplate x:Key="scroll_background" TargetType="RepeatButton">
|
||||
<Border Background="Transparent">
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
<Style x:Key="scroll_thumb_style" TargetType="Thumb">
|
||||
<Setter Property="SnapsToDevicePixels" Value="True"/>
|
||||
<Setter Property="OverridesDefaultStyle" Value="true"/>
|
||||
<Setter Property="IsTabStop" Value="false"/>
|
||||
<Setter Property="Focusable" Value="false"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Thumb">
|
||||
<Rectangle Width="3" Fill="#7A7A7A" RadiusX="1" RadiusY="1">
|
||||
</Rectangle>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<Style x:Key="scroll_thumb_stylecrosswise" TargetType="Thumb">
|
||||
<Setter Property="SnapsToDevicePixels" Value="True"/>
|
||||
<Setter Property="OverridesDefaultStyle" Value="true"/>
|
||||
<Setter Property="IsTabStop" Value="false"/>
|
||||
<Setter Property="Focusable" Value="false"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Thumb">
|
||||
<Rectangle Fill="#7A7A7A" RadiusX="1" RadiusY="1">
|
||||
</Rectangle>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!--DataGrid样式-->
|
||||
<Style TargetType="DataGridColumnHeader">
|
||||
<Setter Property="Background" Value="White"/>
|
||||
<Setter Property="Foreground" Value="#999999"/>
|
||||
<Setter Property="HorizontalContentAlignment" Value="Center"/>
|
||||
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
||||
<Setter Property="FontSize" Value="13"/>
|
||||
<Setter Property="Height" Value="35"/>
|
||||
</Style>
|
||||
<Style TargetType="DataGridRow">
|
||||
<Setter Property="Height" Value="30"/>
|
||||
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
|
||||
</Style>
|
||||
<Style TargetType="DataGridCell">
|
||||
<Setter Property="Padding" Value="5"/>
|
||||
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
||||
<Setter Property="HorizontalContentAlignment" Value="Center"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
</Style>
|
||||
<Style x:Key="CenteredTextBlockStyle" TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
</Style>
|
||||
<Style x:Key="CenteredCheckBlockStyle" TargetType="{x:Type CheckBox}">
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||
</Style>
|
||||
<Style TargetType="{x:Type ScrollBar}">
|
||||
<Setter Property="Stylus.IsPressAndHoldEnabled" Value="false"/>
|
||||
<Setter Property="Stylus.IsFlicksEnabled" Value="false"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
|
||||
<Setter Property="Width" Value="3"/>
|
||||
<Setter Property="MinWidth" Value="3"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ScrollBar}">
|
||||
<Grid x:Name="Bg" SnapsToDevicePixels="true" Background="#F1F1F1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="0.00001*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Track HorizontalAlignment="Center" Name="PART_Track" Width="{TemplateBinding Width}" Maximum="{TemplateBinding Maximum}" Minimum="{TemplateBinding Minimum}"
|
||||
Value="{TemplateBinding Value}" IsDirectionReversed="true">
|
||||
<Track.DecreaseRepeatButton>
|
||||
<RepeatButton Template="{StaticResource scroll_background}" Command="ScrollBar.LineUpCommand" />
|
||||
</Track.DecreaseRepeatButton>
|
||||
<Track.IncreaseRepeatButton>
|
||||
<RepeatButton Template="{StaticResource scroll_background}" Command="ScrollBar.LineDownCommand" />
|
||||
</Track.IncreaseRepeatButton>
|
||||
<Track.Thumb>
|
||||
<Thumb Style="{StaticResource scroll_thumb_style}" >
|
||||
</Thumb>
|
||||
</Track.Thumb>
|
||||
</Track>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="Orientation" Value="Horizontal">
|
||||
<Setter Property="Width" Value="Auto"/>
|
||||
<Setter Property="MinWidth" Value="0"/>
|
||||
<Setter Property="Height" Value="10"/>
|
||||
<Setter Property="MinHeight" Value="10"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ScrollBar}">
|
||||
<Grid x:Name="Bg" SnapsToDevicePixels="true" Background="#7FA7A7A7">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="0.00001*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Track x:Name="PART_Track" Grid.Column="1" IsEnabled="{TemplateBinding IsMouseOver}">
|
||||
<Track.DecreaseRepeatButton>
|
||||
<RepeatButton Template="{StaticResource scroll_background}" Command="ScrollBar.LineUpCommand" />
|
||||
</Track.DecreaseRepeatButton>
|
||||
<Track.IncreaseRepeatButton>
|
||||
<RepeatButton Template="{StaticResource scroll_background}" Command="ScrollBar.LineDownCommand" />
|
||||
</Track.IncreaseRepeatButton>
|
||||
<Track.Thumb>
|
||||
<Thumb Style="{DynamicResource scroll_thumb_stylecrosswise}" Height="8"/>
|
||||
</Track.Thumb>
|
||||
</Track>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
|
||||
</ResourceDictionary>
|
142
AnQing/View/History.xaml
Normal file
@ -0,0 +1,142 @@
|
||||
<UserControl x:Class="AnQing.View.History"
|
||||
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:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:local_index="clr-namespace:AnQing.Commons"
|
||||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
||||
xmlns:local="clr-namespace:AnQing.View"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="700" d:DesignWidth="1100">
|
||||
<UserControl.Resources>
|
||||
<local_index:StringToDateTimeConverter x:Key="StringToDateTimeConverter" />
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="7*"></ColumnDefinition>
|
||||
<ColumnDefinition Width="250"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Border Grid.Column="0" Background="White" Margin="20" CornerRadius="10">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="9*"></RowDefinition>
|
||||
<RowDefinition Height="1*"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<ListView ItemsSource="{Binding DgScanMain_Pagination}" Grid.Row="0" Margin="20"
|
||||
BorderThickness="0" Background="White" MouseDoubleClick="ListView_MouseDoubleClick">
|
||||
<ListView.Resources>
|
||||
<Style TargetType="ListViewItem">
|
||||
<Setter Property="Padding" Value="5"/>
|
||||
<Setter Property="BorderBrush" Value="Gray"/>
|
||||
<Setter Property="BorderThickness" Value="0,0,0,1"/>
|
||||
</Style>
|
||||
</ListView.Resources>
|
||||
|
||||
<ListView.View>
|
||||
<GridView>
|
||||
<GridViewColumn Width="100" Header="序号" DisplayMemberBinding="{Binding id}" />
|
||||
<GridViewColumn Width="200" Header="时间" DisplayMemberBinding="{Binding time,StringFormat='yyyy-MM-dd HH:mm:ss'}" />
|
||||
<GridViewColumn Width="200" Header="资产信息" DisplayMemberBinding="{Binding goodcode}" />
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
</ListView>
|
||||
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="3*"></ColumnDefinition>
|
||||
<ColumnDefinition Width="5*"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<WrapPanel Grid.Row="1" VerticalAlignment="Center" Margin="20,0">
|
||||
<hc:ComboBox Margin="15,0,5,0" VerticalAlignment="Center" ItemsSource="{Binding DataCountPageTime}" SelectedItem="{Binding DataCountPageTimeSelect}"/>
|
||||
<TextBlock FontSize="12" Margin="15,0,5,0" VerticalAlignment="Center">
|
||||
每页显示:
|
||||
</TextBlock>
|
||||
<hc:ComboBox VerticalAlignment="Center" ItemsSource="{Binding DataCountPageNumber}" SelectedItem="{Binding DataCountPerPage}"/>
|
||||
</WrapPanel>
|
||||
|
||||
<hc:Pagination MaxPageCount="{Binding MaxPageCount}" VerticalAlignment="Center" Grid.Column="1"
|
||||
HorizontalAlignment="Right" Margin="20,0,15,0" PageIndex="{Binding PageIndex}"
|
||||
IsJumpEnabled="True"
|
||||
DataCountPerPage="{Binding DataCountPerPage}" MaxPageInterval ="2"
|
||||
>
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="PageUpdated">
|
||||
<i:CallMethodAction TargetObject="{Binding}" MethodName="Pagination_PageUpdated"/>
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</hc:Pagination>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Border>
|
||||
<Border Grid.Column="1" Background="White" Margin="0,20,20,20" CornerRadius="10">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"></RowDefinition>
|
||||
<RowDefinition Height="220"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Grid.Row="0" Margin="10,40,10,0" >
|
||||
<TextBlock VerticalAlignment="Center" Margin="0,0,0,10">开始时间</TextBlock>
|
||||
<hc:DateTimePicker DateTimeFormat="yyyy-MM-dd HH:mm:ss" hc:InfoElement.ShowClearButton="True" SelectedDateTime="{Binding StartTime}" Text="{Binding StartTime}" Style="{StaticResource DateTimePickerPlus}" Margin="0,0,0,10" FontSize="11" Foreground="#999999"/>
|
||||
<TextBlock VerticalAlignment="Center" Margin="0,0,0,10">结束时间</TextBlock>
|
||||
<hc:DateTimePicker DateTimeFormat="yyyy-MM-dd HH:mm:ss" hc:InfoElement.ShowClearButton="True" SelectedDateTime="{Binding EndTime}" Text="{Binding EndTime}" Style="{StaticResource DateTimePickerPlus}" Margin="0,0,0,10" FontSize="11" Foreground="#999999"/>
|
||||
<TextBlock VerticalAlignment="Center" Margin="0,0,0,10">资产条码</TextBlock>
|
||||
<hc:TextBox Text="{Binding Barcodes}" hc:InfoElement.ShowClearButton="True" Margin="0,0,0,10"></hc:TextBox>
|
||||
<Button Style="{StaticResource BtnCornerRadius}" Content="清除筛选条件" Margin="0,30,0,0" Height="35" Command="{Binding ButtonQueryClearCommand}" Cursor="Hand"></Button>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Grid.Row="1" Margin="10,0,10,10" VerticalAlignment="Bottom">
|
||||
<Button Style="{StaticResource BtnCornerRadius2}" Content="查询/刷新" Height="40" Margin="0,0,0,10" Command="{Binding ButtonQueryCommand}"></Button>
|
||||
<Button Style="{StaticResource BtnCornerRadius}" Content="数据统计" Height="35" Margin="0,0,0,10" Command="{Binding ButtonExportCommand}"></Button>
|
||||
<Button Style="{StaticResource BtnCornerRadius2}" Content="返回首页" Height="40" VerticalAlignment="Bottom" Command="{Binding ButtonQuitCommand}"></Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<Border Grid.Column="0" Grid.ColumnSpan="2" Margin="20" CornerRadius="10" Background="White" x:Name="List_DeTail" Visibility="Collapsed">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1*"></ColumnDefinition>
|
||||
<ColumnDefinition Width="200"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<hc:CompareSlider Value="5" Margin="20,50">
|
||||
<hc:CompareSlider.TargetContent>
|
||||
<Border>
|
||||
<Border.Background>
|
||||
<ImageBrush ImageSource="{Binding SelectMain.img}"/>
|
||||
</Border.Background>
|
||||
</Border>
|
||||
</hc:CompareSlider.TargetContent>
|
||||
<hc:CompareSlider.SourceContent>
|
||||
<Border>
|
||||
<Border.Background>
|
||||
<ImageBrush ImageSource="{Binding SelectMain.img_after}"/>
|
||||
</Border.Background>
|
||||
</Border>
|
||||
</hc:CompareSlider.SourceContent>
|
||||
</hc:CompareSlider>
|
||||
|
||||
<Grid Grid.Column="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="8*"></RowDefinition>
|
||||
<RowDefinition Height="2*"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Margin="0,40,10,40">
|
||||
<!--<TextBlock Margin="0,20,0,0">序号:<Run Text="{Binding SelectMain.id}"></Run></TextBlock>
|
||||
<TextBlock Margin="0,20,0,0">时间:<Run Text="{Binding SelectMain.time,StringFormat='yyyy-MM-dd HH:mm:ss'}"></Run></TextBlock>
|
||||
<TextBlock Margin="0,20,0,0">资产编号:</TextBlock>
|
||||
<TextBox Margin="0,10,0,0" Text="{Binding SelectMain.goodcode}" TextWrapping="Wrap" AcceptsReturn="True" IsReadOnly="True"/>
|
||||
<TextBlock Margin="0,20,0,0">未报废图片路径:</TextBlock>
|
||||
<TextBox Margin="0,10,0,0" Text="{Binding SelectMain.img}" TextWrapping="Wrap" AcceptsReturn="True" IsReadOnly="True"/>
|
||||
<TextBlock Margin="0,20,0,0">报废后图片路径:</TextBlock>
|
||||
<TextBox Margin="0,10,0,0" Text="{Binding SelectMain.img_after}" TextWrapping="Wrap" AcceptsReturn="True" IsReadOnly="True"/>-->
|
||||
</StackPanel>
|
||||
|
||||
<Button Style="{StaticResource BtnCornerRadius2}" Grid.Row="1" Content="返回列表" Height="40" Width="160" VerticalAlignment="Center" Command="{Binding ButtonQuit2Command}"></Button>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
</Border>
|
||||
</Grid>
|
||||
</UserControl>
|
65
AnQing/View/History.xaml.cs
Normal file
@ -0,0 +1,65 @@
|
||||
using AnQing.Commons;
|
||||
using AnQing.Models;
|
||||
using RFIDReaderJilin.ViewModel;
|
||||
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.Markup;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace AnQing.View
|
||||
{
|
||||
/// <summary>
|
||||
/// History.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class History : UserControl
|
||||
{
|
||||
public WindowQueryViewModel windowqueryviewmodel;
|
||||
public History()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
windowqueryviewmodel = new WindowQueryViewModel();
|
||||
this.DataContext = windowqueryviewmodel;
|
||||
}
|
||||
|
||||
private void ListView_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
// 获取鼠标点击位置的元素
|
||||
var point = e.GetPosition((UIElement)sender);
|
||||
var hit = VisualTreeHelper.HitTest((UIElement)sender, point);
|
||||
|
||||
// 查找 ListViewItem
|
||||
var listViewItem = FindAncestor<ListViewItem>(hit.VisualHit);
|
||||
|
||||
if (listViewItem != null)
|
||||
{
|
||||
var data = (SCAN_MAIN)listViewItem.Content;
|
||||
windowqueryviewmodel.UpdateSelectMain(data);
|
||||
List_DeTail.Visibility = System.Windows.Visibility.Visible;
|
||||
//MessageBox.Show($"你双击了 {data.id} 的行");
|
||||
}
|
||||
|
||||
}
|
||||
private static T FindAncestor<T>(DependencyObject current) where T : DependencyObject
|
||||
{
|
||||
while (current != null)
|
||||
{
|
||||
if (current is T)
|
||||
return (T)current;
|
||||
current = VisualTreeHelper.GetParent(current);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
34
AnQing/View/ImageSetUp.xaml
Normal file
@ -0,0 +1,34 @@
|
||||
<UserControl x:Class="AnQing.View.ImageSetUp"
|
||||
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:AnQing.View"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="780" d:DesignWidth="1100">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="1*"></RowDefinition>
|
||||
<RowDefinition Height="150"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<!-- 图片显示区域 -->
|
||||
<Image x:Name="MainImage" Stretch="Uniform" VerticalAlignment="Center" Height="560"/>
|
||||
|
||||
<!-- 画布用于框选 -->
|
||||
<Canvas x:Name="SelectionCanvas" Background="Transparent" Height="560">
|
||||
<Rectangle x:Name="SelectionRectangle" Stroke="Red" StrokeThickness="2" Fill="#66FF0000" Visibility="Collapsed"/>
|
||||
</Canvas>
|
||||
|
||||
<!-- 按钮 -->
|
||||
<StackPanel HorizontalAlignment="Center" Grid.Row="1" VerticalAlignment="Bottom" Margin="0,20,0,0" >
|
||||
<!-- 显示选区信息 -->
|
||||
<TextBlock x:Name="InfoText" HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,20,0,0"/>
|
||||
<WrapPanel Margin="0,0,0,20">
|
||||
<Button Content="选择图片" Click="SelectImage_Click" Margin="5"/>
|
||||
<Button Content="获取选区数据" Click="GetSelectionData_Click" Margin="5"/>
|
||||
<Button Content="保存数值并返回" Click="Button_Click" Margin="5"/>
|
||||
</WrapPanel>
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
161
AnQing/View/ImageSetUp.xaml.cs
Normal file
@ -0,0 +1,161 @@
|
||||
using AnQing.Commons;
|
||||
using Microsoft.Win32;
|
||||
using RGD.DBUtility;
|
||||
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 AnQing.View
|
||||
{
|
||||
/// <summary>
|
||||
/// ImageSetUp.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class ImageSetUp : UserControl
|
||||
{
|
||||
private Point startPoint;
|
||||
private bool isDragging = false;
|
||||
private string imagePath;
|
||||
private double scaleRatio = 1; // 记录缩放比例
|
||||
private int originalWidth, originalHeight; // 记录原图尺寸
|
||||
|
||||
public ImageSetUp(string path)
|
||||
{
|
||||
InitializeComponent();
|
||||
SelectionCanvas.MouseDown += SelectionCanvas_MouseDown;
|
||||
SelectionCanvas.MouseMove += SelectionCanvas_MouseMove;
|
||||
SelectionCanvas.MouseUp += SelectionCanvas_MouseUp;
|
||||
imagePath = path;
|
||||
ImageView();
|
||||
}
|
||||
// 选择图片
|
||||
private void SelectImage_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
OpenFileDialog openFileDialog = new OpenFileDialog
|
||||
{
|
||||
Filter = "图片文件 (*.jpg;*.png;*.bmp)|*.jpg;*.png;*.bmp"
|
||||
};
|
||||
|
||||
if (openFileDialog.ShowDialog() == true)
|
||||
{
|
||||
imagePath = openFileDialog.FileName;
|
||||
ImageView();
|
||||
}
|
||||
}
|
||||
public void ImageView()
|
||||
{
|
||||
BitmapImage bitmap = new BitmapImage(new Uri(imagePath));
|
||||
|
||||
// 记录原始尺寸
|
||||
originalWidth = bitmap.PixelWidth;
|
||||
originalHeight = bitmap.PixelHeight;
|
||||
|
||||
// 计算缩放比例,使高度 = 560
|
||||
scaleRatio = 560.0 / originalHeight;
|
||||
|
||||
// 设置缩放后的图片
|
||||
int scaledWidth = (int)(originalWidth * scaleRatio);
|
||||
int scaledHeight = (int)(originalHeight * scaleRatio);
|
||||
|
||||
BitmapImage resizedBitmap = new BitmapImage();
|
||||
resizedBitmap.BeginInit();
|
||||
resizedBitmap.UriSource = new Uri(imagePath);
|
||||
resizedBitmap.DecodePixelHeight = scaledHeight; // 按高度缩放
|
||||
resizedBitmap.EndInit();
|
||||
|
||||
MainImage.Source = resizedBitmap;
|
||||
SelectionCanvas.Width = scaledWidth;
|
||||
SelectionCanvas.Height = scaledHeight;
|
||||
}
|
||||
// 鼠标按下,开始选择区域
|
||||
private void SelectionCanvas_MouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (MainImage.Source == null) return;
|
||||
|
||||
isDragging = true;
|
||||
startPoint = e.GetPosition(SelectionCanvas);
|
||||
|
||||
Canvas.SetLeft(SelectionRectangle, startPoint.X);
|
||||
Canvas.SetTop(SelectionRectangle, startPoint.Y);
|
||||
SelectionRectangle.Width = 0;
|
||||
SelectionRectangle.Height = 0;
|
||||
SelectionRectangle.Visibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
// 鼠标移动,动态调整选取框
|
||||
private void SelectionCanvas_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (isDragging)
|
||||
{
|
||||
Point currentPoint = e.GetPosition(SelectionCanvas);
|
||||
|
||||
double x = Math.Min(currentPoint.X, startPoint.X);
|
||||
double y = Math.Min(currentPoint.Y, startPoint.Y);
|
||||
double width = Math.Abs(currentPoint.X - startPoint.X);
|
||||
double height = Math.Abs(currentPoint.Y - startPoint.Y);
|
||||
|
||||
Canvas.SetLeft(SelectionRectangle, x);
|
||||
Canvas.SetTop(SelectionRectangle, y);
|
||||
SelectionRectangle.Width = width;
|
||||
SelectionRectangle.Height = height;
|
||||
}
|
||||
}
|
||||
|
||||
// 鼠标松开,完成选区
|
||||
private void SelectionCanvas_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
isDragging = false;
|
||||
}
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 释放图像或其他资源
|
||||
if (MainImage.Source is BitmapImage bitmapImage)
|
||||
{
|
||||
// 关闭图像流
|
||||
bitmapImage.StreamSource?.Close();
|
||||
}
|
||||
DbHelperSQL.ExecuteSql($"INSERT INTO IMAGEINFO (x, y, width, height,[index]) VALUES ({originalX}, {originalY}, {originalWidthSelected}, {originalHeightSelected},1)");
|
||||
Common.main.mianWindowViewModel.GetPossibleRegions();
|
||||
Common.MenuViewQuit();
|
||||
}
|
||||
int originalX, originalY, originalWidthSelected, originalHeightSelected;
|
||||
// 获取选区数据(转换为原图尺寸)
|
||||
private void GetSelectionData_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (MainImage.Source == null || SelectionRectangle.Visibility == Visibility.Collapsed)
|
||||
{
|
||||
MessageBox.Show("请先选择图片并框选区域!");
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取缩小后的选区坐标
|
||||
double scaledX = Canvas.GetLeft(SelectionRectangle);
|
||||
double scaledY = Canvas.GetTop(SelectionRectangle);
|
||||
double scaledWidth = SelectionRectangle.Width;
|
||||
double scaledHeight = SelectionRectangle.Height;
|
||||
|
||||
// 转换回原图尺寸
|
||||
originalX = (int)(scaledX / scaleRatio);
|
||||
originalY = (int)(scaledY / scaleRatio);
|
||||
originalWidthSelected = (int)(scaledWidth / scaleRatio);
|
||||
originalHeightSelected = (int)(scaledHeight / scaleRatio);
|
||||
|
||||
// 显示选区数据
|
||||
string selectionInfo = $"原图坐标: X={originalX}, Y={originalY}, 宽={originalWidthSelected}, 高={originalHeightSelected}";
|
||||
InfoText.Text = selectionInfo;
|
||||
//MessageBox.Show(selectionInfo);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
76
AnQing/View/SetUpView.xaml
Normal file
@ -0,0 +1,76 @@
|
||||
<UserControl x:Class="AnQing.View.SetUpView"
|
||||
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:AnQing.View"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="700" d:DesignWidth="1100"
|
||||
>
|
||||
<Border Background="White" CornerRadius="10" Margin="20,10">
|
||||
<Grid Margin="30,0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"></RowDefinition>
|
||||
<RowDefinition Height="70"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<StackPanel Margin="40" Grid.Row="0">
|
||||
<TextBlock FontSize="20" FontWeight="Bold" Foreground="#666">基 础 配 置</TextBlock>
|
||||
<StackPanel Margin="10,20">
|
||||
<Grid Margin="0,0,0,15">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="150"></ColumnDefinition>
|
||||
<ColumnDefinition Width="1*"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock VerticalAlignment="Center" Grid.Column="0">相机一IP:</TextBlock>
|
||||
<TextBox VerticalAlignment="Center" Width="300" HorizontalAlignment="Left" Grid.Column="1" Text="{Binding VideoIP1}"></TextBox>
|
||||
</Grid>
|
||||
<Grid Margin="0,0,0,15">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="150"></ColumnDefinition>
|
||||
<ColumnDefinition Width="1*"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock VerticalAlignment="Center" Grid.Column="0">相机二IP:</TextBlock>
|
||||
<TextBox VerticalAlignment="Center" Width="300" HorizontalAlignment="Left" Grid.Column="1" Text="{Binding VideoIP2}"></TextBox>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
<TextBlock FontSize="20" FontWeight="Bold" Foreground="#666">图 像 配 置</TextBlock>
|
||||
<StackPanel Margin="10,20">
|
||||
<ListView ItemsSource="{Binding DgScanMain}" SelectedItem="{Binding SelectedItem}" Height="280" Grid.Row="0" BorderThickness="0" Background="White">
|
||||
<ListView.View>
|
||||
<GridView>
|
||||
<GridViewColumn Width="100" Header="X起点" DisplayMemberBinding="{Binding x}" />
|
||||
<GridViewColumn Width="100" Header="Y起点" DisplayMemberBinding="{Binding y}" />
|
||||
<GridViewColumn Width="200" Header="宽度" DisplayMemberBinding="{Binding width}" />
|
||||
<GridViewColumn Width="200" Header="高度" DisplayMemberBinding="{Binding height}" />
|
||||
<GridViewColumn Width="200" Header="排序" DisplayMemberBinding="{Binding index}" />
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
</ListView>
|
||||
<WrapPanel Margin="0,10,0,0" HorizontalAlignment="Center">
|
||||
<TextBlock VerticalAlignment="Center" Margin="20,0,0,0">X起点</TextBlock>
|
||||
<TextBox Width="70" Margin="10,0,0,0" Text="{Binding SelectedItem.x}"></TextBox>
|
||||
|
||||
<TextBlock VerticalAlignment="Center" Margin="30,0,0,0">Y起点</TextBlock>
|
||||
<TextBox Width="70" Margin="10,0,0,0" Text="{Binding SelectedItem.y}"></TextBox>
|
||||
|
||||
<TextBlock VerticalAlignment="Center" Margin="30,0,0,0">宽度</TextBlock>
|
||||
<TextBox Width="100" Margin="10,0,0,0" Text="{Binding SelectedItem.width}"></TextBox>
|
||||
|
||||
<TextBlock VerticalAlignment="Center" Margin="30,0,0,0">高度</TextBlock>
|
||||
<TextBox Width="100" Margin="10,0,0,0" Text="{Binding SelectedItem.height}"></TextBox>
|
||||
|
||||
<Button HorizontalAlignment="Right" Width="120" Style="{StaticResource BtnCornerRadius2}" Content="返回首页" Height="30" Margin="50,0" VerticalAlignment="Center" Click="Button_Click"></Button>
|
||||
|
||||
</WrapPanel>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<Grid Grid.Row="1" >
|
||||
<Button HorizontalAlignment="Right" Width="110" Style="{StaticResource BtnCornerRadius}" Content="保存配置并重启" Height="40" Margin="30,0,180,0" VerticalAlignment="Center" Command="{Binding ButtonQuitCommand}">
|
||||
</Button>
|
||||
<Button HorizontalAlignment="Right" Width="120" Style="{StaticResource BtnCornerRadius2}" Content="返回首页" Height="40" Margin="30,0" VerticalAlignment="Center" Click="Button_Click"></Button>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Border>
|
||||
</UserControl>
|
37
AnQing/View/SetUpView.xaml.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using AnQing.Commons;
|
||||
using AnQing.ViewModel;
|
||||
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 AnQing.View
|
||||
{
|
||||
/// <summary>
|
||||
/// SetUpView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class SetUpView : UserControl
|
||||
{
|
||||
public SetUpViewModel SetUpViewModel;
|
||||
public SetUpView()
|
||||
{
|
||||
InitializeComponent();
|
||||
SetUpViewModel = new SetUpViewModel();
|
||||
this.DataContext = SetUpViewModel;
|
||||
}
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Common.MenuViewQuit();
|
||||
}
|
||||
}
|
||||
}
|
848
AnQing/ViewModel/MianWindowViewModel.cs
Normal file
@ -0,0 +1,848 @@
|
||||
using AnQing.Commons;
|
||||
using AnQing.Models;
|
||||
using Modbus.Device;
|
||||
using MvCamCtrl.NET;
|
||||
using RGD.DBUtility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.IO.Ports;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Threading;
|
||||
using ZXing;
|
||||
using ZXing.Common;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
using Application = System.Windows.Application;
|
||||
using Color = System.Drawing.Color;
|
||||
using PixelFormat = System.Drawing.Imaging.PixelFormat;
|
||||
|
||||
namespace AnQing.ViewModel
|
||||
{
|
||||
public class MianWindowViewModel : INotifyPropertyChanged
|
||||
{
|
||||
#region 属性
|
||||
/// <summary>
|
||||
/// 图片识别区域
|
||||
/// </summary>
|
||||
public List<Rectangle> possibleRegions = new List<Rectangle>();
|
||||
/// <summary>
|
||||
/// 摄像头1连接状态
|
||||
/// </summary>
|
||||
private bool video1State;
|
||||
public bool Video1State
|
||||
{
|
||||
get { return video1State; }
|
||||
set
|
||||
{
|
||||
video1State = value;
|
||||
OnPropertyChanged("Video1State");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 摄像头2连接状态
|
||||
/// </summary>
|
||||
private bool video2State;
|
||||
public bool Video2State
|
||||
{
|
||||
get { return video2State; }
|
||||
set
|
||||
{
|
||||
video2State = value;
|
||||
OnPropertyChanged("Video2State");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 识别状态
|
||||
/// </summary>
|
||||
private bool readerState;
|
||||
public bool ReaderState
|
||||
{
|
||||
get { return readerState; }
|
||||
set
|
||||
{
|
||||
readerState = value;
|
||||
OnPropertyChanged("ReaderState");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 识别到的数据信息
|
||||
/// </summary>
|
||||
private string readerText;
|
||||
public string ReaderText
|
||||
{
|
||||
get { return readerText; }
|
||||
set
|
||||
{
|
||||
readerText = value;
|
||||
OnPropertyChanged("ReaderText");
|
||||
}
|
||||
}
|
||||
private string readerText_temp;
|
||||
/// <summary>
|
||||
/// 识别时间
|
||||
/// </summary>
|
||||
private string readerTextTime;
|
||||
public string ReaderTextTime
|
||||
{
|
||||
get { return readerTextTime; }
|
||||
set
|
||||
{
|
||||
readerTextTime = value;
|
||||
OnPropertyChanged("ReaderTextTime");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 图像一
|
||||
/// </summary>
|
||||
private ImageSource _imageSource;
|
||||
public ImageSource ImageSource
|
||||
{
|
||||
get { return _imageSource; }
|
||||
set
|
||||
{
|
||||
if (_imageSource != value)
|
||||
{
|
||||
if (_imageSource is BitmapSource oldBitmapSource)
|
||||
{
|
||||
DisposeBitmapSource(oldBitmapSource);
|
||||
}
|
||||
_imageSource = value;
|
||||
OnPropertyChanged(nameof(ImageSource));
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 释放 BitmapSource 资源,避免 GDI 资源泄漏
|
||||
/// </summary>
|
||||
private void DisposeBitmapSource(BitmapSource bitmapSource)
|
||||
{
|
||||
if (bitmapSource == null) return;
|
||||
|
||||
if (bitmapSource is IDisposable disposable)
|
||||
{
|
||||
disposable.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 图像二
|
||||
/// </summary>
|
||||
private ImageSource _imageSource2;
|
||||
public ImageSource ImageSource2
|
||||
{
|
||||
get { return _imageSource2; }
|
||||
set
|
||||
{
|
||||
if (_imageSource2 != value)
|
||||
{
|
||||
_imageSource2 = value;
|
||||
OnPropertyChanged(nameof(ImageSource2));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 事件
|
||||
/// <summary>
|
||||
/// 摄像触发采集
|
||||
/// </summary>
|
||||
private ICommand buttonGatherCommand;
|
||||
public ICommand ButtonGatherCommand => buttonGatherCommand ??= new RelayCommand(TriggerExec);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 释放
|
||||
/// </summary>
|
||||
private ICommand buttonCloseCommand;
|
||||
public ICommand ButtonCloseCommand => buttonCloseCommand ??= new RelayCommand(CloseCamera);
|
||||
#endregion
|
||||
|
||||
#region 相机初始化
|
||||
//图像一
|
||||
MyCamera.MV_CC_DEVICE_INFO_LIST m_stDeviceList = new MyCamera.MV_CC_DEVICE_INFO_LIST();
|
||||
public MyCamera m_MyCamera = new MyCamera();
|
||||
bool m_bGrabbing = false;
|
||||
//图像二
|
||||
public MyCamera m_MyCamera2 = new MyCamera();
|
||||
bool m_bGrabbing2 = false;
|
||||
/// <summary>
|
||||
/// 关闭程序需要关闭摄像头
|
||||
/// </summary>
|
||||
private void CloseCamera()
|
||||
{
|
||||
// ch:关闭设备 | en:Close Device
|
||||
m_MyCamera.MV_CC_CloseDevice_NET();
|
||||
m_MyCamera.MV_CC_DestroyDevice_NET();
|
||||
}
|
||||
/// <summary>
|
||||
/// 初始化打开摄像头
|
||||
/// </summary>
|
||||
private void OpenCamera()
|
||||
{
|
||||
string targetIp = "192.168.2.11"; // 摄像头IP
|
||||
string targetIp2 = "192.168.3.13"; // 摄像头2 IP
|
||||
|
||||
bool ip1 = false, ip2 = false;
|
||||
System.GC.Collect();
|
||||
m_stDeviceList.nDeviceNum = 0;
|
||||
|
||||
int nRet1 = MyCamera.MV_CC_EnumDevices_NET(MyCamera.MV_GIGE_DEVICE | MyCamera.MV_USB_DEVICE, ref m_stDeviceList);
|
||||
if (nRet1 != 0)
|
||||
{
|
||||
MessageBox.Show("MV_CC_EnumDevices_NET 初始化失败: " + nRet1);
|
||||
return;
|
||||
}
|
||||
|
||||
// ch:获取选择的设备信息 | en:Get selected device information
|
||||
MyCamera.MV_CC_DEVICE_INFO device = new MyCamera.MV_CC_DEVICE_INFO();//相机一
|
||||
MyCamera.MV_CC_DEVICE_INFO device2 = new MyCamera.MV_CC_DEVICE_INFO();//相机二
|
||||
for (int i = 0; i < m_stDeviceList.nDeviceNum; i++)
|
||||
{
|
||||
MyCamera.MV_CC_DEVICE_INFO device_temp = (MyCamera.MV_CC_DEVICE_INFO)Marshal.PtrToStructure(m_stDeviceList.pDeviceInfo[i], typeof(MyCamera.MV_CC_DEVICE_INFO));
|
||||
|
||||
if (device_temp.nTLayerType == MyCamera.MV_GIGE_DEVICE)
|
||||
{
|
||||
MyCamera.MV_GIGE_DEVICE_INFO_EX gigeInfo = (MyCamera.MV_GIGE_DEVICE_INFO_EX)MyCamera.ByteToStruct(device_temp.SpecialInfo.stGigEInfo, typeof(MyCamera.MV_GIGE_DEVICE_INFO_EX));
|
||||
|
||||
string deviceIp = $"{(gigeInfo.nCurrentIp >> 24) & 0xFF}.{(gigeInfo.nCurrentIp >> 16) & 0xFF}.{(gigeInfo.nCurrentIp >> 8) & 0xFF}.{gigeInfo.nCurrentIp & 0xFF}";
|
||||
if (deviceIp == targetIp) // 相机一
|
||||
{
|
||||
device = (MyCamera.MV_CC_DEVICE_INFO)Marshal.PtrToStructure(m_stDeviceList.pDeviceInfo[i], typeof(MyCamera.MV_CC_DEVICE_INFO));
|
||||
ip1 = true;
|
||||
}
|
||||
if (deviceIp == targetIp2) // 相机二
|
||||
{
|
||||
device2 = (MyCamera.MV_CC_DEVICE_INFO)Marshal.PtrToStructure(m_stDeviceList.pDeviceInfo[i], typeof(MyCamera.MV_CC_DEVICE_INFO));
|
||||
ip2 = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ch:打开设备 | en:Open device
|
||||
if (null == m_MyCamera)
|
||||
{
|
||||
m_MyCamera = new MyCamera();
|
||||
if (null == m_MyCamera)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (null == m_MyCamera2)
|
||||
{
|
||||
m_MyCamera2 = new MyCamera();
|
||||
if (null == m_MyCamera2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int nRet = m_MyCamera.MV_CC_CreateDevice_NET(ref device);
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
return;
|
||||
}
|
||||
nRet = m_MyCamera.MV_CC_OpenDevice_NET();
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
m_MyCamera.MV_CC_CloseDevice_NET();
|
||||
m_MyCamera.MV_CC_DestroyDevice_NET();
|
||||
|
||||
//// ch:关闭设备 | en:Close Device
|
||||
m_MyCamera2.MV_CC_CloseDevice_NET();
|
||||
m_MyCamera2.MV_CC_DestroyDevice_NET();
|
||||
return;
|
||||
}
|
||||
|
||||
int nRet_2 = m_MyCamera2.MV_CC_CreateDevice_NET(ref device2);
|
||||
if (MyCamera.MV_OK != nRet_2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
nRet_2 = m_MyCamera2.MV_CC_OpenDevice_NET();
|
||||
if (MyCamera.MV_OK != nRet_2)
|
||||
{
|
||||
m_MyCamera.MV_CC_CloseDevice_NET();
|
||||
m_MyCamera.MV_CC_DestroyDevice_NET();
|
||||
|
||||
//// ch:关闭设备 | en:Close Device
|
||||
m_MyCamera2.MV_CC_CloseDevice_NET();
|
||||
m_MyCamera2.MV_CC_DestroyDevice_NET();
|
||||
return;
|
||||
}
|
||||
|
||||
// ch:探测网络最佳包大小(只对GigE相机有效) | en:Detection network optimal package size(It only works for the GigE camera)
|
||||
if (device.nTLayerType == MyCamera.MV_GIGE_DEVICE)
|
||||
{
|
||||
int nPacketSize = m_MyCamera.MV_CC_GetOptimalPacketSize_NET();
|
||||
if (nPacketSize > 0)
|
||||
{
|
||||
nRet = m_MyCamera.MV_CC_SetIntValueEx_NET("GevSCPSPacketSize", nPacketSize);
|
||||
if (nRet != MyCamera.MV_OK)
|
||||
{
|
||||
MessageBox.Show("MV_CC_SetIntValueEx_NET 初始化失败: " + nRet);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("MV_CC_SetIntValueEx_NET 初始化失败: " + nPacketSize);
|
||||
}
|
||||
}
|
||||
if (device2.nTLayerType == MyCamera.MV_GIGE_DEVICE)
|
||||
{
|
||||
int nPacketSize = m_MyCamera2.MV_CC_GetOptimalPacketSize_NET();
|
||||
if (nPacketSize > 0)
|
||||
{
|
||||
nRet_2 = m_MyCamera2.MV_CC_SetIntValueEx_NET("GevSCPSPacketSize", nPacketSize);
|
||||
if (nRet_2 != MyCamera.MV_OK)
|
||||
{
|
||||
MessageBox.Show("MV_CC_SetIntValueEx_NET 初始化失败: " + nRet_2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("MV_CC_SetIntValueEx_NET 初始化失败: " + nPacketSize);
|
||||
}
|
||||
}
|
||||
|
||||
// ch:设置采集连续模式 | en:Set Continues Aquisition Mode
|
||||
m_MyCamera.MV_CC_SetEnumValue_NET("AcquisitionMode", (uint)MyCamera.MV_CAM_ACQUISITION_MODE.MV_ACQ_MODE_CONTINUOUS);
|
||||
m_MyCamera.MV_CC_SetEnumValue_NET("TriggerMode", (uint)MyCamera.MV_CAM_TRIGGER_MODE.MV_TRIGGER_MODE_ON);
|
||||
m_MyCamera.MV_CC_SetEnumValue_NET("TriggerSource", (uint)MyCamera.MV_CAM_TRIGGER_SOURCE.MV_TRIGGER_SOURCE_SOFTWARE);
|
||||
m_MyCamera2.MV_CC_SetEnumValue_NET("AcquisitionMode", (uint)MyCamera.MV_CAM_ACQUISITION_MODE.MV_ACQ_MODE_CONTINUOUS);
|
||||
m_MyCamera2.MV_CC_SetEnumValue_NET("TriggerMode", (uint)MyCamera.MV_CAM_TRIGGER_MODE.MV_TRIGGER_MODE_ON);
|
||||
m_MyCamera2.MV_CC_SetEnumValue_NET("TriggerSource", (uint)MyCamera.MV_CAM_TRIGGER_SOURCE.MV_TRIGGER_SOURCE_SOFTWARE);
|
||||
|
||||
//bnGetParam_Click(null, null);//获取相机焦距等参数
|
||||
|
||||
// ch:标志位置位true | en:Set position bit true
|
||||
m_bGrabbing = true;
|
||||
m_bGrabbing2 = true;
|
||||
|
||||
// ch:开始采集 | en:Start Grabbing
|
||||
int nRet2 = m_MyCamera.MV_CC_StartGrabbing_NET();
|
||||
if (MyCamera.MV_OK != nRet2)
|
||||
{
|
||||
m_bGrabbing = false;
|
||||
MessageBox.Show("MV_CC_StartGrabbing_NET 初始化失败: " + nRet2);
|
||||
return;
|
||||
}
|
||||
int nRet2_2 = m_MyCamera2.MV_CC_StartGrabbing_NET();
|
||||
if (MyCamera.MV_OK != nRet2_2)
|
||||
{
|
||||
m_bGrabbing2 = false;
|
||||
MessageBox.Show("MV_CC_StartGrabbing_NET 初始化失败: " + nRet2_2);
|
||||
return;
|
||||
}
|
||||
if (ip1)
|
||||
Video1State = true;
|
||||
|
||||
if (ip2)
|
||||
Video2State = true;
|
||||
}
|
||||
|
||||
private List<string> ReadImageGuid_Temp = new List<string> ();
|
||||
public string ReaderImagePath_Temp;
|
||||
/// <summary>
|
||||
/// 抓拍图片
|
||||
/// </summary>
|
||||
public void ReceiveThreadProcess()
|
||||
{
|
||||
MyCamera.MV_FRAME_OUT stFrameInfo = new MyCamera.MV_FRAME_OUT();
|
||||
int nRet = m_MyCamera.MV_CC_GetImageBuffer_NET(ref stFrameInfo, 1000);
|
||||
if (nRet == MyCamera.MV_OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
int width = stFrameInfo.stFrameInfo.nWidth;
|
||||
int height = stFrameInfo.stFrameInfo.nHeight;
|
||||
int stride = width; // Mono8: 每个像素1字节,stride = width
|
||||
|
||||
// 直接利用内存地址创建 Bitmap 对象
|
||||
Bitmap bitmap = new Bitmap(width, height, stride, PixelFormat.Format8bppIndexed, stFrameInfo.pBufAddr);
|
||||
|
||||
// 设置灰度调色板
|
||||
ColorPalette palette = bitmap.Palette;
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
palette.Entries[i] = Color.FromArgb(i, i, i);
|
||||
}
|
||||
bitmap.Palette = palette;
|
||||
|
||||
DateTime start = DateTime.Now;
|
||||
var reader = new BarcodeReader
|
||||
{
|
||||
AutoRotate = true,
|
||||
Options = new DecodingOptions
|
||||
{
|
||||
TryHarder = true, // 深度解析模式
|
||||
PureBarcode = false, // 是否纯条码(无文字干扰)
|
||||
AssumeCode39CheckDigit = false, // 是否验证Code39校验位
|
||||
PossibleFormats = new List<BarcodeFormat>
|
||||
{
|
||||
BarcodeFormat.CODE_128
|
||||
//BarcodeFormat.EAN_13,
|
||||
//BarcodeFormat.EAN_8,
|
||||
//BarcodeFormat.UPC_A,
|
||||
//BarcodeFormat.UPC_E,
|
||||
//BarcodeFormat.CODE_39,
|
||||
//BarcodeFormat.ITF,
|
||||
//BarcodeFormat.CODABAR
|
||||
},
|
||||
CharacterSet = "UTF-8"
|
||||
}
|
||||
};
|
||||
|
||||
foreach (var region in possibleRegions)
|
||||
{
|
||||
Bitmap cropped = CropBarcodeRegion(bitmap, region);
|
||||
var result = reader.Decode(cropped);
|
||||
cropped.Dispose();
|
||||
cropped = null;
|
||||
if (result != null)
|
||||
{
|
||||
readerText_temp = result.Text;
|
||||
ReaderText = result.Text;
|
||||
ReaderState = false;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
readerText_temp = "";
|
||||
}
|
||||
}
|
||||
if (string.IsNullOrEmpty(readerText_temp))
|
||||
{
|
||||
ReaderText = "未检测到条码!";
|
||||
ReaderState = true;
|
||||
}
|
||||
DateTime end = DateTime.Now;
|
||||
TimeSpan duration = end - start;
|
||||
ReaderTextTime = duration.TotalSeconds.ToString() + " 秒";
|
||||
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
// 转换为 WPF BitmapImage 用于 Image 控件显示
|
||||
ImageSource = Common.BitmapToBitmapSource2(bitmap);
|
||||
});
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
ReaderImagePath_Temp = AppDomain.CurrentDomain.BaseDirectory + "ImageList\\" + DateTime.Now.ToString("yyyy-MM-dd") + "\\" + guid + ".jpeg";
|
||||
string imgpath_after = "";
|
||||
string sql = @"
|
||||
IF NOT EXISTS (SELECT 1 FROM SCAN_MIAN WHERE goodcode = @goodcode)
|
||||
BEGIN
|
||||
INSERT INTO SCAN_MIAN (time, goodcode, img, img_after, ex)
|
||||
VALUES (@time, @goodcode, @img, @img_after, @ex)
|
||||
END";
|
||||
|
||||
SqlParameter[] parameters = {
|
||||
new SqlParameter("@time", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")),
|
||||
new SqlParameter("@goodcode", readerText_temp),
|
||||
new SqlParameter("@img", ReaderImagePath_Temp),
|
||||
new SqlParameter("@img_after", imgpath_after),
|
||||
new SqlParameter("@ex", guid)
|
||||
};
|
||||
|
||||
DbHelperSQL.ExecuteSql(sql, parameters);
|
||||
DbHelperSQL.ExecuteSql($"INSERT INTO SCAN_MIAN (time, goodcode, img, img_after,ex) VALUES ('{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}', '{readerText_temp}', '{ReaderImagePath_Temp}', '{imgpath_after}','{guid}');");
|
||||
ReadImageGuid_Temp.Add(guid);
|
||||
// 直接将图像数据保存到本地(例如保存为 JPEG 格式)
|
||||
SaveBitmapToFile(bitmap, ReaderImagePath_Temp);
|
||||
|
||||
bitmap.Dispose();
|
||||
bitmap = null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("图像处理失败: " + ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
m_MyCamera.MV_CC_FreeImageBuffer_NET(ref stFrameInfo);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("获取图像失败,错误码:" + nRet);
|
||||
}
|
||||
}
|
||||
|
||||
public string ReaderImagePath_Temp2;
|
||||
/// <summary>
|
||||
/// 抓拍图片 左相机
|
||||
/// </summary>
|
||||
public void ReceiveThreadProcess2()
|
||||
{
|
||||
MyCamera.MV_FRAME_OUT stFrameInfo = new MyCamera.MV_FRAME_OUT();
|
||||
int nRet = m_MyCamera2.MV_CC_GetImageBuffer_NET(ref stFrameInfo, 1000);
|
||||
if (nRet == MyCamera.MV_OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
int width = stFrameInfo.stFrameInfo.nWidth;
|
||||
int height = stFrameInfo.stFrameInfo.nHeight;
|
||||
int stride = width; // Mono8: 每个像素1字节,stride = width
|
||||
|
||||
// 直接利用内存地址创建 Bitmap 对象
|
||||
Bitmap bitmap = new Bitmap(width, height, stride, PixelFormat.Format8bppIndexed, stFrameInfo.pBufAddr);
|
||||
|
||||
// 设置灰度调色板
|
||||
ColorPalette palette = bitmap.Palette;
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
palette.Entries[i] = Color.FromArgb(i, i, i);
|
||||
}
|
||||
bitmap.Palette = palette;
|
||||
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
// 转换为 WPF BitmapImage 用于 Image 控件显示
|
||||
ImageSource2 = Common.BitmapToBitmapSource2(bitmap);
|
||||
});
|
||||
ReaderImagePath_Temp2 = AppDomain.CurrentDomain.BaseDirectory + "ImageList\\" + DateTime.Now.ToString("yyyy-MM-dd") + "\\" + Guid.NewGuid() + ".jpeg";
|
||||
//DbHelperSQL.ExecuteSql($"update SCAN_MIAN set img_after='{ReaderImagePath_Temp2}' WHERE id = (SELECT id FROM ( SELECT id FROM SCAN_MIAN ORDER BY id DESC OFFSET 2 ROWS FETCH NEXT 1 ROWS ONLY ) AS subquery)");
|
||||
DbHelperSQL.ExecuteSql($"update SCAN_MIAN set img_after='{ReaderImagePath_Temp2}' WHERE ex = '{ReadImageGuid_Temp[0]}'");
|
||||
ReadImageGuid_Temp.Remove(ReadImageGuid_Temp[0]);
|
||||
// 直接将图像数据保存到本地(例如保存为 JPEG 格式)
|
||||
SaveBitmapToFile(bitmap, ReaderImagePath_Temp2);
|
||||
|
||||
bitmap.Dispose();
|
||||
bitmap = null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("图像处理失败: " + ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
m_MyCamera.MV_CC_FreeImageBuffer_NET(ref stFrameInfo);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("获取图像失败,错误码:" + nRet);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 直接将图像保存为文件
|
||||
/// </summary>
|
||||
/// <param name="bitmap"></param>
|
||||
/// <param name="filePath"></param>
|
||||
private void SaveBitmapToFile(Bitmap bitmap, string filePath)
|
||||
{
|
||||
// 使用 MemoryStream 保存图像,减少内存占用
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
{
|
||||
bitmap.Save(ms, ImageFormat.Jpeg); // 保存为 JPEG 格式
|
||||
File.WriteAllBytes(filePath, ms.ToArray());
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 触发拍照指令 右相机
|
||||
/// </summary>
|
||||
public void TriggerExec()
|
||||
{
|
||||
string sql = @"
|
||||
IF NOT EXISTS (SELECT 1 FROM SCAN_MIAN WHERE goodcode = @goodcode)
|
||||
BEGIN
|
||||
INSERT INTO SCAN_MIAN (time, goodcode, img, img_after, ex)
|
||||
VALUES (@time, @goodcode, @img, @img_after, @ex)
|
||||
END";
|
||||
|
||||
SqlParameter[] parameters = {
|
||||
new SqlParameter("@time", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")),
|
||||
new SqlParameter("@goodcode", "123"),
|
||||
new SqlParameter("@img", "321"),
|
||||
new SqlParameter("@img_after", "imgpath_after"),
|
||||
new SqlParameter("@ex", "guid")
|
||||
};
|
||||
DbHelperSQL.ExecuteSql(sql, parameters);
|
||||
//// ch:触发命令 | en:Trigger command
|
||||
//int nRet = m_MyCamera.MV_CC_SetCommandValue_NET("TriggerSoftware");
|
||||
//if (MyCamera.MV_OK != nRet)
|
||||
//{
|
||||
// //ShowErrorMsg("Trigger Software Fail!", nRet);
|
||||
//}
|
||||
//if (m_bGrabbing)
|
||||
//{
|
||||
// Task.Run(() => {
|
||||
// ReceiveThreadProcess();
|
||||
// });
|
||||
//}
|
||||
//TriggerExec_Left();
|
||||
}
|
||||
/// <summary>
|
||||
/// 触发拍照指令 左相机
|
||||
/// </summary>
|
||||
public void TriggerExec_Left()
|
||||
{
|
||||
// ch:触发命令 | en:Trigger command
|
||||
int nRet = m_MyCamera2.MV_CC_SetCommandValue_NET("TriggerSoftware");
|
||||
if (MyCamera.MV_OK != nRet)
|
||||
{
|
||||
//ShowErrorMsg("Trigger Software Fail!", nRet);
|
||||
}
|
||||
if (m_bGrabbing2)
|
||||
{
|
||||
Task.Run(() => {
|
||||
ReceiveThreadProcess2();
|
||||
});
|
||||
}
|
||||
}
|
||||
public static Bitmap CropBarcodeRegion(Bitmap original, Rectangle roi)
|
||||
{
|
||||
// 确保裁剪区域在图片范围内
|
||||
roi.Intersect(new Rectangle(0, 0, original.Width, original.Height));
|
||||
|
||||
// 进行裁剪
|
||||
return original.Clone(roi, original.PixelFormat);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 通讯数据
|
||||
private SerialPort _serialPort;
|
||||
private IModbusSerialMaster _modbusMaster;
|
||||
private DispatcherTimer _timer;
|
||||
|
||||
private bool _leftCameraTriggered;
|
||||
public bool LeftCameraTriggered
|
||||
{
|
||||
get => _leftCameraTriggered;
|
||||
set { _leftCameraTriggered = value; OnPropertyChanged("LeftCameraTriggered"); }
|
||||
}
|
||||
|
||||
private bool _rightCameraTriggered;
|
||||
public bool RightCameraTriggered
|
||||
{
|
||||
get => _rightCameraTriggered;
|
||||
set { _rightCameraTriggered = value; OnPropertyChanged("RightCameraTriggered"); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 初始化连接PLC
|
||||
/// </summary>
|
||||
private void InitializeModbus()
|
||||
{
|
||||
try
|
||||
{
|
||||
// 创建并打开串口
|
||||
_serialPort = new SerialPort("COM10", 115200, Parity.None, 8, StopBits.One);
|
||||
_serialPort.ReadTimeout = 1000; // 设置串口读取超时为1秒
|
||||
_serialPort.WriteTimeout = 1000; // 设置串口写入超时为1秒
|
||||
_serialPort.Open();
|
||||
|
||||
// 创建 Modbus 主站
|
||||
_modbusMaster = ModbusSerialMaster.CreateRtu(_serialPort);
|
||||
_modbusMaster.Transport.Retries = 3;
|
||||
_modbusMaster.Transport.WaitToRetryMilliseconds = 100;
|
||||
_modbusMaster.Transport.SlaveBusyUsesRetryCount = true;
|
||||
Console.WriteLine("MODBUS 连接成功!");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("MODBUS 连接失败: " + ex.Message);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 线程 监听接收信息
|
||||
/// </summary>
|
||||
private void StartPolling()
|
||||
{
|
||||
_timer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(500) };
|
||||
_timer.Tick += (s, e) => ReadPlcData();
|
||||
_timer.Start();
|
||||
}
|
||||
private async Task<ushort[]> ReadHoldingRegistersWithRetry(byte slaveId, ushort startAddress, ushort numRegisters)
|
||||
{
|
||||
int retryCount = 3;
|
||||
int waitTimeMs = 100;
|
||||
ushort[] result = null;
|
||||
|
||||
for (int i = 0; i < retryCount; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
result = _modbusMaster.ReadHoldingRegisters(slaveId, startAddress, numRegisters);
|
||||
return result; // 成功读取则返回结果
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Modbus 读取失败: {ex.Message}");
|
||||
if (i < retryCount - 1) // 如果不是最后一次重试
|
||||
{
|
||||
await Task.Delay(waitTimeMs); // 等待一段时间后重试
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result; // 如果超过重试次数还没成功,可以返回 null 或处理失败逻辑
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 信息接收方法
|
||||
/// </summary>
|
||||
private void ReadPlcData()
|
||||
{
|
||||
try
|
||||
{
|
||||
//return;
|
||||
byte slaveId = 3; // 站号3
|
||||
|
||||
//// 读取左相机寄存器VW2000(Modbus地址0)
|
||||
//ushort[] leftCameraRegisters = _modbusMaster.ReadHoldingRegisters(slaveId, 0, 1);
|
||||
|
||||
//// 读取右相机寄存器VW2002(Modbus地址1)
|
||||
//ushort[] rightCameraRegisters = _modbusMaster.ReadHoldingRegisters(slaveId, 1, 1);
|
||||
|
||||
// 一次性读取左相机和右相机的寄存器
|
||||
ushort[] registers = _modbusMaster.ReadHoldingRegisters(slaveId, 0, 2);
|
||||
|
||||
// 解析左相机信号(VW2000的第0位)
|
||||
LeftCameraTriggered = (registers[0] & 0x0001) != 0;
|
||||
|
||||
// 解析右相机信号(VW2002的第1位)
|
||||
RightCameraTriggered = (registers[1] & 0x0002) != 0;
|
||||
|
||||
// 触发拍照
|
||||
if (RightCameraTriggered) TakePhoto("右相机");
|
||||
if (LeftCameraTriggered) TakePhoto("左相机");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("PLC 读取失败: " + ex.Message);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 向上位机Y5/7发送右相机OK信号至PLC
|
||||
/// </summary>
|
||||
/// <param name="isActive">true=激活信号,false=关闭信号</param>
|
||||
public void SendRightCameraOkSignal()
|
||||
{
|
||||
try
|
||||
{
|
||||
byte slaveId = 3; // 站号3
|
||||
ushort coilAddress = 7; // Y5/7的Modbus VW 2014
|
||||
short value = 1;
|
||||
_modbusMaster.WriteSingleRegister(slaveId, coilAddress,(ushort)value);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("PLC信号发送失败: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private DateTime lastLeftTriggerTime = DateTime.MinValue; // 左相机上次触发时间
|
||||
private DateTime lastRightTriggerTime = DateTime.MinValue; // 右相机上次触发时间
|
||||
|
||||
/// <summary>
|
||||
/// 获取哪个相机要触发
|
||||
/// </summary>
|
||||
/// <param name="camera"></param>
|
||||
|
||||
private void TakePhoto(string camera)
|
||||
{
|
||||
DateTime currentTime = DateTime.Now;
|
||||
|
||||
if (camera == "左相机")
|
||||
{
|
||||
// 判断左相机触发的间隔时间
|
||||
if ((currentTime - lastLeftTriggerTime).TotalSeconds < 1)
|
||||
{
|
||||
Console.WriteLine("左相机触发太快,请稍等...");
|
||||
return;
|
||||
}
|
||||
|
||||
// 更新左相机的触发时间
|
||||
lastLeftTriggerTime = currentTime;
|
||||
|
||||
Console.WriteLine("左相机触发" + currentTime.ToString("yyyy-MM-dd HH:mm:ss"));
|
||||
TriggerExec_Left();
|
||||
}
|
||||
else if (camera == "右相机")
|
||||
{
|
||||
// 判断右相机触发的间隔时间
|
||||
if ((currentTime - lastRightTriggerTime).TotalSeconds < 1)
|
||||
{
|
||||
Console.WriteLine("右相机触发太快,请稍等...");
|
||||
return;
|
||||
}
|
||||
|
||||
// 更新右相机的触发时间
|
||||
lastRightTriggerTime = currentTime;
|
||||
|
||||
Console.WriteLine("右相机触发" + currentTime.ToString("yyyy-MM-dd HH:mm:ss"));
|
||||
TriggerExec();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// 停止定时器
|
||||
_timer?.Stop();
|
||||
|
||||
// 释放 ModbusMaster 和串口资源
|
||||
_modbusMaster?.Dispose();
|
||||
if (_serialPort?.IsOpen == true) _serialPort.Close();
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public MianWindowViewModel()
|
||||
{
|
||||
GetPossibleRegions();
|
||||
|
||||
////ch: 初始化SDK | en: Initialize SDK
|
||||
//MyCamera.MV_CC_Initialize_NET();
|
||||
|
||||
////相机初始化
|
||||
//OpenCamera();
|
||||
|
||||
//plc 通讯初始化
|
||||
//InitializeModbus();
|
||||
//StartPolling();
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取裁切范围
|
||||
/// </summary>
|
||||
public void GetPossibleRegions()
|
||||
{
|
||||
possibleRegions.Clear();
|
||||
DataView dv = DbHelperSQL.Query("select * from IMAGEINFO").Tables[0].DefaultView;
|
||||
foreach (DataRowView rowView in dv)
|
||||
{
|
||||
possibleRegions.Add(new Rectangle(int.Parse(rowView["x"].ToString()), int.Parse(rowView["y"].ToString()), int.Parse(rowView["width"].ToString()), int.Parse(rowView["height"].ToString())));
|
||||
}
|
||||
}
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
protected void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
if (PropertyChanged != null)
|
||||
{
|
||||
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
157
AnQing/ViewModel/SetUpViewModel.cs
Normal file
@ -0,0 +1,157 @@
|
||||
using AnQing.Commons;
|
||||
using AnQing.Model;
|
||||
using AnQing.Models;
|
||||
using RGD.DBUtility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using System.Xml;
|
||||
|
||||
namespace AnQing.ViewModel
|
||||
{
|
||||
public class SetUpViewModel: INotifyPropertyChanged
|
||||
{
|
||||
private string _videoIP1 =Common.GetSetting("VideoIP1");
|
||||
|
||||
public string VideoIP1
|
||||
{
|
||||
get => _videoIP1;
|
||||
set
|
||||
{
|
||||
if (_videoIP1 != value)
|
||||
{
|
||||
_videoIP1 = value;
|
||||
OnPropertyChanged(nameof(VideoIP1));
|
||||
}
|
||||
}
|
||||
}
|
||||
private string _videoIP2 = GetSetting("VideoIP2");
|
||||
|
||||
public string VideoIP2
|
||||
{
|
||||
get => _videoIP2;
|
||||
set
|
||||
{
|
||||
if (_videoIP2 != value)
|
||||
{
|
||||
_videoIP2 = value;
|
||||
OnPropertyChanged(nameof(VideoIP2));
|
||||
}
|
||||
}
|
||||
}
|
||||
private string _imagePath = GetSetting("ImagePath");
|
||||
|
||||
private ObservableCollection<IMAGEINFO> _dgScanMain = new ObservableCollection<IMAGEINFO>();
|
||||
public ObservableCollection<IMAGEINFO> DgScanMain
|
||||
{
|
||||
get => _dgScanMain;
|
||||
set
|
||||
{
|
||||
if (_dgScanMain != value)
|
||||
{
|
||||
_dgScanMain = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
private IMAGEINFO _selectedItem;
|
||||
public IMAGEINFO SelectedItem
|
||||
{
|
||||
get { return _selectedItem; }
|
||||
set
|
||||
{
|
||||
_selectedItem = value;
|
||||
OnPropertyChanged(nameof(SelectedItem));
|
||||
}
|
||||
}
|
||||
public SetUpViewModel()
|
||||
{
|
||||
LoadScanMain();
|
||||
}
|
||||
private void LoadScanMain()
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
DataView dv = DbHelperSQL.Query("select * from IMAGEINFO").Tables[0].DefaultView;
|
||||
DgScanMain = Common.ConvertDataViewToObservableCollection<IMAGEINFO>(dv);
|
||||
//DgScanMain.Add(new IMAGEINFO() { x = 0, y = 0, width = 0, height = 0, index = 0 });
|
||||
});
|
||||
}
|
||||
public string ImagePath
|
||||
{
|
||||
get => _imagePath;
|
||||
set
|
||||
{
|
||||
if (_imagePath != value)
|
||||
{
|
||||
_imagePath = value;
|
||||
OnPropertyChanged(nameof(ImagePath));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
private ICommand buttonQuitCommand;
|
||||
public ICommand ButtonQuitCommand => buttonQuitCommand ??= new RelayCommand(ButtonSave);
|
||||
/// <summary>
|
||||
/// 退出页面
|
||||
/// </summary>
|
||||
private void ButtonSave()
|
||||
{
|
||||
try
|
||||
{
|
||||
SetSetting("VideoIP1", VideoIP1);
|
||||
SetSetting("VideoIP2", VideoIP2);
|
||||
SetSetting("ImagePath", ImagePath);
|
||||
|
||||
App.Restart();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// 处理异常
|
||||
}
|
||||
}
|
||||
public static void SetSetting(string key, string value)
|
||||
{
|
||||
string configFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
|
||||
XmlDocument xmlDoc = new XmlDocument();
|
||||
xmlDoc.Load(configFile);
|
||||
|
||||
XmlNode appSettingsNode = xmlDoc.SelectSingleNode("//appSettings");
|
||||
|
||||
if (appSettingsNode != null)
|
||||
{
|
||||
XmlNode settingNode = appSettingsNode.SelectSingleNode($"add[@key='{key}']");
|
||||
if (settingNode != null)
|
||||
{
|
||||
settingNode.Attributes["value"].Value = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
XmlElement newSetting = xmlDoc.CreateElement("add");
|
||||
newSetting.SetAttribute("key", key);
|
||||
newSetting.SetAttribute("value", value);
|
||||
appSettingsNode.AppendChild(newSetting);
|
||||
}
|
||||
xmlDoc.Save(configFile);
|
||||
}
|
||||
}
|
||||
public static string GetSetting(string key)
|
||||
{
|
||||
return ConfigurationManager.AppSettings[key];
|
||||
}
|
||||
}
|
||||
}
|
436
AnQing/ViewModel/WindowQueryViewModel.cs
Normal file
@ -0,0 +1,436 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows.Input;
|
||||
using System.Data;
|
||||
using System.Windows.Controls;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using AnQing.Models;
|
||||
using RGD.DBUtility;
|
||||
using AnQing.Commons;
|
||||
using Microsoft.Win32;
|
||||
using Microsoft.WindowsAPICodePack.Dialogs;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace RFIDReaderJilin.ViewModel
|
||||
{
|
||||
public class WindowQueryViewModel : INotifyPropertyChanged
|
||||
{
|
||||
private ObservableCollection<SCAN_MAIN> _dgScanMain = new ObservableCollection<SCAN_MAIN>();
|
||||
public ObservableCollection<SCAN_MAIN> DgScanMain
|
||||
{
|
||||
get => _dgScanMain;
|
||||
set
|
||||
{
|
||||
if (_dgScanMain != value)
|
||||
{
|
||||
_dgScanMain = value;
|
||||
OnPropertyChanged();
|
||||
OnPropertyChanged(nameof(MaxPageCount)); // 数据加载后更新 MaxPageCount
|
||||
DgScanMain_Pagination = new ObservableCollection<SCAN_MAIN>(DgScanMain.Skip((PageIndex - 1) * DataCountPerPage).Take(DataCountPerPage));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ObservableCollection<SCAN_MAIN> _dgScanMain_Pagination = new ObservableCollection<SCAN_MAIN>();
|
||||
public ObservableCollection<SCAN_MAIN> DgScanMain_Pagination
|
||||
{
|
||||
get => _dgScanMain_Pagination;
|
||||
set
|
||||
{
|
||||
_dgScanMain_Pagination = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
private ICommand buttonQuit2Command;
|
||||
public ICommand ButtonQuit2Command => buttonQuit2Command ??= new RelayCommand(ButtonQuit2);
|
||||
|
||||
private ICommand buttonQuitCommand;
|
||||
public ICommand ButtonQuitCommand => buttonQuitCommand ??= new RelayCommand(ButtonQuit);
|
||||
|
||||
private ICommand buttonQueryCommand;
|
||||
public ICommand ButtonQueryCommand => buttonQueryCommand ??= new RelayCommand(ButtonQuery);
|
||||
|
||||
private ICommand buttonQueryClearCommand;
|
||||
public ICommand ButtonQueryClearCommand => buttonQueryClearCommand ??= new RelayCommand(ButtonQueryClear);
|
||||
|
||||
private ICommand buttonExportCommand;
|
||||
public ICommand ButtonExportCommand => buttonExportCommand ??= new RelayCommand(ButtonExport);
|
||||
|
||||
public WindowQueryViewModel()
|
||||
{
|
||||
LoadScanMain();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化获取所有历史记录
|
||||
/// </summary>
|
||||
private void LoadScanMain()
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
DataView dv = DbHelperSQL.Query("select * from SCAN_MIAN").Tables[0].DefaultView;
|
||||
DgScanMain = Common.ConvertDataViewToObservableCollection<SCAN_MAIN>(dv);
|
||||
});
|
||||
}
|
||||
/// <summary>
|
||||
/// 退出页面
|
||||
/// </summary>
|
||||
private void ButtonQuit() => Common.MenuViewQuit();
|
||||
|
||||
/// <summary>
|
||||
/// 退出页面
|
||||
/// </summary>
|
||||
private void ButtonQuit2()
|
||||
{
|
||||
SelectMain = null;
|
||||
Common.historycontrol.List_DeTail.Visibility = System.Windows.Visibility.Collapsed;
|
||||
}
|
||||
#region 查询条件
|
||||
private string _barcodes;
|
||||
private string _startTime;
|
||||
private string _endTime;
|
||||
|
||||
public string Barcodes
|
||||
{
|
||||
get => _barcodes;
|
||||
set
|
||||
{
|
||||
if (_barcodes != value)
|
||||
{
|
||||
_barcodes = value;
|
||||
OnPropertyChanged(nameof(Barcodes));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string StartTime
|
||||
{
|
||||
get => _startTime;
|
||||
set
|
||||
{
|
||||
if (_startTime != value)
|
||||
{
|
||||
_startTime = value;
|
||||
OnPropertyChanged(nameof(StartTime));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string EndTime
|
||||
{
|
||||
get => _endTime;
|
||||
set
|
||||
{
|
||||
if (_endTime != value)
|
||||
{
|
||||
_endTime = value;
|
||||
OnPropertyChanged(nameof(EndTime));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询事件
|
||||
/// </summary>
|
||||
private void ButtonQuery()
|
||||
{
|
||||
try
|
||||
{
|
||||
string sql = "select * from SCAN_MIAN";
|
||||
if (!string.IsNullOrEmpty(Barcodes))
|
||||
{
|
||||
sql += $" where goodcode='{Barcodes}'";
|
||||
}
|
||||
else
|
||||
{
|
||||
sql += " where 1=1";
|
||||
}
|
||||
if (!string.IsNullOrEmpty(StartTime))
|
||||
{
|
||||
sql += $" AND time >= '{DateTime.Parse(StartTime).ToString("yyyy-MM-dd HH:mm:ss")}'";
|
||||
}
|
||||
if (!string.IsNullOrEmpty(EndTime))
|
||||
{
|
||||
sql += $" AND time <= '{DateTime.Parse(EndTime).ToString("yyyy-MM-dd HH:mm:ss")}'";
|
||||
}
|
||||
sql += " order by time desc";
|
||||
|
||||
DataView dv = DbHelperSQL.Query(sql).Tables[0].DefaultView;
|
||||
DgScanMain = Common.ConvertDataViewToObservableCollection<SCAN_MAIN>(dv);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空查询条件
|
||||
/// </summary>
|
||||
private void ButtonQueryClear()
|
||||
{
|
||||
try
|
||||
{
|
||||
Barcodes = "";
|
||||
StartTime = "";
|
||||
EndTime = "";
|
||||
DataView dv = DbHelperSQL.Query("select * from SCAN_MIAN").Tables[0].DefaultView;
|
||||
DgScanMain = Common.ConvertDataViewToObservableCollection<SCAN_MAIN>(dv);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonExport()
|
||||
{
|
||||
try
|
||||
{
|
||||
var dialog = new CommonOpenFileDialog();
|
||||
dialog.IsFolderPicker = true;
|
||||
CommonFileDialogResult result = dialog.ShowDialog();
|
||||
if (result == CommonFileDialogResult.Ok)
|
||||
{
|
||||
string path = dialog.FileName + $"\\{DateTime.Now.ToString("yyyyMMddHHmmss")}导出.xlsx";
|
||||
Task.Run(() =>
|
||||
{
|
||||
Common.SaveToExcel(DgScanMain, path);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 分页相关
|
||||
/// <summary>
|
||||
/// 页码数
|
||||
/// </summary>
|
||||
public int MaxPageCount => (int)Math.Ceiling((double)DgScanMain.Count / (double)DataCountPerPage);
|
||||
/// <summary>
|
||||
/// 当前选中页码
|
||||
/// </summary>
|
||||
private int _pageIndex = 1;
|
||||
public int PageIndex
|
||||
{
|
||||
get => _pageIndex;
|
||||
set
|
||||
{
|
||||
if (_pageIndex != value)
|
||||
{
|
||||
_pageIndex = value;
|
||||
OnPropertyChanged(nameof(PageIndex));
|
||||
UpdatePagination(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 每页显示最多数 --当前选中的
|
||||
/// </summary>
|
||||
private int _dataCountPerPage = 10;
|
||||
public int DataCountPerPage
|
||||
{
|
||||
get => _dataCountPerPage;
|
||||
set
|
||||
{
|
||||
if (_dataCountPerPage != value)
|
||||
{
|
||||
_dataCountPerPage = value;
|
||||
OnPropertyChanged(nameof(DataCountPerPage));
|
||||
OnPropertyChanged(nameof(MaxPageCount));
|
||||
UpdatePagination(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void UpdatePagination(int type)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (type == 1)
|
||||
{
|
||||
DgScanMain_Pagination = new ObservableCollection<SCAN_MAIN>(
|
||||
DgScanMain.Skip((PageIndex - 1) * DataCountPerPage).Take(DataCountPerPage)
|
||||
);
|
||||
}
|
||||
else if (type == 2)
|
||||
{
|
||||
string sql = "select * from SCAN_MIAN";
|
||||
switch (DataCountPageTimeSelect)
|
||||
{
|
||||
case "当天":
|
||||
sql += " WHERE time >= CAST(GETDATE() AS DATE)";
|
||||
break;
|
||||
case "近三天":
|
||||
sql += " WHERE time >= DATEADD(DAY, -3, GETDATE())";
|
||||
break;
|
||||
case "近三十天":
|
||||
sql += " WHERE time >= DATEADD(DAY, -30, GETDATE())";
|
||||
break;
|
||||
}
|
||||
sql += " order by time desc";
|
||||
|
||||
DataView dv = DbHelperSQL.Query(sql).Tables[0].DefaultView;
|
||||
DgScanMain = Common.ConvertDataViewToObservableCollection<SCAN_MAIN>(dv);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 页面切换
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
public void Pagination_PageUpdated(object sender, HandyControl.Data.FunctionEventArgs<int> e)
|
||||
{
|
||||
try
|
||||
{
|
||||
PageIndex = e.Info;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 每页显示多少数据
|
||||
/// </summary>
|
||||
private int[] _dataCountPageNumber = { 10, 30, 60, 100, 200, 300 };
|
||||
public int[] DataCountPageNumber
|
||||
{
|
||||
get => _dataCountPageNumber;
|
||||
set
|
||||
{
|
||||
if (_dataCountPageNumber != value)
|
||||
{
|
||||
_dataCountPageNumber = value;
|
||||
OnPropertyChanged(nameof(DataCountPageNumber));
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 查找近几天的
|
||||
/// </summary>
|
||||
private string[] _dataCountPageTime = { "全部时间","当天", "近三天", "近三十天" };
|
||||
public string[] DataCountPageTime
|
||||
{
|
||||
get => _dataCountPageTime;
|
||||
set
|
||||
{
|
||||
if (_dataCountPageTime != value)
|
||||
{
|
||||
_dataCountPageTime = value;
|
||||
OnPropertyChanged(nameof(DataCountPageTime));
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 查找近几天的 --当前选中的
|
||||
/// </summary>
|
||||
private string _dataCountPageTimeSelect = "全部时间";
|
||||
public string DataCountPageTimeSelect
|
||||
{
|
||||
get => _dataCountPageTimeSelect;
|
||||
set
|
||||
{
|
||||
if (_dataCountPageTimeSelect != value)
|
||||
{
|
||||
_dataCountPageTimeSelect = value;
|
||||
OnPropertyChanged(nameof(DataCountPageTimeSelect));
|
||||
UpdatePagination(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找近几天的
|
||||
/// </summary>
|
||||
private SCAN_MAIN_IMG _selectMain;
|
||||
public SCAN_MAIN_IMG SelectMain
|
||||
{
|
||||
get => _selectMain;
|
||||
set
|
||||
{
|
||||
if (_selectMain != value)
|
||||
{
|
||||
_selectMain = value;
|
||||
OnPropertyChanged(nameof(SelectMain));
|
||||
}
|
||||
}
|
||||
}
|
||||
public void UpdateSelectMain(SCAN_MAIN mAIN)
|
||||
{
|
||||
if (SelectMain != null)
|
||||
{
|
||||
// 释放旧的 BitmapImage 资源
|
||||
DisposeBitmapImage(SelectMain.img_after);
|
||||
DisposeBitmapImage(SelectMain.img);
|
||||
}
|
||||
|
||||
var newMain = new SCAN_MAIN_IMG
|
||||
{
|
||||
id = mAIN.id,
|
||||
goodcode = mAIN.goodcode,
|
||||
time = mAIN.time,
|
||||
ex = mAIN.ex,
|
||||
img_after = CreateBitmapImage(mAIN.img_after),
|
||||
img = CreateBitmapImage(mAIN.img)
|
||||
};
|
||||
|
||||
SelectMain = newMain; // 直接替换对象
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 释放 BitmapImage 资源
|
||||
/// </summary>
|
||||
/// <param name="bitmapImage"></param>
|
||||
private void DisposeBitmapImage(BitmapImage bitmapImage)
|
||||
{
|
||||
if (bitmapImage != null)
|
||||
{
|
||||
bitmapImage.StreamSource?.Dispose();
|
||||
bitmapImage.StreamSource = null;
|
||||
bitmapImage = null; // 彻底释放对象
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建 BitmapImage
|
||||
/// </summary>
|
||||
/// <param name="imagePath">图片路径</param>
|
||||
/// <returns>返回新的 BitmapImage</returns>
|
||||
private BitmapImage CreateBitmapImage(string imagePath)
|
||||
{
|
||||
var newBitmap = new BitmapImage();
|
||||
newBitmap.BeginInit();
|
||||
newBitmap.CacheOption = BitmapCacheOption.OnLoad; // 立刻加载到内存,释放文件句柄
|
||||
newBitmap.DecodePixelWidth = 800; // 限制宽度
|
||||
newBitmap.DecodePixelHeight = 620; // 限制高度
|
||||
newBitmap.UriSource = new Uri(imagePath, UriKind.Absolute);
|
||||
newBitmap.EndInit();
|
||||
newBitmap.Freeze(); // 让其在 UI 线程外使用
|
||||
return newBitmap;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
BIN
AnQing/bin/Debug/AnQing.exe
Normal file
25
AnQing/bin/Debug/AnQing.exe.config
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
|
||||
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
||||
</configSections>
|
||||
<connectionStrings>
|
||||
<add name="ConnectionString" connectionString="server=.;uid=sa;pwd=rgd.123;database=AnQing;"/>
|
||||
</connectionStrings>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
|
||||
</startup>
|
||||
<appSettings>
|
||||
<add key="VideoIP1" value="192.168.0.202" />
|
||||
<add key="VideoIP2" value="192.168.0.202" />
|
||||
<add key="ImagePath" value="192.168.0.202" />
|
||||
</appSettings>
|
||||
<entityFramework>
|
||||
<providers>
|
||||
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
|
||||
<provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
|
||||
</providers>
|
||||
</entityFramework>
|
||||
|
||||
</configuration>
|
BIN
AnQing/bin/Debug/AnQing.pdb
Normal file
BIN
AnQing/bin/Debug/EPPlus.Interfaces.dll
Normal file
BIN
AnQing/bin/Debug/EPPlus.System.Drawing.dll
Normal file
BIN
AnQing/bin/Debug/EPPlus.dll
Normal file
72762
AnQing/bin/Debug/EPPlus.xml
Normal file
BIN
AnQing/bin/Debug/EntityFramework.SqlServer.dll
Normal file
2156
AnQing/bin/Debug/EntityFramework.SqlServer.xml
Normal file
BIN
AnQing/bin/Debug/EntityFramework.dll
Normal file
54121
AnQing/bin/Debug/EntityFramework.xml
Normal file
BIN
AnQing/bin/Debug/HandyControl.dll
Normal file
3413
AnQing/bin/Debug/HandyControl.xml
Normal file
After Width: | Height: | Size: 281 KiB |
After Width: | Height: | Size: 245 KiB |
After Width: | Height: | Size: 239 KiB |
After Width: | Height: | Size: 238 KiB |
After Width: | Height: | Size: 250 KiB |
After Width: | Height: | Size: 250 KiB |
After Width: | Height: | Size: 250 KiB |
After Width: | Height: | Size: 245 KiB |
After Width: | Height: | Size: 277 KiB |
After Width: | Height: | Size: 251 KiB |
After Width: | Height: | Size: 270 KiB |
After Width: | Height: | Size: 245 KiB |
After Width: | Height: | Size: 245 KiB |
After Width: | Height: | Size: 247 KiB |
After Width: | Height: | Size: 244 KiB |
After Width: | Height: | Size: 246 KiB |
After Width: | Height: | Size: 250 KiB |
After Width: | Height: | Size: 250 KiB |
After Width: | Height: | Size: 275 KiB |
After Width: | Height: | Size: 247 KiB |
After Width: | Height: | Size: 251 KiB |
After Width: | Height: | Size: 249 KiB |
After Width: | Height: | Size: 247 KiB |
After Width: | Height: | Size: 250 KiB |
After Width: | Height: | Size: 249 KiB |
After Width: | Height: | Size: 245 KiB |
BIN
AnQing/bin/Debug/Microsoft.IO.RecyclableMemoryStream.dll
Normal file
1523
AnQing/bin/Debug/Microsoft.IO.RecyclableMemoryStream.xml
Normal file
BIN
AnQing/bin/Debug/Microsoft.WindowsAPICodePack.Shell.dll
Normal file
25496
AnQing/bin/Debug/Microsoft.WindowsAPICodePack.Shell.xml
Normal file
BIN
AnQing/bin/Debug/Microsoft.WindowsAPICodePack.dll
Normal file
2934
AnQing/bin/Debug/Microsoft.WindowsAPICodePack.xml
Normal file
BIN
AnQing/bin/Debug/Microsoft.Xaml.Behaviors.dll
Normal file
BIN
AnQing/bin/Debug/Microsoft.Xaml.Behaviors.pdb
Normal file
2400
AnQing/bin/Debug/Microsoft.Xaml.Behaviors.xml
Normal file
BIN
AnQing/bin/Debug/NModbus4.dll
Normal file
2393
AnQing/bin/Debug/NModbus4.xml
Normal file
BIN
AnQing/bin/Debug/Newtonsoft.Json.dll
Normal file
11363
AnQing/bin/Debug/Newtonsoft.Json.xml
Normal file
BIN
AnQing/bin/Debug/System.Buffers.dll
Normal file
38
AnQing/bin/Debug/System.Buffers.xml
Normal file
@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><doc>
|
||||
<assembly>
|
||||
<name>System.Buffers</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="T:System.Buffers.ArrayPool`1">
|
||||
<summary>Provides a resource pool that enables reusing instances of type <see cref="T[]"></see>.</summary>
|
||||
<typeparam name="T">The type of the objects that are in the resource pool.</typeparam>
|
||||
</member>
|
||||
<member name="M:System.Buffers.ArrayPool`1.#ctor">
|
||||
<summary>Initializes a new instance of the <see cref="T:System.Buffers.ArrayPool`1"></see> class.</summary>
|
||||
</member>
|
||||
<member name="M:System.Buffers.ArrayPool`1.Create">
|
||||
<summary>Creates a new instance of the <see cref="T:System.Buffers.ArrayPool`1"></see> class.</summary>
|
||||
<returns>A new instance of the <see cref="System.Buffers.ArrayPool`1"></see> class.</returns>
|
||||
</member>
|
||||
<member name="M:System.Buffers.ArrayPool`1.Create(System.Int32,System.Int32)">
|
||||
<summary>Creates a new instance of the <see cref="T:System.Buffers.ArrayPool`1"></see> class using the specifed configuration.</summary>
|
||||
<param name="maxArrayLength">The maximum length of an array instance that may be stored in the pool.</param>
|
||||
<param name="maxArraysPerBucket">The maximum number of array instances that may be stored in each bucket in the pool. The pool groups arrays of similar lengths into buckets for faster access.</param>
|
||||
<returns>A new instance of the <see cref="System.Buffers.ArrayPool`1"></see> class with the specified configuration.</returns>
|
||||
</member>
|
||||
<member name="M:System.Buffers.ArrayPool`1.Rent(System.Int32)">
|
||||
<summary>Retrieves a buffer that is at least the requested length.</summary>
|
||||
<param name="minimumLength">The minimum length of the array.</param>
|
||||
<returns>An array of type <see cref="T[]"></see> that is at least <paramref name="minimumLength">minimumLength</paramref> in length.</returns>
|
||||
</member>
|
||||
<member name="M:System.Buffers.ArrayPool`1.Return(`0[],System.Boolean)">
|
||||
<summary>Returns an array to the pool that was previously obtained using the <see cref="M:System.Buffers.ArrayPool`1.Rent(System.Int32)"></see> method on the same <see cref="T:System.Buffers.ArrayPool`1"></see> instance.</summary>
|
||||
<param name="array">A buffer to return to the pool that was previously obtained using the <see cref="M:System.Buffers.ArrayPool`1.Rent(System.Int32)"></see> method.</param>
|
||||
<param name="clearArray">Indicates whether the contents of the buffer should be cleared before reuse. If <paramref name="clearArray">clearArray</paramref> is set to true, and if the pool will store the buffer to enable subsequent reuse, the <see cref="M:System.Buffers.ArrayPool`1.Return(`0[],System.Boolean)"></see> method will clear the <paramref name="array">array</paramref> of its contents so that a subsequent caller using the <see cref="M:System.Buffers.ArrayPool`1.Rent(System.Int32)"></see> method will not see the content of the previous caller. If <paramref name="clearArray">clearArray</paramref> is set to false or if the pool will release the buffer, the array&#39;s contents are left unchanged.</param>
|
||||
</member>
|
||||
<member name="P:System.Buffers.ArrayPool`1.Shared">
|
||||
<summary>Gets a shared <see cref="T:System.Buffers.ArrayPool`1"></see> instance.</summary>
|
||||
<returns>A shared <see cref="System.Buffers.ArrayPool`1"></see> instance.</returns>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|