上传代码

This commit is contained in:
2026-04-18 18:14:12 +08:00
commit d5e183e551
1472 changed files with 50231 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
{
"ExpandedNodes": [
"",
"\\头罩视野",
"\\头罩视野\\Views"
],
"SelectedNode": "\\头罩视野\\Views\\ChangeLanguage.xaml",
"PreviewInSolutionExplorer": false
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,115 @@
{
"Version": 1,
"WorkspaceRootPath": "D:\\work\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u5934\u7F69\u89C6\u91CEslove\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{FF64DB7C-FA2D-C0B1-BF7C-81E4A64B42BB}|\u5934\u7F69\u89C6\u91CE\\\u5934\u7F69\u89C6\u91CE.csproj|d:\\work\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u5934\u7F69\u89C6\u91CEslove\\\u5934\u7F69\u89C6\u91CE\\views\\visidata.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}",
"RelativeMoniker": "D:0:0:{FF64DB7C-FA2D-C0B1-BF7C-81E4A64B42BB}|\u5934\u7F69\u89C6\u91CE\\\u5934\u7F69\u89C6\u91CE.csproj|solutionrelative:\u5934\u7F69\u89C6\u91CE\\views\\visidata.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}"
},
{
"AbsoluteMoniker": "D:0:0:{FF64DB7C-FA2D-C0B1-BF7C-81E4A64B42BB}|\u5934\u7F69\u89C6\u91CE\\\u5934\u7F69\u89C6\u91CE.csproj|d:\\work\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u5934\u7F69\u89C6\u91CEslove\\\u5934\u7F69\u89C6\u91CE\\views\\pagetest.xaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{FF64DB7C-FA2D-C0B1-BF7C-81E4A64B42BB}|\u5934\u7F69\u89C6\u91CE\\\u5934\u7F69\u89C6\u91CE.csproj|solutionrelative:\u5934\u7F69\u89C6\u91CE\\views\\pagetest.xaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{FF64DB7C-FA2D-C0B1-BF7C-81E4A64B42BB}|\u5934\u7F69\u89C6\u91CE\\\u5934\u7F69\u89C6\u91CE.csproj|d:\\work\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u5934\u7F69\u89C6\u91CEslove\\\u5934\u7F69\u89C6\u91CE\\views\\pagetest.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}",
"RelativeMoniker": "D:0:0:{FF64DB7C-FA2D-C0B1-BF7C-81E4A64B42BB}|\u5934\u7F69\u89C6\u91CE\\\u5934\u7F69\u89C6\u91CE.csproj|solutionrelative:\u5934\u7F69\u89C6\u91CE\\views\\pagetest.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}"
}
],
"DocumentGroupContainers": [
{
"Orientation": 1,
"VerticalTabListWidth": 222,
"DocumentGroups": [
{
"DockedHeight": 80,
"SelectedChildIndex": 4,
"Children": [
{
"$type": "Bookmark",
"Name": "ST:0:0:{d78612c7-9962-4b83-95d9-268046dad23a}"
},
{
"$type": "Bookmark",
"Name": "ST:0:0:{34e76e81-ee4a-11d0-ae2e-00a0c90fffc3}"
},
{
"$type": "Document",
"DocumentIndex": 2,
"Title": "PageTest.xaml",
"DocumentMoniker": "D:\\work\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u5934\u7F69\u89C6\u91CEslove\\\u5934\u7F69\u89C6\u91CE\\Views\\PageTest.xaml",
"RelativeDocumentMoniker": "\u5934\u7F69\u89C6\u91CE\\Views\\PageTest.xaml",
"ToolTip": "D:\\work\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u5934\u7F69\u89C6\u91CEslove\\\u5934\u7F69\u89C6\u91CE\\Views\\PageTest.xaml",
"RelativeToolTip": "\u5934\u7F69\u89C6\u91CE\\Views\\PageTest.xaml",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003549|",
"WhenOpened": "2026-04-18T09:50:52.31Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 1,
"Title": "PageTest.xaml.cs",
"DocumentMoniker": "D:\\work\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u5934\u7F69\u89C6\u91CEslove\\\u5934\u7F69\u89C6\u91CE\\Views\\PageTest.xaml.cs",
"RelativeDocumentMoniker": "\u5934\u7F69\u89C6\u91CE\\Views\\PageTest.xaml.cs",
"ToolTip": "D:\\work\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u5934\u7F69\u89C6\u91CEslove\\\u5934\u7F69\u89C6\u91CE\\Views\\PageTest.xaml.cs",
"RelativeToolTip": "\u5934\u7F69\u89C6\u91CE\\Views\\PageTest.xaml.cs",
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2026-04-18T08:57:40.567Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "VisiData.xaml",
"DocumentMoniker": "D:\\work\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u5934\u7F69\u89C6\u91CEslove\\\u5934\u7F69\u89C6\u91CE\\Views\\VisiData.xaml",
"RelativeDocumentMoniker": "\u5934\u7F69\u89C6\u91CE\\Views\\VisiData.xaml",
"ToolTip": "D:\\work\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u5934\u7F69\u89C6\u91CEslove\\\u5934\u7F69\u89C6\u91CE\\Views\\VisiData.xaml",
"RelativeToolTip": "\u5934\u7F69\u89C6\u91CE\\Views\\VisiData.xaml",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003549|",
"WhenOpened": "2026-04-18T08:48:39.337Z",
"EditorCaption": ""
}
]
},
{
"DockedHeight": 320,
"SelectedChildIndex": -1,
"Children": [
{
"$type": "Bookmark",
"Name": "ST:0:0:{3ae79031-e1bc-11d0-8f78-00a0c9110057}"
},
{
"$type": "Bookmark",
"Name": "ST:131:0:{116d2292-e37d-41cd-a077-ebacac4c8cc4}"
},
{
"$type": "Bookmark",
"Name": "ST:130:0:{1fc202d4-d401-403c-9834-5b218574bb67}"
},
{
"$type": "Bookmark",
"Name": "ST:131:0:{1fc202d4-d401-403c-9834-5b218574bb67}"
},
{
"$type": "Bookmark",
"Name": "ST:133:0:{1fc202d4-d401-403c-9834-5b218574bb67}"
},
{
"$type": "Bookmark",
"Name": "ST:4:0:{34c7837f-3b3a-449c-bdf0-bdad86cbaf4a}"
},
{
"$type": "Bookmark",
"Name": "ST:0:0:{aa2115a1-9712-457b-9047-dbb71ca2cdd2}"
},
{
"$type": "Bookmark",
"Name": "ST:0:0:{eefa5220-e298-11d0-8f78-00a0c9110057}"
}
]
}
]
}
]
}

View File

@@ -0,0 +1,115 @@
{
"Version": 1,
"WorkspaceRootPath": "D:\\work\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u5934\u7F69\u89C6\u91CEslove\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{FF64DB7C-FA2D-C0B1-BF7C-81E4A64B42BB}|\u5934\u7F69\u89C6\u91CE\\\u5934\u7F69\u89C6\u91CE.csproj|d:\\work\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u5934\u7F69\u89C6\u91CEslove\\\u5934\u7F69\u89C6\u91CE\\views\\visidata.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}",
"RelativeMoniker": "D:0:0:{FF64DB7C-FA2D-C0B1-BF7C-81E4A64B42BB}|\u5934\u7F69\u89C6\u91CE\\\u5934\u7F69\u89C6\u91CE.csproj|solutionrelative:\u5934\u7F69\u89C6\u91CE\\views\\visidata.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}"
},
{
"AbsoluteMoniker": "D:0:0:{FF64DB7C-FA2D-C0B1-BF7C-81E4A64B42BB}|\u5934\u7F69\u89C6\u91CE\\\u5934\u7F69\u89C6\u91CE.csproj|d:\\work\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u5934\u7F69\u89C6\u91CEslove\\\u5934\u7F69\u89C6\u91CE\\views\\pagetest.xaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{FF64DB7C-FA2D-C0B1-BF7C-81E4A64B42BB}|\u5934\u7F69\u89C6\u91CE\\\u5934\u7F69\u89C6\u91CE.csproj|solutionrelative:\u5934\u7F69\u89C6\u91CE\\views\\pagetest.xaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{FF64DB7C-FA2D-C0B1-BF7C-81E4A64B42BB}|\u5934\u7F69\u89C6\u91CE\\\u5934\u7F69\u89C6\u91CE.csproj|d:\\work\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u5934\u7F69\u89C6\u91CEslove\\\u5934\u7F69\u89C6\u91CE\\views\\pagetest.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}",
"RelativeMoniker": "D:0:0:{FF64DB7C-FA2D-C0B1-BF7C-81E4A64B42BB}|\u5934\u7F69\u89C6\u91CE\\\u5934\u7F69\u89C6\u91CE.csproj|solutionrelative:\u5934\u7F69\u89C6\u91CE\\views\\pagetest.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}"
}
],
"DocumentGroupContainers": [
{
"Orientation": 1,
"VerticalTabListWidth": 222,
"DocumentGroups": [
{
"DockedHeight": 80,
"SelectedChildIndex": 4,
"Children": [
{
"$type": "Bookmark",
"Name": "ST:0:0:{d78612c7-9962-4b83-95d9-268046dad23a}"
},
{
"$type": "Bookmark",
"Name": "ST:0:0:{34e76e81-ee4a-11d0-ae2e-00a0c90fffc3}"
},
{
"$type": "Document",
"DocumentIndex": 2,
"Title": "PageTest.xaml",
"DocumentMoniker": "D:\\work\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u5934\u7F69\u89C6\u91CEslove\\\u5934\u7F69\u89C6\u91CE\\Views\\PageTest.xaml",
"RelativeDocumentMoniker": "\u5934\u7F69\u89C6\u91CE\\Views\\PageTest.xaml",
"ToolTip": "D:\\work\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u5934\u7F69\u89C6\u91CEslove\\\u5934\u7F69\u89C6\u91CE\\Views\\PageTest.xaml",
"RelativeToolTip": "\u5934\u7F69\u89C6\u91CE\\Views\\PageTest.xaml",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003549|",
"WhenOpened": "2026-04-18T09:50:52.31Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 1,
"Title": "PageTest.xaml.cs",
"DocumentMoniker": "D:\\work\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u5934\u7F69\u89C6\u91CEslove\\\u5934\u7F69\u89C6\u91CE\\Views\\PageTest.xaml.cs",
"RelativeDocumentMoniker": "\u5934\u7F69\u89C6\u91CE\\Views\\PageTest.xaml.cs",
"ToolTip": "D:\\work\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u5934\u7F69\u89C6\u91CEslove\\\u5934\u7F69\u89C6\u91CE\\Views\\PageTest.xaml.cs",
"RelativeToolTip": "\u5934\u7F69\u89C6\u91CE\\Views\\PageTest.xaml.cs",
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2026-04-18T08:57:40.567Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "VisiData.xaml",
"DocumentMoniker": "D:\\work\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u5934\u7F69\u89C6\u91CEslove\\\u5934\u7F69\u89C6\u91CE\\Views\\VisiData.xaml",
"RelativeDocumentMoniker": "\u5934\u7F69\u89C6\u91CE\\Views\\VisiData.xaml",
"ToolTip": "D:\\work\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u5934\u7F69\u89C6\u91CEslove\\\u5934\u7F69\u89C6\u91CE\\Views\\VisiData.xaml",
"RelativeToolTip": "\u5934\u7F69\u89C6\u91CE\\Views\\VisiData.xaml",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003549|",
"WhenOpened": "2026-04-18T08:48:39.337Z",
"EditorCaption": ""
}
]
},
{
"DockedHeight": 320,
"SelectedChildIndex": -1,
"Children": [
{
"$type": "Bookmark",
"Name": "ST:0:0:{3ae79031-e1bc-11d0-8f78-00a0c9110057}"
},
{
"$type": "Bookmark",
"Name": "ST:131:0:{116d2292-e37d-41cd-a077-ebacac4c8cc4}"
},
{
"$type": "Bookmark",
"Name": "ST:130:0:{1fc202d4-d401-403c-9834-5b218574bb67}"
},
{
"$type": "Bookmark",
"Name": "ST:131:0:{1fc202d4-d401-403c-9834-5b218574bb67}"
},
{
"$type": "Bookmark",
"Name": "ST:133:0:{1fc202d4-d401-403c-9834-5b218574bb67}"
},
{
"$type": "Bookmark",
"Name": "ST:4:0:{34c7837f-3b3a-449c-bdf0-bdad86cbaf4a}"
},
{
"$type": "Bookmark",
"Name": "ST:0:0:{aa2115a1-9712-457b-9047-dbb71ca2cdd2}"
},
{
"$type": "Bookmark",
"Name": "ST:0:0:{eefa5220-e298-11d0-8f78-00a0c9110057}"
}
]
}
]
}
]
}

View File

@@ -0,0 +1,9 @@
{
"ExpandedNodes": [
"",
"\\ViewModels",
"\\Views"
],
"SelectedNode": "\\MainWindow.xaml",
"PreviewInSolutionExplorer": false
}

Binary file not shown.

View File

@@ -0,0 +1,90 @@
{
"Version": 1,
"WorkspaceRootPath": "D:\\work\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u5934\u7F69\u89C6\u91CEslove\\\u5934\u7F69\u89C6\u91CE\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|D:\\work\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u5934\u7F69\u89C6\u91CEslove\\\u5934\u7F69\u89C6\u91CE\\MainWindow.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:MainWindow.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|D:\\work\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u5934\u7F69\u89C6\u91CEslove\\\u5934\u7F69\u89C6\u91CE\\MainWindow.xaml||{FA3CD31E-987B-443A-9B81-186104E8DAC1}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:MainWindow.xaml||{FA3CD31E-987B-443A-9B81-186104E8DAC1}"
}
],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 204,
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 9,
"Children": [
{
"$type": "Bookmark",
"Name": "ST:0:0:{3ae79031-e1bc-11d0-8f78-00a0c9110057}"
},
{
"$type": "Bookmark",
"Name": "ST:131:0:{116d2292-e37d-41cd-a077-ebacac4c8cc4}"
},
{
"$type": "Bookmark",
"Name": "ST:130:0:{1fc202d4-d401-403c-9834-5b218574bb67}"
},
{
"$type": "Bookmark",
"Name": "ST:131:0:{1fc202d4-d401-403c-9834-5b218574bb67}"
},
{
"$type": "Bookmark",
"Name": "ST:133:0:{1fc202d4-d401-403c-9834-5b218574bb67}"
},
{
"$type": "Bookmark",
"Name": "ST:0:0:{d78612c7-9962-4b83-95d9-268046dad23a}"
},
{
"$type": "Bookmark",
"Name": "ST:4:0:{34c7837f-3b3a-449c-bdf0-bdad86cbaf4a}"
},
{
"$type": "Bookmark",
"Name": "ST:0:0:{aa2115a1-9712-457b-9047-dbb71ca2cdd2}"
},
{
"$type": "Bookmark",
"Name": "ST:0:0:{eefa5220-e298-11d0-8f78-00a0c9110057}"
},
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "MainWindow.xaml",
"DocumentMoniker": "D:\\work\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u5934\u7F69\u89C6\u91CEslove\\\u5934\u7F69\u89C6\u91CE\\MainWindow.xaml",
"RelativeDocumentMoniker": "MainWindow.xaml",
"ToolTip": "D:\\work\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u5934\u7F69\u89C6\u91CEslove\\\u5934\u7F69\u89C6\u91CE\\MainWindow.xaml",
"RelativeToolTip": "MainWindow.xaml",
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAgAAAAfAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003549|",
"WhenOpened": "2026-04-16T03:17:50.689Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 1,
"Title": "MainWindow.xaml",
"DocumentMoniker": "D:\\work\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u5934\u7F69\u89C6\u91CEslove\\\u5934\u7F69\u89C6\u91CE\\MainWindow.xaml",
"RelativeDocumentMoniker": "MainWindow.xaml",
"ToolTip": "D:\\work\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u5934\u7F69\u89C6\u91CEslove\\\u5934\u7F69\u89C6\u91CE\\MainWindow.xaml",
"RelativeToolTip": "MainWindow.xaml",
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003549|",
"WhenOpened": "2026-04-16T03:17:47.407Z",
"EditorCaption": ""
}
]
}
]
}
]
}

