项目 8 智慧校园管理平台:5 个任务的示例、自绘素材、WisdomCampus 数据库
CI/CD / test (push) Canceled after 0s
CI/CD / deploy (push) Canceled after 0s

- 示例 p8-t1…t5(代码逐个累加):主界面、校园环境界面、环境采集与分析(路灯手动 / 自动控制、
  LED 推送、自动推送火情、7 天温度图表)、校园安防(入侵提示、摄像机方向、拍照入库)、历史图片
  (按日期查询、左右切换),各有评分规则
- 按书补全参考工程里空着的"推送LED信息""自动控制",给"自动推送火情"绑定 CheckedChanged
  (书上第 23 步写成了 ch_autoLamp);任务 5 每次查询前清空 Keys
- 素材:项目 8 的 20 多张图片全部自绘,名字和尺寸与教材一致(project8.py 生成 SVG,
  build-gallery.sh 渲染成 PNG;源文件移到 svg/)
- 数据库 WisdomCampus 按教材的表结构建(EnvironmentData、SecurityData、Users),预置 7 天环境数据
- 测试:参考答案全部通过;没绑定"自动推送火情"、开灯换错背景图片时报出对应原因
- 文档:教材 8 个项目全部有示例,共 23 个

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
xuyueandClaude Opus 5.5 committed 2026-10-23 15:15:00 +08:00
1 parent b20db5721e
commit 65a1b3a81e
109 files changed
+7807 -9

No files matched your search