View File

@@ -0,0 +1,94 @@
{
"Version": 1,
"WorkspaceRootPath": "D:\\work\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u5934\u7F69\u89C6\u91CEslove\\\u5934\u7F69\u89C6\u91CE\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|D:\\work\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u5934\u7F69\u89C6\u91CEslove\\\u5934\u7F69\u89C6\u91CE\\MainWindow.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:MainWindow.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|D:\\work\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u5934\u7F69\u89C6\u91CEslove\\\u5934\u7F69\u89C6\u91CE\\MainWindow.xaml||{FA3CD31E-987B-443A-9B81-186104E8DAC1}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:MainWindow.xaml||{FA3CD31E-987B-443A-9B81-186104E8DAC1}"
}
],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 204,
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 0,
"Children": [
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "MainWindow.xaml",
"DocumentMoniker": "D:\\work\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u5934\u7F69\u89C6\u91CEslove\\\u5934\u7F69\u89C6\u91CE\\MainWindow.xaml",
"RelativeDocumentMoniker": "MainWindow.xaml",
"ToolTip": "D:\\work\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u5934\u7F69\u89C6\u91CEslove\\\u5934\u7F69\u89C6\u91CE\\MainWindow.xaml",
"RelativeToolTip": "MainWindow.xaml",
"ViewState": "AgIAAAAAAAAAAAAAAAAAAA8AAAAhAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003549|",
"WhenOpened": "2026-04-16T03:17:50.689Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 1,
"Title": "MainWindow.xaml",
"DocumentMoniker": "D:\\work\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u5934\u7F69\u89C6\u91CEslove\\\u5934\u7F69\u89C6\u91CE\\MainWindow.xaml",
"RelativeDocumentMoniker": "MainWindow.xaml",
"ToolTip": "D:\\work\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u5934\u7F69\u89C6\u91CEslove\\\u5934\u7F69\u89C6\u91CE\\MainWindow.xaml",
"RelativeToolTip": "MainWindow.xaml",
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003549|",
"WhenOpened": "2026-04-16T03:17:47.407Z",
"EditorCaption": ""
},
{
"$type": "Bookmark",
"Name": "ST:0:0:{cce594b6-0c39-4442-ba28-10c64ac7e89f}"
},
{
"$type": "Bookmark",
"Name": "ST:0:0:{3ae79031-e1bc-11d0-8f78-00a0c9110057}"
},
{
"$type": "Bookmark",
"Name": "ST:131:0:{116d2292-e37d-41cd-a077-ebacac4c8cc4}"
},
{
"$type": "Bookmark",
"Name": "ST:130:0:{1fc202d4-d401-403c-9834-5b218574bb67}"
},
{
"$type": "Bookmark",
"Name": "ST:131:0:{1fc202d4-d401-403c-9834-5b218574bb67}"
},
{
"$type": "Bookmark",
"Name": "ST:133:0:{1fc202d4-d401-403c-9834-5b218574bb67}"
},
{
"$type": "Bookmark",
"Name": "ST:0:0:{d78612c7-9962-4b83-95d9-268046dad23a}"
},
{
"$type": "Bookmark",
"Name": "ST:4:0:{34c7837f-3b3a-449c-bdf0-bdad86cbaf4a}"
},
{
"$type": "Bookmark",
"Name": "ST:0:0:{aa2115a1-9712-457b-9047-dbb71ca2cdd2}"
},
{
"$type": "Bookmark",
"Name": "ST:0:0:{eefa5220-e298-11d0-8f78-00a0c9110057}"
}
]
}
]
}
]
}

View File

@@ -0,0 +1,14 @@
<Application x:Class="头罩视野.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:头罩视野"
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.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>

View File

@@ -0,0 +1,14 @@
using System.Configuration;
using System.Data;
using System.Windows;
namespace
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}

View File

@@ -0,0 +1,10 @@
using System.Windows;
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]

View File

@@ -0,0 +1,30 @@
using System.Collections.Generic;
using System.Windows.Controls;
public static class NavigationHelper
{
public static Frame MainFrame { get; set; }
private static Stack<Page> _history = new Stack<Page>();
// 跳转页面
public static void NavigateTo(Page page)
{
if (MainFrame.Content != null)
_history.Push( MainFrame.Content as Page);
MainFrame.Content = page;
}
// 返回上一页
public static void GoBack()
{
System.Diagnostics.Debug.WriteLine("页面加载了55555");
if (_history.Count > 0)
{
System.Diagnostics.Debug.WriteLine("页面加载了4444");
MainFrame.Content = _history.Pop();
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 KiB

View File

@@ -0,0 +1,77 @@
<Window x:Class="头罩视野.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:local="clr-namespace:头罩视野"
mc:Ignorable="d"
Background="#FFE6F2FF"
Title="MainWindow" Height="768" Width="1024">
<Window.Resources>
<Style x:Key="TabButtonStyle" TargetType="Button">
<Setter Property="Background" Value="#3498DB"/>
<Setter Property="FontSize" Value="20"/>
<Setter Property="Foreground" Value="#fff"/>
<Setter Property="Height" Value="70"/>
<Setter Property="Width" Value="300"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="BorderBrush" Value="#fff"/>
</Style>
</Window.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="507*"/>
<ColumnDefinition Width="5*"/>
</Grid.ColumnDefinitions>
<!-- 背景图片/渐变 -->
<Grid.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="#FF6A95D1" Offset="0"/>
<GradientStop Color="#FF87CEFA" Offset="0.5"/>
<GradientStop Color="#FFE0F7FA" Offset="1"/>
</LinearGradientBrush>
</Grid.Background>
<!-- 世界地图装饰层 -->
<Image Source="/Images/bmg.png" Opacity="1" Width="800"
Margin="0,200,0,0"/>
<!-- 波浪装饰 -->
<Path Data="M0,300 Q250,100 500,300 T1000,300 L1000,600 L0,600 Z"
Fill="White" Opacity="0.2" Stroke="White" StrokeThickness="1" Grid.ColumnSpan="2"/>
<Path Data="M0,350 Q250,150 500,350 T1000,350 L1000,600 L0,600 Z"
Fill="White" Opacity="0.15" Stroke="White" StrokeThickness="1" Grid.ColumnSpan="2"/>
<!-- 主标题区 -->
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Left" Margin="234,0,0,0">
<!-- 中文标题 -->
<TextBlock x:Name="TX_1" Text="头罩视野测试仪"
FontSize="48" FontWeight="Bold"
Foreground="White"
HorizontalAlignment="Center"
Margin="0,-160,0,20"/>
<!-- 英文标题 -->
<TextBlock x:Name="TX_0" Text="Head Hood field of view tester"
FontSize="36" FontWeight="Bold"
Foreground="White"
HorizontalAlignment="Center"
Margin="0,-75,0,20"/>
</StackPanel>
<!--<Button Content="跳转到页面" Click="Button_Click" FontSize="16" Width="120" Height="40" Margin="0,300,0,0"/>-->
<Grid Grid.Row="1" >
<Button Style="{StaticResource TabButtonStyle}" Grid.Column="0" Foreground="#C56DE4" Background="Transparent" BorderThickness="0" Content="点击我进入项目体验吧~"
Click="GoRecord" />
</Grid>
<Grid Grid.Row="2" >
<Button Style="{StaticResource TabButtonStyle}" Width="100" Height="100" VerticalAlignment="Bottom"
HorizontalAlignment="Right" Grid.Column="0" Background="Transparent" BorderThickness="0"
Content="" Click="GoVisiPage"/>
</Grid>
<Frame x:Name="MainFrame" NavigationUIVisibility="Hidden"/>
</Grid>
</Window>

View File

@@ -0,0 +1,36 @@
//using DateRecordView;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using .Views;
namespace
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
//MainFrame.Content = new Views.ChangeLanguage();
}
//private void GoHome(object s, RoutedEventArgs e) => MainFrame.Content = new Views.ChangeLanguage();
private void GoTest(object s, RoutedEventArgs e) => MainFrame.Content = new Views.PageTest();
private void GoRecord(object s, RoutedEventArgs e) => MainFrame.Content = new Views.RecordDate();
private void GoView(object s, RoutedEventArgs e) => MainFrame.Content = new Views.RecordPage();
private void GoVisiPage(object s, RoutedEventArgs e) => MainFrame.Content = new Views.VisiData();
//NavigationService.Navigate(new Views.RecordDate()); 页面相互跳转
}
}

View File

@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace .Services
{
public class BoolSignal
{
private bool _previousValue;
public event Action OnRisingEdge;
// bool value = true;
public bool Value { get; set; }
public void CheckRisingEdge()
{
if (Value && !_previousValue)
{
OnRisingEdge?.Invoke();
}
_previousValue = Value;
}
}
}

View File

@@ -0,0 +1,74 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace .Services
{
public class DataChange
{
/// <summary>
/// ushort转为float类型
/// </summary>
/// <param name="P1"></param>
/// <param name="P2"></param>
/// <returns>float型数据</returns>
public float UshortToFloat(ushort P1, ushort P2)
{
int intSign, intSignRest, intExponent, intExponentRest;
float faResult, faDigit;
intSign = P1 / 32768;
intSignRest = P1 % 32768;
intExponent = intSignRest / 128;
intExponentRest = intSignRest % 128;
faDigit = (float)(intExponentRest * 65536 + P2) / 8388608;
faResult = (float)Math.Pow(-1, intSign) * (float)Math.Pow(2, intExponent - 127) * (faDigit + 1);
return faResult;
}
/// <summary>
/// ushort转为int类型
/// </summary>
/// <param name="u1"></param>
/// <param name="u2"></param>
/// <returns>返回int型数据</returns>
public int UshortToInt1(ushort u1, ushort u2)
{
ushort[] maidong = new ushort[2] { u1, u2 };
byte[] bytes = new byte[maidong.Length * 2];
Buffer.BlockCopy(maidong, 0, bytes, 0, bytes.Length);
int result = BitConverter.ToInt32(bytes, 0);
// 将字节数组转换为32位无符号整数
return result;
}
/// <summary>
/// Float转为Ushort数组发送
/// </summary>
/// <param name="value"></param>
/// <returns>返回ushort数组</returns>
public ushort[] SplitFloatToUShortArray(float value)
{
byte[] floatBytes = BitConverter.GetBytes(value);
ushort[] ushortArray = new ushort[floatBytes.Length / 2];
for (int i = 0, j = 0; i < floatBytes.Length; i += 2, j++)
{
ushortArray[j] = BitConverter.ToUInt16(floatBytes, i);
}
return ushortArray;
}
/// <summary>
/// Int转为ushort数组发送
/// </summary>
/// <param name="res"></param>
/// <returns>返回ushort数组</returns>
public ushort[] intToushorts(int res)
{
ushort ust1 = (ushort)(res >> 16);
ushort ust2 = (ushort)res;
return new ushort[] { ust2, ust1 };
}
}
}

View File

@@ -0,0 +1,151 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace .Services
{
public class ExperData: INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
#region
static string experName = "";
/// <summary>
/// 实验人员
/// </summary>
public string ExperName { get { return experName; } set { experName = value; } }
static string experDate = "";
/// <summary>
/// 实验日期
/// </summary>
public string ExperDate { get { return experDate; } set { experDate = value; } }
static string experNum = "";
/// <summary>
/// 实验编号
/// </summary>
public string ExperNum { get { return experNum; } set { experNum = value; } }
static string experType = " ";
/// <summary>
/// 实验种类
/// </summary>
public string ExperType { get { return experType; } set { experType = value; } }
static float experMaskType = 2.0f;
/// <summary>
/// 口罩类型
/// </summary>
public float ExperMaskType { get { return experMaskType; } set { experMaskType = value; } }
/// <summary>
/// 面罩类型
/// </summary>
static string maskType;
public string MaskType { get { return maskType; } set { maskType = value; } }
static float _yangPinXiShu = 1.0f;
/// <summary>
/// 样品系数
/// </summary>
public float YangPinXiShu { get { return _yangPinXiShu; } set { _yangPinXiShu = value; } }
static string _testStatus = "";
/// <summary>
/// 实验状态
/// </summary>
public string TestStatus { get { return _testStatus; } set { _testStatus = value; } }
static float benDiNongDu = 0.00f;
/// <summary>
/// 本底浓度
/// </summary>
public float BenDiNongDu { get { return benDiNongDu; } set { benDiNongDu = value; } }
static float huanJingWenDu = 0.00f;
/// <summary>
/// 环境温度
/// </summary>
public float HuanJingWenDu { get { return huanJingWenDu; } set { huanJingWenDu = value; } }
static float huanJingShiDu = 0.00f;
/// <summary>
/// 环境湿度
/// </summary>
public float HuanJingShiDu { get { return huanJingShiDu; } set { huanJingShiDu = value; } }
static float o2NongDu = 0.00f;
/// <summary>
/// 环境氧浓度
/// </summary>
public float O2NongDu { get { return o2NongDu; } set { o2NongDu = value; } }
static float cO2NongDu = 0.00f;
/// <summary>
/// 环境C02浓度
/// </summary>
public float CO2NongDu_Indoor { get { return cO2NongDu; } set { cO2NongDu = value; } }
static float inDoor_TSINongDu = 0.00f;
/// <summary>
/// 环境气溶胶浓度
/// </summary>
public float InDoor_TSINongDu { get { return inDoor_TSINongDu; } set { inDoor_TSINongDu = value; } }
static float mask_CO2NongDu = 0.00f;
/// <summary>
/// 口罩内CO2浓度
/// </summary>
public float Mask_CO2NongDu { get { return mask_CO2NongDu; } set { mask_CO2NongDu = value; } }
static float mask_TSINongDu = 0.00f;
/// <summary>
/// 口罩内气溶胶浓度
/// </summary>
public float Mask_TSINongDu { get { return mask_TSINongDu; } set { mask_TSINongDu = value; } }
static float _liuLiang = 0.00f;
/// <summary>
/// 流量
/// </summary>
public float LiuLiang { get { return _liuLiang; } set { _liuLiang = value; } }
static float _xieloulv = 0.00f;
/// <summary>
/// 泄露率
/// </summary>
public float XieLouLv { get { return _xieloulv; } set { _xieloulv = value; } }
#endregion
#region
//单独动作泄露率
public float CumulativeLeakageRate(List<float> inDoor_Tsi,List<float> out_Door_Tsi,float benDiNongdu,float xiShu)
{
if (inDoor_Tsi.Count != 0 && out_Door_Tsi.Count != 0&& benDiNongdu!=0.0f)
{
//计算室内Tsi浓度平均值
float inDoor_Tsi_Avg = inDoor_Tsi.Average();
//计算室外Tsi浓度平均值
float out_Door_Tsi_Avg = out_Door_Tsi.Average();
//计算泄露率
float leakageRate = ((out_Door_Tsi_Avg - inDoor_Tsi_Avg) * xiShu) / benDiNongdu;
return leakageRate;
}
else
{
return 0.00f;
}
}
//全部动作泄露率
public float CumulativeLeakageRate_All(List<float> All_Cv_List)
{
return All_Cv_List.Average();
}
#endregion
}
}

View File

@@ -0,0 +1,223 @@
using Sunny.UI;
using System;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using Modbus.Device;
namespace .Services
{
public class Function
{
ModbusMaster master;
IModbusMaster modbusMaster;
DataChange dc = new DataChange();
public enum ButtonType
{
,
,
,
}
public enum DataType
{
,
}
public Function(ModbusMaster master_in)
{
this.master = master_in;
}
public Function(IModbusMaster modbusMaster)
{
this.modbusMaster = modbusMaster;
}
public void BtnClickFunction(ButtonType buttonType, ushort address)
{
try
{
switch (buttonType)
{
case ButtonType.:
master.WriteSingleCoil(1, address, true);
Thread.Sleep(100);
master.WriteSingleCoil(1, address, false);
Thread.Sleep(100);
break;
case ButtonType.:
if (master.ReadCoils(1, address, 1)[0])
{
master.WriteSingleCoil(1, address, false); Thread.Sleep(100);
}
else
{ master.WriteSingleCoil(1, address, true); Thread.Sleep(100); }
break;
case ButtonType.:
master.WriteSingleCoil(1, address, true);
Thread.Sleep(100);
break;
case ButtonType.:
master.WriteSingleCoil(1, address, false);
Thread.Sleep(100);
break;
default:
break;
}
}
catch (Exception ex)
{
}
}
public void BtnClickFunctionForNew(ButtonType buttonType, ushort address)
{
try
{
switch (buttonType)
{
case ButtonType.:
modbusMaster.WriteSingleCoil(1, address, true);
Thread.Sleep(100);
modbusMaster.WriteSingleCoil(1, address, false);
Thread.Sleep(100);
break;
case ButtonType.:
if (modbusMaster.ReadCoils(1, address, 1)[0])
{
modbusMaster.WriteSingleCoil(1, address, false); Thread.Sleep(100);
}
else
{ modbusMaster.WriteSingleCoil(1, address, true); Thread.Sleep(100); }
break;
case ButtonType.:
modbusMaster.WriteSingleCoil(1, address, true);
Thread.Sleep(100);
break;
case ButtonType.:
modbusMaster.WriteSingleCoil(1, address, false);
Thread.Sleep(100);
break;
default:
break;
}
}
catch (Exception ex)
{
}
}
public void WriteToPLC(string inPutValue, ushort address, DataType dataType)
{
try
{
switch (dataType)
{
case DataType.:
double value = inPutValue.ToDouble();
if (UIInputDialog.ShowInputDoubleDialog(ref value, UIStyle.Inherited, desc: "请输入值", showMask: false))
{
master.WriteMultipleRegisters(1, address, dc.SplitFloatToUShortArray((float)value));
}
break;
case DataType.:
int value_int = inPutValue.ToInt();
if (UIInputDialog.ShowInputIntegerDialog(ref value_int, UIStyle.Inherited, desc: "请输入数据:"))
{
master.WriteMultipleRegisters(1, address, dc.intToushorts(value_int));
}
break;
default:
break;
}
}
catch (Exception ex)
{
MessageBox.Show("操作失败!" + "\n" + "\n" + ex.Message, "错误");
}
}
public void WriteToPLCForNew(string inPutValue, ushort address, DataType dataType)
{
try
{
//KeyboardHelper.ShowSoftKeyboard();
switch (dataType)
{
case DataType.:
double value = inPutValue.ToDouble();
if (UIInputDialog.ShowInputDoubleDialog(ref value, UIStyle.Inherited,3, desc: "请输入值", showMask: false))
{
modbusMaster.WriteMultipleRegisters(1, address, dc.SplitFloatToUShortArray((float)value));
}
break;
case DataType.:
int value_int = inPutValue.ToInt();
if (UIInputDialog.ShowInputIntegerDialog(ref value_int, UIStyle.Inherited, desc: "请输入数据:"))
{
modbusMaster.WriteMultipleRegisters(1, address, dc.intToushorts(value_int));
}
break;
default:
break;
}
//KeyboardHelper.HideSoftKeyboard();
}
catch (Exception ex)
{
MessageBox.Show("操作失败!" + "\n" + "\n" + ex.Message, "错误");
}
}
public void WriteToPLCForNewForThree(string inPutValue, ushort address, DataType dataType)
{
try
{
//KeyboardHelper.ShowSoftKeyboard();
switch (dataType)
{
case DataType.:
double value = inPutValue.ToDouble();
if (UIInputDialog.ShowInputDoubleDialog(ref value, UIStyle.Inherited, 3, desc: "请输入值", showMask: false))
{
modbusMaster.WriteMultipleRegisters(1, address, dc.SplitFloatToUShortArray((float)value));
}
break;
case DataType.:
int value_int = inPutValue.ToInt();
if (UIInputDialog.ShowInputIntegerDialog(ref value_int, UIStyle.Inherited, desc: "请输入数据:"))
{
modbusMaster.WriteMultipleRegisters(1, address, dc.intToushorts(value_int));
}
break;
default:
break;
}
//KeyboardHelper.HideSoftKeyboard();
}
catch (Exception ex)
{
MessageBox.Show("操作失败!" + "\n" + "\n" + ex.Message, "错误");
}
}
}
}

View File

@@ -0,0 +1,21 @@
namespace .Services
{
public class LoginData
{
static string _userName = "";
public string UserName
{
get { return _userName; }
set { _userName = value; }
}
//登陆权限
static int _userPower = 0;//0为普通用户1为管理员
public int UserPower
{
get { return _userPower; }
set { _userPower = value; }
}
}
}

View File

@@ -0,0 +1,70 @@
using System;
using System.Net.Sockets;
using Modbus.Device;
namespace .Services.Data
{
// 单例模式:全局唯一资源管理器
public class ModbusResourceManager
{
// 私有构造函数禁止外部new
private ModbusResourceManager() { }
// 唯一实例
private static readonly Lazy<ModbusResourceManager> _instance = new Lazy<ModbusResourceManager>(() => new ModbusResourceManager());
public static ModbusResourceManager Instance => _instance.Value;
// 共享资源
public TcpClient TcpClient { get; private set; }
public IModbusMaster ModbusMaster { get; private set; }
// 初始化资源在程序启动时调用如MainWindow加载时
public bool Init(string ip, int port)
{
try
{
// 先释放旧资源
ReleaseResource();
// 创建新连接
TcpClient = new TcpClient();
TcpClient.Connect(ip, port);
ModbusMaster = ModbusIpMaster.CreateIp(TcpClient);
return true;
}
catch (Exception ex)
{
Console.WriteLine($"资源初始化失败:{ex.Message}");
ReleaseResource();
return false;
}
}
public void Dispose()
{
try
{
ModbusMaster?.Dispose();
TcpClient?.Close();
}
catch
{
// 忽略清理时的异常
}
}
// 释放资源(统一释放,避免重复关闭)
public void ReleaseResource()
{
ModbusMaster?.Dispose();
ModbusMaster = null;
//if (TcpClient?.Connected ?? false)
//{
// TcpClient.Close();
//}
TcpClient?.Dispose();
TcpClient = null;
}
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace .Services.Data
{
internal class PLC_Data
{
}
}

View File

@@ -0,0 +1,71 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Security.Principal;
using System.Windows;
public class KeyboardHelper
{
public static void ShowSoftKeyboard()
{
if (!IsRunAsAdmin())
{
RestartAsAdmin();
return;
}
// 替换原有的 Process.Start 代码
string oskPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "osk.exe");
if (File.Exists(oskPath))
{
Process.Start(new ProcessStartInfo
{
FileName = oskPath,
UseShellExecute = true
});
}
else
{
//MessageBox.Show("未找到屏幕键盘程序osk.exe可能系统文件缺失或非Windows系统。", "错误");
}
}
public static void HideSoftKeyboard()
{
try
{
Process.Start("cmd.exe", "/C taskkill /IM osk.exe /F");
}
catch (Exception ex)
{
Console.WriteLine("Error: " + ex.Message);
}
}
private static bool IsRunAsAdmin()
{
WindowsIdentity identity = WindowsIdentity.GetCurrent();
WindowsPrincipal principal = new WindowsPrincipal(identity);
return principal.IsInRole(WindowsBuiltInRole.Administrator);
}
private static void RestartAsAdmin()
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.UseShellExecute = true;
startInfo.WorkingDirectory = Environment.CurrentDirectory;
startInfo.FileName = Process.GetCurrentProcess().MainModule.FileName;
startInfo.Verb = "runas";
try
{
Process.Start(startInfo);
}
catch (Exception ex)
{
Console.WriteLine("Error: " + ex.Message);
}
Environment.Exit(0);
}
}

View File

@@ -0,0 +1,115 @@
<Window x:Class="HeadHoodFieldOfViewTester.LanguageSelectWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="头罩视野测试仪 - 语言选择"
Height="800" Width="1200"
WindowStartupLocation="CenterScreen"
Background="#FFE0E5ED">
<Grid>
<!-- 背景科技风装饰 -->
<Grid.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
<GradientStop Color="#FFB0C4DE" Offset="0"/>
<GradientStop Color="#FFE6F2FF" Offset="0.5"/>
<GradientStop Color="#FFD3D3D3" Offset="1"/>
</LinearGradientBrush>
</Grid.Background>
<!-- 科技感环形装饰 -->
<Canvas>
<!-- 左侧中文按钮环形 -->
<Ellipse Width="220" Height="220" Canvas.Left="200" Canvas.Top="250"
Stroke="#FF40E0FF" StrokeThickness="3" Opacity="0.7"/>
<Ellipse Width="180" Height="180" Canvas.Left="220" Canvas.Top="270"
Stroke="#FF87CEFA" StrokeThickness="2" Opacity="0.5"/>
<!-- 右侧英文按钮环形 -->
<Ellipse Width="220" Height="220" Canvas.Left="780" Canvas.Top="250"
Stroke="#FF40E0FF" StrokeThickness="3" Opacity="0.7"/>
<Ellipse Width="180" Height="180" Canvas.Left="800" Canvas.Top="270"
Stroke="#FF87CEFA" StrokeThickness="2" Opacity="0.5"/>
</Canvas>
<!-- 左上角/右上角/左下角 占位框 (FK_0/FK_1/FK_4) -->
<!-- FK_0 标题占位 -->
<Border x:Name="FK_0" BorderBrush="White" BorderThickness="1"
Width="600" Height="80" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,20,0,0">
<TextBlock Text="FK_0" Foreground="Red" FontSize="14" VerticalAlignment="Top"/>
</Border>
<!-- FK_1 右上角占位 -->
<Border x:Name="FK_1" BorderBrush="White" BorderThickness="1"
Width="200" Height="150" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,20,20,0">
<TextBlock Text="FK_1" Foreground="Red" FontSize="14" VerticalAlignment="Top"/>
</Border>
<!-- FK_4 左下角占位 -->
<Border x:Name="FK_4" BorderBrush="White" BorderThickness="1"
Width="200" Height="150" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="20,0,0,20">
<TextBlock Text="FK_4" Foreground="Red" FontSize="14" VerticalAlignment="Top"/>
</Border>
<!-- TX_0 左下角文字 -->
<TextBlock x:Name="TX_0" Text="TX_0" Foreground="Red" FontSize="14"
HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="80,0,0,5"/>
<!-- 主标题 TX_1 -->
<TextBlock x:Name="TX_1" Text="头罩视野测试仪"
FontSize="48" FontWeight="Bold"
Foreground="Red"
TextDecorations="Underline"
HorizontalAlignment="Center"
VerticalAlignment="Top" Margin="0,30,0,0"/>
<!-- 左侧中文按钮 (SW_1) -->
<Button x:Name="SW_1"
Width="180" Height="180"
HorizontalAlignment="Left" VerticalAlignment="Center" Margin="220,0,0,0"
Background="#FF1E3A5F" BorderBrush="#FF40E0FF" BorderThickness="2"
CornerRadius="90" Cursor="Hand"
ToolTip="SW_1 (LW-9134 (16bit): 当前所使用的语言)">
<Grid>
<!-- 按钮内部装饰 -->
<Ellipse Width="160" Height="160" Stroke="#FF40E0FF" StrokeThickness="2" Opacity="0.6"/>
<Ellipse Width="140" Height="140" Stroke="#FF87CEFA" StrokeThickness="1" Opacity="0.4"/>
<!-- 点击手势图标 -->
<TextBlock FontFamily="Segoe MDL2 Assets" FontSize="40" Text="&#xE72A;"
Foreground="#FFFFD700" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,-20,0,0"/>
<!-- 中文文字 TX_2 -->
<TextBlock x:Name="TX_2" Text="中文"
FontSize="36" FontWeight="Bold"
Foreground="#FFFFD700"
HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,0,0,20"/>
</Grid>
</Button>
<!-- 右侧英文按钮 (SW_2) -->
<Button x:Name="SW_2"
Width="180" Height="180"
HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,220,0"
Background="#FF1E3A5F" BorderBrush="#FF40E0FF" BorderThickness="2"
CornerRadius="90" Cursor="Hand"
ToolTip="SW_2 (LW-9134 (16bit): 当前所使用的语言)">
<Grid>
<!-- 按钮内部装饰 -->
<Ellipse Width="160" Height="160" Stroke="#FF40E0FF" StrokeThickness="2" Opacity="0.6"/>
<Ellipse Width="140" Height="140" Stroke="#FF87CEFA" StrokeThickness="1" Opacity="0.4"/>
<!-- 点击手势图标 -->
<TextBlock FontFamily="Segoe MDL2 Assets" FontSize="40" Text="&#xE72A;"
Foreground="#FFFFD700" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,-20,0,0"/>
<!-- 英文文字 -->
<TextBlock Text="English"
FontSize="36" FontWeight="Bold"
Foreground="#FFFFD700"
HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,0,0,20"/>
</Grid>
</Button>
<!-- 按钮标注文字 -->
<TextBlock Text="SW_1 (LW-9134 (16bit): 当前所使用的语言)"
Foreground="Red" FontSize="14"
HorizontalAlignment="Left" VerticalAlignment="Center" Margin="220,180,0,0"/>
<TextBlock Text="SW_2 (LW-9134 (16bit): 当前所使用的语言)"
Foreground="Red" FontSize="14"
HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,180,220,0"/>
</Grid>
</Window>

View File

@@ -0,0 +1,94 @@
<Page x:Class="头罩视野.Views.ChangeLanguage"
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="clr-namespace:头罩视野.Views"
mc:Ignorable="d"
Background="#8AB1EB"
d:DesignHeight="768" d:DesignWidth="1024"
Title="ChangeLanguage">
<Grid>
<!-- 科技光效装饰层 (Canvas绝对定位) -->
<Canvas RenderTransformOrigin="0.5,0.674" Margin="0,148,0,-148" >
<!-- 左侧圆环光晕 -->
<Ellipse Width="280" Height="280" Canvas.Left="160" Canvas.Top="180"
Fill="Transparent" Stroke="#00FFF3" StrokeThickness="2" />
<Ellipse Width="240" Height="240" Canvas.Left="180" Canvas.Top="200"
Fill="Transparent" Stroke="#00FFF3" StrokeThickness="1.5" />
<Ellipse Width="200" Height="200" Canvas.Left="200" Canvas.Top="220"
Fill="Transparent" Stroke="#00FFF3" StrokeThickness="1" />
<!-- 右侧圆环光晕 -->
<Ellipse Width="280" Height="280" Canvas.Left="560" Canvas.Top="180"
Fill="Transparent" Stroke="#00FFF3" StrokeThickness="2" />
<Ellipse Width="240" Height="240" Canvas.Left="580" Canvas.Top="200"
Fill="Transparent" Stroke="#00FFF3" StrokeThickness="1.5" />
<Ellipse Width="200" Height="200" Canvas.Left="600" Canvas.Top="220"
Fill="Transparent" Stroke="#00FFF3" StrokeThickness="1"/>
<!-- 中间加号 -->
<TextBlock Text="+" FontSize="72" Foreground="White"
Canvas.Left="478" Canvas.Top="273" />
</Canvas>
<!-- 文字标注 (对应原图 TX_0, TX_1, TX_2) -->
<TextBlock x:Name="TX_1" Text="头罩视野测试仪"
FontSize="48" FontWeight="Bold" Foreground="White"
HorizontalAlignment="Left" VerticalAlignment="Top" Margin="352,87,0,0"/>
<TextBlock x:Name="TX_0" Text="TX_0" Foreground="White" FontSize="14"
HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="80,0,0,5"/>
<!-- 左侧中文按钮 (SW_1) -->
<Button x:Name="SW_1" Click="BtnGoNextPage_Click"
Width="180" Height="180"
HorizontalAlignment="Left" Margin="210,382,0,0"
Background="#FF141E30" BorderBrush="#00FFF3" BorderThickness="2"
Cursor="Hand" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" VerticalAlignment="Top">
<Button.Template>
<ControlTemplate TargetType="Button">
<Grid>
<!-- 按钮背景圆环 -->
<Ellipse Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="2"/>
<!-- 内容居中 -->
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
</ControlTemplate>
</Button.Template>
<Grid>
<TextBlock Text="👆" FontSize="40" Foreground="#FFFF00" Margin="0,-14,0,54"/>
<TextBlock x:Name="TX_2" Text="中文" FontSize="32" FontWeight="Bold" Foreground="#FFFF00" Margin="0,40,0,0" HorizontalAlignment="Center" Width="64"/>
</Grid>
</Button>
<!-- 右侧英文按钮 (SW_2) -->
<Button x:Name="SW_2"
Width="180" Height="180"
HorizontalAlignment="Left" Margin="614,382,0,0"
Background="#FF141E30" BorderBrush="#00FFF3" BorderThickness="2"
Cursor="Hand" VerticalAlignment="Top">
<Button.Template>
<ControlTemplate TargetType="Button">
<Grid>
<Ellipse Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="2"/>
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
</ControlTemplate>
</Button.Template>
<Grid>
<TextBlock Text="👆" FontSize="40" Foreground="#FFFF00" Margin="0,-14,0,44"/>
<TextBlock Text="英文" FontSize="32" FontWeight="Bold" Foreground="#FFFF00" Margin="0,40,0,0"/>
</Grid>
</Button>
</Grid>
</Page>