+2 -2
View File
@@ -67,8 +67,8 @@ Docker Compose,HTTPS 由服务器上的 Nginx Proxy Manager 负责。推送到
已完成:
- **虚拟实训台**:按教材实训台布局图排列(红外对射、警示灯、LED 屏、照明灯、人体红外、温湿度、光照、烟雾、火焰、ADAM 模块)。每个浏览器会话一台,状态由服务器统一保存:传感器读数由网页上的滑块和开关设定,经服务器推给学生程序;灯、继电器、LED 屏由学生程序控制。
- 新控件:CheckBox、RadioButton(事件顺序与 WinForms 一致)、ListBox、PictureBox、DataGridView、DateTimePicker、TrackBar、Windows Media Player,教材控件库的 Lamp、Alarm。
- 示例工程(按书上代码整理):项目 1 任务 1–2、项目 2 任务 1–3、项目 3 任务 1–2、项目 4 任务 1–3、项目 5 任务 1–3、项目 6 任务 2–3、项目 7 任务 1–3,共 18 个(项目 6 任务 1 在数据库页面上完成)。网址带 `?sample=示例编号` 可直接打开指定示例。
- 新控件:CheckBox、RadioButton(事件顺序与 WinForms 一致)、ListBox、PictureBox、DataGridView、DateTimePicker、TrackBar、Windows Media Player、Chart(图表),教材控件库的 Lamp、Alarm;Panel 停靠布局、背景图片、无边框窗体。
- 示例工程(按书上代码整理):项目 1 任务 1–2、项目 2 任务 1–3、项目 3 任务 1–2、项目 4 任务 1–3、项目 5 任务 1–3、项目 6 任务 2–3、项目 7 任务 1–3、项目 8 任务 1–5,共 23 个(项目 6 任务 1 在数据库页面上完成)。网址带 `?sample=示例编号` 可直接打开指定示例。
- 代码编辑器(Monaco):C# 高亮、编译错误波浪线、点错误跳到对应行、F5 运行 / Shift+F5 停止、草稿自动保存在浏览器本地。
- 窗体设计器(仿 VS,界面中文):工具箱、拖放与改大小、属性窗口、事件窗口、双击生成事件处理方法、撤销 / 重做;读写 VS 格式的 Designer.cs。
- 多窗体:新建、删除窗体;运行时多个窗口可切换前后。
+15 -2
View File
@@ -215,7 +215,7 @@ IOT/
| 5 灾情监测 | 火焰(Timer)、烟雾(Thread)、灾情记录与推送 | Thread(含 Suspend / Resume / Abort)、跨线程改界面、ListBox、FormClosing | 已完成 |
| 6 数据存储 | 建库建表、采集入库与增删改、按时间段查询 | SQL 窗口(代替 SSMS)、SqlClient 仿冒(SQLite)、DataGridView、DateTimePicker | 已完成 |
| 7 情景控制 | 智慧教室、寝室、会议室三种情景联动 | TrackBar、资源图片、PictureBox 当按钮、mp3 播放、虚拟时钟 | 已完成 |
| 8 管理平台 | 主界面、校园环境(自动控制、7 天温度图表)、校园安防(抓拍入库、历史图片) | Panel Dock、无边框窗体、透明背景、Chart、ShowDialog、图片存数据库 | |
| 8 管理平台 | 主界面、校园环境(自动控制、7 天温度图表)、校园安防(抓拍入库、历史图片) | Panel Dock、无边框窗体、透明背景、Chart、ShowDialog、图片存数据库 | 已完成 |
每个实验以数据形式存放(目前在 `samples/`,以后迁到 `content/`),由以下部分组成:
@@ -237,7 +237,7 @@ flowchart TB
P0["阶段 0 · 技术验证(已完成 2026-10-22)<br/>教材项目 2 任务 1 原样运行;实测编译、延迟、内存"]
P1["阶段 1 · MVP(进行中,约 3 个月)<br/>虚拟实训台 ✔、代码编辑器 ✔、窗体设计器 ✔、多窗体 ✔<br/>教材示例:项目 1–3 全部 ✔,项目 4–5 中平台已支持的 3 个任务 ✔<br/>部署(沙箱、Docker Compose、GitHub Actions)✔"]
P2["阶段 2 · 教学闭环(进行中,约 2 个月)<br/>账号与班级 ✔、作品保存在服务器 ✔、自动评分 ✔、布置与提交作业 ✔<br/>评阅(看代码、运行、老师评分、评语)✔、成绩表与导出 ✔;一个班试用"]
P3["阶段 3 · 扩展(进行中)<br/>教材项目 4–8:摄像头 ✔、线程 ✔、SQLite 模拟数据库 ✔、虚拟时钟 ✔、图表"]
P3["阶段 3 · 扩展(进行中)<br/>教材项目 4–8:摄像头 ✔、线程 ✔、SQLite 模拟数据库 ✔、虚拟时钟 ✔、图表 ✔"]
P4["阶段 4 · 进阶(之后)<br/>校园街景场景、故障注入题库、导出 VS 工程"]
P0 -->|"关口:链路跑通,延迟和资源占用可接受"| P1
P1 -->|"关口:教材项目 1–3 能在平台上完整做完"| P2
@@ -298,6 +298,19 @@ flowchart TB
- **TrackBar**:拖动、点轨道(LargeChange)、方向键(SmallChange),先 ValueChanged 再 Scroll,竖向时最小值在下面;设计器工具箱加"滑动条""媒体播放器"。评分规则加 `value`(滑动条的值)、`media`(播放了某个文件)检查。
- 示例:书上任务 1 手动开关灯的判断写反(参考工程是对的),任务 3 漏了填充串口列表,示例里都已改正;任务 3 的"每 5 分钟整点拍照"依赖定时器正好在 0 秒触发,自动评分不检查这一项,由老师评阅。编译检查修正:`System.AppDomain.CurrentDomain.BaseDirectory`(带命名空间)也放行。
- 2026-10-23:项目 8 智慧校园管理平台(5 个任务,每个任务一个示例,代码逐个累加),至此教材 8 个项目全部完成,共 23 个示例。
- **新建类**:实验页"+ 新建类",可以带文件夹(`SQLHelpers/SQLBLL`),文件夹成为命名空间的一段,模板和 VS 2012 一样;可以删除自己建的类。
- **停靠布局**:Dock(上、下、左、右、填充)和 WinForms 一样按 Controls 倒序依次停靠,Panel 的边框、GroupBox 的标题占的地方扣掉;窗体改大小、控件显示隐藏、加入移出时重新布局。设计器里改了停靠或大小也立即按同样的规则排好。
- **背景图片**:BackgroundImage + BackgroundImageLayout(平铺、居中、拉伸、缩放),窗体、面板、图片框都可以设,设计器里从项目资源选。**背景色沿用父控件**:没设置背景色的标签、面板、分组框等画父控件的背景色(不是父控件的背景图片),和 WinForms 一样,所以书上要把放在背景图上的控件设成 Transparent。分组框的标题处边框断开、透出背景(书上分组框放在深色背景上、标题是白字)。文本框的 BackColor 生效。
- **无边框窗体**:FormBorderStyle = None 时没有标题栏;**运行区自动缩放**:窗体比运行区大时(项目 8 的窗体有 1043×791)整体按比例缩小,右上角显示缩放比例;"放大"让运行区占满整个网页(窗体在左、实训台在右),Esc 还原。
- **图表**(`System.Windows.Forms.DataVisualization.Charting.Chart`):ChartAreas、Legends、Series(AddXY、Points、ChartType 等)、DataSource + DataBind(DataTable / DataView / DataSet,按 XValueMember、YValueMembers 取列),浏览器用 Chart.js 画,配色是 WinForms 默认的 BrightPastel。设计器工具箱加"图表"(和 VS 一样带 ChartArea1、Legend1、Series1),属性窗口"系列和图例"打开对话框编辑系列(名称、图表类型、图例、图例文字、X / Y 值字段)和图例,按 VS 的格式和顺序写回 Designer.cs,对话框不管的属性原样保留。
- **路径的反斜杠**:书上写 `BaseDirectory + "Camera\\"`,Linux 上反斜杠会成为文件名的一部分。编译时把传给 System.IO(File、Directory、Path、各种 Stream)和 Image / Bitmap 读写文件方法的路径参数包上 `WindowsPaths.Fix`,反斜杠换成斜杠(和线程、时钟的改写一样不换行、编辑器里看到的是原代码)。
- **其他**:Paint 事件(VS 双击面板生成的空 `panel1_Paint` 能编译,平台不触发);图片框把鼠标按下、松开发给程序(书上方向键按下时转动摄像机、换成按下的图片);数据库里参数化的日期字符串比较时也转换格式(书上拼出的 `"2024/1/23 23:59:59"` 有两个空格)。
- **素材**:项目 8 用到的 20 多张图片(标题、校园背景、三个入口图标、亮灯 / 灭灯的路灯场景、面板背景、监控图标、方向盘和方向键、翻页箭头、关闭按钮)全部自绘,名字和尺寸与教材一致(`runtime/Sim.WinForms/Resources/project8.py` 生成 SVG,`build-gallery.sh` 渲染成 PNG)。
- **数据库 WisdomCampus**:平台按教材的表结构建(EnvironmentData、SecurityData、Users),预置 7 天环境数据,"数据分析"的图表一打开就有内容。学生第一次运行带预置数据库的实验时自动建好自己还没有的库(已有的库不动)。
- **评分规则**新增:`visible`(连同所在容器都可见)、`window`(某个窗体打开着 / 已关闭)、`exited`(程序已退出)、`image` / `background` 写素材名(如 `background: day_01`,按图片内容核对显示的是不是这张素材)、`points`(图表每个系列的数据点数);"点击"图片框时和浏览器一样先发鼠标按下、松开。
- **示例**:书上任务 3 第 23 步把"自动推送火情"的处理写到了 ch_autoLamp 上,参考工程里"推送LED信息""自动控制"是空方法、"自动推送火情"没有绑定事件,示例按书的意思补全;任务 5 每次查询前清空 Keys(书上没清空,重复查询时照片和时间对不上)。任务 2 只做界面,为了能看效果加上了打开、返回窗体。
**其他改进**:
- 2026-10-22:代码编辑器的语言功能:代码补全(输入 `btn_Open.` 列出按钮的属性、方法、事件,只列出平台仿真了的成员)、悬停提示、参数提示(`MessageBox.Show(` 列出重载,标出正在填的参数)、停止输入 1 秒后自动检查编译错误(提示和点"运行"时一样)。语言服务是一个常驻进程,每个浏览器标签页一份工程,只更新有变化的文件。实测(限制 2 核):50 个标签页同时检查 1.2 秒内全部完成,同时补全 0.7 秒;内存约 260 MB。
+2 -2
View File
@@ -1,7 +1,7 @@
# 项目资源素材库
学生在"项目资源"里添加的图片和声音(`Properties.Resources.xxx`),名字和教材一致,全部由平台自绘或合成(不使用教材配套资料里的素材)。
学生在"项目资源"里添加的图片和声音(`Properties.Resources.xxx`),名字和尺寸与教材一致,全部由平台自绘或合成(不使用教材配套资料里的素材)。
- `gallery/`:发布给运行器和网页的文件,`index.json` 是清单(名字、文件、中文说明、类型)。
- `*.svg`:图片的源文件,改了以后用 `rsvg-convert xxx.svg -o gallery/xxx.png` 重新生成。
- `svg/`:图片的源文件;`project8.py` 生成项目 8 的那些 SVG。改了以后运行 `python3 project8.py && sh build-gallery.sh` 重新生成 PNG(需要 rsvg-convert 和思源黑体)。
- `gallery/ring.mp3`:用 ffmpeg 合成的门铃声(叮—咚),命令见提交记录。
@@ -0,0 +1,6 @@
#!/bin/sh
# 把 svg/ 下的素材渲染成 gallery/ 下的 PNG(尺寸取 SVG 自己的 width / height)。需要 rsvg-convert 和思源黑体等中文字体。
cd "$(dirname "$0")"
for f in svg/*.svg; do
rsvg-convert "$f" -o "gallery/$(basename "$f" .svg).png"
done
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

@@ -1,5 +1,27 @@
[
{ "name": "switch_on", "file": "switch_on.png", "label": "开关:开", "kind": "image" },
{ "name": "switch_off", "file": "switch_off.png", "label": "开关:关", "kind": "image" },
{ "name": "ring", "file": "ring.mp3", "label": "铃声", "kind": "audio" }
{ "name": "ring", "file": "ring.mp3", "label": "铃声", "kind": "audio" },
{ "name": "ico_title", "file": "ico_title.png", "label": "标题:智慧校园", "kind": "image" },
{ "name": "bg_home", "file": "bg_home.png", "label": "主界面背景:校园", "kind": "image" },
{ "name": "icon_02", "file": "icon_02.png", "label": "图标:校园环境", "kind": "image" },
{ "name": "icon_03", "file": "icon_03.png", "label": "图标:校园安防", "kind": "image" },
{ "name": "icon_04", "file": "icon_04.png", "label": "图标:退出", "kind": "image" },
{ "name": "day_01", "file": "day_01.png", "label": "路灯场景:亮灯", "kind": "image" },
{ "name": "day_02", "file": "day_02.png", "label": "路灯场景:灭灯", "kind": "image" },
{ "name": "bg_from1", "file": "bg_from1.png", "label": "面板背景(宽)", "kind": "image" },
{ "name": "bg_from2", "file": "bg_from2.png", "label": "面板背景(窄)", "kind": "image" },
{ "name": "icon_monitor", "file": "icon_monitor.png", "label": "监控:无画面", "kind": "image" },
{ "name": "panel_video_ctrl", "file": "panel_video_ctrl.png", "label": "监控:方向盘底座", "kind": "image" },
{ "name": "btn_arrow_up_normal", "file": "btn_arrow_up_normal.png", "label": "方向键:上", "kind": "image" },
{ "name": "btn_arrow_up_press", "file": "btn_arrow_up_press.png", "label": "方向键:上(按下)", "kind": "image" },
{ "name": "btn_arrow_down_normal", "file": "btn_arrow_down_normal.png", "label": "方向键:下", "kind": "image" },
{ "name": "btn_arrow_down_press", "file": "btn_arrow_down_press.png", "label": "方向键:下(按下)", "kind": "image" },
{ "name": "btn_arrow_left_normal", "file": "btn_arrow_left_normal.png", "label": "方向键:左", "kind": "image" },
{ "name": "btn_arrow_left_press", "file": "btn_arrow_left_press.png", "label": "方向键:左(按下)", "kind": "image" },
{ "name": "btn_arrow_right_normal", "file": "btn_arrow_right_normal.png", "label": "方向键:右", "kind": "image" },
{ "name": "btn_arrow_right_press", "file": "btn_arrow_right_press.png", "label": "方向键:右(按下)", "kind": "image" },
{ "name": "arrow_left_normal", "file": "arrow_left_normal.png", "label": "翻页:上一张", "kind": "image" },
{ "name": "arrow_right_normal", "file": "arrow_right_normal.png", "label": "翻页:下一张", "kind": "image" },
{ "name": "windowstate_closed_hover", "file": "windowstate_closed_hover.png", "label": "关闭按钮", "kind": "image" }
]
Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 612 B

+170
View File
@@ -0,0 +1,170 @@
#!/usr/bin/env python3
"""
生成教材项目 8(智慧校园管理平台)用到的素材 SVG:名字和尺寸与教材配套资源一致,内容全部自绘(扁平插画)。
运行后用 build-gallery.sh 渲染成 PNG:python3 project8.py && sh build-gallery.sh
"""
from pathlib import Path
OUT = Path(__file__).parent / "svg"
OUT.mkdir(exist_ok=True)
FONT = "Source Han Sans CN, Noto Sans CJK SC, sans-serif"
def save(name, width, height, body):
(OUT / f"{name}.svg").write_text(
f'<svg xmlns="http://www.w3.org/2000/svg" width="{width}" height="{height}" viewBox="0 0 {width} {height}">\n{body}\n</svg>\n',
encoding="utf-8",
)
# ---------- 标题图:智慧校园 ----------
save("ico_title", 226, 54, f"""
<g transform="translate(8,7)">
<circle cx="20" cy="20" r="19" fill="#ffffff" opacity="0.95"/>
<path d="M7 27 L20 10 L33 27 Z" fill="#3593ed"/>
<rect x="13" y="22" width="14" height="9" fill="#3593ed"/>
<rect x="18" y="25" width="4" height="6" fill="#ffffff"/>
</g>
<text x="56" y="37" font-family="{FONT}" font-size="27" font-weight="bold" fill="#ffffff" letter-spacing="3">智慧校园</text>
""")
# ---------- 校园建筑:主界面背景、路灯场景共用的元素 ----------
def building(x, y, w, h, color, window="#cfe3f5", rows=4, cols=6, roof="#b36b45"):
parts = [f'<rect x="{x}" y="{y}" width="{w}" height="{h}" fill="{color}"/>',
f'<rect x="{x-8}" y="{y-14}" width="{w+16}" height="16" fill="{roof}"/>']
gap_x = w / cols
gap_y = (h - 30) / rows
for r in range(rows):
for c in range(cols):
parts.append(f'<rect x="{x + c*gap_x + gap_x*0.22:.1f}" y="{y + 18 + r*gap_y:.1f}" width="{gap_x*0.56:.1f}" height="{gap_y*0.55:.1f}" fill="{window}"/>')
return "\n".join(parts)
def tree(x, y, s=1.0, color="#4f9a45"):
return (f'<rect x="{x-6*s}" y="{y}" width="{12*s}" height="{60*s}" fill="#7a5230"/>'
f'<circle cx="{x}" cy="{y-30*s}" r="{48*s}" fill="{color}"/><circle cx="{x-32*s}" cy="{y-5*s}" r="{34*s}" fill="{color}"/>'
f'<circle cx="{x+32*s}" cy="{y-5*s}" r="{34*s}" fill="#468c3e"/>')
save("bg_home", 1440, 748, f"""
<defs>
<linearGradient id="sky" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#5aa7ea"/><stop offset="1" stop-color="#cfe8fb"/></linearGradient>
<linearGradient id="lawn" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#8cc66d"/><stop offset="1" stop-color="#5f9e45"/></linearGradient>
</defs>
<rect width="1440" height="748" fill="url(#sky)"/>
<circle cx="1260" cy="120" r="60" fill="#fff3b0" opacity="0.9"/>
<g fill="#ffffff" opacity="0.85">
<ellipse cx="260" cy="120" rx="90" ry="30"/><ellipse cx="320" cy="105" rx="60" ry="28"/>
<ellipse cx="880" cy="90" rx="110" ry="32"/><ellipse cx="950" cy="80" rx="70" ry="28"/>
</g>
<g opacity="0.55" fill="#9fb8cf">
<rect x="40" y="300" width="160" height="260"/><rect x="1230" y="280" width="180" height="280"/><rect x="230" y="340" width="120" height="220"/>
</g>
{building(380, 260, 680, 300, "#f2e3c9")}
<rect x="660" y="190" width="120" height="70" fill="#f2e3c9"/><rect x="650" y="178" width="140" height="16" fill="#b36b45"/>
<circle cx="720" cy="225" r="20" fill="#ffffff" stroke="#8a6a4a" stroke-width="4"/>
<rect x="680" y="470" width="80" height="90" fill="#8a6a4a"/>
{building(1080, 360, 220, 200, "#e8d6bd", rows=3, cols=4)}
{building(150, 380, 210, 180, "#e8d6bd", rows=3, cols=4)}
<rect x="0" y="560" width="1440" height="188" fill="url(#lawn)"/>
<path d="M560 748 L680 560 L760 560 L880 748 Z" fill="#d9c9a8"/>
{tree(120, 600, 1.1)}{tree(330, 620, 0.9)}{tree(1130, 610, 1.0)}{tree(1350, 600, 1.2)}
<g fill="#3f8a3a"><ellipse cx="480" cy="572" rx="90" ry="22"/><ellipse cx="960" cy="572" rx="90" ry="22"/></g>
""")
def street(lit):
sky = ('<stop offset="0" stop-color="#2b3d66"/><stop offset="1" stop-color="#e8a76b"/>' if lit
else '<stop offset="0" stop-color="#6bb0ea"/><stop offset="1" stop-color="#d6ecfb"/>')
window = "#ffd37a" if lit else "#cfe3f5"
lamps = []
for x in (180, 520, 860, 1200):
lamps.append(f'<rect x="{x}" y="380" width="12" height="260" fill="#4b5563"/>'
f'<path d="M{x+6} 386 Q{x+6} 356 {x+46} 356 H{x+70}" stroke="#4b5563" stroke-width="10" fill="none"/>'
f'<rect x="{x+56}" y="348" width="44" height="16" rx="5" fill="#374151"/>')
if lit:
lamps.append(f'<path d="M{x+60} 364 L{x+20} 640 H{x+140} L{x+96} 364 Z" fill="#fff3b0" opacity="0.35"/>'
f'<ellipse cx="{x+78}" cy="366" rx="22" ry="7" fill="#fff8d0"/>')
else:
lamps.append(f'<ellipse cx="{x+78}" cy="366" rx="18" ry="5" fill="#9ca3af"/>')
return f"""
<defs><linearGradient id="sky" x1="0" y1="0" x2="0" y2="1">{sky}</linearGradient></defs>
<rect width="1440" height="716" fill="url(#sky)"/>
{'<circle cx="1180" cy="110" r="36" fill="#fff6c8"/>' if lit else '<circle cx="1220" cy="110" r="50" fill="#fff3b0" opacity="0.9"/>'}
{building(80, 220, 560, 330, "#e9d8bf", window=window, rows=5, cols=7)}
{building(760, 260, 580, 290, "#dcc7a8", window=window, rows=4, cols=7)}
<rect x="0" y="550" width="1440" height="40" fill="#7fb06a"/>
<rect x="0" y="590" width="1440" height="126" fill="#5b6472"/>
<g fill="#f8fafc">{''.join(f'<rect x="{x}" y="648" width="70" height="8"/>' for x in range(30, 1440, 140))}</g>
{''.join(lamps)}
{tree(700, 560, 0.8, "#3f7f45")}{tree(1390, 560, 0.9, "#3f7f45")}
"""
save("day_01", 1440, 716, street(lit=True))
save("day_02", 1440, 716, street(lit=False))
# ---------- 主界面的三个功能图标 ----------
def tile(name, color, icon, label):
save(name, 180, 210, f"""
<rect x="6" y="6" width="168" height="198" rx="18" fill="{color}"/>
<rect x="6" y="6" width="168" height="198" rx="18" fill="#ffffff" opacity="0.08"/>
<g transform="translate(90,82)" fill="#ffffff" stroke="#ffffff">{icon}</g>
<text x="90" y="178" font-family="{FONT}" font-size="24" font-weight="bold" fill="#ffffff" text-anchor="middle">{label}</text>
""")
tile("icon_02", "#2e9e5b", """
<rect x="-6" y="10" width="12" height="40" stroke="none"/>
<circle cx="0" cy="-12" r="34" stroke="none"/><circle cx="-26" cy="8" r="22" stroke="none"/><circle cx="26" cy="8" r="22" stroke="none"/>
<path d="M-4 -2 L0 -30 L4 -2" fill="#2e9e5b" stroke="none"/>""", "校园环境")
tile("icon_03", "#2f7fe0", """
<path d="M0 -48 L40 -32 V2 C40 28 20 44 0 52 C-20 44 -40 28 -40 2 V-32 Z" stroke="none"/>
<path d="M-16 0 L-4 12 L18 -14" fill="none" stroke="#2f7fe0" stroke-width="9" stroke-linecap="round" stroke-linejoin="round"/>""", "校园安防")
tile("icon_04", "#e2803a", """
<path d="M-10 -44 H-40 V44 H-10" fill="none" stroke-width="10" stroke-linejoin="round"/>
<path d="M-12 0 H40 M22 -18 L40 0 L22 18" fill="none" stroke-width="10" stroke-linecap="round" stroke-linejoin="round"/>""", "退 出")
# ---------- 面板背景(半透明深蓝) ----------
for name, width in (("bg_from1", 555), ("bg_from2", 425)):
save(name, width, 670, f"""
<rect x="8" y="8" width="{width-16}" height="654" rx="12" fill="#14304f" opacity="0.88"/>
<rect x="8" y="8" width="{width-16}" height="654" rx="12" fill="none" stroke="#7fb3e6" stroke-width="2" opacity="0.6"/>
<rect x="24" y="22" width="{width-48}" height="4" rx="2" fill="#4fa3ff" opacity="0.8"/>
""")
# ---------- 监控:无画面时的图标、方向盘底座、方向键 ----------
save("icon_monitor", 280, 280, """
<g fill="none" stroke="#c9ced6" stroke-width="10" stroke-linejoin="round" stroke-linecap="round">
<rect x="40" y="70" width="160" height="110" rx="14"/>
<path d="M200 105 L245 80 V170 L200 145"/>
<path d="M90 180 L80 225 M150 180 L160 225 M65 225 H175"/>
</g>
<circle cx="120" cy="125" r="26" fill="none" stroke="#c9ced6" stroke-width="10"/>
""")
save("panel_video_ctrl", 500, 500, """
<defs><radialGradient id="pad" cx="0.5" cy="0.45" r="0.6"><stop offset="0" stop-color="#f4f6f9"/><stop offset="1" stop-color="#c7cdd6"/></radialGradient></defs>
<circle cx="250" cy="250" r="240" fill="url(#pad)" stroke="#aab3bf" stroke-width="6"/>
<circle cx="250" cy="250" r="95" fill="#e9edf2" stroke="#aab3bf" stroke-width="4"/>
<circle cx="250" cy="250" r="40" fill="#d4dae2"/>
""")
ROTATE = {"up": 0, "right": 90, "down": 180, "left": 270}
for direction, angle in ROTATE.items():
for state, (fill, stroke) in {"normal": ("#ffffff", "#5b6472"), "press": ("#2f7fe0", "#ffffff")}.items():
save(f"btn_arrow_{direction}_{state}", 28, 28, f"""
<circle cx="14" cy="14" r="13" fill="{fill}" stroke="#aab3bf" stroke-width="1"/>
<path d="M8 16.5 L14 10 L20 16.5" fill="none" stroke="{stroke}" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" transform="rotate({angle} 14 14)"/>
""")
for direction, angle in (("left", 270), ("right", 90)):
save(f"arrow_{direction}_normal", 60, 60, f"""
<circle cx="30" cy="30" r="27" fill="#000000" opacity="0.45"/>
<path d="M19 35 L30 23 L41 35" fill="none" stroke="#ffffff" stroke-width="5" stroke-linecap="round" stroke-linejoin="round" transform="rotate({angle} 30 30)"/>
""")
save("windowstate_closed_hover", 36, 36, """
<rect x="2" y="2" width="32" height="32" rx="4" fill="#e81123"/>
<path d="M12 12 L24 24 M24 12 L12 24" stroke="#ffffff" stroke-width="3" stroke-linecap="round"/>
""")
@@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" width="60" height="60" viewBox="0 0 60 60">
<circle cx="30" cy="30" r="27" fill="#000000" opacity="0.45"/>
<path d="M19 35 L30 23 L41 35" fill="none" stroke="#ffffff" stroke-width="5" stroke-linecap="round" stroke-linejoin="round" transform="rotate(270 30 30)"/>
</svg>

After

Width:  |  Height:  |  Size: 316 B

@@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" width="60" height="60" viewBox="0 0 60 60">
<circle cx="30" cy="30" r="27" fill="#000000" opacity="0.45"/>
<path d="M19 35 L30 23 L41 35" fill="none" stroke="#ffffff" stroke-width="5" stroke-linecap="round" stroke-linejoin="round" transform="rotate(90 30 30)"/>
</svg>

After

Width:  |  Height:  |  Size: 315 B

@@ -0,0 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg" width="555" height="670" viewBox="0 0 555 670">
<rect x="8" y="8" width="539" height="654" rx="12" fill="#14304f" opacity="0.88"/>
<rect x="8" y="8" width="539" height="654" rx="12" fill="none" stroke="#7fb3e6" stroke-width="2" opacity="0.6"/>
<rect x="24" y="22" width="507" height="4" rx="2" fill="#4fa3ff" opacity="0.8"/>
</svg>

After

Width:  |  Height:  |  Size: 380 B

@@ -0,0 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg" width="425" height="670" viewBox="0 0 425 670">
<rect x="8" y="8" width="409" height="654" rx="12" fill="#14304f" opacity="0.88"/>
<rect x="8" y="8" width="409" height="654" rx="12" fill="none" stroke="#7fb3e6" stroke-width="2" opacity="0.6"/>
<rect x="24" y="22" width="377" height="4" rx="2" fill="#4fa3ff" opacity="0.8"/>
</svg>

After

Width:  |  Height:  |  Size: 380 B

@@ -0,0 +1,78 @@
<svg xmlns="http://www.w3.org/2000/svg" width="1440" height="748" viewBox="0 0 1440 748">
<defs>
<linearGradient id="sky" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#5aa7ea"/><stop offset="1" stop-color="#cfe8fb"/></linearGradient>
<linearGradient id="lawn" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#8cc66d"/><stop offset="1" stop-color="#5f9e45"/></linearGradient>
</defs>
<rect width="1440" height="748" fill="url(#sky)"/>
<circle cx="1260" cy="120" r="60" fill="#fff3b0" opacity="0.9"/>
<g fill="#ffffff" opacity="0.85">
<ellipse cx="260" cy="120" rx="90" ry="30"/><ellipse cx="320" cy="105" rx="60" ry="28"/>
<ellipse cx="880" cy="90" rx="110" ry="32"/><ellipse cx="950" cy="80" rx="70" ry="28"/>
</g>
<g opacity="0.55" fill="#9fb8cf">
<rect x="40" y="300" width="160" height="260"/><rect x="1230" y="280" width="180" height="280"/><rect x="230" y="340" width="120" height="220"/>
</g>
<rect x="380" y="260" width="680" height="300" fill="#f2e3c9"/>
<rect x="372" y="246" width="696" height="16" fill="#b36b45"/>
<rect x="404.9" y="278.0" width="63.5" height="37.1" fill="#cfe3f5"/>
<rect x="518.3" y="278.0" width="63.5" height="37.1" fill="#cfe3f5"/>
<rect x="631.6" y="278.0" width="63.5" height="37.1" fill="#cfe3f5"/>
<rect x="744.9" y="278.0" width="63.5" height="37.1" fill="#cfe3f5"/>
<rect x="858.3" y="278.0" width="63.5" height="37.1" fill="#cfe3f5"/>
<rect x="971.6" y="278.0" width="63.5" height="37.1" fill="#cfe3f5"/>
<rect x="404.9" y="345.5" width="63.5" height="37.1" fill="#cfe3f5"/>
<rect x="518.3" y="345.5" width="63.5" height="37.1" fill="#cfe3f5"/>
<rect x="631.6" y="345.5" width="63.5" height="37.1" fill="#cfe3f5"/>
<rect x="744.9" y="345.5" width="63.5" height="37.1" fill="#cfe3f5"/>
<rect x="858.3" y="345.5" width="63.5" height="37.1" fill="#cfe3f5"/>
<rect x="971.6" y="345.5" width="63.5" height="37.1" fill="#cfe3f5"/>
<rect x="404.9" y="413.0" width="63.5" height="37.1" fill="#cfe3f5"/>
<rect x="518.3" y="413.0" width="63.5" height="37.1" fill="#cfe3f5"/>
<rect x="631.6" y="413.0" width="63.5" height="37.1" fill="#cfe3f5"/>
<rect x="744.9" y="413.0" width="63.5" height="37.1" fill="#cfe3f5"/>
<rect x="858.3" y="413.0" width="63.5" height="37.1" fill="#cfe3f5"/>
<rect x="971.6" y="413.0" width="63.5" height="37.1" fill="#cfe3f5"/>
<rect x="404.9" y="480.5" width="63.5" height="37.1" fill="#cfe3f5"/>
<rect x="518.3" y="480.5" width="63.5" height="37.1" fill="#cfe3f5"/>
<rect x="631.6" y="480.5" width="63.5" height="37.1" fill="#cfe3f5"/>
<rect x="744.9" y="480.5" width="63.5" height="37.1" fill="#cfe3f5"/>
<rect x="858.3" y="480.5" width="63.5" height="37.1" fill="#cfe3f5"/>
<rect x="971.6" y="480.5" width="63.5" height="37.1" fill="#cfe3f5"/>
<rect x="660" y="190" width="120" height="70" fill="#f2e3c9"/><rect x="650" y="178" width="140" height="16" fill="#b36b45"/>
<circle cx="720" cy="225" r="20" fill="#ffffff" stroke="#8a6a4a" stroke-width="4"/>
<rect x="680" y="470" width="80" height="90" fill="#8a6a4a"/>
<rect x="1080" y="360" width="220" height="200" fill="#e8d6bd"/>
<rect x="1072" y="346" width="236" height="16" fill="#b36b45"/>
<rect x="1092.1" y="378.0" width="30.8" height="31.2" fill="#cfe3f5"/>
<rect x="1147.1" y="378.0" width="30.8" height="31.2" fill="#cfe3f5"/>
<rect x="1202.1" y="378.0" width="30.8" height="31.2" fill="#cfe3f5"/>
<rect x="1257.1" y="378.0" width="30.8" height="31.2" fill="#cfe3f5"/>
<rect x="1092.1" y="434.7" width="30.8" height="31.2" fill="#cfe3f5"/>
<rect x="1147.1" y="434.7" width="30.8" height="31.2" fill="#cfe3f5"/>
<rect x="1202.1" y="434.7" width="30.8" height="31.2" fill="#cfe3f5"/>
<rect x="1257.1" y="434.7" width="30.8" height="31.2" fill="#cfe3f5"/>
<rect x="1092.1" y="491.3" width="30.8" height="31.2" fill="#cfe3f5"/>
<rect x="1147.1" y="491.3" width="30.8" height="31.2" fill="#cfe3f5"/>
<rect x="1202.1" y="491.3" width="30.8" height="31.2" fill="#cfe3f5"/>
<rect x="1257.1" y="491.3" width="30.8" height="31.2" fill="#cfe3f5"/>
<rect x="150" y="380" width="210" height="180" fill="#e8d6bd"/>
<rect x="142" y="366" width="226" height="16" fill="#b36b45"/>
<rect x="161.6" y="398.0" width="29.4" height="27.5" fill="#cfe3f5"/>
<rect x="214.1" y="398.0" width="29.4" height="27.5" fill="#cfe3f5"/>
<rect x="266.6" y="398.0" width="29.4" height="27.5" fill="#cfe3f5"/>
<rect x="319.1" y="398.0" width="29.4" height="27.5" fill="#cfe3f5"/>
<rect x="161.6" y="448.0" width="29.4" height="27.5" fill="#cfe3f5"/>
<rect x="214.1" y="448.0" width="29.4" height="27.5" fill="#cfe3f5"/>
<rect x="266.6" y="448.0" width="29.4" height="27.5" fill="#cfe3f5"/>
<rect x="319.1" y="448.0" width="29.4" height="27.5" fill="#cfe3f5"/>
<rect x="161.6" y="498.0" width="29.4" height="27.5" fill="#cfe3f5"/>
<rect x="214.1" y="498.0" width="29.4" height="27.5" fill="#cfe3f5"/>
<rect x="266.6" y="498.0" width="29.4" height="27.5" fill="#cfe3f5"/>
<rect x="319.1" y="498.0" width="29.4" height="27.5" fill="#cfe3f5"/>
<rect x="0" y="560" width="1440" height="188" fill="url(#lawn)"/>
<path d="M560 748 L680 560 L760 560 L880 748 Z" fill="#d9c9a8"/>
<rect x="113.4" y="600" width="13.200000000000001" height="66.0" fill="#7a5230"/><circle cx="120" cy="567.0" r="52.800000000000004" fill="#4f9a45"/><circle cx="84.8" cy="594.5" r="37.400000000000006" fill="#4f9a45"/><circle cx="155.2" cy="594.5" r="37.400000000000006" fill="#468c3e"/><rect x="324.6" y="620" width="10.8" height="54.0" fill="#7a5230"/><circle cx="330" cy="593.0" r="43.2" fill="#4f9a45"/><circle cx="301.2" cy="615.5" r="30.6" fill="#4f9a45"/><circle cx="358.8" cy="615.5" r="30.6" fill="#468c3e"/><rect x="1124.0" y="610" width="12.0" height="60.0" fill="#7a5230"/><circle cx="1130" cy="580.0" r="48.0" fill="#4f9a45"/><circle cx="1098.0" cy="605.0" r="34.0" fill="#4f9a45"/><circle cx="1162.0" cy="605.0" r="34.0" fill="#468c3e"/><rect x="1342.8" y="600" width="14.399999999999999" height="72.0" fill="#7a5230"/><circle cx="1350" cy="564.0" r="57.599999999999994" fill="#4f9a45"/><circle cx="1311.6" cy="594.0" r="40.8" fill="#4f9a45"/><circle cx="1388.4" cy="594.0" r="40.8" fill="#468c3e"/>
<g fill="#3f8a3a"><ellipse cx="480" cy="572" rx="90" ry="22"/><ellipse cx="960" cy="572" rx="90" ry="22"/></g>
</svg>

After

Width:  |  Height:  |  Size: 6.1 KiB

@@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 28 28">
<circle cx="14" cy="14" r="13" fill="#ffffff" stroke="#aab3bf" stroke-width="1"/>
<path d="M8 16.5 L14 10 L20 16.5" fill="none" stroke="#5b6472" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" transform="rotate(180 14 14)"/>
</svg>

After

Width:  |  Height:  |  Size: 338 B

@@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 28 28">
<circle cx="14" cy="14" r="13" fill="#2f7fe0" stroke="#aab3bf" stroke-width="1"/>
<path d="M8 16.5 L14 10 L20 16.5" fill="none" stroke="#ffffff" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" transform="rotate(180 14 14)"/>
</svg>

After

Width:  |  Height:  |  Size: 338 B

@@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 28 28">
<circle cx="14" cy="14" r="13" fill="#ffffff" stroke="#aab3bf" stroke-width="1"/>
<path d="M8 16.5 L14 10 L20 16.5" fill="none" stroke="#5b6472" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" transform="rotate(270 14 14)"/>
</svg>

After

Width:  |  Height:  |  Size: 338 B

@@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 28 28">
<circle cx="14" cy="14" r="13" fill="#2f7fe0" stroke="#aab3bf" stroke-width="1"/>
<path d="M8 16.5 L14 10 L20 16.5" fill="none" stroke="#ffffff" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" transform="rotate(270 14 14)"/>
</svg>

After

Width:  |  Height:  |  Size: 338 B

@@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 28 28">
<circle cx="14" cy="14" r="13" fill="#ffffff" stroke="#aab3bf" stroke-width="1"/>
<path d="M8 16.5 L14 10 L20 16.5" fill="none" stroke="#5b6472" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" transform="rotate(90 14 14)"/>
</svg>

After

Width:  |  Height:  |  Size: 337 B

@@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 28 28">
<circle cx="14" cy="14" r="13" fill="#2f7fe0" stroke="#aab3bf" stroke-width="1"/>
<path d="M8 16.5 L14 10 L20 16.5" fill="none" stroke="#ffffff" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" transform="rotate(90 14 14)"/>
</svg>

After

Width:  |  Height:  |  Size: 337 B

@@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 28 28">
<circle cx="14" cy="14" r="13" fill="#ffffff" stroke="#aab3bf" stroke-width="1"/>
<path d="M8 16.5 L14 10 L20 16.5" fill="none" stroke="#5b6472" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" transform="rotate(0 14 14)"/>
</svg>

After

Width:  |  Height:  |  Size: 336 B

@@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 28 28">
<circle cx="14" cy="14" r="13" fill="#2f7fe0" stroke="#aab3bf" stroke-width="1"/>
<path d="M8 16.5 L14 10 L20 16.5" fill="none" stroke="#ffffff" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" transform="rotate(0 14 14)"/>
</svg>

After

Width:  |  Height:  |  Size: 336 B

@@ -0,0 +1,79 @@
<svg xmlns="http://www.w3.org/2000/svg" width="1440" height="716" viewBox="0 0 1440 716">
<defs><linearGradient id="sky" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#2b3d66"/><stop offset="1" stop-color="#e8a76b"/></linearGradient></defs>
<rect width="1440" height="716" fill="url(#sky)"/>
<circle cx="1180" cy="110" r="36" fill="#fff6c8"/>
<rect x="80" y="220" width="560" height="330" fill="#e9d8bf"/>
<rect x="72" y="206" width="576" height="16" fill="#b36b45"/>
<rect x="97.6" y="238.0" width="44.8" height="33.0" fill="#ffd37a"/>
<rect x="177.6" y="238.0" width="44.8" height="33.0" fill="#ffd37a"/>
<rect x="257.6" y="238.0" width="44.8" height="33.0" fill="#ffd37a"/>
<rect x="337.6" y="238.0" width="44.8" height="33.0" fill="#ffd37a"/>
<rect x="417.6" y="238.0" width="44.8" height="33.0" fill="#ffd37a"/>
<rect x="497.6" y="238.0" width="44.8" height="33.0" fill="#ffd37a"/>
<rect x="577.6" y="238.0" width="44.8" height="33.0" fill="#ffd37a"/>
<rect x="97.6" y="298.0" width="44.8" height="33.0" fill="#ffd37a"/>
<rect x="177.6" y="298.0" width="44.8" height="33.0" fill="#ffd37a"/>
<rect x="257.6" y="298.0" width="44.8" height="33.0" fill="#ffd37a"/>
<rect x="337.6" y="298.0" width="44.8" height="33.0" fill="#ffd37a"/>
<rect x="417.6" y="298.0" width="44.8" height="33.0" fill="#ffd37a"/>
<rect x="497.6" y="298.0" width="44.8" height="33.0" fill="#ffd37a"/>
<rect x="577.6" y="298.0" width="44.8" height="33.0" fill="#ffd37a"/>
<rect x="97.6" y="358.0" width="44.8" height="33.0" fill="#ffd37a"/>
<rect x="177.6" y="358.0" width="44.8" height="33.0" fill="#ffd37a"/>
<rect x="257.6" y="358.0" width="44.8" height="33.0" fill="#ffd37a"/>
<rect x="337.6" y="358.0" width="44.8" height="33.0" fill="#ffd37a"/>
<rect x="417.6" y="358.0" width="44.8" height="33.0" fill="#ffd37a"/>
<rect x="497.6" y="358.0" width="44.8" height="33.0" fill="#ffd37a"/>
<rect x="577.6" y="358.0" width="44.8" height="33.0" fill="#ffd37a"/>
<rect x="97.6" y="418.0" width="44.8" height="33.0" fill="#ffd37a"/>
<rect x="177.6" y="418.0" width="44.8" height="33.0" fill="#ffd37a"/>
<rect x="257.6" y="418.0" width="44.8" height="33.0" fill="#ffd37a"/>
<rect x="337.6" y="418.0" width="44.8" height="33.0" fill="#ffd37a"/>
<rect x="417.6" y="418.0" width="44.8" height="33.0" fill="#ffd37a"/>
<rect x="497.6" y="418.0" width="44.8" height="33.0" fill="#ffd37a"/>
<rect x="577.6" y="418.0" width="44.8" height="33.0" fill="#ffd37a"/>
<rect x="97.6" y="478.0" width="44.8" height="33.0" fill="#ffd37a"/>
<rect x="177.6" y="478.0" width="44.8" height="33.0" fill="#ffd37a"/>
<rect x="257.6" y="478.0" width="44.8" height="33.0" fill="#ffd37a"/>
<rect x="337.6" y="478.0" width="44.8" height="33.0" fill="#ffd37a"/>
<rect x="417.6" y="478.0" width="44.8" height="33.0" fill="#ffd37a"/>
<rect x="497.6" y="478.0" width="44.8" height="33.0" fill="#ffd37a"/>
<rect x="577.6" y="478.0" width="44.8" height="33.0" fill="#ffd37a"/>
<rect x="760" y="260" width="580" height="290" fill="#dcc7a8"/>
<rect x="752" y="246" width="596" height="16" fill="#b36b45"/>
<rect x="778.2" y="278.0" width="46.4" height="35.8" fill="#ffd37a"/>
<rect x="861.1" y="278.0" width="46.4" height="35.8" fill="#ffd37a"/>
<rect x="943.9" y="278.0" width="46.4" height="35.8" fill="#ffd37a"/>
<rect x="1026.8" y="278.0" width="46.4" height="35.8" fill="#ffd37a"/>
<rect x="1109.7" y="278.0" width="46.4" height="35.8" fill="#ffd37a"/>
<rect x="1192.5" y="278.0" width="46.4" height="35.8" fill="#ffd37a"/>
<rect x="1275.4" y="278.0" width="46.4" height="35.8" fill="#ffd37a"/>
<rect x="778.2" y="343.0" width="46.4" height="35.8" fill="#ffd37a"/>
<rect x="861.1" y="343.0" width="46.4" height="35.8" fill="#ffd37a"/>
<rect x="943.9" y="343.0" width="46.4" height="35.8" fill="#ffd37a"/>
<rect x="1026.8" y="343.0" width="46.4" height="35.8" fill="#ffd37a"/>
<rect x="1109.7" y="343.0" width="46.4" height="35.8" fill="#ffd37a"/>
<rect x="1192.5" y="343.0" width="46.4" height="35.8" fill="#ffd37a"/>
<rect x="1275.4" y="343.0" width="46.4" height="35.8" fill="#ffd37a"/>
<rect x="778.2" y="408.0" width="46.4" height="35.8" fill="#ffd37a"/>
<rect x="861.1" y="408.0" width="46.4" height="35.8" fill="#ffd37a"/>
<rect x="943.9" y="408.0" width="46.4" height="35.8" fill="#ffd37a"/>
<rect x="1026.8" y="408.0" width="46.4" height="35.8" fill="#ffd37a"/>
<rect x="1109.7" y="408.0" width="46.4" height="35.8" fill="#ffd37a"/>
<rect x="1192.5" y="408.0" width="46.4" height="35.8" fill="#ffd37a"/>
<rect x="1275.4" y="408.0" width="46.4" height="35.8" fill="#ffd37a"/>
<rect x="778.2" y="473.0" width="46.4" height="35.8" fill="#ffd37a"/>
<rect x="861.1" y="473.0" width="46.4" height="35.8" fill="#ffd37a"/>
<rect x="943.9" y="473.0" width="46.4" height="35.8" fill="#ffd37a"/>
<rect x="1026.8" y="473.0" width="46.4" height="35.8" fill="#ffd37a"/>
<rect x="1109.7" y="473.0" width="46.4" height="35.8" fill="#ffd37a"/>
<rect x="1192.5" y="473.0" width="46.4" height="35.8" fill="#ffd37a"/>
<rect x="1275.4" y="473.0" width="46.4" height="35.8" fill="#ffd37a"/>
<rect x="0" y="550" width="1440" height="40" fill="#7fb06a"/>
<rect x="0" y="590" width="1440" height="126" fill="#5b6472"/>
<g fill="#f8fafc"><rect x="30" y="648" width="70" height="8"/><rect x="170" y="648" width="70" height="8"/><rect x="310" y="648" width="70" height="8"/><rect x="450" y="648" width="70" height="8"/><rect x="590" y="648" width="70" height="8"/><rect x="730" y="648" width="70" height="8"/><rect x="870" y="648" width="70" height="8"/><rect x="1010" y="648" width="70" height="8"/><rect x="1150" y="648" width="70" height="8"/><rect x="1290" y="648" width="70" height="8"/><rect x="1430" y="648" width="70" height="8"/></g>
<rect x="180" y="380" width="12" height="260" fill="#4b5563"/><path d="M186 386 Q186 356 226 356 H250" stroke="#4b5563" stroke-width="10" fill="none"/><rect x="236" y="348" width="44" height="16" rx="5" fill="#374151"/><path d="M240 364 L200 640 H320 L276 364 Z" fill="#fff3b0" opacity="0.35"/><ellipse cx="258" cy="366" rx="22" ry="7" fill="#fff8d0"/><rect x="520" y="380" width="12" height="260" fill="#4b5563"/><path d="M526 386 Q526 356 566 356 H590" stroke="#4b5563" stroke-width="10" fill="none"/><rect x="576" y="348" width="44" height="16" rx="5" fill="#374151"/><path d="M580 364 L540 640 H660 L616 364 Z" fill="#fff3b0" opacity="0.35"/><ellipse cx="598" cy="366" rx="22" ry="7" fill="#fff8d0"/><rect x="860" y="380" width="12" height="260" fill="#4b5563"/><path d="M866 386 Q866 356 906 356 H930" stroke="#4b5563" stroke-width="10" fill="none"/><rect x="916" y="348" width="44" height="16" rx="5" fill="#374151"/><path d="M920 364 L880 640 H1000 L956 364 Z" fill="#fff3b0" opacity="0.35"/><ellipse cx="938" cy="366" rx="22" ry="7" fill="#fff8d0"/><rect x="1200" y="380" width="12" height="260" fill="#4b5563"/><path d="M1206 386 Q1206 356 1246 356 H1270" stroke="#4b5563" stroke-width="10" fill="none"/><rect x="1256" y="348" width="44" height="16" rx="5" fill="#374151"/><path d="M1260 364 L1220 640 H1340 L1296 364 Z" fill="#fff3b0" opacity="0.35"/><ellipse cx="1278" cy="366" rx="22" ry="7" fill="#fff8d0"/>
<rect x="695.2" y="560" width="9.600000000000001" height="48.0" fill="#7a5230"/><circle cx="700" cy="536.0" r="38.400000000000006" fill="#3f7f45"/><circle cx="674.4" cy="556.0" r="27.200000000000003" fill="#3f7f45"/><circle cx="725.6" cy="556.0" r="27.200000000000003" fill="#468c3e"/><rect x="1384.6" y="560" width="10.8" height="54.0" fill="#7a5230"/><circle cx="1390" cy="533.0" r="43.2" fill="#3f7f45"/><circle cx="1361.2" cy="555.5" r="30.6" fill="#3f7f45"/><circle cx="1418.8" cy="555.5" r="30.6" fill="#468c3e"/>
</svg>

After

Width:  |  Height:  |  Size: 7.5 KiB

@@ -0,0 +1,79 @@
<svg xmlns="http://www.w3.org/2000/svg" width="1440" height="716" viewBox="0 0 1440 716">
<defs><linearGradient id="sky" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#6bb0ea"/><stop offset="1" stop-color="#d6ecfb"/></linearGradient></defs>
<rect width="1440" height="716" fill="url(#sky)"/>
<circle cx="1220" cy="110" r="50" fill="#fff3b0" opacity="0.9"/>
<rect x="80" y="220" width="560" height="330" fill="#e9d8bf"/>
<rect x="72" y="206" width="576" height="16" fill="#b36b45"/>
<rect x="97.6" y="238.0" width="44.8" height="33.0" fill="#cfe3f5"/>
<rect x="177.6" y="238.0" width="44.8" height="33.0" fill="#cfe3f5"/>
<rect x="257.6" y="238.0" width="44.8" height="33.0" fill="#cfe3f5"/>
<rect x="337.6" y="238.0" width="44.8" height="33.0" fill="#cfe3f5"/>
<rect x="417.6" y="238.0" width="44.8" height="33.0" fill="#cfe3f5"/>
<rect x="497.6" y="238.0" width="44.8" height="33.0" fill="#cfe3f5"/>
<rect x="577.6" y="238.0" width="44.8" height="33.0" fill="#cfe3f5"/>
<rect x="97.6" y="298.0" width="44.8" height="33.0" fill="#cfe3f5"/>
<rect x="177.6" y="298.0" width="44.8" height="33.0" fill="#cfe3f5"/>
<rect x="257.6" y="298.0" width="44.8" height="33.0" fill="#cfe3f5"/>
<rect x="337.6" y="298.0" width="44.8" height="33.0" fill="#cfe3f5"/>
<rect x="417.6" y="298.0" width="44.8" height="33.0" fill="#cfe3f5"/>
<rect x="497.6" y="298.0" width="44.8" height="33.0" fill="#cfe3f5"/>
<rect x="577.6" y="298.0" width="44.8" height="33.0" fill="#cfe3f5"/>
<rect x="97.6" y="358.0" width="44.8" height="33.0" fill="#cfe3f5"/>
<rect x="177.6" y="358.0" width="44.8" height="33.0" fill="#cfe3f5"/>
<rect x="257.6" y="358.0" width="44.8" height="33.0" fill="#cfe3f5"/>
<rect x="337.6" y="358.0" width="44.8" height="33.0" fill="#cfe3f5"/>
<rect x="417.6" y="358.0" width="44.8" height="33.0" fill="#cfe3f5"/>
<rect x="497.6" y="358.0" width="44.8" height="33.0" fill="#cfe3f5"/>
<rect x="577.6" y="358.0" width="44.8" height="33.0" fill="#cfe3f5"/>
<rect x="97.6" y="418.0" width="44.8" height="33.0" fill="#cfe3f5"/>
<rect x="177.6" y="418.0" width="44.8" height="33.0" fill="#cfe3f5"/>
<rect x="257.6" y="418.0" width="44.8" height="33.0" fill="#cfe3f5"/>
<rect x="337.6" y="418.0" width="44.8" height="33.0" fill="#cfe3f5"/>
<rect x="417.6" y="418.0" width="44.8" height="33.0" fill="#cfe3f5"/>
<rect x="497.6" y="418.0" width="44.8" height="33.0" fill="#cfe3f5"/>
<rect x="577.6" y="418.0" width="44.8" height="33.0" fill="#cfe3f5"/>
<rect x="97.6" y="478.0" width="44.8" height="33.0" fill="#cfe3f5"/>
<rect x="177.6" y="478.0" width="44.8" height="33.0" fill="#cfe3f5"/>
<rect x="257.6" y="478.0" width="44.8" height="33.0" fill="#cfe3f5"/>
<rect x="337.6" y="478.0" width="44.8" height="33.0" fill="#cfe3f5"/>
<rect x="417.6" y="478.0" width="44.8" height="33.0" fill="#cfe3f5"/>
<rect x="497.6" y="478.0" width="44.8" height="33.0" fill="#cfe3f5"/>
<rect x="577.6" y="478.0" width="44.8" height="33.0" fill="#cfe3f5"/>
<rect x="760" y="260" width="580" height="290" fill="#dcc7a8"/>
<rect x="752" y="246" width="596" height="16" fill="#b36b45"/>
<rect x="778.2" y="278.0" width="46.4" height="35.8" fill="#cfe3f5"/>
<rect x="861.1" y="278.0" width="46.4" height="35.8" fill="#cfe3f5"/>
<rect x="943.9" y="278.0" width="46.4" height="35.8" fill="#cfe3f5"/>
<rect x="1026.8" y="278.0" width="46.4" height="35.8" fill="#cfe3f5"/>
<rect x="1109.7" y="278.0" width="46.4" height="35.8" fill="#cfe3f5"/>
<rect x="1192.5" y="278.0" width="46.4" height="35.8" fill="#cfe3f5"/>
<rect x="1275.4" y="278.0" width="46.4" height="35.8" fill="#cfe3f5"/>
<rect x="778.2" y="343.0" width="46.4" height="35.8" fill="#cfe3f5"/>
<rect x="861.1" y="343.0" width="46.4" height="35.8" fill="#cfe3f5"/>
<rect x="943.9" y="343.0" width="46.4" height="35.8" fill="#cfe3f5"/>
<rect x="1026.8" y="343.0" width="46.4" height="35.8" fill="#cfe3f5"/>
<rect x="1109.7" y="343.0" width="46.4" height="35.8" fill="#cfe3f5"/>
<rect x="1192.5" y="343.0" width="46.4" height="35.8" fill="#cfe3f5"/>
<rect x="1275.4" y="343.0" width="46.4" height="35.8" fill="#cfe3f5"/>
<rect x="778.2" y="408.0" width="46.4" height="35.8" fill="#cfe3f5"/>
<rect x="861.1" y="408.0" width="46.4" height="35.8" fill="#cfe3f5"/>
<rect x="943.9" y="408.0" width="46.4" height="35.8" fill="#cfe3f5"/>
<rect x="1026.8" y="408.0" width="46.4" height="35.8" fill="#cfe3f5"/>
<rect x="1109.7" y="408.0" width="46.4" height="35.8" fill="#cfe3f5"/>
<rect x="1192.5" y="408.0" width="46.4" height="35.8" fill="#cfe3f5"/>
<rect x="1275.4" y="408.0" width="46.4" height="35.8" fill="#cfe3f5"/>
<rect x="778.2" y="473.0" width="46.4" height="35.8" fill="#cfe3f5"/>
<rect x="861.1" y="473.0" width="46.4" height="35.8" fill="#cfe3f5"/>
<rect x="943.9" y="473.0" width="46.4" height="35.8" fill="#cfe3f5"/>
<rect x="1026.8" y="473.0" width="46.4" height="35.8" fill="#cfe3f5"/>
<rect x="1109.7" y="473.0" width="46.4" height="35.8" fill="#cfe3f5"/>
<rect x="1192.5" y="473.0" width="46.4" height="35.8" fill="#cfe3f5"/>
<rect x="1275.4" y="473.0" width="46.4" height="35.8" fill="#cfe3f5"/>
<rect x="0" y="550" width="1440" height="40" fill="#7fb06a"/>
<rect x="0" y="590" width="1440" height="126" fill="#5b6472"/>
<g fill="#f8fafc"><rect x="30" y="648" width="70" height="8"/><rect x="170" y="648" width="70" height="8"/><rect x="310" y="648" width="70" height="8"/><rect x="450" y="648" width="70" height="8"/><rect x="590" y="648" width="70" height="8"/><rect x="730" y="648" width="70" height="8"/><rect x="870" y="648" width="70" height="8"/><rect x="1010" y="648" width="70" height="8"/><rect x="1150" y="648" width="70" height="8"/><rect x="1290" y="648" width="70" height="8"/><rect x="1430" y="648" width="70" height="8"/></g>
<rect x="180" y="380" width="12" height="260" fill="#4b5563"/><path d="M186 386 Q186 356 226 356 H250" stroke="#4b5563" stroke-width="10" fill="none"/><rect x="236" y="348" width="44" height="16" rx="5" fill="#374151"/><ellipse cx="258" cy="366" rx="18" ry="5" fill="#9ca3af"/><rect x="520" y="380" width="12" height="260" fill="#4b5563"/><path d="M526 386 Q526 356 566 356 H590" stroke="#4b5563" stroke-width="10" fill="none"/><rect x="576" y="348" width="44" height="16" rx="5" fill="#374151"/><ellipse cx="598" cy="366" rx="18" ry="5" fill="#9ca3af"/><rect x="860" y="380" width="12" height="260" fill="#4b5563"/><path d="M866 386 Q866 356 906 356 H930" stroke="#4b5563" stroke-width="10" fill="none"/><rect x="916" y="348" width="44" height="16" rx="5" fill="#374151"/><ellipse cx="938" cy="366" rx="18" ry="5" fill="#9ca3af"/><rect x="1200" y="380" width="12" height="260" fill="#4b5563"/><path d="M1206 386 Q1206 356 1246 356 H1270" stroke="#4b5563" stroke-width="10" fill="none"/><rect x="1256" y="348" width="44" height="16" rx="5" fill="#374151"/><ellipse cx="1278" cy="366" rx="18" ry="5" fill="#9ca3af"/>
<rect x="695.2" y="560" width="9.600000000000001" height="48.0" fill="#7a5230"/><circle cx="700" cy="536.0" r="38.400000000000006" fill="#3f7f45"/><circle cx="674.4" cy="556.0" r="27.200000000000003" fill="#3f7f45"/><circle cx="725.6" cy="556.0" r="27.200000000000003" fill="#468c3e"/><rect x="1384.6" y="560" width="10.8" height="54.0" fill="#7a5230"/><circle cx="1390" cy="533.0" r="43.2" fill="#3f7f45"/><circle cx="1361.2" cy="555.5" r="30.6" fill="#3f7f45"/><circle cx="1418.8" cy="555.5" r="30.6" fill="#468c3e"/>
</svg>

After

Width:  |  Height:  |  Size: 7.2 KiB

@@ -0,0 +1,11 @@
<svg xmlns="http://www.w3.org/2000/svg" width="226" height="54" viewBox="0 0 226 54">
<g transform="translate(8,7)">
<circle cx="20" cy="20" r="19" fill="#ffffff" opacity="0.95"/>
<path d="M7 27 L20 10 L33 27 Z" fill="#3593ed"/>
<rect x="13" y="22" width="14" height="9" fill="#3593ed"/>
<rect x="18" y="25" width="4" height="6" fill="#ffffff"/>
</g>
<text x="56" y="37" font-family="Source Han Sans CN, Noto Sans CJK SC, sans-serif" font-size="27" font-weight="bold" fill="#ffffff" letter-spacing="3">智慧校园</text>
</svg>

After

Width:  |  Height:  |  Size: 553 B

@@ -0,0 +1,11 @@
<svg xmlns="http://www.w3.org/2000/svg" width="180" height="210" viewBox="0 0 180 210">
<rect x="6" y="6" width="168" height="198" rx="18" fill="#2e9e5b"/>
<rect x="6" y="6" width="168" height="198" rx="18" fill="#ffffff" opacity="0.08"/>
<g transform="translate(90,82)" fill="#ffffff" stroke="#ffffff">
<rect x="-6" y="10" width="12" height="40" stroke="none"/>
<circle cx="0" cy="-12" r="34" stroke="none"/><circle cx="-26" cy="8" r="22" stroke="none"/><circle cx="26" cy="8" r="22" stroke="none"/>
<path d="M-4 -2 L0 -30 L4 -2" fill="#2e9e5b" stroke="none"/></g>
<text x="90" y="178" font-family="Source Han Sans CN, Noto Sans CJK SC, sans-serif" font-size="24" font-weight="bold" fill="#ffffff" text-anchor="middle">校园环境</text>
</svg>

After

Width:  |  Height:  |  Size: 769 B

@@ -0,0 +1,10 @@
<svg xmlns="http://www.w3.org/2000/svg" width="180" height="210" viewBox="0 0 180 210">
<rect x="6" y="6" width="168" height="198" rx="18" fill="#2f7fe0"/>
<rect x="6" y="6" width="168" height="198" rx="18" fill="#ffffff" opacity="0.08"/>
<g transform="translate(90,82)" fill="#ffffff" stroke="#ffffff">
<path d="M0 -48 L40 -32 V2 C40 28 20 44 0 52 C-20 44 -40 28 -40 2 V-32 Z" stroke="none"/>
<path d="M-16 0 L-4 12 L18 -14" fill="none" stroke="#2f7fe0" stroke-width="9" stroke-linecap="round" stroke-linejoin="round"/></g>
<text x="90" y="178" font-family="Source Han Sans CN, Noto Sans CJK SC, sans-serif" font-size="24" font-weight="bold" fill="#ffffff" text-anchor="middle">校园安防</text>
</svg>

After

Width:  |  Height:  |  Size: 724 B

@@ -0,0 +1,10 @@
<svg xmlns="http://www.w3.org/2000/svg" width="180" height="210" viewBox="0 0 180 210">
<rect x="6" y="6" width="168" height="198" rx="18" fill="#e2803a"/>
<rect x="6" y="6" width="168" height="198" rx="18" fill="#ffffff" opacity="0.08"/>
<g transform="translate(90,82)" fill="#ffffff" stroke="#ffffff">
<path d="M-10 -44 H-40 V44 H-10" fill="none" stroke-width="10" stroke-linejoin="round"/>
<path d="M-12 0 H40 M22 -18 L40 0 L22 18" fill="none" stroke-width="10" stroke-linecap="round" stroke-linejoin="round"/></g>
<text x="90" y="178" font-family="Source Han Sans CN, Noto Sans CJK SC, sans-serif" font-size="24" font-weight="bold" fill="#ffffff" text-anchor="middle">退 出</text>
</svg>

After

Width:  |  Height:  |  Size: 713 B

@@ -0,0 +1,10 @@
<svg xmlns="http://www.w3.org/2000/svg" width="280" height="280" viewBox="0 0 280 280">
<g fill="none" stroke="#c9ced6" stroke-width="10" stroke-linejoin="round" stroke-linecap="round">
<rect x="40" y="70" width="160" height="110" rx="14"/>
<path d="M200 105 L245 80 V170 L200 145"/>
<path d="M90 180 L80 225 M150 180 L160 225 M65 225 H175"/>
</g>
<circle cx="120" cy="125" r="26" fill="none" stroke="#c9ced6" stroke-width="10"/>
</svg>

After

Width:  |  Height:  |  Size: 457 B

@@ -0,0 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg" width="500" height="500" viewBox="0 0 500 500">
<defs><radialGradient id="pad" cx="0.5" cy="0.45" r="0.6"><stop offset="0" stop-color="#f4f6f9"/><stop offset="1" stop-color="#c7cdd6"/></radialGradient></defs>
<circle cx="250" cy="250" r="240" fill="url(#pad)" stroke="#aab3bf" stroke-width="6"/>
<circle cx="250" cy="250" r="95" fill="#e9edf2" stroke="#aab3bf" stroke-width="4"/>
<circle cx="250" cy="250" r="40" fill="#d4dae2"/>
</svg>

After

Width:  |  Height:  |  Size: 487 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 390 B

After

Width:  |  Height:  |  Size: 390 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 389 B

After

Width:  |  Height:  |  Size: 389 B

@@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" width="36" height="36" viewBox="0 0 36 36">
<rect x="2" y="2" width="32" height="32" rx="4" fill="#e81123"/>
<path d="M12 12 L24 24 M24 12 L12 24" stroke="#ffffff" stroke-width="3" stroke-linecap="round"/>
</svg>

After

Width:  |  Height:  |  Size: 259 B

+142
View File
@@ -0,0 +1,142 @@
namespace 智慧校园
{
partial class Main
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.panel2 = new System.Windows.Forms.Panel();
this.pic_exit = new System.Windows.Forms.PictureBox();
this.pic_security = new System.Windows.Forms.PictureBox();
this.pic_environment = new System.Windows.Forms.PictureBox();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.panel2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pic_exit)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pic_security)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pic_environment)).BeginInit();
this.SuspendLayout();
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(53)))), ((int)(((byte)(147)))), ((int)(((byte)(237)))));
this.panel1.Controls.Add(this.pictureBox1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(1018, 100);
this.panel1.TabIndex = 0;
this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
//
// pictureBox1
//
this.pictureBox1.Image = global::智慧校园.Properties.Resources.ico_title;
this.pictureBox1.Location = new System.Drawing.Point(57, 23);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(197, 54);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// panel2
//
this.panel2.BackgroundImage = global::智慧校园.Properties.Resources.bg_home;
this.panel2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.panel2.Controls.Add(this.pic_exit);
this.panel2.Controls.Add(this.pic_security);
this.panel2.Controls.Add(this.pic_environment);
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel2.Location = new System.Drawing.Point(0, 100);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(1018, 516);
this.panel2.TabIndex = 1;
this.panel2.Paint += new System.Windows.Forms.PaintEventHandler(this.panel2_Paint);
//
// pic_exit
//
this.pic_exit.BackColor = System.Drawing.Color.Transparent;
this.pic_exit.Image = global::智慧校园.Properties.Resources.icon_04;
this.pic_exit.Location = new System.Drawing.Point(660, 124);
this.pic_exit.Name = "pic_exit";
this.pic_exit.Size = new System.Drawing.Size(180, 210);
this.pic_exit.TabIndex = 6;
this.pic_exit.TabStop = false;
this.pic_exit.Click += new System.EventHandler(this.pic_exit_Click);
//
// pic_security
//
this.pic_security.BackColor = System.Drawing.Color.Transparent;
this.pic_security.Image = global::智慧校园.Properties.Resources.icon_03;
this.pic_security.Location = new System.Drawing.Point(404, 124);
this.pic_security.Name = "pic_security";
this.pic_security.Size = new System.Drawing.Size(180, 210);
this.pic_security.TabIndex = 5;
this.pic_security.TabStop = false;
//
// pic_environment
//
this.pic_environment.BackColor = System.Drawing.Color.Transparent;
this.pic_environment.Image = global::智慧校园.Properties.Resources.icon_02;
this.pic_environment.Location = new System.Drawing.Point(133, 124);
this.pic_environment.Name = "pic_environment";
this.pic_environment.Size = new System.Drawing.Size(180, 210);
this.pic_environment.TabIndex = 4;
this.pic_environment.TabStop = false;
//
// Main
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1018, 616);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "Main";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Form1";
this.panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pic_exit)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pic_security)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pic_environment)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.PictureBox pic_exit;
private System.Windows.Forms.PictureBox pic_security;
private System.Windows.Forms.PictureBox pic_environment;
}
}
+34
View File
@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace 智慧校园
{
public partial class Main : Form
{
public Main()
{
InitializeComponent();
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
private void panel2_Paint(object sender, PaintEventArgs e)
{
}
private void pic_exit_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
+22
View File
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace 智慧校园
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Main());
}
}
}
+39
View File
@@ -0,0 +1,39 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 项目资源(平台素材库)。在"项目资源"里添加或移除,不要手动修改这个文件。
// </auto-generated>
//------------------------------------------------------------------------------
namespace 智慧校园.Properties {
/// <summary>
/// 项目资源:Properties.Resources.资源名
/// </summary>
internal class Resources {
/// <summary>标题:智慧校园</summary>
internal static System.Drawing.Bitmap ico_title {
get { return global::Sim.Host.ProjectResources.Image("ico_title.png"); }
}
/// <summary>主界面背景:校园</summary>
internal static System.Drawing.Bitmap bg_home {
get { return global::Sim.Host.ProjectResources.Image("bg_home.png"); }
}
/// <summary>图标:校园环境</summary>
internal static System.Drawing.Bitmap icon_02 {
get { return global::Sim.Host.ProjectResources.Image("icon_02.png"); }
}
/// <summary>图标:校园安防</summary>
internal static System.Drawing.Bitmap icon_03 {
get { return global::Sim.Host.ProjectResources.Image("icon_03.png"); }
}
/// <summary>图标:退出</summary>
internal static System.Drawing.Bitmap icon_04 {
get { return global::Sim.Host.ProjectResources.Image("icon_04.png"); }
}
}
}
+14
View File
@@ -0,0 +1,14 @@
# 评分规则:书上评价表的功能项。每项单独启动一次程序,按步骤操作,核对结果。
# 格式说明见 server/src/grading/checks.ts
- title: 主界面显示标题和三个功能入口
steps:
- expect: { control: pictureBox1, image: ico_title, desc: 显示"智慧校园"标题图(ico_title) }
- expect: { control: panel2, background: bg_home, desc: 背景是校园图片(bg_home) }
- expect: { control: pic_environment, image: icon_02, desc: 显示"校园环境"图标(icon_02) }
- expect: { control: pic_security, image: icon_03, desc: 显示"校园安防"图标(icon_03) }
- expect: { control: pic_exit, image: icon_04, desc: 显示"退出"图标(icon_04) }
- title: 实现退出功能
steps:
- click: pic_exit
- expect: { exited: true, desc: 点"退出"后关闭主窗体、程序退出 }
+4
View File
@@ -0,0 +1,4 @@
{
"title": "项目8 任务1 制作管理平台的主界面",
"source": "教材书 p157–159,界面和代码取自配套参考工程;图片是平台素材库里自绘的同名素材(尺寸和教材一致)"
}
+545
View File
@@ -0,0 +1,545 @@
namespace 智慧校园
{
partial class Environment
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend3 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Legend legend4 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Series series3 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.Series series4 = new System.Windows.Forms.DataVisualization.Charting.Series();
this.panel1 = new System.Windows.Forms.Panel();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.panel2 = new System.Windows.Forms.Panel();
this.panel_bg = new System.Windows.Forms.Panel();
this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart();
this.panel_form = new System.Windows.Forms.Panel();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.pic_lampOpen = new System.Windows.Forms.PictureBox();
this.label10 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.txt_autoLight = new System.Windows.Forms.TextBox();
this.label7 = new System.Windows.Forms.Label();
this.ch_autoLamp = new System.Windows.Forms.CheckBox();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.btn_ledEnvironment2 = new System.Windows.Forms.Button();
this.ch_autoLedFire = new System.Windows.Forms.CheckBox();
this.btn_ledSendMsg = new System.Windows.Forms.Button();
this.txt_ledMsg = new System.Windows.Forms.TextBox();
this.label8 = new System.Windows.Forms.Label();
this.panel5 = new System.Windows.Forms.Panel();
this.btn_dataAnalyse = new System.Windows.Forms.Button();
this.btn_ledEnvironment1 = new System.Windows.Forms.Button();
this.label6 = new System.Windows.Forms.Label();
this.txt_humidity = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.txt_fire = new System.Windows.Forms.TextBox();
this.txt_temperature = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.txt_smoke = new System.Windows.Forms.TextBox();
this.txt_light = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.panel3 = new System.Windows.Forms.Panel();
this.lb_return = new System.Windows.Forms.Label();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.panel2.SuspendLayout();
this.panel_bg.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit();
this.panel_form.SuspendLayout();
this.groupBox2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pic_lampOpen)).BeginInit();
this.groupBox3.SuspendLayout();
this.panel5.SuspendLayout();
this.panel3.SuspendLayout();
this.SuspendLayout();
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(116)))), ((int)(((byte)(133)))));
this.panel1.Controls.Add(this.pictureBox1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(1043, 100);
this.panel1.TabIndex = 0;
this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
//
// pictureBox1
//
this.pictureBox1.Image = global::智慧校园.Properties.Resources.ico_title;
this.pictureBox1.Location = new System.Drawing.Point(44, 12);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(226, 54);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// panel2
//
this.panel2.Controls.Add(this.panel_bg);
this.panel2.Controls.Add(this.panel3);
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel2.Location = new System.Drawing.Point(0, 100);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(1043, 691);
this.panel2.TabIndex = 1;
//
// panel_bg
//
this.panel_bg.BackgroundImage = global::智慧校园.Properties.Resources.day_02;
this.panel_bg.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.panel_bg.Controls.Add(this.chart1);
this.panel_bg.Controls.Add(this.panel_form);
this.panel_bg.Controls.Add(this.panel5);
this.panel_bg.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel_bg.Location = new System.Drawing.Point(0, 39);
this.panel_bg.Name = "panel_bg";
this.panel_bg.Size = new System.Drawing.Size(1043, 652);
this.panel_bg.TabIndex = 1;
//
// chart1
//
chartArea2.Name = "ChartArea1";
this.chart1.ChartAreas.Add(chartArea2);
legend3.Name = "MaxLegend";
legend3.TitleForeColor = System.Drawing.Color.DimGray;
legend4.Name = "AVGLegend";
legend4.TitleForeColor = System.Drawing.Color.DimGray;
this.chart1.Legends.Add(legend3);
this.chart1.Legends.Add(legend4);
this.chart1.Location = new System.Drawing.Point(44, 172);
this.chart1.Name = "chart1";
series3.ChartArea = "ChartArea1";
series3.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
series3.Legend = "MaxLegend";
series3.LegendText = "最大值";
series3.Name = "MaxSeries";
series3.XValueMember = "_Time";
series3.YValueMembers = "MaxTemperature";
series4.ChartArea = "ChartArea1";
series4.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
series4.Legend = "AVGLegend";
series4.LegendText = "平均值";
series4.Name = "AVGSeries";
series4.XValueMember = "_Time";
series4.YValueMembers = "AVGTemperature";
this.chart1.Series.Add(series3);
this.chart1.Series.Add(series4);
this.chart1.Size = new System.Drawing.Size(455, 327);
this.chart1.TabIndex = 3;
this.chart1.Text = "chart1";
//
// panel_form
//
this.panel_form.BackColor = System.Drawing.Color.Transparent;
this.panel_form.BackgroundImage = global::智慧校园.Properties.Resources.bg_from2;
this.panel_form.Controls.Add(this.groupBox2);
this.panel_form.Controls.Add(this.groupBox3);
this.panel_form.Dock = System.Windows.Forms.DockStyle.Right;
this.panel_form.Location = new System.Drawing.Point(617, 0);
this.panel_form.Name = "panel_form";
this.panel_form.Size = new System.Drawing.Size(426, 552);
this.panel_form.TabIndex = 2;
//
// groupBox2
//
this.groupBox2.Controls.Add(this.pic_lampOpen);
this.groupBox2.Controls.Add(this.label10);
this.groupBox2.Controls.Add(this.label9);
this.groupBox2.Controls.Add(this.txt_autoLight);
this.groupBox2.Controls.Add(this.label7);
this.groupBox2.Controls.Add(this.ch_autoLamp);
this.groupBox2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupBox2.ForeColor = System.Drawing.Color.White;
this.groupBox2.Location = new System.Drawing.Point(22, 21);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(392, 150);
this.groupBox2.TabIndex = 3;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "路灯控制";
//
// pic_lampOpen
//
this.pic_lampOpen.BackgroundImage = global::智慧校园.Properties.Resources.switch_off;
this.pic_lampOpen.Location = new System.Drawing.Point(103, 103);
this.pic_lampOpen.Name = "pic_lampOpen";
this.pic_lampOpen.Size = new System.Drawing.Size(48, 24);
this.pic_lampOpen.TabIndex = 5;
this.pic_lampOpen.TabStop = false;
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(33, 105);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(59, 17);
this.label10.TabIndex = 4;
this.label10.Text = "灯光控制:";
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(278, 58);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(17, 17);
this.label9.TabIndex = 3;
this.label9.Text = "lx";
//
// txt_autoLight
//
this.txt_autoLight.Location = new System.Drawing.Point(128, 55);
this.txt_autoLight.Name = "txt_autoLight";
this.txt_autoLight.Size = new System.Drawing.Size(144, 23);
this.txt_autoLight.TabIndex = 2;
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(33, 58);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(92, 17);
this.label7.TabIndex = 1;
this.label7.Text = "设定开灯光照值";
//
// ch_autoLamp
//
this.ch_autoLamp.AutoSize = true;
this.ch_autoLamp.Location = new System.Drawing.Point(35, 30);
this.ch_autoLamp.Name = "ch_autoLamp";
this.ch_autoLamp.Size = new System.Drawing.Size(75, 21);
this.ch_autoLamp.TabIndex = 0;
this.ch_autoLamp.Text = "自动控制";
this.ch_autoLamp.UseVisualStyleBackColor = true;
//
// groupBox3
//
this.groupBox3.Controls.Add(this.btn_ledEnvironment2);
this.groupBox3.Controls.Add(this.ch_autoLedFire);
this.groupBox3.Controls.Add(this.btn_ledSendMsg);
this.groupBox3.Controls.Add(this.txt_ledMsg);
this.groupBox3.Controls.Add(this.label8);
this.groupBox3.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupBox3.ForeColor = System.Drawing.Color.White;
this.groupBox3.Location = new System.Drawing.Point(22, 209);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(392, 316);
this.groupBox3.TabIndex = 4;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "LED推送";
//
// btn_ledEnvironment2
//
this.btn_ledEnvironment2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(149)))), ((int)(((byte)(212)))));
this.btn_ledEnvironment2.Font = new System.Drawing.Font("微软雅黑", 12F);
this.btn_ledEnvironment2.Location = new System.Drawing.Point(234, 217);
this.btn_ledEnvironment2.Name = "btn_ledEnvironment2";
this.btn_ledEnvironment2.Size = new System.Drawing.Size(145, 32);
this.btn_ledEnvironment2.TabIndex = 11;
this.btn_ledEnvironment2.Text = "推送天气信息";
this.btn_ledEnvironment2.UseVisualStyleBackColor = false;
//
// ch_autoLedFire
//
this.ch_autoLedFire.AutoSize = true;
this.ch_autoLedFire.Location = new System.Drawing.Point(265, 35);
this.ch_autoLedFire.Name = "ch_autoLedFire";
this.ch_autoLedFire.Size = new System.Drawing.Size(99, 21);
this.ch_autoLedFire.TabIndex = 4;
this.ch_autoLedFire.Text = "自动推送火情";
this.ch_autoLedFire.UseVisualStyleBackColor = true;
//
// btn_ledSendMsg
//
this.btn_ledSendMsg.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(168)))), ((int)(((byte)(255)))));
this.btn_ledSendMsg.Font = new System.Drawing.Font("微软雅黑", 12F);
this.btn_ledSendMsg.Location = new System.Drawing.Point(26, 217);
this.btn_ledSendMsg.Name = "btn_ledSendMsg";
this.btn_ledSendMsg.Size = new System.Drawing.Size(145, 32);
this.btn_ledSendMsg.TabIndex = 2;
this.btn_ledSendMsg.Text = "推送LED信息";
this.btn_ledSendMsg.UseVisualStyleBackColor = false;
//
// txt_ledMsg
//
this.txt_ledMsg.Location = new System.Drawing.Point(23, 62);
this.txt_ledMsg.Multiline = true;
this.txt_ledMsg.Name = "txt_ledMsg";
this.txt_ledMsg.Size = new System.Drawing.Size(356, 130);
this.txt_ledMsg.TabIndex = 1;
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(20, 36);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(54, 17);
this.label8.TabIndex = 0;
this.label8.Text = "LED信息";
//
// panel5
//
this.panel5.Controls.Add(this.btn_dataAnalyse);
this.panel5.Controls.Add(this.btn_ledEnvironment1);
this.panel5.Controls.Add(this.label6);
this.panel5.Controls.Add(this.txt_humidity);
this.panel5.Controls.Add(this.label1);
this.panel5.Controls.Add(this.label5);
this.panel5.Controls.Add(this.txt_fire);
this.panel5.Controls.Add(this.txt_temperature);
this.panel5.Controls.Add(this.label2);
this.panel5.Controls.Add(this.label4);
this.panel5.Controls.Add(this.txt_smoke);
this.panel5.Controls.Add(this.txt_light);
this.panel5.Controls.Add(this.label3);
this.panel5.Dock = System.Windows.Forms.DockStyle.Bottom;
this.panel5.Location = new System.Drawing.Point(0, 552);
this.panel5.Name = "panel5";
this.panel5.Size = new System.Drawing.Size(1043, 100);
this.panel5.TabIndex = 1;
//
// btn_dataAnalyse
//
this.btn_dataAnalyse.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(168)))), ((int)(((byte)(255)))));
this.btn_dataAnalyse.Font = new System.Drawing.Font("微软雅黑", 12F);
this.btn_dataAnalyse.Location = new System.Drawing.Point(792, 35);
this.btn_dataAnalyse.Name = "btn_dataAnalyse";
this.btn_dataAnalyse.Size = new System.Drawing.Size(119, 32);
this.btn_dataAnalyse.TabIndex = 23;
this.btn_dataAnalyse.Text = "数据分析";
this.btn_dataAnalyse.UseVisualStyleBackColor = false;
//
// btn_ledEnvironment1
//
this.btn_ledEnvironment1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(149)))), ((int)(((byte)(212)))));
this.btn_ledEnvironment1.Font = new System.Drawing.Font("微软雅黑", 12F);
this.btn_ledEnvironment1.Location = new System.Drawing.Point(910, 35);
this.btn_ledEnvironment1.Name = "btn_ledEnvironment1";
this.btn_ledEnvironment1.Size = new System.Drawing.Size(121, 32);
this.btn_ledEnvironment1.TabIndex = 15;
this.btn_ledEnvironment1.Text = "推送天气信息";
this.btn_ledEnvironment1.UseVisualStyleBackColor = false;
//
// label6
//
this.label6.AutoSize = true;
this.label6.Font = new System.Drawing.Font("微软雅黑", 18F);
this.label6.Location = new System.Drawing.Point(12, 31);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(110, 31);
this.label6.TabIndex = 11;
this.label6.Text = "环境数据";
//
// txt_humidity
//
this.txt_humidity.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(206)))), ((int)(((byte)(206)))), ((int)(((byte)(206)))));
this.txt_humidity.Font = new System.Drawing.Font("微软雅黑", 14F);
this.txt_humidity.Location = new System.Drawing.Point(716, 36);
this.txt_humidity.Name = "txt_humidity";
this.txt_humidity.Size = new System.Drawing.Size(70, 32);
this.txt_humidity.TabIndex = 22;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("微软雅黑", 14F);
this.label1.Location = new System.Drawing.Point(132, 38);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(50, 25);
this.label1.TabIndex = 12;
this.label1.Text = "火焰";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Font = new System.Drawing.Font("微软雅黑", 14F);
this.label5.Location = new System.Drawing.Point(660, 39);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(50, 25);
this.label5.TabIndex = 21;
this.label5.Text = "湿度";
//
// txt_fire
//
this.txt_fire.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(206)))), ((int)(((byte)(206)))), ((int)(((byte)(206)))));
this.txt_fire.Font = new System.Drawing.Font("微软雅黑", 14F);
this.txt_fire.Location = new System.Drawing.Point(188, 35);
this.txt_fire.Name = "txt_fire";
this.txt_fire.Size = new System.Drawing.Size(70, 32);
this.txt_fire.TabIndex = 13;
//
// txt_temperature
//
this.txt_temperature.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(206)))), ((int)(((byte)(206)))), ((int)(((byte)(206)))));
this.txt_temperature.Font = new System.Drawing.Font("微软雅黑", 14F);
this.txt_temperature.Location = new System.Drawing.Point(584, 35);
this.txt_temperature.Name = "txt_temperature";
this.txt_temperature.Size = new System.Drawing.Size(70, 32);
this.txt_temperature.TabIndex = 20;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("微软雅黑", 14F);
this.label2.Location = new System.Drawing.Point(264, 36);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(50, 25);
this.label2.TabIndex = 14;
this.label2.Text = "烟雾";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Font = new System.Drawing.Font("微软雅黑", 14F);
this.label4.Location = new System.Drawing.Point(528, 38);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(50, 25);
this.label4.TabIndex = 19;
this.label4.Text = "温度";
//
// txt_smoke
//
this.txt_smoke.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(206)))), ((int)(((byte)(206)))), ((int)(((byte)(206)))));
this.txt_smoke.Font = new System.Drawing.Font("微软雅黑", 14F);
this.txt_smoke.Location = new System.Drawing.Point(320, 33);
this.txt_smoke.Name = "txt_smoke";
this.txt_smoke.Size = new System.Drawing.Size(70, 32);
this.txt_smoke.TabIndex = 16;
//
// txt_light
//
this.txt_light.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(206)))), ((int)(((byte)(206)))), ((int)(((byte)(206)))));
this.txt_light.Font = new System.Drawing.Font("微软雅黑", 14F);
this.txt_light.Location = new System.Drawing.Point(452, 32);
this.txt_light.Name = "txt_light";
this.txt_light.Size = new System.Drawing.Size(70, 32);
this.txt_light.TabIndex = 18;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("微软雅黑", 14F);
this.label3.Location = new System.Drawing.Point(396, 35);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(50, 25);
this.label3.TabIndex = 17;
this.label3.Text = "光照";
//
// panel3
//
this.panel3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(229)))), ((int)(((byte)(229)))), ((int)(((byte)(229)))));
this.panel3.Controls.Add(this.lb_return);
this.panel3.Dock = System.Windows.Forms.DockStyle.Top;
this.panel3.Location = new System.Drawing.Point(0, 0);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(1043, 39);
this.panel3.TabIndex = 0;
this.panel3.Paint += new System.Windows.Forms.PaintEventHandler(this.panel3_Paint);
//
// lb_return
//
this.lb_return.AutoSize = true;
this.lb_return.Location = new System.Drawing.Point(25, 12);
this.lb_return.Name = "lb_return";
this.lb_return.Size = new System.Drawing.Size(83, 12);
this.lb_return.TabIndex = 0;
this.lb_return.Text = "< 返回主窗体";
this.lb_return.Click += new System.EventHandler(this.lb_return_Click);
//
// Environment
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1043, 791);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "Environment";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Environment";
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.panel2.ResumeLayout(false);
this.panel_bg.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit();
this.panel_form.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pic_lampOpen)).EndInit();
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
this.panel5.ResumeLayout(false);
this.panel5.PerformLayout();
this.panel3.ResumeLayout(false);
this.panel3.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Panel panel3;
private System.Windows.Forms.Label lb_return;
private System.Windows.Forms.Panel panel_bg;
private System.Windows.Forms.Panel panel5;
private System.Windows.Forms.Panel panel_form;
private System.Windows.Forms.Button btn_dataAnalyse;
private System.Windows.Forms.Button btn_ledEnvironment1;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.TextBox txt_humidity;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox txt_fire;
private System.Windows.Forms.TextBox txt_temperature;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox txt_smoke;
private System.Windows.Forms.TextBox txt_light;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.PictureBox pic_lampOpen;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.TextBox txt_autoLight;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.CheckBox ch_autoLamp;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.Button btn_ledEnvironment2;
private System.Windows.Forms.CheckBox ch_autoLedFire;
private System.Windows.Forms.Button btn_ledSendMsg;
private System.Windows.Forms.TextBox txt_ledMsg;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.DataVisualization.Charting.Chart chart1;
}
}
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace 智慧校园
{
public partial class Environment : Form
{
public Environment()
{
InitializeComponent();
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
private void lb_return_Click(object sender, EventArgs e)
{
this.Close();
}
private void panel3_Paint(object sender, PaintEventArgs e)
{
}
}
}
+143
View File
@@ -0,0 +1,143 @@
namespace 智慧校园
{
partial class Main
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.panel2 = new System.Windows.Forms.Panel();
this.pic_exit = new System.Windows.Forms.PictureBox();
this.pic_security = new System.Windows.Forms.PictureBox();
this.pic_environment = new System.Windows.Forms.PictureBox();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.panel2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pic_exit)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pic_security)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pic_environment)).BeginInit();
this.SuspendLayout();
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(53)))), ((int)(((byte)(147)))), ((int)(((byte)(237)))));
this.panel1.Controls.Add(this.pictureBox1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(1018, 100);
this.panel1.TabIndex = 0;
this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
//
// pictureBox1
//
this.pictureBox1.Image = global::智慧校园.Properties.Resources.ico_title;
this.pictureBox1.Location = new System.Drawing.Point(57, 23);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(197, 54);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// panel2
//
this.panel2.BackgroundImage = global::智慧校园.Properties.Resources.bg_home;
this.panel2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.panel2.Controls.Add(this.pic_exit);
this.panel2.Controls.Add(this.pic_security);
this.panel2.Controls.Add(this.pic_environment);
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel2.Location = new System.Drawing.Point(0, 100);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(1018, 516);
this.panel2.TabIndex = 1;
this.panel2.Paint += new System.Windows.Forms.PaintEventHandler(this.panel2_Paint);
//
// pic_exit
//
this.pic_exit.BackColor = System.Drawing.Color.Transparent;
this.pic_exit.Image = global::智慧校园.Properties.Resources.icon_04;
this.pic_exit.Location = new System.Drawing.Point(660, 124);
this.pic_exit.Name = "pic_exit";
this.pic_exit.Size = new System.Drawing.Size(180, 210);
this.pic_exit.TabIndex = 6;
this.pic_exit.TabStop = false;
this.pic_exit.Click += new System.EventHandler(this.pic_exit_Click);
//
// pic_security
//
this.pic_security.BackColor = System.Drawing.Color.Transparent;
this.pic_security.Image = global::智慧校园.Properties.Resources.icon_03;
this.pic_security.Location = new System.Drawing.Point(404, 124);
this.pic_security.Name = "pic_security";
this.pic_security.Size = new System.Drawing.Size(180, 210);
this.pic_security.TabIndex = 5;
this.pic_security.TabStop = false;
//
// pic_environment
//
this.pic_environment.BackColor = System.Drawing.Color.Transparent;
this.pic_environment.Image = global::智慧校园.Properties.Resources.icon_02;
this.pic_environment.Location = new System.Drawing.Point(133, 124);
this.pic_environment.Name = "pic_environment";
this.pic_environment.Size = new System.Drawing.Size(180, 210);
this.pic_environment.TabIndex = 4;
this.pic_environment.TabStop = false;
this.pic_environment.Click += new System.EventHandler(this.pic_environment_Click);
//
// Main
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1018, 616);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "Main";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Form1";
this.panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pic_exit)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pic_security)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pic_environment)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.PictureBox pic_exit;
private System.Windows.Forms.PictureBox pic_security;
private System.Windows.Forms.PictureBox pic_environment;
}
}
+46
View File
@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace 智慧校园
{
public partial class Main : Form
{
public Main()
{
InitializeComponent();
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
private void pic_environment_Click(object sender, EventArgs e)
{
try
{
new Environment().Show();
}
catch
{
}
}
private void panel2_Paint(object sender, PaintEventArgs e)
{
}
private void pic_exit_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace 智慧校园
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Main());
}
}
}
@@ -0,0 +1,54 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 项目资源(平台素材库)。在"项目资源"里添加或移除,不要手动修改这个文件。
// </auto-generated>
//------------------------------------------------------------------------------
namespace 智慧校园.Properties {
/// <summary>
/// 项目资源:Properties.Resources.资源名
/// </summary>
internal class Resources {
/// <summary>标题:智慧校园</summary>
internal static System.Drawing.Bitmap ico_title {
get { return global::Sim.Host.ProjectResources.Image("ico_title.png"); }
}
/// <summary>主界面背景:校园</summary>
internal static System.Drawing.Bitmap bg_home {
get { return global::Sim.Host.ProjectResources.Image("bg_home.png"); }
}
/// <summary>图标:校园环境</summary>
internal static System.Drawing.Bitmap icon_02 {
get { return global::Sim.Host.ProjectResources.Image("icon_02.png"); }
}
/// <summary>图标:校园安防</summary>
internal static System.Drawing.Bitmap icon_03 {
get { return global::Sim.Host.ProjectResources.Image("icon_03.png"); }
}
/// <summary>图标:退出</summary>
internal static System.Drawing.Bitmap icon_04 {
get { return global::Sim.Host.ProjectResources.Image("icon_04.png"); }
}
/// <summary>路灯场景:灭灯</summary>
internal static System.Drawing.Bitmap day_02 {
get { return global::Sim.Host.ProjectResources.Image("day_02.png"); }
}
/// <summary>面板背景(窄)</summary>
internal static System.Drawing.Bitmap bg_from2 {
get { return global::Sim.Host.ProjectResources.Image("bg_from2.png"); }
}
/// <summary>开关:关</summary>
internal static System.Drawing.Bitmap switch_off {
get { return global::Sim.Host.ProjectResources.Image("switch_off.png"); }
}
}
}
@@ -0,0 +1,38 @@
# 评分规则:书上评价表的功能项。每项单独启动一次程序,按步骤操作,核对结果。
# 格式说明见 server/src/grading/checks.ts
- title: 主界面能打开"校园环境"界面
steps:
- click: pic_environment
- expect: { window: Environment, desc: 点"校园环境"打开 Environment 窗体 }
- expect: { control: panel_bg, background: day_02, desc: 背景是路灯场景(day_02) }
- title: 界面有环境数据栏
steps:
- click: pic_environment
- expect: { control: txt_fire, visible: true }
- expect: { control: txt_smoke, visible: true }
- expect: { control: txt_light, visible: true }
- expect: { control: txt_temperature, visible: true }
- expect: { control: txt_humidity, visible: true }
- expect: { control: btn_dataAnalyse, text: 数据分析 }
- expect: { control: btn_ledEnvironment1, text: 推送天气信息 }
- title: 界面有路灯控制、LED 推送和图表
steps:
- click: pic_environment
- expect: { control: ch_autoLamp, text: 自动控制 }
- expect: { control: txt_autoLight, visible: true }
- expect: { control: pic_lampOpen, background: switch_off, desc: 灯光控制显示"关"的开关图片(switch_off) }
- expect: { control: ch_autoLedFire, text: 自动推送火情 }
- expect: { control: txt_ledMsg, visible: true }
- expect: { control: btn_ledSendMsg, text: 推送LED信息 }
- expect: { control: btn_ledEnvironment2, text: 推送天气信息 }
- expect: { control: chart1, visible: true }
- title: 能返回主窗体
steps:
- click: pic_environment
- expect: { window: Environment }
- click: lb_return
- expect: { window: Environment, open: false, desc: 点"<返回主窗体"关闭 Environment 窗体 }
- expect: { window: Main, desc: 主窗体还在 }
@@ -0,0 +1,4 @@
{
"title": "项目8 任务2 制作\"校园环境\"界面",
"source": "教材书 p159–164,界面和代码取自配套参考工程;图片是平台素材库里自绘的同名素材(尺寸和教材一致);本任务只做界面,为了能看效果,加上了主界面\"校园环境\"打开窗体和\"<返回主窗体\"关闭窗体(书上在任务 3 第 10、22 步)"
}
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 智慧校园
{
class AppSet
{
//串口设置
public static string ADAM4017_COM = "COM2";
public static string ADAM4150_COM = "COM3";
public static string LED_COM = "COM5";
public static string ZigBee_COM = "COM4";
//摄像机参数
public static string Camera_Ip = "192.168.1.100";
public static string Camera_Uid = "admin";
public static string Camera_Pwd = "";
//数据库连接字符串
public static string SqlConn = "Data Source=.;Initial Catalog=WisdomCampus;User ID=sa;Password=123";
}
}
@@ -0,0 +1,555 @@
namespace 智慧校园
{
partial class Environment
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend3 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Legend legend4 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Series series3 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.Series series4 = new System.Windows.Forms.DataVisualization.Charting.Series();
this.panel1 = new System.Windows.Forms.Panel();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.panel2 = new System.Windows.Forms.Panel();
this.panel_bg = new System.Windows.Forms.Panel();
this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart();
this.panel_form = new System.Windows.Forms.Panel();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.pic_lampOpen = new System.Windows.Forms.PictureBox();
this.label10 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.txt_autoLight = new System.Windows.Forms.TextBox();
this.label7 = new System.Windows.Forms.Label();
this.ch_autoLamp = new System.Windows.Forms.CheckBox();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.btn_ledEnvironment2 = new System.Windows.Forms.Button();
this.ch_autoLedFire = new System.Windows.Forms.CheckBox();
this.btn_ledSendMsg = new System.Windows.Forms.Button();
this.txt_ledMsg = new System.Windows.Forms.TextBox();
this.label8 = new System.Windows.Forms.Label();
this.panel5 = new System.Windows.Forms.Panel();
this.btn_dataAnalyse = new System.Windows.Forms.Button();
this.btn_ledEnvironment1 = new System.Windows.Forms.Button();
this.label6 = new System.Windows.Forms.Label();
this.txt_humidity = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.txt_fire = new System.Windows.Forms.TextBox();
this.txt_temperature = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.txt_smoke = new System.Windows.Forms.TextBox();
this.txt_light = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.panel3 = new System.Windows.Forms.Panel();
this.lb_return = new System.Windows.Forms.Label();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.panel2.SuspendLayout();
this.panel_bg.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit();
this.panel_form.SuspendLayout();
this.groupBox2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pic_lampOpen)).BeginInit();
this.groupBox3.SuspendLayout();
this.panel5.SuspendLayout();
this.panel3.SuspendLayout();
this.SuspendLayout();
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(116)))), ((int)(((byte)(133)))));
this.panel1.Controls.Add(this.pictureBox1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(1043, 100);
this.panel1.TabIndex = 0;
this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
//
// pictureBox1
//
this.pictureBox1.Image = global::智慧校园.Properties.Resources.ico_title;
this.pictureBox1.Location = new System.Drawing.Point(44, 12);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(226, 54);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// panel2
//
this.panel2.Controls.Add(this.panel_bg);
this.panel2.Controls.Add(this.panel3);
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel2.Location = new System.Drawing.Point(0, 100);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(1043, 691);
this.panel2.TabIndex = 1;
//
// panel_bg
//
this.panel_bg.BackgroundImage = global::智慧校园.Properties.Resources.day_02;
this.panel_bg.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.panel_bg.Controls.Add(this.chart1);
this.panel_bg.Controls.Add(this.panel_form);
this.panel_bg.Controls.Add(this.panel5);
this.panel_bg.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel_bg.Location = new System.Drawing.Point(0, 39);
this.panel_bg.Name = "panel_bg";
this.panel_bg.Size = new System.Drawing.Size(1043, 652);
this.panel_bg.TabIndex = 1;
//
// chart1
//
chartArea2.Name = "ChartArea1";
this.chart1.ChartAreas.Add(chartArea2);
legend3.Name = "MaxLegend";
legend3.TitleForeColor = System.Drawing.Color.DimGray;
legend4.Name = "AVGLegend";
legend4.TitleForeColor = System.Drawing.Color.DimGray;
this.chart1.Legends.Add(legend3);
this.chart1.Legends.Add(legend4);
this.chart1.Location = new System.Drawing.Point(44, 172);
this.chart1.Name = "chart1";
series3.ChartArea = "ChartArea1";
series3.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
series3.Legend = "MaxLegend";
series3.LegendText = "最大值";
series3.Name = "MaxSeries";
series3.XValueMember = "_Time";
series3.YValueMembers = "MaxTemperature";
series4.ChartArea = "ChartArea1";
series4.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
series4.Legend = "AVGLegend";
series4.LegendText = "平均值";
series4.Name = "AVGSeries";
series4.XValueMember = "_Time";
series4.YValueMembers = "AVGTemperature";
this.chart1.Series.Add(series3);
this.chart1.Series.Add(series4);
this.chart1.Size = new System.Drawing.Size(455, 327);
this.chart1.TabIndex = 3;
this.chart1.Text = "chart1";
//
// panel_form
//
this.panel_form.BackColor = System.Drawing.Color.Transparent;
this.panel_form.BackgroundImage = global::智慧校园.Properties.Resources.bg_from2;
this.panel_form.Controls.Add(this.groupBox2);
this.panel_form.Controls.Add(this.groupBox3);
this.panel_form.Dock = System.Windows.Forms.DockStyle.Right;
this.panel_form.Location = new System.Drawing.Point(617, 0);
this.panel_form.Name = "panel_form";
this.panel_form.Size = new System.Drawing.Size(426, 552);
this.panel_form.TabIndex = 2;
//
// groupBox2
//
this.groupBox2.Controls.Add(this.pic_lampOpen);
this.groupBox2.Controls.Add(this.label10);
this.groupBox2.Controls.Add(this.label9);
this.groupBox2.Controls.Add(this.txt_autoLight);
this.groupBox2.Controls.Add(this.label7);
this.groupBox2.Controls.Add(this.ch_autoLamp);
this.groupBox2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupBox2.ForeColor = System.Drawing.Color.White;
this.groupBox2.Location = new System.Drawing.Point(22, 21);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(392, 150);
this.groupBox2.TabIndex = 3;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "路灯控制";
//
// pic_lampOpen
//
this.pic_lampOpen.BackgroundImage = global::智慧校园.Properties.Resources.switch_off;
this.pic_lampOpen.Location = new System.Drawing.Point(103, 103);
this.pic_lampOpen.Name = "pic_lampOpen";
this.pic_lampOpen.Size = new System.Drawing.Size(48, 24);
this.pic_lampOpen.TabIndex = 5;
this.pic_lampOpen.TabStop = false;
this.pic_lampOpen.Click += new System.EventHandler(this.pic_lampOpen_Click);
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(33, 105);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(59, 17);
this.label10.TabIndex = 4;
this.label10.Text = "灯光控制:";
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(278, 58);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(17, 17);
this.label9.TabIndex = 3;
this.label9.Text = "lx";
//
// txt_autoLight
//
this.txt_autoLight.Location = new System.Drawing.Point(128, 55);
this.txt_autoLight.Name = "txt_autoLight";
this.txt_autoLight.Size = new System.Drawing.Size(144, 23);
this.txt_autoLight.TabIndex = 2;
this.txt_autoLight.TextChanged += new System.EventHandler(this.txt_autoLight_TextChanged);
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(33, 58);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(92, 17);
this.label7.TabIndex = 1;
this.label7.Text = "设定开灯光照值";
//
// ch_autoLamp
//
this.ch_autoLamp.AutoSize = true;
this.ch_autoLamp.Location = new System.Drawing.Point(35, 30);
this.ch_autoLamp.Name = "ch_autoLamp";
this.ch_autoLamp.Size = new System.Drawing.Size(75, 21);
this.ch_autoLamp.TabIndex = 0;
this.ch_autoLamp.Text = "自动控制";
this.ch_autoLamp.UseVisualStyleBackColor = true;
this.ch_autoLamp.CheckedChanged += new System.EventHandler(this.ch_autoLamp_CheckedChanged);
//
// groupBox3
//
this.groupBox3.Controls.Add(this.btn_ledEnvironment2);
this.groupBox3.Controls.Add(this.ch_autoLedFire);
this.groupBox3.Controls.Add(this.btn_ledSendMsg);
this.groupBox3.Controls.Add(this.txt_ledMsg);
this.groupBox3.Controls.Add(this.label8);
this.groupBox3.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupBox3.ForeColor = System.Drawing.Color.White;
this.groupBox3.Location = new System.Drawing.Point(22, 209);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(392, 316);
this.groupBox3.TabIndex = 4;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "LED推送";
//
// btn_ledEnvironment2
//
this.btn_ledEnvironment2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(149)))), ((int)(((byte)(212)))));
this.btn_ledEnvironment2.Font = new System.Drawing.Font("微软雅黑", 12F);
this.btn_ledEnvironment2.Location = new System.Drawing.Point(234, 217);
this.btn_ledEnvironment2.Name = "btn_ledEnvironment2";
this.btn_ledEnvironment2.Size = new System.Drawing.Size(145, 32);
this.btn_ledEnvironment2.TabIndex = 11;
this.btn_ledEnvironment2.Text = "推送天气信息";
this.btn_ledEnvironment2.UseVisualStyleBackColor = false;
this.btn_ledEnvironment2.Click += new System.EventHandler(this.btn_ledEnvironment2_Click);
//
// ch_autoLedFire
//
this.ch_autoLedFire.AutoSize = true;
this.ch_autoLedFire.Location = new System.Drawing.Point(265, 35);
this.ch_autoLedFire.Name = "ch_autoLedFire";
this.ch_autoLedFire.Size = new System.Drawing.Size(99, 21);
this.ch_autoLedFire.TabIndex = 4;
this.ch_autoLedFire.Text = "自动推送火情";
this.ch_autoLedFire.UseVisualStyleBackColor = true;
this.ch_autoLedFire.CheckedChanged += new System.EventHandler(this.ch_autoLedFire_CheckedChanged);
//
// btn_ledSendMsg
//
this.btn_ledSendMsg.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(168)))), ((int)(((byte)(255)))));
this.btn_ledSendMsg.Font = new System.Drawing.Font("微软雅黑", 12F);
this.btn_ledSendMsg.Location = new System.Drawing.Point(26, 217);
this.btn_ledSendMsg.Name = "btn_ledSendMsg";
this.btn_ledSendMsg.Size = new System.Drawing.Size(145, 32);
this.btn_ledSendMsg.TabIndex = 2;
this.btn_ledSendMsg.Text = "推送LED信息";
this.btn_ledSendMsg.UseVisualStyleBackColor = false;
this.btn_ledSendMsg.Click += new System.EventHandler(this.btn_ledSendMsg_Click);
//
// txt_ledMsg
//
this.txt_ledMsg.Location = new System.Drawing.Point(23, 62);
this.txt_ledMsg.Multiline = true;
this.txt_ledMsg.Name = "txt_ledMsg";
this.txt_ledMsg.Size = new System.Drawing.Size(356, 130);
this.txt_ledMsg.TabIndex = 1;
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(20, 36);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(54, 17);
this.label8.TabIndex = 0;
this.label8.Text = "LED信息";
//
// panel5
//
this.panel5.Controls.Add(this.btn_dataAnalyse);
this.panel5.Controls.Add(this.btn_ledEnvironment1);
this.panel5.Controls.Add(this.label6);
this.panel5.Controls.Add(this.txt_humidity);
this.panel5.Controls.Add(this.label1);
this.panel5.Controls.Add(this.label5);
this.panel5.Controls.Add(this.txt_fire);
this.panel5.Controls.Add(this.txt_temperature);
this.panel5.Controls.Add(this.label2);
this.panel5.Controls.Add(this.label4);
this.panel5.Controls.Add(this.txt_smoke);
this.panel5.Controls.Add(this.txt_light);
this.panel5.Controls.Add(this.label3);
this.panel5.Dock = System.Windows.Forms.DockStyle.Bottom;
this.panel5.Location = new System.Drawing.Point(0, 552);
this.panel5.Name = "panel5";
this.panel5.Size = new System.Drawing.Size(1043, 100);
this.panel5.TabIndex = 1;
//
// btn_dataAnalyse
//
this.btn_dataAnalyse.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(168)))), ((int)(((byte)(255)))));
this.btn_dataAnalyse.Font = new System.Drawing.Font("微软雅黑", 12F);
this.btn_dataAnalyse.Location = new System.Drawing.Point(792, 35);
this.btn_dataAnalyse.Name = "btn_dataAnalyse";
this.btn_dataAnalyse.Size = new System.Drawing.Size(119, 32);
this.btn_dataAnalyse.TabIndex = 23;
this.btn_dataAnalyse.Text = "数据分析";
this.btn_dataAnalyse.UseVisualStyleBackColor = false;
this.btn_dataAnalyse.Click += new System.EventHandler(this.btn_dataAnalyse_Click);
//
// btn_ledEnvironment1
//
this.btn_ledEnvironment1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(149)))), ((int)(((byte)(212)))));
this.btn_ledEnvironment1.Font = new System.Drawing.Font("微软雅黑", 12F);
this.btn_ledEnvironment1.Location = new System.Drawing.Point(910, 35);
this.btn_ledEnvironment1.Name = "btn_ledEnvironment1";
this.btn_ledEnvironment1.Size = new System.Drawing.Size(121, 32);
this.btn_ledEnvironment1.TabIndex = 15;
this.btn_ledEnvironment1.Text = "推送天气信息";
this.btn_ledEnvironment1.UseVisualStyleBackColor = false;
this.btn_ledEnvironment1.Click += new System.EventHandler(this.btn_ledEnvironment1_Click);
//
// label6
//
this.label6.AutoSize = true;
this.label6.Font = new System.Drawing.Font("微软雅黑", 18F);
this.label6.Location = new System.Drawing.Point(12, 31);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(110, 31);
this.label6.TabIndex = 11;
this.label6.Text = "环境数据";
//
// txt_humidity
//
this.txt_humidity.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(206)))), ((int)(((byte)(206)))), ((int)(((byte)(206)))));
this.txt_humidity.Font = new System.Drawing.Font("微软雅黑", 14F);
this.txt_humidity.Location = new System.Drawing.Point(716, 36);
this.txt_humidity.Name = "txt_humidity";
this.txt_humidity.Size = new System.Drawing.Size(70, 32);
this.txt_humidity.TabIndex = 22;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("微软雅黑", 14F);
this.label1.Location = new System.Drawing.Point(132, 38);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(50, 25);
this.label1.TabIndex = 12;
this.label1.Text = "火焰";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Font = new System.Drawing.Font("微软雅黑", 14F);
this.label5.Location = new System.Drawing.Point(660, 39);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(50, 25);
this.label5.TabIndex = 21;
this.label5.Text = "湿度";
//
// txt_fire
//
this.txt_fire.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(206)))), ((int)(((byte)(206)))), ((int)(((byte)(206)))));
this.txt_fire.Font = new System.Drawing.Font("微软雅黑", 14F);
this.txt_fire.Location = new System.Drawing.Point(188, 35);
this.txt_fire.Name = "txt_fire";
this.txt_fire.Size = new System.Drawing.Size(70, 32);
this.txt_fire.TabIndex = 13;
//
// txt_temperature
//
this.txt_temperature.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(206)))), ((int)(((byte)(206)))), ((int)(((byte)(206)))));
this.txt_temperature.Font = new System.Drawing.Font("微软雅黑", 14F);
this.txt_temperature.Location = new System.Drawing.Point(584, 35);
this.txt_temperature.Name = "txt_temperature";
this.txt_temperature.Size = new System.Drawing.Size(70, 32);
this.txt_temperature.TabIndex = 20;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("微软雅黑", 14F);
this.label2.Location = new System.Drawing.Point(264, 36);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(50, 25);
this.label2.TabIndex = 14;
this.label2.Text = "烟雾";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Font = new System.Drawing.Font("微软雅黑", 14F);
this.label4.Location = new System.Drawing.Point(528, 38);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(50, 25);
this.label4.TabIndex = 19;
this.label4.Text = "温度";
//
// txt_smoke
//
this.txt_smoke.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(206)))), ((int)(((byte)(206)))), ((int)(((byte)(206)))));
this.txt_smoke.Font = new System.Drawing.Font("微软雅黑", 14F);
this.txt_smoke.Location = new System.Drawing.Point(320, 33);
this.txt_smoke.Name = "txt_smoke";
this.txt_smoke.Size = new System.Drawing.Size(70, 32);
this.txt_smoke.TabIndex = 16;
//
// txt_light
//
this.txt_light.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(206)))), ((int)(((byte)(206)))), ((int)(((byte)(206)))));
this.txt_light.Font = new System.Drawing.Font("微软雅黑", 14F);
this.txt_light.Location = new System.Drawing.Point(452, 32);
this.txt_light.Name = "txt_light";
this.txt_light.Size = new System.Drawing.Size(70, 32);
this.txt_light.TabIndex = 18;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("微软雅黑", 14F);
this.label3.Location = new System.Drawing.Point(396, 35);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(50, 25);
this.label3.TabIndex = 17;
this.label3.Text = "光照";
//
// panel3
//
this.panel3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(229)))), ((int)(((byte)(229)))), ((int)(((byte)(229)))));
this.panel3.Controls.Add(this.lb_return);
this.panel3.Dock = System.Windows.Forms.DockStyle.Top;
this.panel3.Location = new System.Drawing.Point(0, 0);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(1043, 39);
this.panel3.TabIndex = 0;
this.panel3.Paint += new System.Windows.Forms.PaintEventHandler(this.panel3_Paint);
//
// lb_return
//
this.lb_return.AutoSize = true;
this.lb_return.Location = new System.Drawing.Point(25, 12);
this.lb_return.Name = "lb_return";
this.lb_return.Size = new System.Drawing.Size(83, 12);
this.lb_return.TabIndex = 0;
this.lb_return.Text = "< 返回主窗体";
this.lb_return.Click += new System.EventHandler(this.lb_return_Click);
//
// Environment
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1043, 791);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "Environment";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Environment";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Environment_FormClosed);
this.Load += new System.EventHandler(this.Environment_Load);
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.panel2.ResumeLayout(false);
this.panel_bg.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit();
this.panel_form.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pic_lampOpen)).EndInit();
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
this.panel5.ResumeLayout(false);
this.panel5.PerformLayout();
this.panel3.ResumeLayout(false);
this.panel3.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Panel panel3;
private System.Windows.Forms.Label lb_return;
private System.Windows.Forms.Panel panel_bg;
private System.Windows.Forms.Panel panel5;
private System.Windows.Forms.Panel panel_form;
private System.Windows.Forms.Button btn_dataAnalyse;
private System.Windows.Forms.Button btn_ledEnvironment1;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.TextBox txt_humidity;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox txt_fire;
private System.Windows.Forms.TextBox txt_temperature;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox txt_smoke;
private System.Windows.Forms.TextBox txt_light;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.PictureBox pic_lampOpen;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.TextBox txt_autoLight;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.CheckBox ch_autoLamp;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.Button btn_ledEnvironment2;
private System.Windows.Forms.CheckBox ch_autoLedFire;
private System.Windows.Forms.Button btn_ledSendMsg;
private System.Windows.Forms.TextBox txt_ledMsg;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.DataVisualization.Charting.Chart chart1;
}
}
@@ -0,0 +1,279 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DeviceCtrlLibrary;
using DeviceCtrlLibrary.Model;
using 智慧校园.SQLHelpers;
using System.Threading;
namespace 智慧校园
{
public partial class Environment : Form
{
public Environment()
{
InitializeComponent();
}
//用于各类耗时长的操作(SQL、数据采集、设备控制等)
Thread thread;
//用于异步通行
SynchronizationContext _main;
//结果模型
ADAM4017ResModel ResModel_4017;
ADAM4150ResModel ResModel_4150;
//设置自动控制路灯的光照值
double environmentLight, setLight;
//按钮状态标志
bool IsAuto_Lamp = false;
bool IsAuto_FireMsg = false;
bool IsLampOpen = false;
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
private void lb_return_Click(object sender, EventArgs e)
{
this.Close();
}
private void Environment_Load(object sender, EventArgs e)
{
try
{
//隐藏曲线图
chart1.Visible = false;
thread = new Thread(new ThreadStart(Tick));
_main = WindowsFormsSynchronizationContext.Current;
thread.Start();
}
catch
{
}
}
private void Tick()
{
try
{
while (true)
{
//数据采集
ResModel_4017 = DeviceCtrlHelper.adam4017Helper.SetData();
Thread.Sleep(500);
ResModel_4150 = DeviceCtrlHelper.adam4150Helper.SetData();
//UI显示数据
_main.Send(_ =>
{
try //防止无数据出错
{
txt_fire.Text = (ResModel_4150.fireValue ? "发生火情" : "正常");
txt_smoke.Text = (ResModel_4150.smokeValue ? "发生烟情" : "正常");
txt_light.Text = ResModel_4017.lightValue;
txt_temperature.Text = ResModel_4017.temperatureValue;
txt_humidity.Text = ResModel_4017.humidityValue;
}
catch { }
}, null);
//自动路灯控制
double.TryParse(ResModel_4017.lightValue, out environmentLight);
if (IsAuto_Lamp && environmentLight < setLight)
{
LampOnOff(1, true);
}
else if (IsAuto_Lamp && !(environmentLight < setLight))
{
LampOnOff(1, false);
}
//自动推送火情LED信息控制
if (IsAuto_FireMsg)
{
if (ResModel_4150.fireValue && ResModel_4150.smokeValue)
DeviceCtrlHelper.ledHelper.SendLedString("发生严重火灾 ");
else if (ResModel_4150.fireValue)
DeviceCtrlHelper.ledHelper.SendLedString("发现火情 ");
else if (ResModel_4150.smokeValue)
DeviceCtrlHelper.ledHelper.SendLedString("发现烟情 ");
}
//执行数据上传
SQLBLL.EnvironmentUpData(ResModel_4150.fireValue, ResModel_4150.smokeValue, ResModel_4017.lightValue, ResModel_4017.temperatureValue, ResModel_4017.humidityValue);
Thread.Sleep(5000);
}
}
catch
{
}
}
private void LampOnOff(int RelayNum, bool IsOpen)
{
try
{
//开启路灯
DeviceCtrlHelper.zigBeeHelper.OnOff(RelayNum, IsOpen);
//切换UI背景
_main.Send(_ =>
{
if (IsOpen)
{
pic_lampOpen.BackgroundImage = Properties.Resources.switch_on;
panel_bg.BackgroundImage = Properties.Resources.day_01;
}
else
{
panel_bg.BackgroundImage = Properties.Resources.day_02;
pic_lampOpen.BackgroundImage = Properties.Resources.switch_off;
}
}, null);
}
catch
{
}
}
private void Environment_FormClosed(object sender, FormClosedEventArgs e)
{
try
{
thread.Suspend();
thread = null;
}
catch
{
}
}
private void btn_dataAnalyse_Click(object sender, EventArgs e)
{
try
{
if (btn_dataAnalyse.Text.Equals("数据分析"))
{
//绑定图标数据
chart1.DataSource = SQLBLL.GetEnvironmentGraphData();
//更新图标数据
chart1.DataBind();
chart1.Visible = true;
btn_dataAnalyse.Text = "关闭图表";
}
else if (btn_dataAnalyse.Text.Equals("关闭图表"))
{
chart1.Visible = false;
btn_dataAnalyse.Text = "数据分析";
}
}
catch
{
}
}
private void pic_lampOpen_Click(object sender, EventArgs e)
{
//手动路灯控制
try
{
if (!IsLampOpen)
{
LampOnOff(1, true);
}
else
{
LampOnOff(1, false);
}
IsLampOpen = !IsLampOpen;
}
catch
{
}
}
private void btn_ledEnvironment1_Click(object sender, EventArgs e)
{
try
{
//推送LED天气信息
if (ResModel_4017 != null && ResModel_4150 != null)
DeviceCtrlHelper.ledHelper.SendLedString("当前温度:" + ResModel_4017.temperatureValue + "℃ 湿度:" + ResModel_4017.humidityValue + "%");
}
catch
{
}
}
private void btn_ledEnvironment2_Click(object sender, EventArgs e)
{
try
{
//推送LED天气信息
if (ResModel_4017 != null && ResModel_4150 != null)
DeviceCtrlHelper.ledHelper.SendLedString("当前温度:" + ResModel_4017.temperatureValue + "℃ 湿度:" + ResModel_4017.humidityValue + "%");
}
catch
{
}
}
private void panel3_Paint(object sender, PaintEventArgs e)
{
}
private void txt_autoLight_TextChanged(object sender, EventArgs e)
{
try
{
//获取光照比较值
double.TryParse(txt_autoLight.Text,out setLight);
}
catch
{
}
}
private void btn_ledSendMsg_Click(object sender, EventArgs e)
{
try
{
//推送LED信息
DeviceCtrlHelper.ledHelper.SendLedString(txt_ledMsg.Text);
}
catch
{
}
}
private void ch_autoLamp_CheckedChanged(object sender, EventArgs e)
{
//自动控制路灯
IsAuto_Lamp = ch_autoLamp.Checked;
}
private void ch_autoLedFire_CheckedChanged(object sender, EventArgs e)
{
//自动推送火情
IsAuto_FireMsg = ch_autoLedFire.Checked;
}
}
}
+144
View File
@@ -0,0 +1,144 @@
namespace 智慧校园
{
partial class Main
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.panel2 = new System.Windows.Forms.Panel();
this.pic_exit = new System.Windows.Forms.PictureBox();
this.pic_security = new System.Windows.Forms.PictureBox();
this.pic_environment = new System.Windows.Forms.PictureBox();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.panel2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pic_exit)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pic_security)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pic_environment)).BeginInit();
this.SuspendLayout();
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(53)))), ((int)(((byte)(147)))), ((int)(((byte)(237)))));
this.panel1.Controls.Add(this.pictureBox1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(1018, 100);
this.panel1.TabIndex = 0;
this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
//
// pictureBox1
//
this.pictureBox1.Image = global::智慧校园.Properties.Resources.ico_title;
this.pictureBox1.Location = new System.Drawing.Point(57, 23);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(197, 54);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// panel2
//
this.panel2.BackgroundImage = global::智慧校园.Properties.Resources.bg_home;
this.panel2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.panel2.Controls.Add(this.pic_exit);
this.panel2.Controls.Add(this.pic_security);
this.panel2.Controls.Add(this.pic_environment);
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel2.Location = new System.Drawing.Point(0, 100);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(1018, 516);
this.panel2.TabIndex = 1;
this.panel2.Paint += new System.Windows.Forms.PaintEventHandler(this.panel2_Paint);
//
// pic_exit
//
this.pic_exit.BackColor = System.Drawing.Color.Transparent;
this.pic_exit.Image = global::智慧校园.Properties.Resources.icon_04;
this.pic_exit.Location = new System.Drawing.Point(660, 124);
this.pic_exit.Name = "pic_exit";
this.pic_exit.Size = new System.Drawing.Size(180, 210);
this.pic_exit.TabIndex = 6;
this.pic_exit.TabStop = false;
this.pic_exit.Click += new System.EventHandler(this.pic_exit_Click);
//
// pic_security
//
this.pic_security.BackColor = System.Drawing.Color.Transparent;
this.pic_security.Image = global::智慧校园.Properties.Resources.icon_03;
this.pic_security.Location = new System.Drawing.Point(404, 124);
this.pic_security.Name = "pic_security";
this.pic_security.Size = new System.Drawing.Size(180, 210);
this.pic_security.TabIndex = 5;
this.pic_security.TabStop = false;
//
// pic_environment
//
this.pic_environment.BackColor = System.Drawing.Color.Transparent;
this.pic_environment.Image = global::智慧校园.Properties.Resources.icon_02;
this.pic_environment.Location = new System.Drawing.Point(133, 124);
this.pic_environment.Name = "pic_environment";
this.pic_environment.Size = new System.Drawing.Size(180, 210);
this.pic_environment.TabIndex = 4;
this.pic_environment.TabStop = false;
this.pic_environment.Click += new System.EventHandler(this.pic_environment_Click);
//
// Main
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1018, 616);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "Main";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Form1";
this.Load += new System.EventHandler(this.Main_Load);
this.panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pic_exit)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pic_security)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pic_environment)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.PictureBox pic_exit;
private System.Windows.Forms.PictureBox pic_security;
private System.Windows.Forms.PictureBox pic_environment;
}
}
@@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DeviceCtrlLibrary;
namespace 智慧校园
{
public partial class Main : Form
{
public Main()
{
InitializeComponent();
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
private void pic_environment_Click(object sender, EventArgs e)
{
try
{
new Environment().Show();
}
catch
{
}
}
private void panel2_Paint(object sender, PaintEventArgs e)
{
}
private void Main_Load(object sender, EventArgs e)
{
try
{
//实例化工具类
DeviceCtrlHelper.adam4017Helper.Open(AppSet.ADAM4017_COM);
DeviceCtrlHelper.adam4150Helper.Open(AppSet.ADAM4150_COM);
DeviceCtrlHelper.zigBeeHelper.Open(AppSet.ZigBee_COM);
DeviceCtrlHelper.ledHelper.OpenLedCom(AppSet.LED_COM);
}
catch { }
}
private void pic_exit_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace 智慧校园
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Main());
}
}
}
@@ -0,0 +1,64 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 项目资源(平台素材库)。在"项目资源"里添加或移除,不要手动修改这个文件。
// </auto-generated>
//------------------------------------------------------------------------------
namespace 智慧校园.Properties {
/// <summary>
/// 项目资源:Properties.Resources.资源名
/// </summary>
internal class Resources {
/// <summary>标题:智慧校园</summary>
internal static System.Drawing.Bitmap ico_title {
get { return global::Sim.Host.ProjectResources.Image("ico_title.png"); }
}
/// <summary>主界面背景:校园</summary>
internal static System.Drawing.Bitmap bg_home {
get { return global::Sim.Host.ProjectResources.Image("bg_home.png"); }
}
/// <summary>图标:校园环境</summary>
internal static System.Drawing.Bitmap icon_02 {
get { return global::Sim.Host.ProjectResources.Image("icon_02.png"); }
}
/// <summary>图标:校园安防</summary>
internal static System.Drawing.Bitmap icon_03 {
get { return global::Sim.Host.ProjectResources.Image("icon_03.png"); }
}
/// <summary>图标:退出</summary>
internal static System.Drawing.Bitmap icon_04 {
get { return global::Sim.Host.ProjectResources.Image("icon_04.png"); }
}
/// <summary>路灯场景:亮灯</summary>
internal static System.Drawing.Bitmap day_01 {
get { return global::Sim.Host.ProjectResources.Image("day_01.png"); }
}
/// <summary>路灯场景:灭灯</summary>
internal static System.Drawing.Bitmap day_02 {
get { return global::Sim.Host.ProjectResources.Image("day_02.png"); }
}
/// <summary>面板背景(窄)</summary>
internal static System.Drawing.Bitmap bg_from2 {
get { return global::Sim.Host.ProjectResources.Image("bg_from2.png"); }
}
/// <summary>开关:开</summary>
internal static System.Drawing.Bitmap switch_on {
get { return global::Sim.Host.ProjectResources.Image("switch_on.png"); }
}
/// <summary>开关:关</summary>
internal static System.Drawing.Bitmap switch_off {
get { return global::Sim.Host.ProjectResources.Image("switch_off.png"); }
}
}
}
@@ -0,0 +1,106 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 智慧校园.SQLHelpers
{
class SQLBLL
{
public static SQLRes SecurityUpData(Image img)//把图片保存到数据库
{
SQLRes sqlRes = new SQLRes();
byte[] imgByte = null;
using (MemoryStream ms = new MemoryStream())//图片转换为二进制数组
{
img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
imgByte = new byte[ms.Length];
imgByte = ms.ToArray();
}
string sqlStr = "INSERT INTO SecurityData (EvenTime,EvenImage) VALUES (@time,@img)";
SqlParameter[] sqlParameter = new SqlParameter[] { new SqlParameter("time", DateTime.Now.ToString()), new SqlParameter("img", imgByte) };
if (SQLHelper.Exec(sqlStr, sqlParameter) >= 1)
{
sqlRes.Result = true;
sqlRes.Msg = "成功!";
}
else
{
sqlRes.Result = false;
sqlRes.Msg = "失败!";
}
return sqlRes;
}
public static Dictionary<string, Image> GetSecurityData(DateTime startDate, DateTime endDate)
{
Dictionary<string, Image> ImgDictionary = new Dictionary<string, Image>();
if (string.IsNullOrWhiteSpace(startDate.Month.ToString()) && string.IsNullOrWhiteSpace(endDate.Month .ToString()))
{
return ImgDictionary;
}
//选择查询日期日期
string sql = "SELECT * FROM SecurityData WHERE EvenTime between @time_start and @time_end";
SqlParameter[] sqlParameter = new SqlParameter[] { new SqlParameter("time_start", startDate.Year + "/" + startDate.Month + "/" + startDate.Day), new SqlParameter("time_end", endDate.Year + "/" + endDate.Month + "/" + endDate.Day+" 23:59:59" )};
DataSet ds = SQLHelper.getData(sql, sqlParameter);
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
ImgDictionary.Add(ds.Tables[0].Rows[i]["EvenTime"].ToString(), Image.FromStream(new MemoryStream((byte[])ds.Tables[0].Rows[i]["EvenImage"])));
}
return ImgDictionary;
}
public static SQLRes EnvironmentUpData(bool fire, bool smoke, string light, string temperature, string humidity)
{
SQLRes sqlRes = new SQLRes();
string sqlStr = "INSERT INTO EnvironmentData (Fire ,Smoke ,Temperature ,Humidity , Light, _Time) VALUES (@fire,@smoke,@temperature,@humidity,@light,@time)";
SqlParameter[] sqlParameter = new SqlParameter[] { new SqlParameter("time", DateTime.Now.ToString()), new SqlParameter("fire", fire), new SqlParameter("smoke", smoke), new SqlParameter("temperature", temperature), new SqlParameter("humidity", humidity), new SqlParameter("light", light) };
if (SQLHelper.Exec(sqlStr, sqlParameter) >= 1)
{
sqlRes.Result = true;
sqlRes.Msg = "成功!";
}
else
{
sqlRes.Result = false;
sqlRes.Msg = "失败!";
}
return sqlRes;
}
public static DataTable GetEnvironmentGraphData()
{
string sqlStr = "SELECT TOP 7 CONVERT(varchar(10),_Time,120) AS _Time, ROUND(Max(Temperature),2) AS MaxTemperature, ROUND(AVG(Temperature),2) AS AVGTemperature FROM EnvironmentData GROUP BY CONVERT(varchar(10),_Time,120) ORDER BY CONVERT(varchar(10),_Time,120) DESC ";
return SQLHelper.getData(sqlStr, null).Tables[0];
}
}
class SQLRes
{
public string Msg { get; set; }
public bool Result { get; set; }
}
}
@@ -0,0 +1,112 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 智慧校园.SQLHelpers
{
class SQLHelper
{
public static string strConn = AppSet.SqlConn;
public static bool SaveData(string sql, DataTable dt)
{
try
{
SqlConnection conn = new SqlConnection(strConn);
conn.Open();
SqlDataAdapter sda = new SqlDataAdapter(sql, conn);
SqlCommandBuilder objCommandBuilder = new SqlCommandBuilder(sda);
sda.Update(dt);
conn.Close();
return true;
}
catch (Exception e)
{
string Error = e.Message;
return false;
}
}
public static DataSet getData(string sql, params SqlParameter[] para)
{
DataSet ds = new DataSet();
try
{
SqlConnection conn = new SqlConnection(strConn);
conn.Open();
SqlCommand cmd = new SqlCommand(sql, conn);
if (para != null)
{
foreach (SqlParameter item in para)
{
cmd.Parameters.Add(item);
}
}
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.Fill(ds);
cmd.Parameters.Clear();
conn.Close();
}
catch(Exception e)
{
string Error = e.Message;
}
return ds;
}
public static DataSet getData(SqlCommand cmd)
{
DataSet ds = new DataSet();
try
{
SqlConnection conn = new SqlConnection(strConn);
conn.Open();
cmd.Connection = conn;
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.Fill(ds);
cmd.Parameters.Clear();
conn.Close();
}
catch (Exception e)
{
string Error = e.Message;
}
return ds;
}
public static int Exec(string sql, params SqlParameter[] para)
{
try
{
SqlConnection conn = new SqlConnection(strConn);
conn.Open();
SqlCommand cmd = new SqlCommand(sql, conn);
if (para != null)
{
foreach (SqlParameter item in para)
{
cmd.Parameters.Add(item);
}
}
int iRsult = cmd.ExecuteNonQuery();
conn.Close();
return iRsult;
}
catch (Exception e)
{
string Error = e.Message;
return -1;
}
}
}
}
@@ -0,0 +1,71 @@
# 评分规则:书上评价表的功能项。每项单独启动一次程序,按步骤操作,核对结果。
# 格式说明见 server/src/grading/checks.ts
# 采集线程每 5.5 秒左右采集一次,所以等待时间写 8s。
- title: 能实时显示环境数据和火情、烟情
steps:
- click: pic_environment
- board: { temperature: 28, humidity: 55, light: 650 }
- expect: { control: txt_temperature, text: '28', within: 8s }
- expect: { control: txt_humidity, text: '55', within: 8s }
- expect: { control: txt_light, text: '650', within: 8s }
- expect: { control: txt_fire, text: 正常, within: 8s }
- board: { fire: true, smoke: true }
- expect: { control: txt_fire, text: 发生火情, within: 8s }
- expect: { control: txt_smoke, text: 发生烟情, within: 8s }
- title: 路灯能手动控制
steps:
- click: pic_environment
- click: pic_lampOpen
- expect: { zigbee: 1, on: true, desc: 点灯光开关打开路灯 }
- expect: { control: pic_lampOpen, background: switch_on, desc: 开关换成"开"的图片(switch_on) }
- expect: { control: panel_bg, background: day_01, desc: 背景换成亮灯的场景(day_01) }
- click: pic_lampOpen
- expect: { zigbee: 1, on: false, desc: 再点一次关闭路灯 }
- expect: { control: pic_lampOpen, background: switch_off }
- expect: { control: panel_bg, background: day_02 }
- title: 路灯能根据光照度自动控制
steps:
- click: pic_environment
- text: { control: txt_autoLight, value: '400' }
- click: ch_autoLamp
- board: { light: 200 }
- expect: { zigbee: 1, on: true, within: 8s, desc: 光照低于设定值 400 时自动打开路灯 }
- expect: { control: panel_bg, background: day_01 }
- board: { light: 800 }
- expect: { zigbee: 1, on: false, within: 8s, desc: 光照高于设定值时自动关闭路灯 }
- title: 能推送天气信息和自定义信息到 LED 屏
steps:
- board: { temperature: 26, humidity: 50 }
- click: pic_environment
- expect: { control: txt_temperature, text: '26', within: 8s }
- click: btn_ledEnvironment1
- expect: { led: 当前温度:26℃ 湿度:50%, desc: 显示"当前温度:26℃ 湿度:50%"(点下方的"推送天气信息") }
- text: { control: txt_ledMsg, value: 欢迎参观智慧校园 }
- click: btn_ledSendMsg
- expect: { led: 欢迎参观智慧校园, desc: 显示输入的文字(点"推送LED信息") }
- click: btn_ledEnvironment2
- expect: { led: 当前温度:26℃, desc: 显示天气信息(点右边的"推送天气信息") }
- title: 能自动推送火情到 LED 屏
steps:
- click: pic_environment
- click: ch_autoLedFire
- board: { fire: true }
- expect: { led: 发现火情, within: 8s, desc: 显示"发现火情"(勾选"自动推送火情"后有火焰) }
- board: { smoke: true }
- expect: { led: 发生严重火灾, within: 8s, desc: 显示"发生严重火灾"(火焰和烟雾都有) }
- title: 图表能正确显示数据
steps:
- click: pic_environment
- expect: { control: chart1, visible: false, desc: 刚打开时图表隐藏 }
- click: btn_dataAnalyse
- expect: { control: chart1, visible: true, desc: 点"数据分析"显示图表 }
- expect: { control: chart1, points: 7, desc: 显示最近 7 天的最高温度和平均温度 }
- expect: { control: btn_dataAnalyse, text: 关闭图表 }
- click: btn_dataAnalyse
- expect: { control: chart1, visible: false, desc: 点"关闭图表"隐藏图表 }
- expect: { control: btn_dataAnalyse, text: 数据分析 }
@@ -0,0 +1,54 @@
-- 实验的初始数据库 WisdomCampus(教材"综合实训"附带的库):环境数据表 EnvironmentData、报警图片表 SecurityData、用户表 Users。
-- EnvironmentData 预置了 7 天的历史数据,"数据分析"的图表一打开就有内容;SecurityData 是空的,拍照或有人入侵时才有记录。
-- 学生可以在数据库页面"恢复实验初始数据";评分时每个检查项用一份新的。
CREATE DATABASE WisdomCampus
GO
USE WisdomCampus
GO
CREATE TABLE Users (Id int IDENTITY(1,1) PRIMARY KEY, UserName nvarchar(50) NOT NULL, Password nvarchar(50) NOT NULL)
CREATE TABLE EnvironmentData (Id int IDENTITY(1,1) PRIMARY KEY, Fire bit NOT NULL, Smoke bit NOT NULL, Temperature float NULL, Humidity float NULL, Light float NULL, _Time datetime NOT NULL)
CREATE TABLE SecurityData (Id int IDENTITY(1,1) PRIMARY KEY, EvenTime datetime NOT NULL, EvenImage image NOT NULL)
GO
INSERT INTO Users (UserName, Password) VALUES ('admin', '123')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 15.9, 58, 258, '2026-10-14 08:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 18.1, 53, 475, '2026-10-14 10:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.8, 51, 761, '2026-10-14 12:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 22.5, 49, 733, '2026-10-14 14:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.3, 54, 528, '2026-10-14 16:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 17.1, 57, 283, '2026-10-14 18:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 17.9, 59, 261, '2026-10-15 08:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.6, 53, 499, '2026-10-15 10:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 21.8, 52, 764, '2026-10-15 12:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 23.5, 47, 778, '2026-10-15 14:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 21.8, 52, 503, '2026-10-15 16:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.6, 56, 218, '2026-10-15 18:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 13.9, 63, 258, '2026-10-16 08:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 16.6, 60, 477, '2026-10-16 10:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.8, 51, 741, '2026-10-16 12:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 20.5, 54, 796, '2026-10-16 14:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.3, 55, 488, '2026-10-16 16:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 16.6, 59, 214, '2026-10-16 18:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 11.9, 67, 234, '2026-10-17 08:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 15.1, 63, 544, '2026-10-17 10:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 16.3, 60, 804, '2026-10-17 12:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 18.5, 54, 801, '2026-10-17 14:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 17.8, 59, 524, '2026-10-17 16:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 15.1, 58, 286, '2026-10-17 18:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 16.4, 59, 250, '2026-10-18 08:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.6, 55, 533, '2026-10-18 10:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 21.3, 50, 749, '2026-10-18 12:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 24, 48, 766, '2026-10-18 14:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 20.8, 54, 534, '2026-10-18 16:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.1, 53, 241, '2026-10-18 18:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 18.4, 54, 253, '2026-10-19 08:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 21.1, 50, 474, '2026-10-19 10:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 22.3, 48, 778, '2026-10-19 12:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 26, 46, 783, '2026-10-19 14:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 23.3, 50, 520, '2026-10-19 16:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 20.6, 50, 213, '2026-10-19 18:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 15.9, 62, 230, '2026-10-20 08:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 18.6, 52, 471, '2026-10-20 10:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.3, 53, 751, '2026-10-20 12:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 21.5, 48, 747, '2026-10-20 14:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.3, 55, 527, '2026-10-20 16:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 17.1, 57, 220, '2026-10-20 18:00:00')
@@ -0,0 +1,4 @@
{
"title": "项目8 任务3 实现\"校园环境\"数据采集及数据分析功能",
"source": "教材书 p164–174,界面和代码取自配套参考工程;图片是平台素材库里自绘的同名素材(尺寸和教材一致);按书补全了参考工程里空着的\"推送LED信息\"\"自动控制\",给\"自动推送火情\"复选框加上 CheckedChanged(书上第 23 步把控件名写成了 ch_autoLamp);数据库 WisdomCampus 是平台按教材的表结构建的,预置 7 天环境数据"
}
+25
View File
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 智慧校园
{
class AppSet
{
//串口设置
public static string ADAM4017_COM = "COM2";
public static string ADAM4150_COM = "COM3";
public static string LED_COM = "COM5";
public static string ZigBee_COM = "COM4";
//摄像机参数
public static string Camera_Ip = "192.168.1.100";
public static string Camera_Uid = "admin";
public static string Camera_Pwd = "";
//数据库连接字符串
public static string SqlConn = "Data Source=.;Initial Catalog=WisdomCampus;User ID=sa;Password=123";
}
}
+555
View File
@@ -0,0 +1,555 @@
namespace 智慧校园
{
partial class Environment
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend3 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Legend legend4 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Series series3 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.Series series4 = new System.Windows.Forms.DataVisualization.Charting.Series();
this.panel1 = new System.Windows.Forms.Panel();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.panel2 = new System.Windows.Forms.Panel();
this.panel_bg = new System.Windows.Forms.Panel();
this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart();
this.panel_form = new System.Windows.Forms.Panel();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.pic_lampOpen = new System.Windows.Forms.PictureBox();
this.label10 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.txt_autoLight = new System.Windows.Forms.TextBox();
this.label7 = new System.Windows.Forms.Label();
this.ch_autoLamp = new System.Windows.Forms.CheckBox();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.btn_ledEnvironment2 = new System.Windows.Forms.Button();
this.ch_autoLedFire = new System.Windows.Forms.CheckBox();
this.btn_ledSendMsg = new System.Windows.Forms.Button();
this.txt_ledMsg = new System.Windows.Forms.TextBox();
this.label8 = new System.Windows.Forms.Label();
this.panel5 = new System.Windows.Forms.Panel();
this.btn_dataAnalyse = new System.Windows.Forms.Button();
this.btn_ledEnvironment1 = new System.Windows.Forms.Button();
this.label6 = new System.Windows.Forms.Label();
this.txt_humidity = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.txt_fire = new System.Windows.Forms.TextBox();
this.txt_temperature = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.txt_smoke = new System.Windows.Forms.TextBox();
this.txt_light = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.panel3 = new System.Windows.Forms.Panel();
this.lb_return = new System.Windows.Forms.Label();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.panel2.SuspendLayout();
this.panel_bg.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit();
this.panel_form.SuspendLayout();
this.groupBox2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pic_lampOpen)).BeginInit();
this.groupBox3.SuspendLayout();
this.panel5.SuspendLayout();
this.panel3.SuspendLayout();
this.SuspendLayout();
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(116)))), ((int)(((byte)(133)))));
this.panel1.Controls.Add(this.pictureBox1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(1043, 100);
this.panel1.TabIndex = 0;
this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
//
// pictureBox1
//
this.pictureBox1.Image = global::智慧校园.Properties.Resources.ico_title;
this.pictureBox1.Location = new System.Drawing.Point(44, 12);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(226, 54);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// panel2
//
this.panel2.Controls.Add(this.panel_bg);
this.panel2.Controls.Add(this.panel3);
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel2.Location = new System.Drawing.Point(0, 100);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(1043, 691);
this.panel2.TabIndex = 1;
//
// panel_bg
//
this.panel_bg.BackgroundImage = global::智慧校园.Properties.Resources.day_02;
this.panel_bg.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.panel_bg.Controls.Add(this.chart1);
this.panel_bg.Controls.Add(this.panel_form);
this.panel_bg.Controls.Add(this.panel5);
this.panel_bg.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel_bg.Location = new System.Drawing.Point(0, 39);
this.panel_bg.Name = "panel_bg";
this.panel_bg.Size = new System.Drawing.Size(1043, 652);
this.panel_bg.TabIndex = 1;
//
// chart1
//
chartArea2.Name = "ChartArea1";
this.chart1.ChartAreas.Add(chartArea2);
legend3.Name = "MaxLegend";
legend3.TitleForeColor = System.Drawing.Color.DimGray;
legend4.Name = "AVGLegend";
legend4.TitleForeColor = System.Drawing.Color.DimGray;
this.chart1.Legends.Add(legend3);
this.chart1.Legends.Add(legend4);
this.chart1.Location = new System.Drawing.Point(44, 172);
this.chart1.Name = "chart1";
series3.ChartArea = "ChartArea1";
series3.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
series3.Legend = "MaxLegend";
series3.LegendText = "最大值";
series3.Name = "MaxSeries";
series3.XValueMember = "_Time";
series3.YValueMembers = "MaxTemperature";
series4.ChartArea = "ChartArea1";
series4.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
series4.Legend = "AVGLegend";
series4.LegendText = "平均值";
series4.Name = "AVGSeries";
series4.XValueMember = "_Time";
series4.YValueMembers = "AVGTemperature";
this.chart1.Series.Add(series3);
this.chart1.Series.Add(series4);
this.chart1.Size = new System.Drawing.Size(455, 327);
this.chart1.TabIndex = 3;
this.chart1.Text = "chart1";
//
// panel_form
//
this.panel_form.BackColor = System.Drawing.Color.Transparent;
this.panel_form.BackgroundImage = global::智慧校园.Properties.Resources.bg_from2;
this.panel_form.Controls.Add(this.groupBox2);
this.panel_form.Controls.Add(this.groupBox3);
this.panel_form.Dock = System.Windows.Forms.DockStyle.Right;
this.panel_form.Location = new System.Drawing.Point(617, 0);
this.panel_form.Name = "panel_form";
this.panel_form.Size = new System.Drawing.Size(426, 552);
this.panel_form.TabIndex = 2;
//
// groupBox2
//
this.groupBox2.Controls.Add(this.pic_lampOpen);
this.groupBox2.Controls.Add(this.label10);
this.groupBox2.Controls.Add(this.label9);
this.groupBox2.Controls.Add(this.txt_autoLight);
this.groupBox2.Controls.Add(this.label7);
this.groupBox2.Controls.Add(this.ch_autoLamp);
this.groupBox2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupBox2.ForeColor = System.Drawing.Color.White;
this.groupBox2.Location = new System.Drawing.Point(22, 21);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(392, 150);
this.groupBox2.TabIndex = 3;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "路灯控制";
//
// pic_lampOpen
//
this.pic_lampOpen.BackgroundImage = global::智慧校园.Properties.Resources.switch_off;
this.pic_lampOpen.Location = new System.Drawing.Point(103, 103);
this.pic_lampOpen.Name = "pic_lampOpen";
this.pic_lampOpen.Size = new System.Drawing.Size(48, 24);
this.pic_lampOpen.TabIndex = 5;
this.pic_lampOpen.TabStop = false;
this.pic_lampOpen.Click += new System.EventHandler(this.pic_lampOpen_Click);
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(33, 105);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(59, 17);
this.label10.TabIndex = 4;
this.label10.Text = "灯光控制:";
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(278, 58);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(17, 17);
this.label9.TabIndex = 3;
this.label9.Text = "lx";
//
// txt_autoLight
//
this.txt_autoLight.Location = new System.Drawing.Point(128, 55);
this.txt_autoLight.Name = "txt_autoLight";
this.txt_autoLight.Size = new System.Drawing.Size(144, 23);
this.txt_autoLight.TabIndex = 2;
this.txt_autoLight.TextChanged += new System.EventHandler(this.txt_autoLight_TextChanged);
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(33, 58);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(92, 17);
this.label7.TabIndex = 1;
this.label7.Text = "设定开灯光照值";
//
// ch_autoLamp
//
this.ch_autoLamp.AutoSize = true;
this.ch_autoLamp.Location = new System.Drawing.Point(35, 30);
this.ch_autoLamp.Name = "ch_autoLamp";
this.ch_autoLamp.Size = new System.Drawing.Size(75, 21);
this.ch_autoLamp.TabIndex = 0;
this.ch_autoLamp.Text = "自动控制";
this.ch_autoLamp.UseVisualStyleBackColor = true;
this.ch_autoLamp.CheckedChanged += new System.EventHandler(this.ch_autoLamp_CheckedChanged);
//
// groupBox3
//
this.groupBox3.Controls.Add(this.btn_ledEnvironment2);
this.groupBox3.Controls.Add(this.ch_autoLedFire);
this.groupBox3.Controls.Add(this.btn_ledSendMsg);
this.groupBox3.Controls.Add(this.txt_ledMsg);
this.groupBox3.Controls.Add(this.label8);
this.groupBox3.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupBox3.ForeColor = System.Drawing.Color.White;
this.groupBox3.Location = new System.Drawing.Point(22, 209);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(392, 316);
this.groupBox3.TabIndex = 4;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "LED推送";
//
// btn_ledEnvironment2
//
this.btn_ledEnvironment2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(149)))), ((int)(((byte)(212)))));
this.btn_ledEnvironment2.Font = new System.Drawing.Font("微软雅黑", 12F);
this.btn_ledEnvironment2.Location = new System.Drawing.Point(234, 217);
this.btn_ledEnvironment2.Name = "btn_ledEnvironment2";
this.btn_ledEnvironment2.Size = new System.Drawing.Size(145, 32);
this.btn_ledEnvironment2.TabIndex = 11;
this.btn_ledEnvironment2.Text = "推送天气信息";
this.btn_ledEnvironment2.UseVisualStyleBackColor = false;
this.btn_ledEnvironment2.Click += new System.EventHandler(this.btn_ledEnvironment2_Click);
//
// ch_autoLedFire
//
this.ch_autoLedFire.AutoSize = true;
this.ch_autoLedFire.Location = new System.Drawing.Point(265, 35);
this.ch_autoLedFire.Name = "ch_autoLedFire";
this.ch_autoLedFire.Size = new System.Drawing.Size(99, 21);
this.ch_autoLedFire.TabIndex = 4;
this.ch_autoLedFire.Text = "自动推送火情";
this.ch_autoLedFire.UseVisualStyleBackColor = true;
this.ch_autoLedFire.CheckedChanged += new System.EventHandler(this.ch_autoLedFire_CheckedChanged);
//
// btn_ledSendMsg
//
this.btn_ledSendMsg.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(168)))), ((int)(((byte)(255)))));
this.btn_ledSendMsg.Font = new System.Drawing.Font("微软雅黑", 12F);
this.btn_ledSendMsg.Location = new System.Drawing.Point(26, 217);
this.btn_ledSendMsg.Name = "btn_ledSendMsg";
this.btn_ledSendMsg.Size = new System.Drawing.Size(145, 32);
this.btn_ledSendMsg.TabIndex = 2;
this.btn_ledSendMsg.Text = "推送LED信息";
this.btn_ledSendMsg.UseVisualStyleBackColor = false;
this.btn_ledSendMsg.Click += new System.EventHandler(this.btn_ledSendMsg_Click);
//
// txt_ledMsg
//
this.txt_ledMsg.Location = new System.Drawing.Point(23, 62);
this.txt_ledMsg.Multiline = true;
this.txt_ledMsg.Name = "txt_ledMsg";
this.txt_ledMsg.Size = new System.Drawing.Size(356, 130);
this.txt_ledMsg.TabIndex = 1;
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(20, 36);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(54, 17);
this.label8.TabIndex = 0;
this.label8.Text = "LED信息";
//
// panel5
//
this.panel5.Controls.Add(this.btn_dataAnalyse);
this.panel5.Controls.Add(this.btn_ledEnvironment1);
this.panel5.Controls.Add(this.label6);
this.panel5.Controls.Add(this.txt_humidity);
this.panel5.Controls.Add(this.label1);
this.panel5.Controls.Add(this.label5);
this.panel5.Controls.Add(this.txt_fire);
this.panel5.Controls.Add(this.txt_temperature);
this.panel5.Controls.Add(this.label2);
this.panel5.Controls.Add(this.label4);
this.panel5.Controls.Add(this.txt_smoke);
this.panel5.Controls.Add(this.txt_light);
this.panel5.Controls.Add(this.label3);
this.panel5.Dock = System.Windows.Forms.DockStyle.Bottom;
this.panel5.Location = new System.Drawing.Point(0, 552);
this.panel5.Name = "panel5";
this.panel5.Size = new System.Drawing.Size(1043, 100);
this.panel5.TabIndex = 1;
//
// btn_dataAnalyse
//
this.btn_dataAnalyse.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(168)))), ((int)(((byte)(255)))));
this.btn_dataAnalyse.Font = new System.Drawing.Font("微软雅黑", 12F);
this.btn_dataAnalyse.Location = new System.Drawing.Point(792, 35);
this.btn_dataAnalyse.Name = "btn_dataAnalyse";
this.btn_dataAnalyse.Size = new System.Drawing.Size(119, 32);
this.btn_dataAnalyse.TabIndex = 23;
this.btn_dataAnalyse.Text = "数据分析";
this.btn_dataAnalyse.UseVisualStyleBackColor = false;
this.btn_dataAnalyse.Click += new System.EventHandler(this.btn_dataAnalyse_Click);
//
// btn_ledEnvironment1
//
this.btn_ledEnvironment1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(149)))), ((int)(((byte)(212)))));
this.btn_ledEnvironment1.Font = new System.Drawing.Font("微软雅黑", 12F);
this.btn_ledEnvironment1.Location = new System.Drawing.Point(910, 35);
this.btn_ledEnvironment1.Name = "btn_ledEnvironment1";
this.btn_ledEnvironment1.Size = new System.Drawing.Size(121, 32);
this.btn_ledEnvironment1.TabIndex = 15;
this.btn_ledEnvironment1.Text = "推送天气信息";
this.btn_ledEnvironment1.UseVisualStyleBackColor = false;
this.btn_ledEnvironment1.Click += new System.EventHandler(this.btn_ledEnvironment1_Click);
//
// label6
//
this.label6.AutoSize = true;
this.label6.Font = new System.Drawing.Font("微软雅黑", 18F);
this.label6.Location = new System.Drawing.Point(12, 31);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(110, 31);
this.label6.TabIndex = 11;
this.label6.Text = "环境数据";
//
// txt_humidity
//
this.txt_humidity.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(206)))), ((int)(((byte)(206)))), ((int)(((byte)(206)))));
this.txt_humidity.Font = new System.Drawing.Font("微软雅黑", 14F);
this.txt_humidity.Location = new System.Drawing.Point(716, 36);
this.txt_humidity.Name = "txt_humidity";
this.txt_humidity.Size = new System.Drawing.Size(70, 32);
this.txt_humidity.TabIndex = 22;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("微软雅黑", 14F);
this.label1.Location = new System.Drawing.Point(132, 38);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(50, 25);
this.label1.TabIndex = 12;
this.label1.Text = "火焰";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Font = new System.Drawing.Font("微软雅黑", 14F);
this.label5.Location = new System.Drawing.Point(660, 39);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(50, 25);
this.label5.TabIndex = 21;
this.label5.Text = "湿度";
//
// txt_fire
//
this.txt_fire.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(206)))), ((int)(((byte)(206)))), ((int)(((byte)(206)))));
this.txt_fire.Font = new System.Drawing.Font("微软雅黑", 14F);
this.txt_fire.Location = new System.Drawing.Point(188, 35);
this.txt_fire.Name = "txt_fire";
this.txt_fire.Size = new System.Drawing.Size(70, 32);
this.txt_fire.TabIndex = 13;
//
// txt_temperature
//
this.txt_temperature.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(206)))), ((int)(((byte)(206)))), ((int)(((byte)(206)))));
this.txt_temperature.Font = new System.Drawing.Font("微软雅黑", 14F);
this.txt_temperature.Location = new System.Drawing.Point(584, 35);
this.txt_temperature.Name = "txt_temperature";
this.txt_temperature.Size = new System.Drawing.Size(70, 32);
this.txt_temperature.TabIndex = 20;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("微软雅黑", 14F);
this.label2.Location = new System.Drawing.Point(264, 36);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(50, 25);
this.label2.TabIndex = 14;
this.label2.Text = "烟雾";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Font = new System.Drawing.Font("微软雅黑", 14F);
this.label4.Location = new System.Drawing.Point(528, 38);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(50, 25);
this.label4.TabIndex = 19;
this.label4.Text = "温度";
//
// txt_smoke
//
this.txt_smoke.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(206)))), ((int)(((byte)(206)))), ((int)(((byte)(206)))));
this.txt_smoke.Font = new System.Drawing.Font("微软雅黑", 14F);
this.txt_smoke.Location = new System.Drawing.Point(320, 33);
this.txt_smoke.Name = "txt_smoke";
this.txt_smoke.Size = new System.Drawing.Size(70, 32);
this.txt_smoke.TabIndex = 16;
//
// txt_light
//
this.txt_light.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(206)))), ((int)(((byte)(206)))), ((int)(((byte)(206)))));
this.txt_light.Font = new System.Drawing.Font("微软雅黑", 14F);
this.txt_light.Location = new System.Drawing.Point(452, 32);
this.txt_light.Name = "txt_light";
this.txt_light.Size = new System.Drawing.Size(70, 32);
this.txt_light.TabIndex = 18;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("微软雅黑", 14F);
this.label3.Location = new System.Drawing.Point(396, 35);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(50, 25);
this.label3.TabIndex = 17;
this.label3.Text = "光照";
//
// panel3
//
this.panel3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(229)))), ((int)(((byte)(229)))), ((int)(((byte)(229)))));
this.panel3.Controls.Add(this.lb_return);
this.panel3.Dock = System.Windows.Forms.DockStyle.Top;
this.panel3.Location = new System.Drawing.Point(0, 0);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(1043, 39);
this.panel3.TabIndex = 0;
this.panel3.Paint += new System.Windows.Forms.PaintEventHandler(this.panel3_Paint);
//
// lb_return
//
this.lb_return.AutoSize = true;
this.lb_return.Location = new System.Drawing.Point(25, 12);
this.lb_return.Name = "lb_return";
this.lb_return.Size = new System.Drawing.Size(83, 12);
this.lb_return.TabIndex = 0;
this.lb_return.Text = "< 返回主窗体";
this.lb_return.Click += new System.EventHandler(this.lb_return_Click);
//
// Environment
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1043, 791);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "Environment";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Environment";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Environment_FormClosed);
this.Load += new System.EventHandler(this.Environment_Load);
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.panel2.ResumeLayout(false);
this.panel_bg.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit();
this.panel_form.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pic_lampOpen)).EndInit();
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
this.panel5.ResumeLayout(false);
this.panel5.PerformLayout();
this.panel3.ResumeLayout(false);
this.panel3.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Panel panel3;
private System.Windows.Forms.Label lb_return;
private System.Windows.Forms.Panel panel_bg;
private System.Windows.Forms.Panel panel5;
private System.Windows.Forms.Panel panel_form;
private System.Windows.Forms.Button btn_dataAnalyse;
private System.Windows.Forms.Button btn_ledEnvironment1;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.TextBox txt_humidity;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox txt_fire;
private System.Windows.Forms.TextBox txt_temperature;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox txt_smoke;
private System.Windows.Forms.TextBox txt_light;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.PictureBox pic_lampOpen;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.TextBox txt_autoLight;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.CheckBox ch_autoLamp;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.Button btn_ledEnvironment2;
private System.Windows.Forms.CheckBox ch_autoLedFire;
private System.Windows.Forms.Button btn_ledSendMsg;
private System.Windows.Forms.TextBox txt_ledMsg;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.DataVisualization.Charting.Chart chart1;
}
}
+279
View File
@@ -0,0 +1,279 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DeviceCtrlLibrary;
using DeviceCtrlLibrary.Model;
using 智慧校园.SQLHelpers;
using System.Threading;
namespace 智慧校园
{
public partial class Environment : Form
{
public Environment()
{
InitializeComponent();
}
//用于各类耗时长的操作(SQL、数据采集、设备控制等)
Thread thread;
//用于异步通行
SynchronizationContext _main;
//结果模型
ADAM4017ResModel ResModel_4017;
ADAM4150ResModel ResModel_4150;
//设置自动控制路灯的光照值
double environmentLight, setLight;
//按钮状态标志
bool IsAuto_Lamp = false;
bool IsAuto_FireMsg = false;
bool IsLampOpen = false;
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
private void lb_return_Click(object sender, EventArgs e)
{
this.Close();
}
private void Environment_Load(object sender, EventArgs e)
{
try
{
//隐藏曲线图
chart1.Visible = false;
thread = new Thread(new ThreadStart(Tick));
_main = WindowsFormsSynchronizationContext.Current;
thread.Start();
}
catch
{
}
}
private void Tick()
{
try
{
while (true)
{
//数据采集
ResModel_4017 = DeviceCtrlHelper.adam4017Helper.SetData();
Thread.Sleep(500);
ResModel_4150 = DeviceCtrlHelper.adam4150Helper.SetData();
//UI显示数据
_main.Send(_ =>
{
try //防止无数据出错
{
txt_fire.Text = (ResModel_4150.fireValue ? "发生火情" : "正常");
txt_smoke.Text = (ResModel_4150.smokeValue ? "发生烟情" : "正常");
txt_light.Text = ResModel_4017.lightValue;
txt_temperature.Text = ResModel_4017.temperatureValue;
txt_humidity.Text = ResModel_4017.humidityValue;
}
catch { }
}, null);
//自动路灯控制
double.TryParse(ResModel_4017.lightValue, out environmentLight);
if (IsAuto_Lamp && environmentLight < setLight)
{
LampOnOff(1, true);
}
else if (IsAuto_Lamp && !(environmentLight < setLight))
{
LampOnOff(1, false);
}
//自动推送火情LED信息控制
if (IsAuto_FireMsg)
{
if (ResModel_4150.fireValue && ResModel_4150.smokeValue)
DeviceCtrlHelper.ledHelper.SendLedString("发生严重火灾 ");
else if (ResModel_4150.fireValue)
DeviceCtrlHelper.ledHelper.SendLedString("发现火情 ");
else if (ResModel_4150.smokeValue)
DeviceCtrlHelper.ledHelper.SendLedString("发现烟情 ");
}
//执行数据上传
SQLBLL.EnvironmentUpData(ResModel_4150.fireValue, ResModel_4150.smokeValue, ResModel_4017.lightValue, ResModel_4017.temperatureValue, ResModel_4017.humidityValue);
Thread.Sleep(5000);
}
}
catch
{
}
}
private void LampOnOff(int RelayNum, bool IsOpen)
{
try
{
//开启路灯
DeviceCtrlHelper.zigBeeHelper.OnOff(RelayNum, IsOpen);
//切换UI背景
_main.Send(_ =>
{
if (IsOpen)
{
pic_lampOpen.BackgroundImage = Properties.Resources.switch_on;
panel_bg.BackgroundImage = Properties.Resources.day_01;
}
else
{
panel_bg.BackgroundImage = Properties.Resources.day_02;
pic_lampOpen.BackgroundImage = Properties.Resources.switch_off;
}
}, null);
}
catch
{
}
}
private void Environment_FormClosed(object sender, FormClosedEventArgs e)
{
try
{
thread.Suspend();
thread = null;
}
catch
{
}
}
private void btn_dataAnalyse_Click(object sender, EventArgs e)
{
try
{
if (btn_dataAnalyse.Text.Equals("数据分析"))
{
//绑定图标数据
chart1.DataSource = SQLBLL.GetEnvironmentGraphData();
//更新图标数据
chart1.DataBind();
chart1.Visible = true;
btn_dataAnalyse.Text = "关闭图表";
}
else if (btn_dataAnalyse.Text.Equals("关闭图表"))
{
chart1.Visible = false;
btn_dataAnalyse.Text = "数据分析";
}
}
catch
{
}
}
private void pic_lampOpen_Click(object sender, EventArgs e)
{
//手动路灯控制
try
{
if (!IsLampOpen)
{
LampOnOff(1, true);
}
else
{
LampOnOff(1, false);
}
IsLampOpen = !IsLampOpen;
}
catch
{
}
}
private void btn_ledEnvironment1_Click(object sender, EventArgs e)
{
try
{
//推送LED天气信息
if (ResModel_4017 != null && ResModel_4150 != null)
DeviceCtrlHelper.ledHelper.SendLedString("当前温度:" + ResModel_4017.temperatureValue + "℃ 湿度:" + ResModel_4017.humidityValue + "%");
}
catch
{
}
}
private void btn_ledEnvironment2_Click(object sender, EventArgs e)
{
try
{
//推送LED天气信息
if (ResModel_4017 != null && ResModel_4150 != null)
DeviceCtrlHelper.ledHelper.SendLedString("当前温度:" + ResModel_4017.temperatureValue + "℃ 湿度:" + ResModel_4017.humidityValue + "%");
}
catch
{
}
}
private void panel3_Paint(object sender, PaintEventArgs e)
{
}
private void txt_autoLight_TextChanged(object sender, EventArgs e)
{
try
{
//获取光照比较值
double.TryParse(txt_autoLight.Text,out setLight);
}
catch
{
}
}
private void btn_ledSendMsg_Click(object sender, EventArgs e)
{
try
{
//推送LED信息
DeviceCtrlHelper.ledHelper.SendLedString(txt_ledMsg.Text);
}
catch
{
}
}
private void ch_autoLamp_CheckedChanged(object sender, EventArgs e)
{
//自动控制路灯
IsAuto_Lamp = ch_autoLamp.Checked;
}
private void ch_autoLedFire_CheckedChanged(object sender, EventArgs e)
{
//自动推送火情
IsAuto_FireMsg = ch_autoLedFire.Checked;
}
}
}
+145
View File
@@ -0,0 +1,145 @@
namespace 智慧校园
{
partial class Main
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.panel2 = new System.Windows.Forms.Panel();
this.pic_exit = new System.Windows.Forms.PictureBox();
this.pic_security = new System.Windows.Forms.PictureBox();
this.pic_environment = new System.Windows.Forms.PictureBox();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.panel2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pic_exit)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pic_security)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pic_environment)).BeginInit();
this.SuspendLayout();
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(53)))), ((int)(((byte)(147)))), ((int)(((byte)(237)))));
this.panel1.Controls.Add(this.pictureBox1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(1018, 100);
this.panel1.TabIndex = 0;
this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
//
// pictureBox1
//
this.pictureBox1.Image = global::智慧校园.Properties.Resources.ico_title;
this.pictureBox1.Location = new System.Drawing.Point(57, 23);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(197, 54);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// panel2
//
this.panel2.BackgroundImage = global::智慧校园.Properties.Resources.bg_home;
this.panel2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.panel2.Controls.Add(this.pic_exit);
this.panel2.Controls.Add(this.pic_security);
this.panel2.Controls.Add(this.pic_environment);
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel2.Location = new System.Drawing.Point(0, 100);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(1018, 516);
this.panel2.TabIndex = 1;
this.panel2.Paint += new System.Windows.Forms.PaintEventHandler(this.panel2_Paint);
//
// pic_exit
//
this.pic_exit.BackColor = System.Drawing.Color.Transparent;
this.pic_exit.Image = global::智慧校园.Properties.Resources.icon_04;
this.pic_exit.Location = new System.Drawing.Point(660, 124);
this.pic_exit.Name = "pic_exit";
this.pic_exit.Size = new System.Drawing.Size(180, 210);
this.pic_exit.TabIndex = 6;
this.pic_exit.TabStop = false;
this.pic_exit.Click += new System.EventHandler(this.pic_exit_Click);
//
// pic_security
//
this.pic_security.BackColor = System.Drawing.Color.Transparent;
this.pic_security.Image = global::智慧校园.Properties.Resources.icon_03;
this.pic_security.Location = new System.Drawing.Point(404, 124);
this.pic_security.Name = "pic_security";
this.pic_security.Size = new System.Drawing.Size(180, 210);
this.pic_security.TabIndex = 5;
this.pic_security.TabStop = false;
this.pic_security.Click += new System.EventHandler(this.pic_security_Click);
//
// pic_environment
//
this.pic_environment.BackColor = System.Drawing.Color.Transparent;
this.pic_environment.Image = global::智慧校园.Properties.Resources.icon_02;
this.pic_environment.Location = new System.Drawing.Point(133, 124);
this.pic_environment.Name = "pic_environment";
this.pic_environment.Size = new System.Drawing.Size(180, 210);
this.pic_environment.TabIndex = 4;
this.pic_environment.TabStop = false;
this.pic_environment.Click += new System.EventHandler(this.pic_environment_Click);
//
// Main
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1018, 616);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "Main";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Form1";
this.Load += new System.EventHandler(this.Main_Load);
this.panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pic_exit)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pic_security)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pic_environment)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.PictureBox pic_exit;
private System.Windows.Forms.PictureBox pic_security;
private System.Windows.Forms.PictureBox pic_environment;
}
}
+72
View File
@@ -0,0 +1,72 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DeviceCtrlLibrary;
namespace 智慧校园
{
public partial class Main : Form
{
public Main()
{
InitializeComponent();
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
private void pic_environment_Click(object sender, EventArgs e)
{
try
{
new Environment().Show();
}
catch
{
}
}
private void panel2_Paint(object sender, PaintEventArgs e)
{
}
private void Main_Load(object sender, EventArgs e)
{
try
{
//实例化工具类
DeviceCtrlHelper.adam4017Helper.Open(AppSet.ADAM4017_COM);
DeviceCtrlHelper.adam4150Helper.Open(AppSet.ADAM4150_COM);
DeviceCtrlHelper.zigBeeHelper.Open(AppSet.ZigBee_COM);
DeviceCtrlHelper.ledHelper.OpenLedCom(AppSet.LED_COM);
}
catch { }
}
private void pic_security_Click(object sender, EventArgs e)
{
try
{
new Security().Show();
}
catch
{
}
}
private void pic_exit_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
+22
View File
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace 智慧校园
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Main());
}
}
}
@@ -0,0 +1,114 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 项目资源(平台素材库)。在"项目资源"里添加或移除,不要手动修改这个文件。
// </auto-generated>
//------------------------------------------------------------------------------
namespace 智慧校园.Properties {
/// <summary>
/// 项目资源:Properties.Resources.资源名
/// </summary>
internal class Resources {
/// <summary>标题:智慧校园</summary>
internal static System.Drawing.Bitmap ico_title {
get { return global::Sim.Host.ProjectResources.Image("ico_title.png"); }
}
/// <summary>主界面背景:校园</summary>
internal static System.Drawing.Bitmap bg_home {
get { return global::Sim.Host.ProjectResources.Image("bg_home.png"); }
}
/// <summary>图标:校园环境</summary>
internal static System.Drawing.Bitmap icon_02 {
get { return global::Sim.Host.ProjectResources.Image("icon_02.png"); }
}
/// <summary>图标:校园安防</summary>
internal static System.Drawing.Bitmap icon_03 {
get { return global::Sim.Host.ProjectResources.Image("icon_03.png"); }
}
/// <summary>图标:退出</summary>
internal static System.Drawing.Bitmap icon_04 {
get { return global::Sim.Host.ProjectResources.Image("icon_04.png"); }
}
/// <summary>路灯场景:亮灯</summary>
internal static System.Drawing.Bitmap day_01 {
get { return global::Sim.Host.ProjectResources.Image("day_01.png"); }
}
/// <summary>路灯场景:灭灯</summary>
internal static System.Drawing.Bitmap day_02 {
get { return global::Sim.Host.ProjectResources.Image("day_02.png"); }
}
/// <summary>面板背景(窄)</summary>
internal static System.Drawing.Bitmap bg_from2 {
get { return global::Sim.Host.ProjectResources.Image("bg_from2.png"); }
}
/// <summary>开关:开</summary>
internal static System.Drawing.Bitmap switch_on {
get { return global::Sim.Host.ProjectResources.Image("switch_on.png"); }
}
/// <summary>开关:关</summary>
internal static System.Drawing.Bitmap switch_off {
get { return global::Sim.Host.ProjectResources.Image("switch_off.png"); }
}
/// <summary>监控:无画面</summary>
internal static System.Drawing.Bitmap icon_monitor {
get { return global::Sim.Host.ProjectResources.Image("icon_monitor.png"); }
}
/// <summary>监控:方向盘底座</summary>
internal static System.Drawing.Bitmap panel_video_ctrl {
get { return global::Sim.Host.ProjectResources.Image("panel_video_ctrl.png"); }
}
/// <summary>方向键:上</summary>
internal static System.Drawing.Bitmap btn_arrow_up_normal {
get { return global::Sim.Host.ProjectResources.Image("btn_arrow_up_normal.png"); }
}
/// <summary>方向键:上(按下)</summary>
internal static System.Drawing.Bitmap btn_arrow_up_press {
get { return global::Sim.Host.ProjectResources.Image("btn_arrow_up_press.png"); }
}
/// <summary>方向键:下</summary>
internal static System.Drawing.Bitmap btn_arrow_down_normal {
get { return global::Sim.Host.ProjectResources.Image("btn_arrow_down_normal.png"); }
}
/// <summary>方向键:下(按下)</summary>
internal static System.Drawing.Bitmap btn_arrow_down_press {
get { return global::Sim.Host.ProjectResources.Image("btn_arrow_down_press.png"); }
}
/// <summary>方向键:左</summary>
internal static System.Drawing.Bitmap btn_arrow_left_normal {
get { return global::Sim.Host.ProjectResources.Image("btn_arrow_left_normal.png"); }
}
/// <summary>方向键:左(按下)</summary>
internal static System.Drawing.Bitmap btn_arrow_left_press {
get { return global::Sim.Host.ProjectResources.Image("btn_arrow_left_press.png"); }
}
/// <summary>方向键:右</summary>
internal static System.Drawing.Bitmap btn_arrow_right_normal {
get { return global::Sim.Host.ProjectResources.Image("btn_arrow_right_normal.png"); }
}
/// <summary>方向键:右(按下)</summary>
internal static System.Drawing.Bitmap btn_arrow_right_press {
get { return global::Sim.Host.ProjectResources.Image("btn_arrow_right_press.png"); }
}
}
}
@@ -0,0 +1,106 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 智慧校园.SQLHelpers
{
class SQLBLL
{
public static SQLRes SecurityUpData(Image img)//把图片保存到数据库
{
SQLRes sqlRes = new SQLRes();
byte[] imgByte = null;
using (MemoryStream ms = new MemoryStream())//图片转换为二进制数组
{
img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
imgByte = new byte[ms.Length];
imgByte = ms.ToArray();
}
string sqlStr = "INSERT INTO SecurityData (EvenTime,EvenImage) VALUES (@time,@img)";
SqlParameter[] sqlParameter = new SqlParameter[] { new SqlParameter("time", DateTime.Now.ToString()), new SqlParameter("img", imgByte) };
if (SQLHelper.Exec(sqlStr, sqlParameter) >= 1)
{
sqlRes.Result = true;
sqlRes.Msg = "成功!";
}
else
{
sqlRes.Result = false;
sqlRes.Msg = "失败!";
}
return sqlRes;
}
public static Dictionary<string, Image> GetSecurityData(DateTime startDate, DateTime endDate)
{
Dictionary<string, Image> ImgDictionary = new Dictionary<string, Image>();
if (string.IsNullOrWhiteSpace(startDate.Month.ToString()) && string.IsNullOrWhiteSpace(endDate.Month .ToString()))
{
return ImgDictionary;
}
//选择查询日期日期
string sql = "SELECT * FROM SecurityData WHERE EvenTime between @time_start and @time_end";
SqlParameter[] sqlParameter = new SqlParameter[] { new SqlParameter("time_start", startDate.Year + "/" + startDate.Month + "/" + startDate.Day), new SqlParameter("time_end", endDate.Year + "/" + endDate.Month + "/" + endDate.Day+" 23:59:59" )};
DataSet ds = SQLHelper.getData(sql, sqlParameter);
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
ImgDictionary.Add(ds.Tables[0].Rows[i]["EvenTime"].ToString(), Image.FromStream(new MemoryStream((byte[])ds.Tables[0].Rows[i]["EvenImage"])));
}
return ImgDictionary;
}
public static SQLRes EnvironmentUpData(bool fire, bool smoke, string light, string temperature, string humidity)
{
SQLRes sqlRes = new SQLRes();
string sqlStr = "INSERT INTO EnvironmentData (Fire ,Smoke ,Temperature ,Humidity , Light, _Time) VALUES (@fire,@smoke,@temperature,@humidity,@light,@time)";
SqlParameter[] sqlParameter = new SqlParameter[] { new SqlParameter("time", DateTime.Now.ToString()), new SqlParameter("fire", fire), new SqlParameter("smoke", smoke), new SqlParameter("temperature", temperature), new SqlParameter("humidity", humidity), new SqlParameter("light", light) };
if (SQLHelper.Exec(sqlStr, sqlParameter) >= 1)
{
sqlRes.Result = true;
sqlRes.Msg = "成功!";
}
else
{
sqlRes.Result = false;
sqlRes.Msg = "失败!";
}
return sqlRes;
}
public static DataTable GetEnvironmentGraphData()
{
string sqlStr = "SELECT TOP 7 CONVERT(varchar(10),_Time,120) AS _Time, ROUND(Max(Temperature),2) AS MaxTemperature, ROUND(AVG(Temperature),2) AS AVGTemperature FROM EnvironmentData GROUP BY CONVERT(varchar(10),_Time,120) ORDER BY CONVERT(varchar(10),_Time,120) DESC ";
return SQLHelper.getData(sqlStr, null).Tables[0];
}
}
class SQLRes
{
public string Msg { get; set; }
public bool Result { get; set; }
}
}
@@ -0,0 +1,112 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 智慧校园.SQLHelpers
{
class SQLHelper
{
public static string strConn = AppSet.SqlConn;
public static bool SaveData(string sql, DataTable dt)
{
try
{
SqlConnection conn = new SqlConnection(strConn);
conn.Open();
SqlDataAdapter sda = new SqlDataAdapter(sql, conn);
SqlCommandBuilder objCommandBuilder = new SqlCommandBuilder(sda);
sda.Update(dt);
conn.Close();
return true;
}
catch (Exception e)
{
string Error = e.Message;
return false;
}
}
public static DataSet getData(string sql, params SqlParameter[] para)
{
DataSet ds = new DataSet();
try
{
SqlConnection conn = new SqlConnection(strConn);
conn.Open();
SqlCommand cmd = new SqlCommand(sql, conn);
if (para != null)
{
foreach (SqlParameter item in para)
{
cmd.Parameters.Add(item);
}
}
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.Fill(ds);
cmd.Parameters.Clear();
conn.Close();
}
catch(Exception e)
{
string Error = e.Message;
}
return ds;
}
public static DataSet getData(SqlCommand cmd)
{
DataSet ds = new DataSet();
try
{
SqlConnection conn = new SqlConnection(strConn);
conn.Open();
cmd.Connection = conn;
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.Fill(ds);
cmd.Parameters.Clear();
conn.Close();
}
catch (Exception e)
{
string Error = e.Message;
}
return ds;
}
public static int Exec(string sql, params SqlParameter[] para)
{
try
{
SqlConnection conn = new SqlConnection(strConn);
conn.Open();
SqlCommand cmd = new SqlCommand(sql, conn);
if (para != null)
{
foreach (SqlParameter item in para)
{
cmd.Parameters.Add(item);
}
}
int iRsult = cmd.ExecuteNonQuery();
conn.Close();
return iRsult;
}
catch (Exception e)
{
string Error = e.Message;
return -1;
}
}
}
}
+296
View File
@@ -0,0 +1,296 @@
namespace 智慧校园
{
partial class Security
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.panel3 = new System.Windows.Forms.Panel();
this.lb_return = new System.Windows.Forms.Label();
this.panel1 = new System.Windows.Forms.Panel();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.panel_bg_video = new System.Windows.Forms.Panel();
this.btn_history = new System.Windows.Forms.Button();
this.btn_camera = new System.Windows.Forms.Button();
this.panel_video_ctrl = new System.Windows.Forms.Panel();
this.pic_left = new System.Windows.Forms.PictureBox();
this.pic_right = new System.Windows.Forms.PictureBox();
this.pic_down = new System.Windows.Forms.PictureBox();
this.pic_up = new System.Windows.Forms.PictureBox();
this.panel2 = new System.Windows.Forms.Panel();
this.label2 = new System.Windows.Forms.Label();
this.lb_infrared = new System.Windows.Forms.Label();
this.pic_video = new System.Windows.Forms.PictureBox();
this.panel3.SuspendLayout();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.panel_bg_video.SuspendLayout();
this.panel_video_ctrl.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pic_left)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pic_right)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pic_down)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pic_up)).BeginInit();
this.panel2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pic_video)).BeginInit();
this.SuspendLayout();
//
// panel3
//
this.panel3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(229)))), ((int)(((byte)(229)))), ((int)(((byte)(229)))));
this.panel3.Controls.Add(this.lb_return);
this.panel3.Dock = System.Windows.Forms.DockStyle.Top;
this.panel3.Location = new System.Drawing.Point(0, 100);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(1081, 39);
this.panel3.TabIndex = 1;
//
// lb_return
//
this.lb_return.AutoSize = true;
this.lb_return.Location = new System.Drawing.Point(25, 12);
this.lb_return.Name = "lb_return";
this.lb_return.Size = new System.Drawing.Size(83, 12);
this.lb_return.TabIndex = 0;
this.lb_return.Text = "< 返回主窗体";
this.lb_return.Click += new System.EventHandler(this.lb_return_Click);
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(116)))), ((int)(((byte)(133)))));
this.panel1.Controls.Add(this.pictureBox1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(1081, 100);
this.panel1.TabIndex = 2;
this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
//
// pictureBox1
//
this.pictureBox1.Image = global::智慧校园.Properties.Resources.ico_title;
this.pictureBox1.Location = new System.Drawing.Point(44, 12);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(226, 54);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// panel_bg_video
//
this.panel_bg_video.BackColor = System.Drawing.Color.White;
this.panel_bg_video.Controls.Add(this.btn_history);
this.panel_bg_video.Controls.Add(this.btn_camera);
this.panel_bg_video.Controls.Add(this.panel_video_ctrl);
this.panel_bg_video.Controls.Add(this.panel2);
this.panel_bg_video.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel_bg_video.Location = new System.Drawing.Point(0, 139);
this.panel_bg_video.Name = "panel_bg_video";
this.panel_bg_video.Size = new System.Drawing.Size(1081, 499);
this.panel_bg_video.TabIndex = 3;
this.panel_bg_video.Paint += new System.Windows.Forms.PaintEventHandler(this.panel_bg_video_Paint);
//
// btn_history
//
this.btn_history.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(143)))), ((int)(((byte)(213)))), ((int)(((byte)(122)))));
this.btn_history.Font = new System.Drawing.Font("微软雅黑", 14F);
this.btn_history.Location = new System.Drawing.Point(804, 410);
this.btn_history.Name = "btn_history";
this.btn_history.Size = new System.Drawing.Size(160, 49);
this.btn_history.TabIndex = 10;
this.btn_history.Text = "查看历史图像";
this.btn_history.UseVisualStyleBackColor = false;
//
// btn_camera
//
this.btn_camera.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(200)))), ((int)(((byte)(81)))));
this.btn_camera.Font = new System.Drawing.Font("微软雅黑", 16F);
this.btn_camera.Location = new System.Drawing.Point(804, 326);
this.btn_camera.Name = "btn_camera";
this.btn_camera.Size = new System.Drawing.Size(160, 49);
this.btn_camera.TabIndex = 9;
this.btn_camera.Text = "拍照";
this.btn_camera.UseVisualStyleBackColor = false;
this.btn_camera.Click += new System.EventHandler(this.btn_camera_Click);
//
// panel_video_ctrl
//
this.panel_video_ctrl.BackgroundImage = global::智慧校园.Properties.Resources.panel_video_ctrl;
this.panel_video_ctrl.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.panel_video_ctrl.Controls.Add(this.pic_left);
this.panel_video_ctrl.Controls.Add(this.pic_right);
this.panel_video_ctrl.Controls.Add(this.pic_down);
this.panel_video_ctrl.Controls.Add(this.pic_up);
this.panel_video_ctrl.Location = new System.Drawing.Point(741, 15);
this.panel_video_ctrl.Name = "panel_video_ctrl";
this.panel_video_ctrl.Size = new System.Drawing.Size(328, 294);
this.panel_video_ctrl.TabIndex = 1;
//
// pic_left
//
this.pic_left.BackgroundImage = global::智慧校园.Properties.Resources.btn_arrow_left_normal;
this.pic_left.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.pic_left.Location = new System.Drawing.Point(63, 116);
this.pic_left.Name = "pic_left";
this.pic_left.Size = new System.Drawing.Size(39, 54);
this.pic_left.TabIndex = 6;
this.pic_left.TabStop = false;
this.pic_left.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pic_left_MouseDown);
this.pic_left.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pic_left_MouseUp);
//
// pic_right
//
this.pic_right.BackgroundImage = global::智慧校园.Properties.Resources.btn_arrow_right_normal;
this.pic_right.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.pic_right.Location = new System.Drawing.Point(223, 116);
this.pic_right.Name = "pic_right";
this.pic_right.Size = new System.Drawing.Size(39, 54);
this.pic_right.TabIndex = 5;
this.pic_right.TabStop = false;
this.pic_right.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pic_right_MouseDown);
this.pic_right.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pic_right_MouseUp);
//
// pic_down
//
this.pic_down.BackgroundImage = global::智慧校园.Properties.Resources.btn_arrow_down_normal;
this.pic_down.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.pic_down.Location = new System.Drawing.Point(143, 202);
this.pic_down.Name = "pic_down";
this.pic_down.Size = new System.Drawing.Size(39, 54);
this.pic_down.TabIndex = 4;
this.pic_down.TabStop = false;
this.pic_down.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pic_down_MouseDown);
this.pic_down.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pic_down_MouseUp);
//
// pic_up
//
this.pic_up.BackgroundImage = global::智慧校园.Properties.Resources.btn_arrow_up_normal;
this.pic_up.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.pic_up.Location = new System.Drawing.Point(142, 20);
this.pic_up.Name = "pic_up";
this.pic_up.Size = new System.Drawing.Size(39, 54);
this.pic_up.TabIndex = 1;
this.pic_up.TabStop = false;
this.pic_up.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pic_up_MouseDown);
this.pic_up.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pic_up_MouseUp);
//
// panel2
//
this.panel2.BackColor = System.Drawing.Color.DimGray;
this.panel2.Controls.Add(this.label2);
this.panel2.Controls.Add(this.lb_infrared);
this.panel2.Controls.Add(this.pic_video);
this.panel2.Location = new System.Drawing.Point(69, 15);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(666, 472);
this.panel2.TabIndex = 0;
//
// label2
//
this.label2.AutoSize = true;
this.label2.BackColor = System.Drawing.Color.Transparent;
this.label2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label2.ForeColor = System.Drawing.Color.White;
this.label2.Location = new System.Drawing.Point(545, 91);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(46, 21);
this.label2.TabIndex = 12;
this.label2.Text = "入侵:";
//
// lb_infrared
//
this.lb_infrared.AutoSize = true;
this.lb_infrared.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lb_infrared.ForeColor = System.Drawing.Color.White;
this.lb_infrared.Location = new System.Drawing.Point(597, 91);
this.lb_infrared.Name = "lb_infrared";
this.lb_infrared.Size = new System.Drawing.Size(41, 21);
this.lb_infrared.TabIndex = 11;
this.lb_infrared.Text = "N/A";
//
// pic_video
//
this.pic_video.BackColor = System.Drawing.Color.DarkGray;
this.pic_video.BackgroundImage = global::智慧校园.Properties.Resources.icon_monitor;
this.pic_video.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
this.pic_video.Location = new System.Drawing.Point(32, 38);
this.pic_video.Name = "pic_video";
this.pic_video.Size = new System.Drawing.Size(478, 322);
this.pic_video.TabIndex = 0;
this.pic_video.TabStop = false;
this.pic_video.Click += new System.EventHandler(this.pictureBox2_Click);
//
// Security
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1081, 638);
this.Controls.Add(this.panel_bg_video);
this.Controls.Add(this.panel3);
this.Controls.Add(this.panel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "Security";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Security";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Security_FormClosed);
this.Load += new System.EventHandler(this.Security_Load);
this.panel3.ResumeLayout(false);
this.panel3.PerformLayout();
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.panel_bg_video.ResumeLayout(false);
this.panel_video_ctrl.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pic_left)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pic_right)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pic_down)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pic_up)).EndInit();
this.panel2.ResumeLayout(false);
this.panel2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pic_video)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel3;
private System.Windows.Forms.Label lb_return;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Panel panel_bg_video;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.PictureBox pic_video;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label lb_infrared;
private System.Windows.Forms.Button btn_history;
private System.Windows.Forms.Button btn_camera;
private System.Windows.Forms.Panel panel_video_ctrl;
private System.Windows.Forms.PictureBox pic_left;
private System.Windows.Forms.PictureBox pic_right;
private System.Windows.Forms.PictureBox pic_down;
private System.Windows.Forms.PictureBox pic_up;
}
}
+240
View File
@@ -0,0 +1,240 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Threading;
using DeviceCtrlLibrary;
using 智慧校园.SQLHelpers;
namespace 智慧校园
{
public partial class Security : Form
{ //显示图像
Image img = null;
//入侵标识
bool IsInfrared = false;
//图像文件夹路径
string ImgDir = AppDomain.CurrentDomain.BaseDirectory + "Camera\\";
//用于数据采集和SQL操作
Thread thread;
SynchronizationContext _main;
public Security()
{
InitializeComponent();
}
void ipCameraHelper_ImageRead(ImageReadEvenArgs e)
{
img = e.img;
pic_video.Image = e.img;
}
void tick()
{
try
{
while (true)
{
try
{
//采集入侵状态
IsInfrared = DeviceCtrlHelper.adam4150Helper.SetData().infraredValue;
//UI显示入侵状态
_main.Send(_ =>
{
lb_infrared.Text = IsInfrared ? "发现入侵" : "正常";
}, null);
if (IsInfrared)
{
if (img != null)
//上传报警信息
SQLBLL.SecurityUpData(img);
}
}
catch
{
}
Thread.Sleep(1000);
}
}
catch
{
}
}
private void pictureBox2_Click(object sender, EventArgs e)
{
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
private void panel_bg_video_Paint(object sender, PaintEventArgs e)
{
}
private void Security_Load(object sender, EventArgs e)
{
try
{
//实例化摄像头控制类
DeviceCtrlHelper.ipCameraHelper.Open(AppSet.Camera_Ip, AppSet.Camera_Uid, AppSet.Camera_Pwd);
DeviceCtrlHelper.ipCameraHelper.ImageRead += ipCameraHelper_ImageRead;
DeviceCtrlHelper.ipCameraHelper.Start();
thread = new Thread(new ThreadStart(tick));
_main = WindowsFormsSynchronizationContext.Current;
thread.Start();
if (!Directory.Exists(ImgDir))
//创建文件夹
Directory.CreateDirectory(ImgDir);
}
catch
{
}
}
private void Security_FormClosed(object sender, FormClosedEventArgs e)
{
try
{
DeviceCtrlHelper.ipCameraHelper.Stop();
DeviceCtrlHelper.ipCameraHelper.Close();
thread.Suspend();
thread = null;
}
catch
{
}
}
private void btn_camera_Click(object sender, EventArgs e)
{
try
{
pic_video.Image.Save(ImgDir + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".jpg");
SQLBLL.SecurityUpData(pic_video.Image);
}
catch
{
}
}
private void pic_up_MouseDown(object sender, MouseEventArgs e)
{
try
{
pic_up.BackgroundImage = Properties.Resources.btn_arrow_up_press;
DeviceCtrlHelper.ipCameraHelper.PanUp();
}
catch
{
}
}
private void pic_up_MouseUp(object sender, MouseEventArgs e)
{
try
{
pic_up.BackgroundImage = Properties.Resources.btn_arrow_up_normal;
DeviceCtrlHelper.ipCameraHelper.PanUp();
}
catch
{
}
}
private void pic_down_MouseDown(object sender, MouseEventArgs e)
{
try
{
pic_down.BackgroundImage = Properties.Resources.btn_arrow_down_press;
DeviceCtrlHelper.ipCameraHelper.PanDown();
}
catch
{
}
}
private void pic_down_MouseUp(object sender, MouseEventArgs e)
{
try
{
pic_down.BackgroundImage = Properties.Resources.btn_arrow_down_normal;
DeviceCtrlHelper.ipCameraHelper.PanDown();
}
catch
{
}
}
private void pic_left_MouseDown(object sender, MouseEventArgs e)
{
try
{
pic_left.BackgroundImage = Properties.Resources.btn_arrow_left_press;
DeviceCtrlHelper.ipCameraHelper.PanLeft();
}
catch
{
}
}
private void pic_left_MouseUp(object sender, MouseEventArgs e)
{
try
{
pic_left.BackgroundImage = Properties.Resources.btn_arrow_left_normal;
DeviceCtrlHelper.ipCameraHelper.PanLeft();
}
catch
{
}
}
private void pic_right_MouseDown(object sender, MouseEventArgs e)
{
try
{
pic_right.BackgroundImage = Properties.Resources.btn_arrow_right_press;
DeviceCtrlHelper.ipCameraHelper.PanRight();
}
catch
{
}
}
private void pic_right_MouseUp(object sender, MouseEventArgs e)
{
try
{
pic_right.BackgroundImage = Properties.Resources.btn_arrow_right_normal;
DeviceCtrlHelper.ipCameraHelper.PanRight();
}
catch
{
}
}
private void lb_return_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
+46
View File
@@ -0,0 +1,46 @@
# 评分规则:书上评价表的功能项。每项单独启动一次程序,按步骤操作,核对结果。
# 格式说明见 server/src/grading/checks.ts
- title: 摄像机能正常打开
steps:
- click: pic_security
- expect: { window: Security, desc: 点"校园安防"打开 Security 窗体 }
- expect: { camera: on }
- expect: { control: pic_video, image: true, within: 3s, desc: 显示摄像机拍到的图像 }
- title: 人体入侵有文字提示
steps:
- click: pic_security
- board: { infrared: true }
- expect: { control: lb_infrared, text: 发现入侵, within: 3s, desc: 红外对射被遮挡时显示"发现入侵" }
- board: { infrared: false }
- expect: { control: lb_infrared, text: 正常, within: 3s }
- title: 摄像机可以调整方向
steps:
- click: pic_security
- click: pic_up
- expect: { camera: up, desc: 按"↑"向上转 }
- expect: { control: pic_up, background: btn_arrow_up_normal, desc: 松开后方向键换回原来的图片 }
- click: pic_left
- expect: { camera: left, desc: 按"←"向左转 }
- click: pic_down
- click: pic_down
- expect: { camera: down, desc: 按"↓"向下转 }
- click: pic_right
- click: pic_right
- expect: { camera: right, desc: 按"→"向右转 }
- title: 摄像机能拍照并保存图片
steps:
- click: pic_security
- expect: { control: pic_video, image: true, within: 3s }
- click: btn_camera
- expect: { savedImage: Camera/, desc: 把照片保存到 Camera 文件夹 }
- title: 返回主窗体时关闭摄像机
steps:
- click: pic_security
- expect: { camera: on }
- click: lb_return
- expect: { window: Security, open: false }
- expect: { camera: off }
+54
View File
@@ -0,0 +1,54 @@
-- 实验的初始数据库 WisdomCampus(教材"综合实训"附带的库):环境数据表 EnvironmentData、报警图片表 SecurityData、用户表 Users。
-- EnvironmentData 预置了 7 天的历史数据,"数据分析"的图表一打开就有内容;SecurityData 是空的,拍照或有人入侵时才有记录。
-- 学生可以在数据库页面"恢复实验初始数据";评分时每个检查项用一份新的。
CREATE DATABASE WisdomCampus
GO
USE WisdomCampus
GO
CREATE TABLE Users (Id int IDENTITY(1,1) PRIMARY KEY, UserName nvarchar(50) NOT NULL, Password nvarchar(50) NOT NULL)
CREATE TABLE EnvironmentData (Id int IDENTITY(1,1) PRIMARY KEY, Fire bit NOT NULL, Smoke bit NOT NULL, Temperature float NULL, Humidity float NULL, Light float NULL, _Time datetime NOT NULL)
CREATE TABLE SecurityData (Id int IDENTITY(1,1) PRIMARY KEY, EvenTime datetime NOT NULL, EvenImage image NOT NULL)
GO
INSERT INTO Users (UserName, Password) VALUES ('admin', '123')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 15.9, 58, 258, '2026-10-14 08:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 18.1, 53, 475, '2026-10-14 10:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.8, 51, 761, '2026-10-14 12:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 22.5, 49, 733, '2026-10-14 14:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.3, 54, 528, '2026-10-14 16:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 17.1, 57, 283, '2026-10-14 18:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 17.9, 59, 261, '2026-10-15 08:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.6, 53, 499, '2026-10-15 10:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 21.8, 52, 764, '2026-10-15 12:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 23.5, 47, 778, '2026-10-15 14:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 21.8, 52, 503, '2026-10-15 16:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.6, 56, 218, '2026-10-15 18:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 13.9, 63, 258, '2026-10-16 08:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 16.6, 60, 477, '2026-10-16 10:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.8, 51, 741, '2026-10-16 12:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 20.5, 54, 796, '2026-10-16 14:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.3, 55, 488, '2026-10-16 16:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 16.6, 59, 214, '2026-10-16 18:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 11.9, 67, 234, '2026-10-17 08:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 15.1, 63, 544, '2026-10-17 10:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 16.3, 60, 804, '2026-10-17 12:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 18.5, 54, 801, '2026-10-17 14:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 17.8, 59, 524, '2026-10-17 16:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 15.1, 58, 286, '2026-10-17 18:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 16.4, 59, 250, '2026-10-18 08:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.6, 55, 533, '2026-10-18 10:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 21.3, 50, 749, '2026-10-18 12:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 24, 48, 766, '2026-10-18 14:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 20.8, 54, 534, '2026-10-18 16:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.1, 53, 241, '2026-10-18 18:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 18.4, 54, 253, '2026-10-19 08:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 21.1, 50, 474, '2026-10-19 10:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 22.3, 48, 778, '2026-10-19 12:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 26, 46, 783, '2026-10-19 14:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 23.3, 50, 520, '2026-10-19 16:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 20.6, 50, 213, '2026-10-19 18:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 15.9, 62, 230, '2026-10-20 08:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 18.6, 52, 471, '2026-10-20 10:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.3, 53, 751, '2026-10-20 12:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 21.5, 48, 747, '2026-10-20 14:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.3, 55, 527, '2026-10-20 16:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 17.1, 57, 220, '2026-10-20 18:00:00')
+4
View File
@@ -0,0 +1,4 @@
{
"title": "项目8 任务4 实现\"校园安防\"功能模块",
"source": "教材书 p174–180,界面和代码取自配套参考工程;图片是平台素材库里自绘的同名素材(尺寸和教材一致);\"查看历史图像\"在任务 5 做"
}
+25
View File
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 智慧校园
{
class AppSet
{
//串口设置
public static string ADAM4017_COM = "COM2";
public static string ADAM4150_COM = "COM3";
public static string LED_COM = "COM5";
public static string ZigBee_COM = "COM4";
//摄像机参数
public static string Camera_Ip = "192.168.1.100";
public static string Camera_Uid = "admin";
public static string Camera_Pwd = "";
//数据库连接字符串
public static string SqlConn = "Data Source=.;Initial Catalog=WisdomCampus;User ID=sa;Password=123";
}
}
+555
View File
@@ -0,0 +1,555 @@
namespace 智慧校园
{
partial class Environment
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend3 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Legend legend4 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Series series3 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.Series series4 = new System.Windows.Forms.DataVisualization.Charting.Series();
this.panel1 = new System.Windows.Forms.Panel();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.panel2 = new System.Windows.Forms.Panel();
this.panel_bg = new System.Windows.Forms.Panel();
this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart();
this.panel_form = new System.Windows.Forms.Panel();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.pic_lampOpen = new System.Windows.Forms.PictureBox();
this.label10 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.txt_autoLight = new System.Windows.Forms.TextBox();
this.label7 = new System.Windows.Forms.Label();
this.ch_autoLamp = new System.Windows.Forms.CheckBox();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.btn_ledEnvironment2 = new System.Windows.Forms.Button();
this.ch_autoLedFire = new System.Windows.Forms.CheckBox();
this.btn_ledSendMsg = new System.Windows.Forms.Button();
this.txt_ledMsg = new System.Windows.Forms.TextBox();
this.label8 = new System.Windows.Forms.Label();
this.panel5 = new System.Windows.Forms.Panel();
this.btn_dataAnalyse = new System.Windows.Forms.Button();
this.btn_ledEnvironment1 = new System.Windows.Forms.Button();
this.label6 = new System.Windows.Forms.Label();
this.txt_humidity = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.txt_fire = new System.Windows.Forms.TextBox();
this.txt_temperature = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.txt_smoke = new System.Windows.Forms.TextBox();
this.txt_light = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.panel3 = new System.Windows.Forms.Panel();
this.lb_return = new System.Windows.Forms.Label();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.panel2.SuspendLayout();
this.panel_bg.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit();
this.panel_form.SuspendLayout();
this.groupBox2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pic_lampOpen)).BeginInit();
this.groupBox3.SuspendLayout();
this.panel5.SuspendLayout();
this.panel3.SuspendLayout();
this.SuspendLayout();
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(116)))), ((int)(((byte)(133)))));
this.panel1.Controls.Add(this.pictureBox1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(1043, 100);
this.panel1.TabIndex = 0;
this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
//
// pictureBox1
//
this.pictureBox1.Image = global::智慧校园.Properties.Resources.ico_title;
this.pictureBox1.Location = new System.Drawing.Point(44, 12);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(226, 54);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// panel2
//
this.panel2.Controls.Add(this.panel_bg);
this.panel2.Controls.Add(this.panel3);
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel2.Location = new System.Drawing.Point(0, 100);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(1043, 691);
this.panel2.TabIndex = 1;
//
// panel_bg
//
this.panel_bg.BackgroundImage = global::智慧校园.Properties.Resources.day_02;
this.panel_bg.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.panel_bg.Controls.Add(this.chart1);
this.panel_bg.Controls.Add(this.panel_form);
this.panel_bg.Controls.Add(this.panel5);
this.panel_bg.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel_bg.Location = new System.Drawing.Point(0, 39);
this.panel_bg.Name = "panel_bg";
this.panel_bg.Size = new System.Drawing.Size(1043, 652);
this.panel_bg.TabIndex = 1;
//
// chart1
//
chartArea2.Name = "ChartArea1";
this.chart1.ChartAreas.Add(chartArea2);
legend3.Name = "MaxLegend";
legend3.TitleForeColor = System.Drawing.Color.DimGray;
legend4.Name = "AVGLegend";
legend4.TitleForeColor = System.Drawing.Color.DimGray;
this.chart1.Legends.Add(legend3);
this.chart1.Legends.Add(legend4);
this.chart1.Location = new System.Drawing.Point(44, 172);
this.chart1.Name = "chart1";
series3.ChartArea = "ChartArea1";
series3.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
series3.Legend = "MaxLegend";
series3.LegendText = "最大值";
series3.Name = "MaxSeries";
series3.XValueMember = "_Time";
series3.YValueMembers = "MaxTemperature";
series4.ChartArea = "ChartArea1";
series4.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
series4.Legend = "AVGLegend";
series4.LegendText = "平均值";
series4.Name = "AVGSeries";
series4.XValueMember = "_Time";
series4.YValueMembers = "AVGTemperature";
this.chart1.Series.Add(series3);
this.chart1.Series.Add(series4);
this.chart1.Size = new System.Drawing.Size(455, 327);
this.chart1.TabIndex = 3;
this.chart1.Text = "chart1";
//
// panel_form
//
this.panel_form.BackColor = System.Drawing.Color.Transparent;
this.panel_form.BackgroundImage = global::智慧校园.Properties.Resources.bg_from2;
this.panel_form.Controls.Add(this.groupBox2);
this.panel_form.Controls.Add(this.groupBox3);
this.panel_form.Dock = System.Windows.Forms.DockStyle.Right;
this.panel_form.Location = new System.Drawing.Point(617, 0);
this.panel_form.Name = "panel_form";
this.panel_form.Size = new System.Drawing.Size(426, 552);
this.panel_form.TabIndex = 2;
//
// groupBox2
//
this.groupBox2.Controls.Add(this.pic_lampOpen);
this.groupBox2.Controls.Add(this.label10);
this.groupBox2.Controls.Add(this.label9);
this.groupBox2.Controls.Add(this.txt_autoLight);
this.groupBox2.Controls.Add(this.label7);
this.groupBox2.Controls.Add(this.ch_autoLamp);
this.groupBox2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupBox2.ForeColor = System.Drawing.Color.White;
this.groupBox2.Location = new System.Drawing.Point(22, 21);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(392, 150);
this.groupBox2.TabIndex = 3;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "路灯控制";
//
// pic_lampOpen
//
this.pic_lampOpen.BackgroundImage = global::智慧校园.Properties.Resources.switch_off;
this.pic_lampOpen.Location = new System.Drawing.Point(103, 103);
this.pic_lampOpen.Name = "pic_lampOpen";
this.pic_lampOpen.Size = new System.Drawing.Size(48, 24);
this.pic_lampOpen.TabIndex = 5;
this.pic_lampOpen.TabStop = false;
this.pic_lampOpen.Click += new System.EventHandler(this.pic_lampOpen_Click);
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(33, 105);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(59, 17);
this.label10.TabIndex = 4;
this.label10.Text = "灯光控制:";
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(278, 58);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(17, 17);
this.label9.TabIndex = 3;
this.label9.Text = "lx";
//
// txt_autoLight
//
this.txt_autoLight.Location = new System.Drawing.Point(128, 55);
this.txt_autoLight.Name = "txt_autoLight";
this.txt_autoLight.Size = new System.Drawing.Size(144, 23);
this.txt_autoLight.TabIndex = 2;
this.txt_autoLight.TextChanged += new System.EventHandler(this.txt_autoLight_TextChanged);
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(33, 58);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(92, 17);
this.label7.TabIndex = 1;
this.label7.Text = "设定开灯光照值";
//
// ch_autoLamp
//
this.ch_autoLamp.AutoSize = true;
this.ch_autoLamp.Location = new System.Drawing.Point(35, 30);
this.ch_autoLamp.Name = "ch_autoLamp";
this.ch_autoLamp.Size = new System.Drawing.Size(75, 21);
this.ch_autoLamp.TabIndex = 0;
this.ch_autoLamp.Text = "自动控制";
this.ch_autoLamp.UseVisualStyleBackColor = true;
this.ch_autoLamp.CheckedChanged += new System.EventHandler(this.ch_autoLamp_CheckedChanged);
//
// groupBox3
//
this.groupBox3.Controls.Add(this.btn_ledEnvironment2);
this.groupBox3.Controls.Add(this.ch_autoLedFire);
this.groupBox3.Controls.Add(this.btn_ledSendMsg);
this.groupBox3.Controls.Add(this.txt_ledMsg);
this.groupBox3.Controls.Add(this.label8);
this.groupBox3.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupBox3.ForeColor = System.Drawing.Color.White;
this.groupBox3.Location = new System.Drawing.Point(22, 209);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(392, 316);
this.groupBox3.TabIndex = 4;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "LED推送";
//
// btn_ledEnvironment2
//
this.btn_ledEnvironment2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(149)))), ((int)(((byte)(212)))));
this.btn_ledEnvironment2.Font = new System.Drawing.Font("微软雅黑", 12F);
this.btn_ledEnvironment2.Location = new System.Drawing.Point(234, 217);
this.btn_ledEnvironment2.Name = "btn_ledEnvironment2";
this.btn_ledEnvironment2.Size = new System.Drawing.Size(145, 32);
this.btn_ledEnvironment2.TabIndex = 11;
this.btn_ledEnvironment2.Text = "推送天气信息";
this.btn_ledEnvironment2.UseVisualStyleBackColor = false;
this.btn_ledEnvironment2.Click += new System.EventHandler(this.btn_ledEnvironment2_Click);
//
// ch_autoLedFire
//
this.ch_autoLedFire.AutoSize = true;
this.ch_autoLedFire.Location = new System.Drawing.Point(265, 35);
this.ch_autoLedFire.Name = "ch_autoLedFire";
this.ch_autoLedFire.Size = new System.Drawing.Size(99, 21);
this.ch_autoLedFire.TabIndex = 4;
this.ch_autoLedFire.Text = "自动推送火情";
this.ch_autoLedFire.UseVisualStyleBackColor = true;
this.ch_autoLedFire.CheckedChanged += new System.EventHandler(this.ch_autoLedFire_CheckedChanged);
//
// btn_ledSendMsg
//
this.btn_ledSendMsg.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(168)))), ((int)(((byte)(255)))));
this.btn_ledSendMsg.Font = new System.Drawing.Font("微软雅黑", 12F);
this.btn_ledSendMsg.Location = new System.Drawing.Point(26, 217);
this.btn_ledSendMsg.Name = "btn_ledSendMsg";
this.btn_ledSendMsg.Size = new System.Drawing.Size(145, 32);
this.btn_ledSendMsg.TabIndex = 2;
this.btn_ledSendMsg.Text = "推送LED信息";
this.btn_ledSendMsg.UseVisualStyleBackColor = false;
this.btn_ledSendMsg.Click += new System.EventHandler(this.btn_ledSendMsg_Click);
//
// txt_ledMsg
//
this.txt_ledMsg.Location = new System.Drawing.Point(23, 62);
this.txt_ledMsg.Multiline = true;
this.txt_ledMsg.Name = "txt_ledMsg";
this.txt_ledMsg.Size = new System.Drawing.Size(356, 130);
this.txt_ledMsg.TabIndex = 1;
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(20, 36);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(54, 17);
this.label8.TabIndex = 0;
this.label8.Text = "LED信息";
//
// panel5
//
this.panel5.Controls.Add(this.btn_dataAnalyse);
this.panel5.Controls.Add(this.btn_ledEnvironment1);
this.panel5.Controls.Add(this.label6);
this.panel5.Controls.Add(this.txt_humidity);
this.panel5.Controls.Add(this.label1);
this.panel5.Controls.Add(this.label5);
this.panel5.Controls.Add(this.txt_fire);
this.panel5.Controls.Add(this.txt_temperature);
this.panel5.Controls.Add(this.label2);
this.panel5.Controls.Add(this.label4);
this.panel5.Controls.Add(this.txt_smoke);
this.panel5.Controls.Add(this.txt_light);
this.panel5.Controls.Add(this.label3);
this.panel5.Dock = System.Windows.Forms.DockStyle.Bottom;
this.panel5.Location = new System.Drawing.Point(0, 552);
this.panel5.Name = "panel5";
this.panel5.Size = new System.Drawing.Size(1043, 100);
this.panel5.TabIndex = 1;
//
// btn_dataAnalyse
//
this.btn_dataAnalyse.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(168)))), ((int)(((byte)(255)))));
this.btn_dataAnalyse.Font = new System.Drawing.Font("微软雅黑", 12F);
this.btn_dataAnalyse.Location = new System.Drawing.Point(792, 35);
this.btn_dataAnalyse.Name = "btn_dataAnalyse";
this.btn_dataAnalyse.Size = new System.Drawing.Size(119, 32);
this.btn_dataAnalyse.TabIndex = 23;
this.btn_dataAnalyse.Text = "数据分析";
this.btn_dataAnalyse.UseVisualStyleBackColor = false;
this.btn_dataAnalyse.Click += new System.EventHandler(this.btn_dataAnalyse_Click);
//
// btn_ledEnvironment1
//
this.btn_ledEnvironment1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(149)))), ((int)(((byte)(212)))));
this.btn_ledEnvironment1.Font = new System.Drawing.Font("微软雅黑", 12F);
this.btn_ledEnvironment1.Location = new System.Drawing.Point(910, 35);
this.btn_ledEnvironment1.Name = "btn_ledEnvironment1";
this.btn_ledEnvironment1.Size = new System.Drawing.Size(121, 32);
this.btn_ledEnvironment1.TabIndex = 15;
this.btn_ledEnvironment1.Text = "推送天气信息";
this.btn_ledEnvironment1.UseVisualStyleBackColor = false;
this.btn_ledEnvironment1.Click += new System.EventHandler(this.btn_ledEnvironment1_Click);
//
// label6
//
this.label6.AutoSize = true;
this.label6.Font = new System.Drawing.Font("微软雅黑", 18F);
this.label6.Location = new System.Drawing.Point(12, 31);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(110, 31);
this.label6.TabIndex = 11;
this.label6.Text = "环境数据";
//
// txt_humidity
//
this.txt_humidity.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(206)))), ((int)(((byte)(206)))), ((int)(((byte)(206)))));
this.txt_humidity.Font = new System.Drawing.Font("微软雅黑", 14F);
this.txt_humidity.Location = new System.Drawing.Point(716, 36);
this.txt_humidity.Name = "txt_humidity";
this.txt_humidity.Size = new System.Drawing.Size(70, 32);
this.txt_humidity.TabIndex = 22;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("微软雅黑", 14F);
this.label1.Location = new System.Drawing.Point(132, 38);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(50, 25);
this.label1.TabIndex = 12;
this.label1.Text = "火焰";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Font = new System.Drawing.Font("微软雅黑", 14F);
this.label5.Location = new System.Drawing.Point(660, 39);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(50, 25);
this.label5.TabIndex = 21;
this.label5.Text = "湿度";
//
// txt_fire
//
this.txt_fire.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(206)))), ((int)(((byte)(206)))), ((int)(((byte)(206)))));
this.txt_fire.Font = new System.Drawing.Font("微软雅黑", 14F);
this.txt_fire.Location = new System.Drawing.Point(188, 35);
this.txt_fire.Name = "txt_fire";
this.txt_fire.Size = new System.Drawing.Size(70, 32);
this.txt_fire.TabIndex = 13;
//
// txt_temperature
//
this.txt_temperature.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(206)))), ((int)(((byte)(206)))), ((int)(((byte)(206)))));
this.txt_temperature.Font = new System.Drawing.Font("微软雅黑", 14F);
this.txt_temperature.Location = new System.Drawing.Point(584, 35);
this.txt_temperature.Name = "txt_temperature";
this.txt_temperature.Size = new System.Drawing.Size(70, 32);
this.txt_temperature.TabIndex = 20;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("微软雅黑", 14F);
this.label2.Location = new System.Drawing.Point(264, 36);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(50, 25);
this.label2.TabIndex = 14;
this.label2.Text = "烟雾";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Font = new System.Drawing.Font("微软雅黑", 14F);
this.label4.Location = new System.Drawing.Point(528, 38);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(50, 25);
this.label4.TabIndex = 19;
this.label4.Text = "温度";
//
// txt_smoke
//
this.txt_smoke.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(206)))), ((int)(((byte)(206)))), ((int)(((byte)(206)))));
this.txt_smoke.Font = new System.Drawing.Font("微软雅黑", 14F);
this.txt_smoke.Location = new System.Drawing.Point(320, 33);
this.txt_smoke.Name = "txt_smoke";
this.txt_smoke.Size = new System.Drawing.Size(70, 32);
this.txt_smoke.TabIndex = 16;
//
// txt_light
//
this.txt_light.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(206)))), ((int)(((byte)(206)))), ((int)(((byte)(206)))));
this.txt_light.Font = new System.Drawing.Font("微软雅黑", 14F);
this.txt_light.Location = new System.Drawing.Point(452, 32);
this.txt_light.Name = "txt_light";
this.txt_light.Size = new System.Drawing.Size(70, 32);
this.txt_light.TabIndex = 18;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("微软雅黑", 14F);
this.label3.Location = new System.Drawing.Point(396, 35);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(50, 25);
this.label3.TabIndex = 17;
this.label3.Text = "光照";
//
// panel3
//
this.panel3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(229)))), ((int)(((byte)(229)))), ((int)(((byte)(229)))));
this.panel3.Controls.Add(this.lb_return);
this.panel3.Dock = System.Windows.Forms.DockStyle.Top;
this.panel3.Location = new System.Drawing.Point(0, 0);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(1043, 39);
this.panel3.TabIndex = 0;
this.panel3.Paint += new System.Windows.Forms.PaintEventHandler(this.panel3_Paint);
//
// lb_return
//
this.lb_return.AutoSize = true;
this.lb_return.Location = new System.Drawing.Point(25, 12);
this.lb_return.Name = "lb_return";
this.lb_return.Size = new System.Drawing.Size(83, 12);
this.lb_return.TabIndex = 0;
this.lb_return.Text = "< 返回主窗体";
this.lb_return.Click += new System.EventHandler(this.lb_return_Click);
//
// Environment
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1043, 791);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "Environment";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Environment";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Environment_FormClosed);
this.Load += new System.EventHandler(this.Environment_Load);
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.panel2.ResumeLayout(false);
this.panel_bg.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit();
this.panel_form.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pic_lampOpen)).EndInit();
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
this.panel5.ResumeLayout(false);
this.panel5.PerformLayout();
this.panel3.ResumeLayout(false);
this.panel3.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Panel panel3;
private System.Windows.Forms.Label lb_return;
private System.Windows.Forms.Panel panel_bg;
private System.Windows.Forms.Panel panel5;
private System.Windows.Forms.Panel panel_form;
private System.Windows.Forms.Button btn_dataAnalyse;
private System.Windows.Forms.Button btn_ledEnvironment1;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.TextBox txt_humidity;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox txt_fire;
private System.Windows.Forms.TextBox txt_temperature;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox txt_smoke;
private System.Windows.Forms.TextBox txt_light;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.PictureBox pic_lampOpen;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.TextBox txt_autoLight;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.CheckBox ch_autoLamp;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.Button btn_ledEnvironment2;
private System.Windows.Forms.CheckBox ch_autoLedFire;
private System.Windows.Forms.Button btn_ledSendMsg;
private System.Windows.Forms.TextBox txt_ledMsg;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.DataVisualization.Charting.Chart chart1;
}
}
+279
View File
@@ -0,0 +1,279 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DeviceCtrlLibrary;
using DeviceCtrlLibrary.Model;
using 智慧校园.SQLHelpers;
using System.Threading;
namespace 智慧校园
{
public partial class Environment : Form
{
public Environment()
{
InitializeComponent();
}
//用于各类耗时长的操作(SQL、数据采集、设备控制等)
Thread thread;
//用于异步通行
SynchronizationContext _main;
//结果模型
ADAM4017ResModel ResModel_4017;
ADAM4150ResModel ResModel_4150;
//设置自动控制路灯的光照值
double environmentLight, setLight;
//按钮状态标志
bool IsAuto_Lamp = false;
bool IsAuto_FireMsg = false;
bool IsLampOpen = false;
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
private void lb_return_Click(object sender, EventArgs e)
{
this.Close();
}
private void Environment_Load(object sender, EventArgs e)
{
try
{
//隐藏曲线图
chart1.Visible = false;
thread = new Thread(new ThreadStart(Tick));
_main = WindowsFormsSynchronizationContext.Current;
thread.Start();
}
catch
{
}
}
private void Tick()
{
try
{
while (true)
{
//数据采集
ResModel_4017 = DeviceCtrlHelper.adam4017Helper.SetData();
Thread.Sleep(500);
ResModel_4150 = DeviceCtrlHelper.adam4150Helper.SetData();
//UI显示数据
_main.Send(_ =>
{
try //防止无数据出错
{
txt_fire.Text = (ResModel_4150.fireValue ? "发生火情" : "正常");
txt_smoke.Text = (ResModel_4150.smokeValue ? "发生烟情" : "正常");
txt_light.Text = ResModel_4017.lightValue;
txt_temperature.Text = ResModel_4017.temperatureValue;
txt_humidity.Text = ResModel_4017.humidityValue;
}
catch { }
}, null);
//自动路灯控制
double.TryParse(ResModel_4017.lightValue, out environmentLight);
if (IsAuto_Lamp && environmentLight < setLight)
{
LampOnOff(1, true);
}
else if (IsAuto_Lamp && !(environmentLight < setLight))
{
LampOnOff(1, false);
}
//自动推送火情LED信息控制
if (IsAuto_FireMsg)
{
if (ResModel_4150.fireValue && ResModel_4150.smokeValue)
DeviceCtrlHelper.ledHelper.SendLedString("发生严重火灾 ");
else if (ResModel_4150.fireValue)
DeviceCtrlHelper.ledHelper.SendLedString("发现火情 ");
else if (ResModel_4150.smokeValue)
DeviceCtrlHelper.ledHelper.SendLedString("发现烟情 ");
}
//执行数据上传
SQLBLL.EnvironmentUpData(ResModel_4150.fireValue, ResModel_4150.smokeValue, ResModel_4017.lightValue, ResModel_4017.temperatureValue, ResModel_4017.humidityValue);
Thread.Sleep(5000);
}
}
catch
{
}
}
private void LampOnOff(int RelayNum, bool IsOpen)
{
try
{
//开启路灯
DeviceCtrlHelper.zigBeeHelper.OnOff(RelayNum, IsOpen);
//切换UI背景
_main.Send(_ =>
{
if (IsOpen)
{
pic_lampOpen.BackgroundImage = Properties.Resources.switch_on;
panel_bg.BackgroundImage = Properties.Resources.day_01;
}
else
{
panel_bg.BackgroundImage = Properties.Resources.day_02;
pic_lampOpen.BackgroundImage = Properties.Resources.switch_off;
}
}, null);
}
catch
{
}
}
private void Environment_FormClosed(object sender, FormClosedEventArgs e)
{
try
{
thread.Suspend();
thread = null;
}
catch
{
}
}
private void btn_dataAnalyse_Click(object sender, EventArgs e)
{
try
{
if (btn_dataAnalyse.Text.Equals("数据分析"))
{
//绑定图标数据
chart1.DataSource = SQLBLL.GetEnvironmentGraphData();
//更新图标数据
chart1.DataBind();
chart1.Visible = true;
btn_dataAnalyse.Text = "关闭图表";
}
else if (btn_dataAnalyse.Text.Equals("关闭图表"))
{
chart1.Visible = false;
btn_dataAnalyse.Text = "数据分析";
}
}
catch
{
}
}
private void pic_lampOpen_Click(object sender, EventArgs e)
{
//手动路灯控制
try
{
if (!IsLampOpen)
{
LampOnOff(1, true);
}
else
{
LampOnOff(1, false);
}
IsLampOpen = !IsLampOpen;
}
catch
{
}
}
private void btn_ledEnvironment1_Click(object sender, EventArgs e)
{
try
{
//推送LED天气信息
if (ResModel_4017 != null && ResModel_4150 != null)
DeviceCtrlHelper.ledHelper.SendLedString("当前温度:" + ResModel_4017.temperatureValue + "℃ 湿度:" + ResModel_4017.humidityValue + "%");
}
catch
{
}
}
private void btn_ledEnvironment2_Click(object sender, EventArgs e)
{
try
{
//推送LED天气信息
if (ResModel_4017 != null && ResModel_4150 != null)
DeviceCtrlHelper.ledHelper.SendLedString("当前温度:" + ResModel_4017.temperatureValue + "℃ 湿度:" + ResModel_4017.humidityValue + "%");
}
catch
{
}
}
private void panel3_Paint(object sender, PaintEventArgs e)
{
}
private void txt_autoLight_TextChanged(object sender, EventArgs e)
{
try
{
//获取光照比较值
double.TryParse(txt_autoLight.Text,out setLight);
}
catch
{
}
}
private void btn_ledSendMsg_Click(object sender, EventArgs e)
{
try
{
//推送LED信息
DeviceCtrlHelper.ledHelper.SendLedString(txt_ledMsg.Text);
}
catch
{
}
}
private void ch_autoLamp_CheckedChanged(object sender, EventArgs e)
{
//自动控制路灯
IsAuto_Lamp = ch_autoLamp.Checked;
}
private void ch_autoLedFire_CheckedChanged(object sender, EventArgs e)
{
//自动推送火情
IsAuto_FireMsg = ch_autoLedFire.Checked;
}
}
}
+145
View File
@@ -0,0 +1,145 @@
namespace 智慧校园
{
partial class Main
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.panel2 = new System.Windows.Forms.Panel();
this.pic_exit = new System.Windows.Forms.PictureBox();
this.pic_security = new System.Windows.Forms.PictureBox();
this.pic_environment = new System.Windows.Forms.PictureBox();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.panel2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pic_exit)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pic_security)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pic_environment)).BeginInit();
this.SuspendLayout();
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(53)))), ((int)(((byte)(147)))), ((int)(((byte)(237)))));
this.panel1.Controls.Add(this.pictureBox1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(1018, 100);
this.panel1.TabIndex = 0;
this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
//
// pictureBox1
//
this.pictureBox1.Image = global::智慧校园.Properties.Resources.ico_title;
this.pictureBox1.Location = new System.Drawing.Point(57, 23);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(197, 54);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// panel2
//
this.panel2.BackgroundImage = global::智慧校园.Properties.Resources.bg_home;
this.panel2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.panel2.Controls.Add(this.pic_exit);
this.panel2.Controls.Add(this.pic_security);
this.panel2.Controls.Add(this.pic_environment);
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel2.Location = new System.Drawing.Point(0, 100);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(1018, 516);
this.panel2.TabIndex = 1;
this.panel2.Paint += new System.Windows.Forms.PaintEventHandler(this.panel2_Paint);
//
// pic_exit
//
this.pic_exit.BackColor = System.Drawing.Color.Transparent;
this.pic_exit.Image = global::智慧校园.Properties.Resources.icon_04;
this.pic_exit.Location = new System.Drawing.Point(660, 124);
this.pic_exit.Name = "pic_exit";
this.pic_exit.Size = new System.Drawing.Size(180, 210);
this.pic_exit.TabIndex = 6;
this.pic_exit.TabStop = false;
this.pic_exit.Click += new System.EventHandler(this.pic_exit_Click);
//
// pic_security
//
this.pic_security.BackColor = System.Drawing.Color.Transparent;
this.pic_security.Image = global::智慧校园.Properties.Resources.icon_03;
this.pic_security.Location = new System.Drawing.Point(404, 124);
this.pic_security.Name = "pic_security";
this.pic_security.Size = new System.Drawing.Size(180, 210);
this.pic_security.TabIndex = 5;
this.pic_security.TabStop = false;
this.pic_security.Click += new System.EventHandler(this.pic_security_Click);
//
// pic_environment
//
this.pic_environment.BackColor = System.Drawing.Color.Transparent;
this.pic_environment.Image = global::智慧校园.Properties.Resources.icon_02;
this.pic_environment.Location = new System.Drawing.Point(133, 124);
this.pic_environment.Name = "pic_environment";
this.pic_environment.Size = new System.Drawing.Size(180, 210);
this.pic_environment.TabIndex = 4;
this.pic_environment.TabStop = false;
this.pic_environment.Click += new System.EventHandler(this.pic_environment_Click);
//
// Main
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1018, 616);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "Main";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Form1";
this.Load += new System.EventHandler(this.Main_Load);
this.panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pic_exit)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pic_security)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pic_environment)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.PictureBox pic_exit;
private System.Windows.Forms.PictureBox pic_security;
private System.Windows.Forms.PictureBox pic_environment;
}
}
+72
View File
@@ -0,0 +1,72 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DeviceCtrlLibrary;
namespace 智慧校园
{
public partial class Main : Form
{
public Main()
{
InitializeComponent();
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
private void pic_environment_Click(object sender, EventArgs e)
{
try
{
new Environment().Show();
}
catch
{
}
}
private void panel2_Paint(object sender, PaintEventArgs e)
{
}
private void Main_Load(object sender, EventArgs e)
{
try
{
//实例化工具类
DeviceCtrlHelper.adam4017Helper.Open(AppSet.ADAM4017_COM);
DeviceCtrlHelper.adam4150Helper.Open(AppSet.ADAM4150_COM);
DeviceCtrlHelper.zigBeeHelper.Open(AppSet.ZigBee_COM);
DeviceCtrlHelper.ledHelper.OpenLedCom(AppSet.LED_COM);
}
catch { }
}
private void pic_security_Click(object sender, EventArgs e)
{
try
{
new Security().Show();
}
catch
{
}
}
private void pic_exit_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
+22
View File
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace 智慧校园
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Main());
}
}
}
@@ -0,0 +1,129 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 项目资源(平台素材库)。在"项目资源"里添加或移除,不要手动修改这个文件。
// </auto-generated>
//------------------------------------------------------------------------------
namespace 智慧校园.Properties {
/// <summary>
/// 项目资源:Properties.Resources.资源名
/// </summary>
internal class Resources {
/// <summary>标题:智慧校园</summary>
internal static System.Drawing.Bitmap ico_title {
get { return global::Sim.Host.ProjectResources.Image("ico_title.png"); }
}
/// <summary>主界面背景:校园</summary>
internal static System.Drawing.Bitmap bg_home {
get { return global::Sim.Host.ProjectResources.Image("bg_home.png"); }
}
/// <summary>图标:校园环境</summary>
internal static System.Drawing.Bitmap icon_02 {
get { return global::Sim.Host.ProjectResources.Image("icon_02.png"); }
}
/// <summary>图标:校园安防</summary>
internal static System.Drawing.Bitmap icon_03 {
get { return global::Sim.Host.ProjectResources.Image("icon_03.png"); }
}
/// <summary>图标:退出</summary>
internal static System.Drawing.Bitmap icon_04 {
get { return global::Sim.Host.ProjectResources.Image("icon_04.png"); }
}
/// <summary>路灯场景:亮灯</summary>
internal static System.Drawing.Bitmap day_01 {
get { return global::Sim.Host.ProjectResources.Image("day_01.png"); }
}
/// <summary>路灯场景:灭灯</summary>
internal static System.Drawing.Bitmap day_02 {
get { return global::Sim.Host.ProjectResources.Image("day_02.png"); }
}
/// <summary>面板背景(窄)</summary>
internal static System.Drawing.Bitmap bg_from2 {
get { return global::Sim.Host.ProjectResources.Image("bg_from2.png"); }
}
/// <summary>开关:开</summary>
internal static System.Drawing.Bitmap switch_on {
get { return global::Sim.Host.ProjectResources.Image("switch_on.png"); }
}
/// <summary>开关:关</summary>
internal static System.Drawing.Bitmap switch_off {
get { return global::Sim.Host.ProjectResources.Image("switch_off.png"); }
}
/// <summary>监控:无画面</summary>
internal static System.Drawing.Bitmap icon_monitor {
get { return global::Sim.Host.ProjectResources.Image("icon_monitor.png"); }
}
/// <summary>监控:方向盘底座</summary>
internal static System.Drawing.Bitmap panel_video_ctrl {
get { return global::Sim.Host.ProjectResources.Image("panel_video_ctrl.png"); }
}
/// <summary>方向键:上</summary>
internal static System.Drawing.Bitmap btn_arrow_up_normal {
get { return global::Sim.Host.ProjectResources.Image("btn_arrow_up_normal.png"); }
}
/// <summary>方向键:上(按下)</summary>
internal static System.Drawing.Bitmap btn_arrow_up_press {
get { return global::Sim.Host.ProjectResources.Image("btn_arrow_up_press.png"); }
}
/// <summary>方向键:下</summary>
internal static System.Drawing.Bitmap btn_arrow_down_normal {
get { return global::Sim.Host.ProjectResources.Image("btn_arrow_down_normal.png"); }
}
/// <summary>方向键:下(按下)</summary>
internal static System.Drawing.Bitmap btn_arrow_down_press {
get { return global::Sim.Host.ProjectResources.Image("btn_arrow_down_press.png"); }
}
/// <summary>方向键:左</summary>
internal static System.Drawing.Bitmap btn_arrow_left_normal {
get { return global::Sim.Host.ProjectResources.Image("btn_arrow_left_normal.png"); }
}
/// <summary>方向键:左(按下)</summary>
internal static System.Drawing.Bitmap btn_arrow_left_press {
get { return global::Sim.Host.ProjectResources.Image("btn_arrow_left_press.png"); }
}
/// <summary>方向键:右</summary>
internal static System.Drawing.Bitmap btn_arrow_right_normal {
get { return global::Sim.Host.ProjectResources.Image("btn_arrow_right_normal.png"); }
}
/// <summary>方向键:右(按下)</summary>
internal static System.Drawing.Bitmap btn_arrow_right_press {
get { return global::Sim.Host.ProjectResources.Image("btn_arrow_right_press.png"); }
}
/// <summary>翻页:上一张</summary>
internal static System.Drawing.Bitmap arrow_left_normal {
get { return global::Sim.Host.ProjectResources.Image("arrow_left_normal.png"); }
}
/// <summary>翻页:下一张</summary>
internal static System.Drawing.Bitmap arrow_right_normal {
get { return global::Sim.Host.ProjectResources.Image("arrow_right_normal.png"); }
}
/// <summary>关闭按钮</summary>
internal static System.Drawing.Bitmap windowstate_closed_hover {
get { return global::Sim.Host.ProjectResources.Image("windowstate_closed_hover.png"); }
}
}
}
@@ -0,0 +1,106 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 智慧校园.SQLHelpers
{
class SQLBLL
{
public static SQLRes SecurityUpData(Image img)//把图片保存到数据库
{
SQLRes sqlRes = new SQLRes();
byte[] imgByte = null;
using (MemoryStream ms = new MemoryStream())//图片转换为二进制数组
{
img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
imgByte = new byte[ms.Length];
imgByte = ms.ToArray();
}
string sqlStr = "INSERT INTO SecurityData (EvenTime,EvenImage) VALUES (@time,@img)";
SqlParameter[] sqlParameter = new SqlParameter[] { new SqlParameter("time", DateTime.Now.ToString()), new SqlParameter("img", imgByte) };
if (SQLHelper.Exec(sqlStr, sqlParameter) >= 1)
{
sqlRes.Result = true;
sqlRes.Msg = "成功!";
}
else
{
sqlRes.Result = false;
sqlRes.Msg = "失败!";
}
return sqlRes;
}
public static Dictionary<string, Image> GetSecurityData(DateTime startDate, DateTime endDate)
{
Dictionary<string, Image> ImgDictionary = new Dictionary<string, Image>();
if (string.IsNullOrWhiteSpace(startDate.Month.ToString()) && string.IsNullOrWhiteSpace(endDate.Month .ToString()))
{
return ImgDictionary;
}
//选择查询日期日期
string sql = "SELECT * FROM SecurityData WHERE EvenTime between @time_start and @time_end";
SqlParameter[] sqlParameter = new SqlParameter[] { new SqlParameter("time_start", startDate.Year + "/" + startDate.Month + "/" + startDate.Day), new SqlParameter("time_end", endDate.Year + "/" + endDate.Month + "/" + endDate.Day+" 23:59:59" )};
DataSet ds = SQLHelper.getData(sql, sqlParameter);
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
ImgDictionary.Add(ds.Tables[0].Rows[i]["EvenTime"].ToString(), Image.FromStream(new MemoryStream((byte[])ds.Tables[0].Rows[i]["EvenImage"])));
}
return ImgDictionary;
}
public static SQLRes EnvironmentUpData(bool fire, bool smoke, string light, string temperature, string humidity)
{
SQLRes sqlRes = new SQLRes();
string sqlStr = "INSERT INTO EnvironmentData (Fire ,Smoke ,Temperature ,Humidity , Light, _Time) VALUES (@fire,@smoke,@temperature,@humidity,@light,@time)";
SqlParameter[] sqlParameter = new SqlParameter[] { new SqlParameter("time", DateTime.Now.ToString()), new SqlParameter("fire", fire), new SqlParameter("smoke", smoke), new SqlParameter("temperature", temperature), new SqlParameter("humidity", humidity), new SqlParameter("light", light) };
if (SQLHelper.Exec(sqlStr, sqlParameter) >= 1)
{
sqlRes.Result = true;
sqlRes.Msg = "成功!";
}
else
{
sqlRes.Result = false;
sqlRes.Msg = "失败!";
}
return sqlRes;
}
public static DataTable GetEnvironmentGraphData()
{
string sqlStr = "SELECT TOP 7 CONVERT(varchar(10),_Time,120) AS _Time, ROUND(Max(Temperature),2) AS MaxTemperature, ROUND(AVG(Temperature),2) AS AVGTemperature FROM EnvironmentData GROUP BY CONVERT(varchar(10),_Time,120) ORDER BY CONVERT(varchar(10),_Time,120) DESC ";
return SQLHelper.getData(sqlStr, null).Tables[0];
}
}
class SQLRes
{
public string Msg { get; set; }
public bool Result { get; set; }
}
}
Loaded 100 of 109 files, more files were not shown because too many files have changed in this diff. Show more