View File

@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Text;
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 .Views
{
/// <summary>
/// ChangeLanguage.xaml 的交互逻辑
/// </summary>
public partial class ChangeLanguage : Page
{
public ChangeLanguage()
{
InitializeComponent();
}
private void SW_2_Click(object sender, RoutedEventArgs e)
{
}
private void BtnGoNextPage_Click(object sender, RoutedEventArgs e)
{
// 跳转到你要去的页面(比如 MainTestPage
NavigationService?.Navigate(new MainWindow());
}
}
}

View File

@@ -0,0 +1,6 @@
namespace .Views
{
public class ExperimentReportData
{
}
}

View File

@@ -0,0 +1,74 @@
<Page x:Class="头罩视野.Views.Help"
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:头罩视野.Views"
mc:Ignorable="d"
d:DesignHeight="768" d:DesignWidth="1024"
Background="#F0E6FA"
Title="Help">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- 左上角"帮助"标题 -->
<TextBlock Text="帮助"
FontSize="32"
FontWeight="Bold"
Margin="20,10,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"/>
<!-- 主内容区 -->
<StackPanel Grid.Row="1"
VerticalAlignment="Center"
HorizontalAlignment="Center">
<!-- 第一行:上海程斯,服务全球 -->
<Border BorderBrush="White"
BorderThickness="2"
CornerRadius="4"
Background="Transparent"
Margin="0,0,0,40"
Padding="30,15,30,15">
<TextBlock Text="上海程斯,服务全球"
FontSize="40"
FontWeight="Bold"
HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Border>
<!-- 第二行:公司信息 -->
<Border BorderBrush="White"
BorderThickness="2"
CornerRadius="4"
Background="Transparent"
Margin="0,0,0,60"
Padding="30,20,30,20">
<StackPanel HorizontalAlignment="Center">
<TextBlock Text="总公司美国CSI----Sincerity"
FontSize="26"
Margin="0,0,0,8"
HorizontalAlignment="Center"/>
<TextBlock Text="上海分公司:上海程斯智能科技(美国)有限公司"
FontSize="26"
Margin="0,0,0,8"
HorizontalAlignment="Center"/>
<TextBlock Text="联系方式19821311892"
FontSize="26"
HorizontalAlignment="Center"/>
</StackPanel>
</Border>
<!-- 第三行:网址 -->
<TextBlock Text="http://www.csizhineng.com"
FontSize="30"
HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</StackPanel>
</Grid>
</Page>

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Text;
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 .Views
{
/// <summary>
/// Help.xaml 的交互逻辑
/// </summary>
public partial class Help : Page
{
public Help()
{
InitializeComponent();
}
}
}

View File

@@ -0,0 +1,270 @@
<Page x:Class="头罩视野.Views.PageTest"
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="clr-namespace:头罩视野.Views"
mc:Ignorable="d"
Background="#F5F7FA"
d:DesignHeight="768" d:DesignWidth="1024"
Title="PageTest" Loaded="Page_Loaded">
<Page.Resources>
<!-- 标题样式 -->
<Style x:Key="MainTitleStyle" TargetType="TextBlock">
<Setter Property="FontSize" Value="28"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="Foreground" Value="#2C3E50"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="Margin" Value="0,15,0,15"/>
</Style>
<Style x:Key="LabelStyle" TargetType="TextBlock">
<Setter Property="FontSize" Value="16"/>
<Setter Property="Foreground" Value="#5D6D7E"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Margin" Value="0,0,10,0"/>
<Setter Property="Margin" Value="0,0,10,0"/>
<Setter Property="Width" Value="100"/>
</Style>
<Style x:Key="UnitStyle" TargetType="TextBlock">
<Setter Property="FontSize" Value="14"/>
<Setter Property="Foreground" Value="#7F8C8D"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Margin" Value="10,0,0,0"/>
<Setter Property="FontStyle" Value="Italic"/>
</Style>
<Style x:Key="TextBoxStyle" TargetType="TextBox">
<Setter Property="Height" Value="40"/>
<Setter Property="Width" Value="200"/>
<Setter Property="FontSize" Value="18"/>
<Setter Property="TextAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="BorderBrush" Value="#D5D8DC"/>
<Setter Property="BorderThickness" Value="2"/>
<Setter Property="Background" Value="#FFFFFF"/>
<Setter Property="Foreground" Value="#2C3E50"/>
<Setter Property="Padding" Value="10,5"/>
<Style.Triggers>
<Trigger Property="IsFocused" Value="True">
<Setter Property="BorderBrush" Value="#3498DB"/>
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="TabButtonStyle" TargetType="Button">
<Setter Property="Background" Value="#3498DB"/>
<Setter Property="FontSize" Value="20"/>
<Setter Property="Foreground" Value="#fff"/>
<Setter Property="Height" Value="70"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="BorderBrush" Value="#fff"/>
</Style>
<!--<Style x:Key="ActButtonStyle" TargetType="Button">
<Setter Property="Background" Value="#8AB1EB"/>
<Setter Property="FontSize" Value="18"/>
<Setter Property="Foreground" Value="#fff"/>
<Setter Property="Height" Value="60"/>
<Setter Property="Width" Value="120"/>
</Style>-->
</Page.Resources>
<Grid Margin="10,0,0,0 ">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto" MinHeight="227"/>
<RowDefinition/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- 顶部标题栏 -->
<Grid Grid.Row="0" Margin="0,0,0,10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<!-- 测试界面标题 -->
<TextBlock Grid.Column="2" Style="{StaticResource MainTitleStyle}" Text="测试界面"
HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
<!-- 第二行:参数显示区 -->
<Grid Grid.Row="1" Margin="0,0,0,10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Border Grid.Row="0" Background="#FFFFFF" CornerRadius="10"
BorderBrush="#E5E8E8" BorderThickness="1"
Padding="25,20" Margin="0,0,0,25" >
<StackPanel Cursor="" Grid.Column="0">
<StackPanel Orientation="Horizontal" Margin="0,0,0,15">
<TextBlock Text="分辨角度:" Style="{StaticResource LabelStyle}"/>
<TextBox Name="fbspeed" Text="" Style="{StaticResource TextBoxStyle}" GotFocus="fbspeed_GotFocus"/>
<TextBlock Text="°" Style="{StaticResource UnitStyle}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="当前角度:" Style="{StaticResource LabelStyle}"/>
<TextBox Name="dqangle" Text="" Style="{StaticResource TextBoxStyle}" GotFocus="dqangle_GotFocus"/>
<TextBlock Text="°" Style="{StaticResource UnitStyle}"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,15,0,0">
<TextBlock Text="转动速度:" Style="{StaticResource LabelStyle}"/>
<TextBox Name="zdangle" Text="" Style="{StaticResource TextBoxStyle}" GotFocus="zdangle_GotFocus"/>
<TextBlock Text="°/S" Style="{StaticResource UnitStyle}"/>
</StackPanel>
</StackPanel>
</Border>
<StackPanel Grid.Column="1">
<Image Grid.Row="2" Source="/Images/touzhao.png" Opacity="1" Width="224"
Margin="200,0,0,0" Height="194"/>
</StackPanel>
<Button Grid.Column="2" Content="打印" HorizontalAlignment="Left" Margin="77,6,0,0" VerticalAlignment="Top" Height="42" Width="75" Click="Button_Click_Print" FontSize="18" RenderTransformOrigin="0.360,-0.63"/>
<RadioButton Grid.Column="1" Content="试样测试"
Margin="121,16,0,0" VerticalAlignment="Top"
FontSize="18" HorizontalAlignment="Left"
Checked="RadioButton_Checked"
RenderTransformOrigin="1.521,-0.3"
Unchecked="RadioButton_Unchecked"
/>
<TextBlock x:Name="当前模式" Grid.Column="1" HorizontalAlignment="Left" Margin="39,16,0,0" TextWrapping="Wrap" VerticalAlignment="Top" FontSize="18" RenderTransformOrigin="-6.776,-2.381" Width="116"><Run Text="当前模式"/><Run Language="zh-cn" Text=""/></TextBlock>
</Grid>
<!-- 第三行:视野数据区 -->
<Grid Grid.Row="2" Margin="0,0,0,10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Border Grid.Row="0" Grid.Column="0" Background="#FFFFFF" CornerRadius="10"
BorderBrush="#E5E8E8" BorderThickness="1"
Padding="25,20" Margin="0,0,0,15" >
<StackPanel Cursor="">
<StackPanel Orientation="Horizontal" Margin="0,0,0,15">
<TextBlock Text="左目视野面积:" Style="{StaticResource LabelStyle}"/>
<TextBox Name="zmsyarea" Text="" Style="{StaticResource TextBoxStyle}"/>
<TextBlock Text="cm²" Style="{StaticResource UnitStyle}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="双目视野面积:" Style="{StaticResource LabelStyle}"/>
<TextBox Name="smsyarea" Text="" Style="{StaticResource TextBoxStyle}"/>
<TextBlock Text="cm²" Style="{StaticResource UnitStyle}"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,15,0,0">
<TextBlock Text="空白视野面积:" Style="{StaticResource LabelStyle}"/>
<TextBox Name="kbsyarea" Text="" Style="{StaticResource TextBoxStyle}"/>
<TextBlock Text="cm²" Style="{StaticResource UnitStyle}"/>
</StackPanel>
</StackPanel>
</Border>
<Border Grid.Column="1" Background="#FFFFFF" CornerRadius="10"
BorderBrush="#E5E8E8" BorderThickness="1"
Padding="25,20" Margin="31,0,19,15" >
<StackPanel Cursor="">
<StackPanel Orientation="Horizontal" Margin="0,0,0,15">
<TextBlock Text="右目视野面积:" Style="{StaticResource LabelStyle}"/>
<TextBox Name="ymsyarea" Text="" Style="{StaticResource TextBoxStyle}"/>
<TextBlock Text="cm²" Style="{StaticResource UnitStyle}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="下方视野:" Style="{StaticResource LabelStyle}"/>
<TextBox Name="xfsyarea" Text="" Style="{StaticResource TextBoxStyle}"/>
<TextBlock Text="°" Style="{StaticResource UnitStyle}"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,15,0,0">
<TextBlock Text="视野保存率:" Style="{StaticResource LabelStyle}"/>
<TextBox Name="sybhl" Text="" Style="{StaticResource TextBoxStyle}"/>
<TextBlock Text="%" Style="{StaticResource UnitStyle}"/>
</StackPanel>
</StackPanel>
</Border>
</Grid>
<!-- 第四行:控制按钮区 -->
<Grid Grid.Row="3" Margin="0,10,0,10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- 复位 -->
<Button Grid.Row="0" Grid.Column="0" Grid.RowSpan="2" Content="复位" FontSize="18"
Width="120" Height="50" Background="#FF87CEFA" Foreground="White" Margin="5" Click="Button_Click_Reset" />
<!-- 左眼开 -->
<Button Grid.Row="0" Grid.Column="1" Content="左眼开" FontSize="18"
Width="120" Height="50" Background="#FF87CEFA" Foreground="White" Margin="5" Click="Button_Click_left" />
<!-- 反转 -->
<Button Grid.Row="0" Grid.Column="2" Content="反转" FontSize="18"
Width="120" Height="50" Background="#FF87CEFA" Foreground="White" Margin="5" Click="Button_Click_Res" />
<!-- 右眼开 -->
<Button Grid.Row="1" Grid.Column="1" Content="右眼开" FontSize="18"
Width="120" Height="50" Background="#FF87CEFA" Foreground="White" Margin="5" Click="Button_Click_Right" />
<!-- 正转 -->
<Button Grid.Row="1" Grid.Column="2" Content="正转" FontSize="18"
Width="120" Height="50" Background="#FF87CEFA" Foreground="White" Margin="5" Click="Button_Click_For" />
<!-- 测试 -->
<Button Grid.Row="0" Grid.Column="4" Grid.RowSpan="2" Content="测试" FontSize="18"
Width="120" Height="50" Background="#A4ADB3" Foreground="White" Margin="5" Click="Button_Click_Test"/>
<!-- 停止 -->
<Button Grid.Row="0" Grid.Column="5" Grid.RowSpan="2" Content="停止" FontSize="18"
Width="120" Height="50" Background="red" Foreground="White" Margin="5" Click="Button_Click_Stop" />
</Grid>
<!-- 底部导航栏 -->
<Grid Grid.Row="4">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button Style="{StaticResource TabButtonStyle}" Grid.Column="0" Content="主页"
Click="GoHome" />
<Button Style="{StaticResource TabButtonStyle}" Grid.Column="1" Content="测试界面"
Click="GoTest" />
<Button Style="{StaticResource TabButtonStyle}" Grid.Column="2" Content="数据记录"
Click="GoRecord" />
<Button Style="{StaticResource TabButtonStyle}" Grid.Column="3" Content="记录画面"
Click="GoView" />
</Grid>
</Grid>
</Page>

View File

@@ -0,0 +1,296 @@
using Modbus.Device;
using Sunny.UI;
//using RecordDateView;
using System;
using System.Collections.Generic;
using System.Net.Sockets;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;
using .Services;
using .Services.Data;
namespace .Views
{
/// <summary>
/// PageTest.xaml 的交互逻辑
/// </summary>
public partial class PageTest : Page
{
private TcpClient _tcpClient => ModbusResourceManager.Instance.TcpClient;
private IModbusMaster _modbusMaster => ModbusResourceManager.Instance.ModbusMaster;
DataChange c = new DataChange();
Function ma;
public PageTest()
{
InitializeComponent();
}
//复位btn
private void Button_Click_Reset(object sender, RoutedEventArgs e)
{
ma.BtnClickFunction(Function.ButtonType., 90);
MessageBox.Show("数据已复位", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
}
//左开眼
private void Button_Click_left(object sender, RoutedEventArgs e)
{
ma.BtnClickFunction(Function.ButtonType., 0);
}
//右开眼
private void Button_Click_Right(object sender, RoutedEventArgs e)
{
ma.BtnClickFunction(Function.ButtonType., 1);
}
//反转
private void Button_Click_Res(object sender, RoutedEventArgs e)
{
ma.BtnClickFunction(Function.ButtonType., 10);
}
//正转
private void Button_Click_For(object sender, RoutedEventArgs e)
{
ma.BtnClickFunction(Function.ButtonType., 11);
}
//测试btn
private void Button_Click_Test(object sender, RoutedEventArgs e)
{
ma.BtnClickFunction(Function.ButtonType., 101);
}
//停止btn
private void Button_Click_Stop(object sender, RoutedEventArgs e)
{
ma.BtnClickFunction(Function.ButtonType., 103);
}
//打印
private void Button_Click_Print(object sender, RoutedEventArgs e)
{
ma.BtnClickFunction(Function.ButtonType., 103);
}
//试样测试
private void RadioButton_Checked(object sender, RoutedEventArgs e)
{
ma.BtnClickFunction(Function.ButtonType., 41);
}
private void RadioButton_Unchecked(object sender, RoutedEventArgs e)
{
ma.BtnClickFunction(Function.ButtonType., 41);
}
private void Button_Click_home(object sender, RoutedEventArgs e)
{
NavigationService.Content = null;
}
//读取数据
private DispatcherTimer InitDispatcherTimer()
{
var timer = new DispatcherTimer
{
Interval = TimeSpan.FromMilliseconds(100)
};
timer.Tick += async (s, e) =>
{
if (_modbusMaster != null)
{
try
{
await ReadAddr262DataAsync();
}
catch { }
}
};
return timer;
}
private async System.Threading.Tasks.Task ReadAddr262DataAsync()
{
try
{
// 创建任务列表
var tasks = new List<Task>
{
ReadAndUpdateFloatAsync(200, 2, fbspeed, "F2", "°"),
ReadAndUpdateFloatAsync(202, 2, dqangle, "F2", "°"),
ReadAndUpdateFloatAsync(310, 2, zdangle, "F2", "°/S"),
ReadAndUpdateFloatAsync(204, 2, zmsyarea, "F2", "cm²"),
ReadAndUpdateFloatAsync(208, 2, smsyarea, "F2", "cm²"),
ReadAndUpdateFloatAsync(424 ,2, kbsyarea, "F2", "cm²"),
ReadAndUpdateFloatAsync(210 ,2, ymsyarea, "F2", " "),
ReadAndUpdateFloatAsync(206 ,2, xfsyarea, "F2", " "),
ReadAndUpdateFloatAsync(430 ,2, sybhl, "F2", " "),
};
await Task.WhenAll(tasks);
}
catch (Exception ex)
{
ShowError($"读取数据失败:{ex.Message}");
}
}
// 地址, 根据格式显示字符长度 322 161 绑定页面的name 值F2 保留两位小数,单位
private async Task ReadAndUpdateFloatAsync(int address, int length, System.Windows.Controls.TextBox control, string format, string unit)
{
try
{
ushort[] registers = await Task.Run(async () =>
await _modbusMaster.ReadHoldingRegistersAsync(1, (ushort)address, (ushort)length)
);
if (registers != null && registers.Length >= 2)
{
float value = c.UshortToFloat(registers[1], registers[0]);
Dispatcher.Invoke(() => control.Text = value.ToString(format) + unit);
}
else if (registers != null && registers.Length >= 1)
{
int value = registers[0];
Dispatcher.Invoke(() => control.Text = value.ToString(format) + unit);
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"读取地址{address}失败:{ex.Message}");
}
}
private async Task ReadAndUpdateFloatAsync(int address, int length, System.Windows.Controls.TextBlock control, string format, string unit)
{
try
{
ushort[] registers = await Task.Run(async () =>
await _modbusMaster.ReadHoldingRegistersAsync(1, (ushort)address, (ushort)length)
);
if (registers != null && registers.Length >= 2)
{
float value = c.UshortToFloat(registers[1], registers[0]);
Dispatcher.Invoke(() => control.Text = value.ToString(format) + unit);
}
else if (registers != null && registers.Length >= 1)
{
int value = registers[0];
Dispatcher.Invoke(() => control.Text = value.ToString(format) + unit);
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"读取地址{address}失败:{ex.Message}");
}
}
private async Task ReadAndUpdateIntAsync(int address, int length, System.Windows.Controls.Control control, string format)
{
try
{
ushort[] registers = await Task.Run(() =>
_modbusMaster.ReadHoldingRegisters(1, (ushort)address, (ushort)length)
);
if (registers != null && registers.Length >= 1)
{
int value = registers[0];
Dispatcher.Invoke(() =>
{
if (control is System.Windows.Controls.ContentControl contentControl)
contentControl.Content = value.ToString(format);
else if (control is System.Windows.Controls.TextBox textBox)
textBox.Text = value.ToString(format);
});
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"读取地址{address}失败:{ex.Message}");
}
}
//写入
private void fbspeed_GotFocus(object sender, RoutedEventArgs e)
{
ma.WriteToPLCForNew(fbspeed.Text.Trim(), 200, Function.DataType.);
//程序等待50s 在进行
System.Threading.Tasks.Task.Delay(50);
fbspeed.Focus();
}
private void dqangle_GotFocus(object sender, RoutedEventArgs e)
{
ma.WriteToPLCForNew(fbspeed.Text.Trim(), 202, Function.DataType.);
System.Threading.Tasks.Task.Delay(50);
fbspeed.Focus();
}
private void zdangle_GotFocus(object sender, RoutedEventArgs e)
{
ma.WriteToPLCForNew(fbspeed.Text.Trim(), 310, Function.DataType.);
System.Threading.Tasks.Task.Delay(50);
fbspeed.Focus();
}
//错误信息提示
private void ShowError(string msg) => MessageBox.Show(msg, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
private void GoHome(object s, RoutedEventArgs e) => NavigationService.Content = null;
private void GoTest(object s, RoutedEventArgs e) => NavigationService.Content = new Views.PageTest();
private void GoRecord(object s, RoutedEventArgs e) => NavigationService.Content = new Views.RecordDate();
private void GoView(object s, RoutedEventArgs e) => NavigationService.Content = new Views.RecordPage();
private void InitializeModbusTcp()
{
try
{
string plcIp = "192.168.1.10";
bool initSuccess = ModbusResourceManager.Instance.Init(plcIp, 502);
if (!initSuccess)
{
MessageBox.Show("连接Modbus服务器失败", "错误");
//this.Close();
return;
}
// 检查连接状态
if (_tcpClient == null || !_tcpClient.Connected)
{
MessageBox.Show("Modbus连接异常", "错误");
return;
}
ma = new Function(_modbusMaster);
}
catch (Exception ex)
{
ShowError($"Modbus初始化失败: {ex.Message}");
}
}
private void Page_Loaded(object sender, RoutedEventArgs e)
{
InitializeModbusTcp();
}
}
}

View File

@@ -0,0 +1,255 @@
<Page x:Class="头罩视野.Views.RecordDate"
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:头罩视野.Views"
mc:Ignorable="d"
d:DesignHeight="768" d:DesignWidth="1024"
Background="#F5F7FA"
Title="RecordDate">
<Page.Resources>
<!-- 标题样式 -->
<Style x:Key="MainTitleStyle" TargetType="TextBlock">
<Setter Property="FontSize" Value="28"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="Foreground" Value="#2C3E50"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="Margin" Value="0,15,0,15"/>
</Style>
<!-- DataGrid 样式 -->
<Style x:Key="DataGridStyle" TargetType="DataGrid">
<Setter Property="Background" Value="#FFFFFF"/>
<Setter Property="BorderBrush" Value="#E5E8E8"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="GridLinesVisibility" Value="Horizontal"/>
<Setter Property="HorizontalGridLinesBrush" Value="#ECF0F1"/>
<Setter Property="VerticalGridLinesBrush" Value="#ECF0F1"/>
<Setter Property="HeadersVisibility" Value="Column"/>
<Setter Property="CanUserAddRows" Value="False"/>
<Setter Property="CanUserDeleteRows" Value="False"/>
<Setter Property="AutoGenerateColumns" Value="False"/>
<Setter Property="IsReadOnly" Value="True"/>
<Setter Property="SelectionMode" Value="Single"/>
<Setter Property="SelectionUnit" Value="FullRow"/>
<Setter Property="RowHeight" Value="36"/>
<Setter Property="FontSize" Value="13"/>
<Setter Property="Foreground" Value="#2C3E50"/>
<Setter Property="ScrollViewer.CanContentScroll" Value="True"/>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
</Style>
<!-- DataGrid 列头样式 -->
<Style x:Key="DataGridColumnHeaderStyle" TargetType="DataGridColumnHeader">
<Setter Property="Background" Value="#E5E5E5"/>
<Setter Property="Foreground" Value="Black"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="Height" Value="40"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Padding" Value="10,8"/>
<Setter Property="BorderBrush" Value="#E5E5E5"/>
<Setter Property="BorderThickness" Value="0,0,1,0"/>
</Style>
<!-- DataGrid 行样式 -->
<Style x:Key="DataGridRowStyle" TargetType="DataGridRow">
<Setter Property="Background" Value="White"/>
<Style.Triggers>
<!-- 斑马线效果 -->
<Trigger Property="AlternationIndex" Value="0">
<Setter Property="Background" Value="#FFFFFF"/>
</Trigger>
<Trigger Property="AlternationIndex" Value="1">
<Setter Property="Background" Value="#F8F9F9"/>
</Trigger>
<!-- 鼠标悬停效果 -->
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#EBF5FB"/>
</Trigger>
<!-- 选中效果 -->
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="#D6EAF8"/>
<Setter Property="BorderBrush" Value="#3498DB"/>
<Setter Property="BorderThickness" Value="1"/>
</Trigger>
</Style.Triggers>
</Style>
<!-- DataGrid 单元格样式 -->
<Style x:Key="DataGridCellStyle" TargetType="DataGridCell">
<Setter Property="BorderBrush" Value="#ECF0F1"/>
<Setter Property="BorderThickness" Value="0,0,1,1"/>
<Setter Property="Padding" Value="10,8"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="TextBlock.TextAlignment" Value="Center"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="DataGridCell">
<Border BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}"
Padding="{TemplateBinding Padding}"
SnapsToDevicePixels="True">
<ContentPresenter VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="TabButtonStyle" TargetType="Button">
<Setter Property="Background" Value="#3498DB"/>
<Setter Property="FontSize" Value="20"/>
<Setter Property="Foreground" Value="#fff"/>
<Setter Property="Height" Value="70"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="BorderBrush" Value="#fff"/>
</Style>
</Page.Resources>
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- 顶部标题栏 -->
<Grid Grid.Row="0" Margin="0 0 0 10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="2" Style="{StaticResource MainTitleStyle}" Text="数据记录"
HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
<Grid Grid.Row="1">
<TextBlock Text="左眼" FontSize="16" Margin="0,0,0,5"/>
</Grid>
<!--表格-->
<Grid Grid.Row="2" Margin="0 0 0 10">
<DataGrid x:Name="dataGrid1"
Height="190"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
AutoGenerateColumns="False"
CanUserAddRows="False"
IsReadOnly="True"
HeadersVisibility="Column"
GridLinesVisibility="All"
Style="{StaticResource DataGridStyle}"
ItemsSource="{Binding ReportData}"
AlternationCount="2"
ColumnHeaderStyle="{StaticResource DataGridColumnHeaderStyle}"
RowStyle="{StaticResource DataGridRowStyle}"
CellStyle="{StaticResource DataGridCellStyle}"
>
<!-- 表格列(你要的 6 列) -->
<DataGrid.Columns>
<DataGridTextColumn Header="编号" Binding="{Binding Id}" Width="80"/>
<DataGridTextColumn Header="时间" Binding="{Binding Time}" Width="120"/>
<DataGridTextColumn Header="日期" Binding="{Binding Date}" Width="120"/>
<DataGridTextColumn Header="ch.1" Binding="{Binding ChOne}" Width="*"/>
<DataGridTextColumn Header="ch.2" Binding="{Binding ChTwo}" Width="*"/>
<DataGridTextColumn Header="ch.3" Binding="{Binding ChThree}" Width="*"/>
<DataGridTextColumn Header="ch.4" Binding="{Binding ChFour}" Width="*"/>
<DataGridTextColumn Header="ch.5" Binding="{Binding ChFive}" Width="*"/>
<DataGridTextColumn Header="ch.6" Binding="{Binding ChSix}" Width="*"/>
<DataGridTextColumn Header="ch.7" Binding="{Binding ChSeven}" Width="*"/>
<DataGridTextColumn Header="ch.8" Binding="{Binding ChEight}" Width="*"/>
</DataGrid.Columns>
</DataGrid>
</Grid>
<Grid Grid.Row="3">
<TextBlock Text="左眼" FontSize="16" Margin="0,0,0,5"/>
</Grid>
<!--表格-->
<Grid Grid.Row="4" Margin="0 0 0 10">
<DataGrid x:Name="dataGrid2"
Height="190"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
AutoGenerateColumns="False"
CanUserAddRows="False"
IsReadOnly="True"
HeadersVisibility="Column"
GridLinesVisibility="All"
Style="{StaticResource DataGridStyle}"
ItemsSource="{Binding ReportData}"
AlternationCount="2"
ColumnHeaderStyle="{StaticResource DataGridColumnHeaderStyle}"
RowStyle="{StaticResource DataGridRowStyle}"
CellStyle="{StaticResource DataGridCellStyle}"
>
<!-- 表格列(你要的 6 列) -->
<DataGrid.Columns>
<DataGridTextColumn Header="编号" Binding="{Binding Id}" Width="80"/>
<DataGridTextColumn Header="时间" Binding="{Binding Time}" Width="120"/>
<DataGridTextColumn Header="日期" Binding="{Binding Date}" Width="120"/>
<DataGridTextColumn Header="ch.1" Binding="{Binding ChOne}" Width="*"/>
<DataGridTextColumn Header="ch.2" Binding="{Binding ChTwo}" Width="*"/>
<DataGridTextColumn Header="ch.3" Binding="{Binding ChThree}" Width="*"/>
<DataGridTextColumn Header="ch.4" Binding="{Binding ChFour}" Width="*"/>
<DataGridTextColumn Header="ch.5" Binding="{Binding ChFive}" Width="*"/>
<DataGridTextColumn Header="ch.6" Binding="{Binding ChSic}" Width="*"/>
<DataGridTextColumn Header="ch.7" Binding="{Binding ChSeven}" Width="*"/>
<DataGridTextColumn Header="ch.8" Binding="{Binding ChEight}" Width="*"/>
</DataGrid.Columns>
</DataGrid>
</Grid>
<!--按钮-->
<Grid Grid.Row="5" >
<!-- 停止 -->
<Button Content="保存" FontSize="18"
Width="120" Height="50" Background="#3498DB" Foreground="White" HorizontalAlignment="Left" Margin="870,0,0,0" />
<Button Content="清除" FontSize="18"
Width="120" Height="50" Background="White" BorderBrush="red" Foreground="red" HorizontalAlignment="Left" Margin="14,0,0,0" />
<TextBlock HorizontalAlignment="Left" Foreground="red"
FontSize="18"
Width="142" Margin="148,25,0,23" RenderTransformOrigin="0.5,0.5">
<TextBlock.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform AngleY="-0.614"/>
<RotateTransform/>
<TranslateTransform Y="-0.739"/>
</TransformGroup>
</TextBlock.RenderTransform><Run Language="zh-cn" Text="备注: 清除长按"/></TextBlock>
</Grid>
<!-- 底部导航栏 -->
<Grid Grid.Row="6" VerticalAlignment="Bottom">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button Style="{StaticResource TabButtonStyle}" Grid.Column="0" Content="主页"
Click="GoHome" />
<Button Style="{StaticResource TabButtonStyle}" Grid.Column="1" Content="测试界面"
Click="GoTest" />
<Button Style="{StaticResource TabButtonStyle}" Grid.Column="2" Content="数据记录"
Click="GoRecord" />
<Button Style="{StaticResource TabButtonStyle}" Grid.Column="3" Content="记录画面"
Click="GoView" />
</Grid>
</Grid>
</Page>

View File

@@ -0,0 +1,90 @@
using Sunny.UI;
using System;
using System.Collections.Generic;
using System.Text;
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 .Views
{
/// <summary>
/// RecordDate.xaml 的交互逻辑
/// </summary>
///
public class VisionData
{
public int Id { get; set; }
public string Time { get; set; } = string.Empty;
public string Date { get; set; } = string.Empty;
public string ChOne { get; set; } = string.Empty;
public string ChTwo { get; set; } = string.Empty;
public int ChThree { get; set; }
public int ChFour { get; set; }
public int ChFive { get; set; }
public int ChSix { get; set; }
public int ChSeven { get; set; }
public int ChEight { get; set; }
}
public partial class RecordDate : Page
{
public RecordDate()
{
InitializeComponent();
CreateTableData(); // 生成表格
}
// 核心:生成表格数据
private void CreateTableData()
{
// 新建列表
List<VisionData> list = new List<VisionData>();
// 添加测试数据(可循环添加多条)
list.Add(new VisionData
{
Id = 1,
Time = "10:25:30",
Date = "2025-12-25",
ChOne = "36.5",
ChTwo = "37.2",
ChThree = 67,
ChFour = 89,
ChFive = 94,
ChSix = 87,
ChSeven = 21,
ChEight = 55,
});
// 验证输出列表数据条数运行后看控制台确认有2条
Console.WriteLine($"数据条数:{list.Count}");
Console.WriteLine($"数据条数1111");
// ########### 加这行调试输出 ###########
Console.WriteLine("Hello, World!");
System.Diagnostics.Debug.WriteLine("页面加载了112222222");
// ####################################
// 绑定到 DataGrid 显示
dataGrid1.ItemsSource = list;
}
private void btnBack_Click(object sender, RoutedEventArgs e)
{
NavigationService.Content = null;
}
private void GoHome(object s, RoutedEventArgs e) => NavigationService.Content = null;
private void GoTest(object s, RoutedEventArgs e) => NavigationService.Content = new Views.PageTest();
private void GoRecord(object s, RoutedEventArgs e) => NavigationService.Content = new Views.RecordDate();
private void GoView(object s, RoutedEventArgs e) => NavigationService.Content = new Views.RecordPage();
//NavigationService.Navigate(new Views.RecordDate()); 页面相互跳转
}
}

View File

@@ -0,0 +1,192 @@
<Page x:Class="头罩视野.Views.RecordPage"
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:头罩视野.Views"
mc:Ignorable="d"
d:DesignHeight="768" d:DesignWidth="1024"
Background="#F5F7FA"
Title="RecordPage">
<Page.Resources>
<!-- 标题样式 -->
<Style x:Key="MainTitleStyle" TargetType="TextBlock">
<Setter Property="FontSize" Value="28"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="Foreground" Value="#2C3E50"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="Margin" Value="0,15,0,15"/>
</Style>
<!-- DataGrid 样式 -->
<Style x:Key="DataGridStyle" TargetType="DataGrid">
<Setter Property="Background" Value="#FFFFFF"/>
<Setter Property="BorderBrush" Value="#E5E8E8"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="GridLinesVisibility" Value="Horizontal"/>
<Setter Property="HorizontalGridLinesBrush" Value="#ECF0F1"/>
<Setter Property="VerticalGridLinesBrush" Value="#ECF0F1"/>
<Setter Property="HeadersVisibility" Value="Column"/>
<Setter Property="CanUserAddRows" Value="False"/>
<Setter Property="CanUserDeleteRows" Value="False"/>
<Setter Property="AutoGenerateColumns" Value="False"/>
<Setter Property="IsReadOnly" Value="True"/>
<Setter Property="SelectionMode" Value="Single"/>
<Setter Property="SelectionUnit" Value="FullRow"/>
<Setter Property="RowHeight" Value="36"/>
<Setter Property="FontSize" Value="13"/>
<Setter Property="Foreground" Value="#2C3E50"/>
<Setter Property="ScrollViewer.CanContentScroll" Value="True"/>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
</Style>
<!-- DataGrid 列头样式 -->
<Style x:Key="DataGridColumnHeaderStyle" TargetType="DataGridColumnHeader">
<Setter Property="Background" Value="#E5E5E5"/>
<Setter Property="Foreground" Value="Black"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="Height" Value="40"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Padding" Value="10,8"/>
<Setter Property="BorderBrush" Value="#E5E5E5"/>
<Setter Property="BorderThickness" Value="0,0,1,0"/>
</Style>
<!-- DataGrid 行样式 -->
<Style x:Key="DataGridRowStyle" TargetType="DataGridRow">
<Setter Property="Background" Value="White"/>
<Style.Triggers>
<!-- 斑马线效果 -->
<Trigger Property="AlternationIndex" Value="0">
<Setter Property="Background" Value="#FFFFFF"/>
</Trigger>
<Trigger Property="AlternationIndex" Value="1">
<Setter Property="Background" Value="#F8F9F9"/>
</Trigger>
<!-- 鼠标悬停效果 -->
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#EBF5FB"/>
</Trigger>
<!-- 选中效果 -->
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="#D6EAF8"/>
<Setter Property="BorderBrush" Value="#3498DB"/>
<Setter Property="BorderThickness" Value="1"/>
</Trigger>
</Style.Triggers>
</Style>
<!-- DataGrid 单元格样式 -->
<Style x:Key="DataGridCellStyle" TargetType="DataGridCell">
<Setter Property="BorderBrush" Value="#ECF0F1"/>
<Setter Property="BorderThickness" Value="0,0,1,1"/>
<Setter Property="Padding" Value="10,8"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="TextBlock.TextAlignment" Value="Center"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="DataGridCell">
<Border BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}"
Padding="{TemplateBinding Padding}"
SnapsToDevicePixels="True">
<ContentPresenter VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="TabButtonStyle" TargetType="Button">
<Setter Property="Background" Value="#3498DB"/>
<Setter Property="FontSize" Value="20"/>
<Setter Property="Foreground" Value="#fff"/>
<Setter Property="Height" Value="70"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="BorderBrush" Value="#fff"/>
</Style>
</Page.Resources>
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- 顶部标题栏 -->
<Grid Grid.Row="0" Margin="0 0 0 10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="2" Style="{StaticResource MainTitleStyle}" Text="记录画面"
HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
<!--表格-->
<Grid Grid.Row="1" Margin="0 0 0 10">
<DataGrid x:Name="RecordDataGrid"
Height="400"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
AutoGenerateColumns="False"
CanUserAddRows="False"
IsReadOnly="True"
HeadersVisibility="Column"
GridLinesVisibility="All"
Style="{StaticResource DataGridStyle}"
AlternationCount="2"
ColumnHeaderStyle="{StaticResource DataGridColumnHeaderStyle}"
RowStyle="{StaticResource DataGridRowStyle}"
CellStyle="{StaticResource DataGridCellStyle}"
>
<!-- 表格列(你要的 6 列) -->
<DataGrid.Columns>
<DataGridTextColumn Header="编号" Binding="{Binding Id}" Width="80" IsReadOnly="True" />
<DataGridTextColumn Header="时间" Binding="{Binding Time}" Width="120" IsReadOnly="True"/>
<DataGridTextColumn Header="日期" Binding="{Binding Date}" Width="120" IsReadOnly="True" />
<DataGridTextColumn Header="左目视野面积" Binding="{Binding LeftEyeArea,StringFormat=F2}" Width="*" IsReadOnly="True" />
<DataGridTextColumn Header="右目视野面积" Binding="{Binding RightEyeArea,StringFormat=F2}" Width="*" IsReadOnly="True"/>
<DataGridTextColumn Header="双目视野面积" Binding="{Binding BinocularArea,StringFormat=F2}" Width="*" IsReadOnly="True"/>
</DataGrid.Columns>
</DataGrid>
</Grid>
<!--按钮-->
<Grid Grid.Row="2" Margin="0,30,0,0">
<!-- 停止 -->
<Button Content="保存" FontSize="18"
Width="120" Height="50" Background="#3498DB" Foreground="White" Margin="840,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Click="btnSave_Click" />
<Button Content="清除" FontSize="18"
Width="120" Height="50" Background="White" BorderBrush="red" Foreground="red" Margin="10,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Click="btnClear_Click"/>
<TextBlock HorizontalAlignment="Left" Foreground="red" Margin="139,14,0,0" TextWrapping="Wrap" VerticalAlignment="Top" FontSize="18" Width="202"><Run Language="zh-cn" Text="备注: 清除长按"/></TextBlock>
</Grid>
<!-- 底部导航栏 -->
<Grid Grid.Row="3" VerticalAlignment="Bottom">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button Style="{StaticResource TabButtonStyle}" Grid.Column="0" Content="主页"
Click="GoHome" />
<Button Style="{StaticResource TabButtonStyle}" Grid.Column="1" Content="测试界面"
Click="GoTest" />
<Button Style="{StaticResource TabButtonStyle}" Grid.Column="2" Content="数据记录"
Click="GoRecord" />
<Button Style="{StaticResource TabButtonStyle}" Grid.Column="3" Content="记录画面"
Click="GoView" />
</Grid>
</Grid>
</Page>

View File

@@ -0,0 +1,181 @@
using Modbus.Device;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO;
using System.Net.Sockets;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;
using OfficeOpenXml;
using .Services.Data;
namespace .Views
{
public class RecordList
{
public int Id { get; set; } // 编号
public string Time { get; set; } = string.Empty; // 时间
public string Date { get; set; } = string.Empty; // 日期
public double LeftEyeArea { get; set; } // 左目视野面积
public double RightEyeArea { get; set; } // 右目视野面积
public double BinocularArea { get; set; } // 双目视野面积
}
/// <summary>
/// RecordPage.xaml 的交互逻辑
/// </summary>
public partial class RecordPage : Page
{
// 表格数据源ObservableCollection增删会自动更新UI
private ObservableCollection<RecordList> _recordList = new ObservableCollection<RecordList>();
// Modbus通信对象从你的全局单例获取
private TcpClient _tcpClient => ModbusResourceManager.Instance.TcpClient;
private IModbusMaster _modbusMaster => ModbusResourceManager.Instance.ModbusMaster;
public RecordPage()
{
InitializeComponent();
// 绑定表格数据源
RecordDataGrid.ItemsSource = _recordList;
}
//#region 1. 从设备读取数据并添加到表格
public async System.Threading.Tasks.Task AddRecordFromDeviceAsync()
{
if (_modbusMaster == null)
{
MessageBox.Show("设备未连接,无法读取数据!");
return;
}
try
{
// 1. 从设备读取数据(替换成你实际的寄存器地址)
ushort[] leftReg = await _modbusMaster.ReadHoldingRegistersAsync(1, 100, 2);
ushort[] rightReg = await _modbusMaster.ReadHoldingRegistersAsync(1, 102, 2);
ushort[] binocularReg = await _modbusMaster.ReadHoldingRegistersAsync(1, 104, 2);
// 2. 把寄存器数据转成float
float leftEye = ConvertRegistersToFloat(leftReg);
float rightEye = ConvertRegistersToFloat(rightReg);
float binocularEye = ConvertRegistersToFloat(binocularReg);
// 3. 新增一条记录
var now = DateTime.Now;
var newRecord = new RecordList
{
Id = _recordList.Count + 1,
Date = now.ToString("yyyy-MM-dd"),
Time = now.ToString("HH:mm:ss"),
LeftEyeArea = leftEye,
RightEyeArea = rightEye,
BinocularArea = binocularEye
};
// 4. 添加到表格UI自动更新
_recordList.Add(newRecord);
MessageBox.Show("数据读取成功,已添加到表格!");
}
catch (Exception ex)
{
MessageBox.Show($"读取设备数据失败:{ex.Message}");
}
}
// 工具方法Modbus寄存器转float
private float ConvertRegistersToFloat(ushort[] registers)
{
byte[] bytes = new byte[4];
bytes[0] = (byte)(registers[0] >> 8);
bytes[1] = (byte)(registers[0] & 0xFF);
bytes[2] = (byte)(registers[1] >> 8);
bytes[3] = (byte)(registers[1] & 0xFF);
return BitConverter.ToSingle(bytes, 0);
}
//#endregion
//#region 2. 清除表格数据
private void btnClear_Click(object sender, RoutedEventArgs e)
{
// 确认清除
if (MessageBox.Show("确定要清除所有记录吗?", "确认", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
{
_recordList.Clear();
MessageBox.Show("数据已清除!");
}
}
//#endregion
//#region 3. 保存为Excel
private void btnSave_Click(object sender, RoutedEventArgs e)
{
// 你表格的数据源 👇
var dataList = RecordDataGrid.ItemsSource as IEnumerable<RecordList>;
if (dataList == null || !dataList.Any())
{
MessageBox.Show("没有数据可保存!");
return;
}
Microsoft.Win32.SaveFileDialog save = new Microsoft.Win32.SaveFileDialog();
save.Filter = "Excel 文件|*.xlsx";
save.FileName = "测试记录_" + DateTime.Now.ToString("yyyyMMddHHmmss");
if (save.ShowDialog() != true) return;
using (ExcelPackage package = new ExcelPackage())
{
ExcelWorksheet sheet = package.Workbook.Worksheets.Add("测试记录");
// 表头
sheet.Cells["A1"].Value = "编号";
sheet.Cells["B1"].Value = "时间";
sheet.Cells["C1"].Value = "日期";
sheet.Cells["D1"].Value = "左目视野面积";
sheet.Cells["E1"].Value = "右目视野面积";
sheet.Cells["F1"].Value = "双目视野面积";
// 写入数据
int row = 2;
foreach (var item in dataList)
{
sheet.Cells[row, 1].Value = item.Id;
sheet.Cells[row, 2].Value = item.Time;
sheet.Cells[row, 3].Value = item.Date;
sheet.Cells[row, 4].Value = item.LeftEyeArea;
sheet.Cells[row, 5].Value = item.RightEyeArea;
sheet.Cells[row, 6].Value = item.BinocularArea;
row++;
}
// 保存
File.WriteAllBytes(save.FileName, package.GetAsByteArray());
}
MessageBox.Show("保存成功!");
}
//#endregion
private void Page_Loaded(object sender, RoutedEventArgs e)
{
//InitializeModbusTcp();
}
private void GoHome(object s, RoutedEventArgs e) => NavigationService.Content = null;
private void GoTest(object s, RoutedEventArgs e) => NavigationService.Content = new Views.PageTest();
private void GoRecord(object s, RoutedEventArgs e) => NavigationService.Content = new Views.RecordDate();
private void GoView(object s, RoutedEventArgs e) => NavigationService.Content = new Views.RecordPage();
}
}

View File

@@ -0,0 +1,152 @@
<Page x:Class="头罩视野.Views.SetPassWord"
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:头罩视野.Views"
mc:Ignorable="d"
d:DesignHeight="768" d:DesignWidth="1024"
Background="#F0F0F0"
Title="SetPassWord">
<Grid Margin="20">
<!-- 背景圆环装饰 -->
<Canvas>
<Ellipse Canvas.Left="200" Canvas.Top="150" Width="600" Height="350"
Stroke="#87CEFA" StrokeThickness="6" Opacity="0.3"/>
<Ellipse Canvas.Left="250" Canvas.Top="200" Width="500" Height="250"
Stroke="#87CEFA" StrokeThickness="4" Opacity="0.2"/>
</Canvas>
<ScrollViewer VerticalScrollBarVisibility="Auto">
<StackPanel HorizontalAlignment="Center" Width="950">
<!-- 标题 -->
<TextBlock Text="密码时间设定" FontSize="36"
HorizontalAlignment="Center" Margin="0 20 0 40"
Foreground="Black" />
<!-- ===== 第一部分:当前时间 ===== -->
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="0 0 0 20">
<TextBlock Text="当前时间" FontSize="20" Foreground="Black"
VerticalAlignment="Center" Width="120"/>
<!-- 年 月 日 -->
<TextBox x:Name="NE_7" Text="" Width="130" Height="45" FontSize="20"
Foreground="Black" Background="White" Margin="5 0"/>
<TextBlock Text="年" FontSize="20" Foreground="Black" Margin="10 0 20 0"/>
<TextBox x:Name="NE_8" Text="" Width="130" Height="45" FontSize="20"
Foreground="Black" Background="White" Margin="5 0"/>
<TextBlock Text="月" FontSize="20" Foreground="Black" Margin="10 0 20 0"/>
<TextBox x:Name="NE_9" Text="" Width="130" Height="45" FontSize="20"
Foreground="Black" Background="White" Margin="5 0"/>
<TextBlock Text="日" FontSize="20" Foreground="Black" Margin="10 0 20 0"/>
<TextBlock Text="本机时间" FontSize="18" Foreground="Black" Margin="20 0 0 0"/>
</StackPanel>
<!-- ===== 第二部分提醒1 ===== -->
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="0 0 0 15">
<TextBlock Text="提醒1" FontSize="20" Foreground="Black"
VerticalAlignment="Center" Width="120"/>
<!-- 年 月 日 -->
<TextBox x:Name="NE_14" Text="" Width="130" Height="45" FontSize="20"
Foreground="Black" Background="White" Margin="5 0"/>
<TextBlock Text="年" FontSize="20" Foreground="Black" Margin="10 0 20 0"/>
<TextBox x:Name="NE_15" Text="" Width="130" Height="45" FontSize="20"
Foreground="Black" Background="White" Margin="5 0"/>
<TextBlock Text="月" FontSize="20" Foreground="Black" Margin="10 0 20 0"/>
<TextBox x:Name="NE_16" Text="" Width="130" Height="45" FontSize="20"
Foreground="Black" Background="White" Margin="5 0"/>
<TextBlock Text="日" FontSize="20" Foreground="Black" Margin="10 0 20 0"/>
</StackPanel>
<!-- ===== 第三部分到期1 ===== -->
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="0 0 0 15">
<TextBlock Text="到期1" FontSize="20" Foreground="Black"
VerticalAlignment="Center" Width="120"/>
<!-- 年 月 日 -->
<TextBox x:Name="NE_17" Text="" Width="130" Height="45" FontSize="20"
Foreground="Black" Background="White" Margin="5 0"/>
<TextBlock Text="年" FontSize="20" Foreground="Black" Margin="10 0 20 0"/>
<TextBox x:Name="NE_18" Text="" Width="130" Height="45" FontSize="20"
Foreground="Black" Background="White" Margin="5 0"/>
<TextBlock Text="月" FontSize="20" Foreground="Black" Margin="10 0 20 0"/>
<TextBox x:Name="NE_19" Text="" Width="130" Height="45" FontSize="20"
Foreground="Black" Background="White" Margin="5 0"/>
<TextBlock Text="日" FontSize="20" Foreground="Black" Margin="10 0 20 0"/>
</StackPanel>
<!-- ===== 第四部分提醒2 ===== -->
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="0 0 0 15">
<TextBlock Text="提醒2" FontSize="20" Foreground="Black"
VerticalAlignment="Center" Width="120"/>
<!-- 年 月 日 -->
<TextBox x:Name="NE_20" Text="" Width="130" Height="45" FontSize="20"
Foreground="Black" Background="White" Margin="5 0"/>
<TextBlock Text="年" FontSize="20" Foreground="Black" Margin="10 0 20 0"/>
<TextBox x:Name="NE_21" Text="" Width="130" Height="45" FontSize="20"
Foreground="Black" Background="White" Margin="5 0"/>
<TextBlock Text="月" FontSize="20" Foreground="Black" Margin="10 0 20 0"/>
<TextBox x:Name="NE_22" Text="" Width="130" Height="45" FontSize="20"
Foreground="Black" Background="White" Margin="5 0"/>
<TextBlock Text="日" FontSize="20" Foreground="Black" Margin="10 0 20 0"/>
</StackPanel>
<!-- ===== 第五部分到期2 ===== -->
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="0 0 0 15">
<TextBlock Text="到期2" FontSize="20" Foreground="Black"
VerticalAlignment="Center" Width="120"/>
<!-- 年 月 日 -->
<TextBox x:Name="NE_23" Text="" Width="130" Height="45" FontSize="20"
Foreground="Black" Background="White" Margin="5 0"/>
<TextBlock Text="年" FontSize="20" Foreground="Black" Margin="10 0 20 0"/>
<TextBox x:Name="NE_24" Text="" Width="130" Height="45" FontSize="20"
Foreground="Black" Background="White" Margin="5 0"/>
<TextBlock Text="月" FontSize="20" Foreground="Black" Margin="10 0 20 0"/>
<TextBox x:Name="NE_25" Text="" Width="130" Height="45" FontSize="20"
Foreground="Black" Background="White" Margin="5 0"/>
<TextBlock Text="日" FontSize="20" Foreground="Black" Margin="10 0 20 0"/>
</StackPanel>
<!-- ===== 第六部分:激活码与完全激活码 ===== -->
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="0 30 0 20">
<TextBlock Text="激活码" FontSize="22" Foreground="Black"
VerticalAlignment="Center" Width="120"/>
<!-- 激活码使用PasswordBox隐藏输入显示#### -->
<PasswordBox x:Name="ActiveCode_Password" Width="250" Height="45"
FontSize="20" Margin="5 0" Background="White"
PasswordChar="#"/>
<TextBlock Text="完全激活码" FontSize="20" Foreground="Black"
Margin="30 12 20 0"/>
<!-- 完全激活码 -->
<PasswordBox x:Name="FullActiveCode_Password" Width="250" Height="45"
FontSize="20" Margin="5 0" Background="White"
PasswordChar="#"/>
</StackPanel>
<!-- ===== 保存按钮 ===== -->
<Button x:Name="TS_0" Content="保存" FontSize="16"
Width="140" Height="50" HorizontalAlignment="Left"
Background="#87CEFA" Foreground="White"
Margin="140 20 0 30" />
</StackPanel>
</ScrollViewer>
</Grid>
</Page>

View File

@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Text;
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 .Views
{
/// <summary>
/// SetPassWord.xaml 的交互逻辑
/// </summary>
public partial class SetPassWord : Page
{
public SetPassWord()
{
InitializeComponent();
}
private void TS_0_Click(object sender, RoutedEventArgs e)
{
// 1. 获取普通文本框值(如时间)
string year1 = NE_7.Text;
string month1 = NE_8.Text;
// 2. 获取密码框值(激活码)
string activeCode = ActiveCode_Password.Password;
string fullActiveCode = FullActiveCode_Password.Password;
// 3. 在这里写入保存逻辑
MessageBox.Show($"保存成功!\n激活码{activeCode}", "提示");
}
}
}

View File

@@ -0,0 +1,117 @@
<Page x:Class="头罩视野.Views.SetTime"
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:头罩视野.Views"
mc:Ignorable="d"
d:DesignHeight="768" d:DesignWidth="1024"
Background="#F0F0F0"
Title="SetTime">
<Grid Background="#E0E9F2">
<!-- 背景科技感圆环 -->
<Canvas>
<Ellipse Canvas.Left="150" Canvas.Top="100" Width="500" Height="350"
Stroke="#87CEFA" StrokeThickness="8" Opacity="0.6"/>
<Ellipse Canvas.Left="200" Canvas.Top="150" Width="400" Height="250"
Stroke="#87CEFA" StrokeThickness="6" Opacity="0.4"/>
</Canvas>
<StackPanel VerticalAlignment="Top" HorizontalAlignment="Left" Margin="4,100,0,0">
<!-- 标题 -->
<TextBlock Text="打印时间设定" FontSize="32" Height="70"
HorizontalAlignment="Center" Margin="0 20 0 40"
/>
<!-- 第一行标签 -->
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0 0 0 15" Width="1011" Height="30">
<TextBlock FontSize="20" Width="118"><Run Language="zh-cn" Text=" "/><Run Text="年设置"/></TextBlock>
<TextBlock FontSize="20" Margin="0 0 30 0" Width="144"><Run Text=" "/><Run Language="zh-cn" Text=" "/><Run Text="月设置"/></TextBlock>
<TextBlock FontSize="20" Margin="0 0 30 0" Width="118"><Run Language="zh-cn" Text=" "/><Run Text="日设置"/></TextBlock>
<TextBlock FontSize="20" Margin="0 0 30 0" Width="118"><Run Text=" "/><Run Language="zh-cn" Text=" "/><Run Text="时设置"/></TextBlock>
<TextBlock FontSize="20" Margin="0 0 30 0" Width="110"><Run Text=" "/><Run Language="zh-cn" Text=" "/><Run Text="分设置"/></TextBlock>
<TextBlock FontSize="20" Margin="0 0 30 0" Width="110"><Run Language="zh-cn" Text=" "/><Run Text="秒设置"/></TextBlock>
<TextBlock FontSize="20" Width="125" ><Run Text=" "/><Run Language="zh-cn" Text=" "/><Run Text="星期"/></TextBlock>
</StackPanel>
<!-- 第一行输入框NE系列 -->
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0 0 0 20">
<TextBox x:Name="NE_0" Width="100" Height="40" FontSize="16"
Margin="0 0 15 0" BorderBrush="Gray" BorderThickness="1" TextChanged="NE_0_TextChanged"/>
<TextBlock Text="年" FontSize="16" VerticalAlignment="Center" Margin="0 0 15 0" />
<TextBox x:Name="NE_1" Width="100" Height="40" FontSize="16"
Margin="0 0 15 0" BorderBrush="Gray" BorderThickness="1"/>
<TextBlock Text="月" FontSize="16" VerticalAlignment="Center" Margin="0 0 15 0" />
<TextBox x:Name="NE_5" Width="100" Height="40" FontSize="16"
Margin="0 0 15 0" BorderBrush="Gray" BorderThickness="1"/>
<TextBlock Text="日" FontSize="16" VerticalAlignment="Center" Margin="0 0 15 0" />
<TextBox x:Name="NE_4" Width="100" Height="40" FontSize="16"
Margin="0 0 15 0" BorderBrush="Gray" BorderThickness="1"/>
<TextBlock Text="时" FontSize="16" VerticalAlignment="Center" Margin="0 0 15 0" />
<TextBox x:Name="NE_3" Width="100" Height="40" FontSize="16"
Margin="0 0 15 0" BorderBrush="Gray" BorderThickness="1"/>
<TextBlock Text="分" FontSize="16" VerticalAlignment="Center" Margin="0 0 15 0" />
<TextBox x:Name="NE_2" Width="100" Height="40" FontSize="16"
Margin="0 0 15 0" BorderBrush="Gray" BorderThickness="1"/>
<TextBlock Text="秒" FontSize="16" VerticalAlignment="Center" Margin="0 0 15 0" />
<TextBox x:Name="NE_6" Width="100" Height="40" FontSize="16"
BorderBrush="Gray" BorderThickness="1"/>
</StackPanel>
<!-- 第二行输入框ND/NE系列 -->
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0 0 0 40">
<TextBox x:Name="ND_0" Width="100" Height="40" FontSize="16"
Margin="0 0 15 0" BorderBrush="Gray" BorderThickness="1"/>
<TextBlock Text="年" FontSize="16" VerticalAlignment="Center" Margin="0 0 15 0" />
<TextBox x:Name="ND_1" Width="100" Height="40" FontSize="16"
Margin="0 0 15 0" BorderBrush="Gray" BorderThickness="1"/>
<TextBlock Text="月" FontSize="16" VerticalAlignment="Center" Margin="0 0 15 0" />
<TextBox x:Name="ND_5" Width="100" Height="40" FontSize="16"
Margin="0 0 15 0" BorderBrush="Gray" BorderThickness="1"/>
<TextBlock Text="日" FontSize="16" VerticalAlignment="Center" Margin="0 0 15 0" />
<TextBox x:Name="ND_4" Width="100" Height="40" FontSize="16"
Margin="0 0 15 0" BorderBrush="Gray" BorderThickness="1"/>
<TextBlock Text="时" FontSize="16" VerticalAlignment="Center" Margin="0 0 15 0" />
<TextBox x:Name="ND_3" Width="100" Height="40" FontSize="16"
Margin="0 0 15 0" BorderBrush="Gray" BorderThickness="1"/>
<TextBlock Text="分" FontSize="16" VerticalAlignment="Center" Margin="0 0 15 0" />
<TextBox x:Name="ND_2" Width="100" Height="40" FontSize="16"
Margin="0 0 15 0" BorderBrush="Gray" BorderThickness="1"/>
<TextBlock Text="秒" FontSize="16" VerticalAlignment="Center" Margin="0 0 15 0" />
<TextBox x:Name="NE_7" Width="100" Height="40" FontSize="16"
BorderBrush="Gray" BorderThickness="1"/>
</StackPanel>
<Button x:Name="TS_0" Content="保存" FontSize="24"
Width="160" Height="50"
Background="#87CEFA" Foreground="White"
BorderBrush="Gray" BorderThickness="0"
/>
<!-- 保存按钮 -->
</StackPanel>
<!-- 右下角退出按钮 -->
<Button x:Name="FK_0" Content="退出" FontSize="20"
Width="100" Height="50" HorizontalAlignment="Right" VerticalAlignment="Bottom"
Margin="0 0 10 10" Background="#87CEFA" Foreground="White"
/>
<Image Source="/Images/printTime.png" Opacity="1"
Margin="0,532,749,78"
/>
</Grid>
</Page>

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Text;
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 .Views
{
/// <summary>
/// SetTime.xaml 的交互逻辑
/// </summary>
public partial class SetTime : Page
{
public SetTime()
{
InitializeComponent();
//TS_0.Click += (s, e) => MessageBox.Show("时间设置已保存!");
//FK_0.Click += (s, e) => this.Close();
}
private void NE_0_TextChanged(object sender, TextChangedEventArgs e)
{
}
}
}

View File

@@ -0,0 +1,305 @@
<Page x:Class="头罩视野.Views.VisiData"
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:头罩视野.Views"
mc:Ignorable="d"
d:DesignHeight="769" d:DesignWidth="1024"
Background="#F5F7FA"
Title="VisiData" Loaded="Page_Loaded" >
<Page.Resources>
<!-- 标题样式 -->
<Style x:Key="MainTitleStyle" TargetType="TextBlock">
<Setter Property="FontSize" Value="28"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="Foreground" Value="#2C3E50"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="Margin" Value="0,15,0,15"/>
</Style>
<Style x:Key="LabelStyle" TargetType="TextBlock">
<Setter Property="FontSize" Value="16"/>
<Setter Property="Foreground" Value="#5D6D7E"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Margin" Value="0,0,10,0"/>
<Setter Property="Margin" Value="0,0,10,0"/>
<Setter Property="Width" Value="100"/>
</Style>
<Style x:Key="TextBoxStyle" TargetType="TextBox">
<Setter Property="Height" Value="40"/>
<Setter Property="Width" Value="150"/>
<Setter Property="FontSize" Value="18"/>
<Setter Property="TextAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="BorderBrush" Value="#D5D8DC"/>
<Setter Property="BorderThickness" Value="2"/>
<Setter Property="Background" Value="#FFFFFF"/>
<Setter Property="Foreground" Value="#2C3E50"/>
<Setter Property="Padding" Value="10,5"/>
<Style.Triggers>
<Trigger Property="IsFocused" Value="True">
<Setter Property="BorderBrush" Value="#3498DB"/>
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="TabButtonStyle" TargetType="Button">
<Setter Property="Background" Value="#3498DB"/>
<Setter Property="FontSize" Value="20"/>
<Setter Property="Foreground" Value="#fff"/>
<Setter Property="Height" Value="70"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="BorderBrush" Value="#fff"/>
</Style>
<!--<Style x:Key="ActButtonStyle" TargetType="Button">
<Setter Property="Background" Value="#8AB1EB"/>
<Setter Property="FontSize" Value="18"/>
<Setter Property="Foreground" Value="#fff"/>
<Setter Property="Height" Value="60"/>
<Setter Property="Width" Value="120"/>
</Style>-->
</Page.Resources>
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- 顶部标题栏 -->
<Grid Grid.Row="0" Margin="0 0 0 10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<!-- 测试界面标题 -->
<TextBlock Grid.Column="2" Style="{StaticResource MainTitleStyle}" Text="数据记录"
HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
<!-- 第二行:参数显示区 -->
<Grid Grid.Row="1" Margin="0 0 0 0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Border Grid.Row="0" Grid.Column="0" Background="#FFFFFF" CornerRadius="10"
BorderBrush="#E5E8E8" BorderThickness="1"
Padding="25,20" Margin="0,1,20,14" >
<StackPanel Cursor="" Grid.Column="0">
<StackPanel Orientation="Horizontal" Margin="0,0,0,15">
<TextBlock Text="上灯条数据1" Style="{StaticResource LabelStyle}"/>
<TextBox Name="sdtsj1" Text="" Style="{StaticResource TextBoxStyle}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="上灯条数据2" Style="{StaticResource LabelStyle}"/>
<TextBox Name="sdtsj2" Text="" Style="{StaticResource TextBoxStyle}"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,15,0,0">
<TextBlock Text="上灯条数据3" Style="{StaticResource LabelStyle}"/>
<TextBox Name="sdtsj3" Text="" Style="{StaticResource TextBoxStyle}"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,15,0,15">
<TextBlock Text="上灯条数据4" Style="{StaticResource LabelStyle}"/>
<TextBox Name="sdtsj4" Text="" Style="{StaticResource TextBoxStyle}" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="上灯条数据5" Style="{StaticResource LabelStyle}"/>
<TextBox Name="sdtsj5" Text="" Style="{StaticResource TextBoxStyle}"/>
</StackPanel>
</StackPanel>
</Border>
<Border Grid.Column="1" Background="#FFFFFF" CornerRadius="10"
BorderBrush="#E5E8E8" BorderThickness="1"
Padding="20,20" Margin="0,0,20,15" >
<StackPanel Cursor="" Grid.Column="0">
<StackPanel Orientation="Horizontal" Margin="0,0,0,15">
<TextBlock Text="下灯条数据1" Style="{StaticResource LabelStyle}"/>
<TextBox Name="xdtsj1" Text="" Style="{StaticResource TextBoxStyle}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="下灯条数据2" Style="{StaticResource LabelStyle}"/>
<TextBox Name="xdtsj2" Text="" Style="{StaticResource TextBoxStyle}"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,15,0,0">
<TextBlock Text="下灯条数据3" Style="{StaticResource LabelStyle}"/>
<TextBox Name="xdtsj3" Text="" Style="{StaticResource TextBoxStyle}"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,15,0,0">
<TextBlock Text="下灯条数据4" Style="{StaticResource LabelStyle}"/>
<TextBox Name="xdtsj4" Text="" Style="{StaticResource TextBoxStyle}"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,15,0,0">
<TextBlock Text="下灯条数据5" Style="{StaticResource LabelStyle}"/>
<TextBox Name="xdtsj5" Text="" Style="{StaticResource TextBoxStyle}"/>
</StackPanel>
</StackPanel>
</Border>
<Border Grid.Column="2" Background="#FFFFFF" CornerRadius="10"
BorderBrush="#E5E8E8" BorderThickness="1"
Padding="20,20" Margin="0,0,0,15" >
<StackPanel Cursor="" Grid.Column="0">
<StackPanel Orientation="Horizontal" Margin="0,0,0,15">
<TextBlock Text="左眼面积系数:" Style="{StaticResource LabelStyle}"/>
<TextBox Name="zymjxs" Text="" Style="{StaticResource TextBoxStyle}" Width="156"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="右眼面积系数:" Style="{StaticResource LabelStyle}"/>
<TextBox Name="yymjxs" Text="" Style="{StaticResource TextBoxStyle}" Width="156"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,15,0,0">
<TextBlock Text="保存矫正系数:" Style="{StaticResource LabelStyle}"/>
<TextBox Name="bcjzxs" Text="" Style="{StaticResource TextBoxStyle}" Width="158"/>
</StackPanel>
</StackPanel>
</Border>
</Grid>
<!-- 第三行:视野数据区 -->
<Grid Grid.Row="2" Margin="0 0 0 10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Border Grid.Row="0" Grid.Column="0" Background="#FFFFFF" CornerRadius="10"
BorderBrush="#E5E8E8" BorderThickness="1"
Padding="25,20" Margin="0,0,0,0" >
<StackPanel Cursor="">
<StackPanel Orientation="Horizontal">
<TextBlock Text="中灯条数据1" Style="{StaticResource LabelStyle}"/>
<TextBox Name="zdtsj1" Text="" Style="{StaticResource TextBoxStyle}"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,15,0,0">
<TextBlock Text="中灯条数据2" Style="{StaticResource LabelStyle}"/>
<TextBox Name="zdtsj2" Text="" Style="{StaticResource TextBoxStyle}"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,15,0,0">
<TextBlock Text="中灯条数据3" Style="{StaticResource LabelStyle}"/>
<TextBox Name="zdtsj3" Text="" Style="{StaticResource TextBoxStyle}"/>
</StackPanel>
</StackPanel>
</Border>
<Border Grid.Row="1" Grid.Column="1" Background="#FFFFFF" CornerRadius="10"
BorderBrush="#E5E8E8" BorderThickness="1"
Padding="20" Margin="20,0,0,0" >
<StackPanel Cursor="">
<StackPanel Orientation="Horizontal" Margin="0,15,0,0">
<TextBlock Text="中灯条数据4" Style="{StaticResource LabelStyle}"/>
<TextBox Name="zdtsj4" Text="" Style="{StaticResource TextBoxStyle}"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,15,0,0">
<TextBlock Text="中灯条数据5" Style="{StaticResource LabelStyle}"/>
<TextBox Name="zdtsj5" Text="" Style="{StaticResource TextBoxStyle}"/>
</StackPanel>
</StackPanel>
</Border>
<Border Grid.Row="2" Grid.Column="2" Background="#FFFFFF" CornerRadius="10"
BorderBrush="#E5E8E8" BorderThickness="1"
Padding="25,20" Margin="20,0,0,0" >
<StackPanel Cursor="">
<StackPanel Orientation="Horizontal" Margin="0,15,0,0">
<TextBlock Text="复位补偿:" Style="{StaticResource LabelStyle}"/>
<TextBox Name="fwbc" Text="" Style="{StaticResource TextBoxStyle}"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,15,0,0">
<TextBlock Text="电机限位:" Style="{StaticResource LabelStyle}"/>
<TextBox Name="djxw" Text="" Style="{StaticResource TextBoxStyle}"/>
</StackPanel>
</StackPanel>
</Border>
</Grid>
<!-- 第四行:控制按钮区 -->
<Grid Grid.Row="3" Margin="0 10 0 10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- 复位 -->
<Button Grid.Row="0" Grid.Column="0" Content="复位" FontSize="18"
Width="120" Height="40" Background="red" Foreground="White" Margin="5" Click="Button_Click_Reset" />
<!-- 左眼开 -->
<Button Grid.Row="0" Grid.Column="1" Content="左眼开" FontSize="18"
Width="120" Height="40" Background="#FF87CEFA" Foreground="White" Margin="5" Click="Button_Click_left"/>
<!-- 反转 -->
<Button Grid.Row="0" Grid.Column="2" Content="反转" FontSize="18"
Width="120" Height="40" Background="#FF87CEFA" Foreground="White" Margin="5" Click="Button_Click_Res"/>
<!-- 右眼开 -->
<Button Grid.Column="3" Content="右眼开" FontSize="18"
Width="120" Height="40" Background="#FF87CEFA" Foreground="White" Margin="6,0,0,0" Click="Button_Click_Right"
HorizontalAlignment="Left"/>
<!-- 正转 -->
<Button Grid.Column="3" Content="正转" FontSize="18"
Width="120" Height="40" Background="#FF87CEFA" Foreground="White" Click="Button_Click_For"
Margin="135,0,0,0" HorizontalAlignment="Left"/>
</Grid>
<!-- 底部导航栏 -->
<Grid Grid.Row="4" VerticalAlignment="Bottom">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button Style="{StaticResource TabButtonStyle}" Grid.Column="0" Content="主页"
Click="GoHome" />
<Button Style="{StaticResource TabButtonStyle}" Grid.Column="1" Content="测试界面"
Click="GoTest" />
<Button Style="{StaticResource TabButtonStyle}" Grid.Column="2" Content="数据记录"
Click="GoRecord" />
<Button Style="{StaticResource TabButtonStyle}" Grid.Column="3" Content="记录画面"
Click="GoView" />
</Grid>
</Grid>
</Page>

View File

@@ -0,0 +1,255 @@
using System;
using System.Collections.Generic;
using Modbus.Device;
using System.Net.Sockets;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;
using .Services;
using .Services.Data;
namespace .Views
{
/// <summary>
/// VisiData.xaml 的交互逻辑
/// </summary>
public partial class VisiData : Page
{
private TcpClient _tcpClient => ModbusResourceManager.Instance.TcpClient;
private IModbusMaster _modbusMaster => ModbusResourceManager.Instance.ModbusMaster;
DataChange c = new DataChange();
Function ma;
public VisiData()
{
InitializeComponent();
}
//复位btn
private void Button_Click_Reset(object sender, RoutedEventArgs e)
{
ma.BtnClickFunction(Function.ButtonType., 90);
}
//左开眼
private void Button_Click_left(object sender, RoutedEventArgs e)
{
ma.BtnClickFunction(Function.ButtonType., 0);
}
//右开眼
private void Button_Click_Right(object sender, RoutedEventArgs e)
{
ma.BtnClickFunction(Function.ButtonType., 1);
}
//反转
private void Button_Click_Res(object sender, RoutedEventArgs e)
{
ma.BtnClickFunction(Function.ButtonType., 10);
}
//正转
private void Button_Click_For(object sender, RoutedEventArgs e)
{
ma.BtnClickFunction(Function.ButtonType., 11);
}
//测试btn
private void Button_Click_Test(object sender, RoutedEventArgs e)
{
ma.BtnClickFunction(Function.ButtonType., 101);
}
//停止btn
private void Button_Click_Stop(object sender, RoutedEventArgs e)
{
ma.BtnClickFunction(Function.ButtonType., 103);
}
//读取
//读取数据
private DispatcherTimer InitDispatcherTimer()
{
var timer = new DispatcherTimer
{
Interval = TimeSpan.FromMilliseconds(100)
};
timer.Tick += async (s, e) =>
{
if (_modbusMaster != null)
{
try
{
await ReadAddr262DataAsync();
}
catch { }
}
};
return timer;
}
private async System.Threading.Tasks.Task ReadAddr262DataAsync()
{
try
{
// 创建任务列表
var tasks = new List<Task>
{
ReadAndUpdateFloatAsync(350, 1, sdtsj1, "F2", ""),
ReadAndUpdateFloatAsync(351, 1, sdtsj2, "F2", ""),
ReadAndUpdateFloatAsync(352, 1, sdtsj3, "F2", ""),
ReadAndUpdateFloatAsync(353, 1, sdtsj4, "F2", ""),
ReadAndUpdateFloatAsync(354, 1, sdtsj5, "F2", ""),
ReadAndUpdateFloatAsync(212, 2, zymjxs, "F2", ""),
ReadAndUpdateFloatAsync(214, 2, yymjxs, "F2", ""),
ReadAndUpdateFloatAsync(428,2, bcjzxs, "F2", ""),
ReadAndUpdateFloatAsync(355,1, xdtsj1, "F2", " "),
ReadAndUpdateFloatAsync(356,1, xdtsj2, "F2", " "),
ReadAndUpdateFloatAsync(357,1, xdtsj3, "F2", " "),
ReadAndUpdateFloatAsync(358,1, xdtsj4, "F2", " "),
ReadAndUpdateFloatAsync(359,1, xdtsj5, "F2", " "),
ReadAndUpdateFloatAsync(360,1, zdtsj1, "F2", " "),
ReadAndUpdateFloatAsync(361,1, zdtsj2, "F2", " "),
ReadAndUpdateFloatAsync(362,1, zdtsj3, "F2", " "),
ReadAndUpdateFloatAsync(363,1, zdtsj4, "F2", " "),
ReadAndUpdateFloatAsync(364,1, zdtsj5, "F2", " "),
ReadAndUpdateFloatAsync(340,2, fwbc, "F2", " "),
ReadAndUpdateFloatAsync(330,2, djxw, "F2", " "),
};
await Task.WhenAll(tasks);
}
catch (Exception ex)
{
ShowError($"读取数据失败:{ex.Message}");
}
}
// 地址, 根据格式显示字符长度 322 161 绑定页面的name 值F2 保留两位小数,单位
private async Task ReadAndUpdateFloatAsync(int address, int length, System.Windows.Controls.TextBox control, string format, string unit)
{
try
{
ushort[] registers = await Task.Run(async () =>
await _modbusMaster.ReadHoldingRegistersAsync(1, (ushort)address, (ushort)length)
);
if (registers != null && registers.Length >= 2)
{
float value = c.UshortToFloat(registers[1], registers[0]);
Dispatcher.Invoke(() => control.Text = value.ToString(format) + unit);
}
else if (registers != null && registers.Length >= 1)
{
int value = registers[0];
Dispatcher.Invoke(() => control.Text = value.ToString(format) + unit);
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"读取地址{address}失败:{ex.Message}");
}
}
private async Task ReadAndUpdateFloatAsync(int address, int length, System.Windows.Controls.TextBlock control, string format, string unit)
{
try
{
ushort[] registers = await Task.Run(async () =>
await _modbusMaster.ReadHoldingRegistersAsync(1, (ushort)address, (ushort)length)
);
if (registers != null && registers.Length >= 2)
{
float value = c.UshortToFloat(registers[1], registers[0]);
Dispatcher.Invoke(() => control.Text = value.ToString(format) + unit);
}
else if (registers != null && registers.Length >= 1)
{
int value = registers[0];
Dispatcher.Invoke(() => control.Text = value.ToString(format) + unit);
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"读取地址{address}失败:{ex.Message}");
}
}
private async Task ReadAndUpdateIntAsync(int address, int length, System.Windows.Controls.Control control, string format)
{
try
{
ushort[] registers = await Task.Run(() =>
_modbusMaster.ReadHoldingRegisters(1, (ushort)address, (ushort)length)
);
if (registers != null && registers.Length >= 1)
{
int value = registers[0];
Dispatcher.Invoke(() =>
{
if (control is System.Windows.Controls.ContentControl contentControl)
contentControl.Content = value.ToString(format);
else if (control is System.Windows.Controls.TextBox textBox)
textBox.Text = value.ToString(format);
});
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"读取地址{address}失败:{ex.Message}");
}
}
private void ShowError(string msg) => MessageBox.Show(msg, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
private void GoHome(object s, RoutedEventArgs e) => NavigationService.Content = null;
private void GoTest(object s, RoutedEventArgs e) => NavigationService.Content = new Views.PageTest();
private void GoRecord(object s, RoutedEventArgs e) => NavigationService.Content = new Views.RecordDate();
private void GoView(object s, RoutedEventArgs e) => NavigationService.Content = new Views.RecordPage();
private void InitializeModbusTcp()
{
try
{
string plcIp = "192.168.1.10";
bool initSuccess = ModbusResourceManager.Instance.Init(plcIp, 502);
if (!initSuccess)
{
MessageBox.Show("连接Modbus服务器失败", "错误");
//this.Close();
return;
}
// 检查连接状态
if (_tcpClient == null || !_tcpClient.Connected)
{
MessageBox.Show("Modbus连接异常", "错误");
return;
}
ma = new Function(_modbusMaster);
}
catch (Exception ex)
{
ShowError($"Modbus初始化失败: {ex.Message}");
}
}
private void Page_Loaded(object sender, RoutedEventArgs e)
{
//InitializeModbusTcp();
}
}
}

Some files were not shown because too many files have changed in this diff Show More