Frm_Main.xaml.cs
3.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
using HHWCS.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace HHWCSHost.View
{
/// <summary>
/// Frm_Main.xaml 的交互逻辑
/// </summary>
public partial class Frm_Main : Window
{
//所有子窗口
Dictionary<string, Window> windows = new Dictionary<string, Window>();
public Frm_Main()
{
InitializeComponent();
InitMenu();
InitStatusBar();
}
private void InitStatusBar()
{
statusBar.Items.Add("欢迎:"+AppCommon.User.UserName+" 登录时间:"+DateTime.Now.ToString());
}
private void InitMenu()
{
//构建菜单
//系统
MenuItem menu_sys = new MenuItem();
menu_sys.Header = "系统";
MenuItem menu_sys_exit = new MenuItem();
menu_sys_exit.Header = "退出";
menu_sys_exit.Click += Menu_sys_exit_Click;
menu_sys.Items.Add(menu_sys_exit);
//设备
MenuItem menu_device = new MenuItem();
menu_device.Header = "设备管理";
MenuItem menu_device_info = new MenuItem();
menu_device_info.Header = "设备信息管理";
menu_device_info.Click += Menu_device_info_Click;
menu_device.Items.Add(menu_device_info);
//任务
MenuItem menu_task = new MenuItem();
menu_task.Header = "任务管理";
MenuItem menu_task_info = new MenuItem();
menu_task_info.Header = "任务查看";
menu_task_info.Click += Menu_task_info_Click;
menu_task.Items.Add(menu_task_info);
menu.Items.Add(menu_sys);
menu.Items.Add(menu_device);
menu.Items.Add(menu_task);
}
private void Menu_task_info_Click(object sender, RoutedEventArgs e)
{
Frm_TaskInfo frm_TaskInfo =(Frm_TaskInfo)windows.FirstOrDefault(t => t.Key == "frm_taskinfo").Value;
if (frm_TaskInfo == null)
{
frm_TaskInfo = new Frm_TaskInfo();
windows.Add("frm_taskinfo", frm_TaskInfo);
}
frm_TaskInfo.Show();
if (frm_TaskInfo.WindowState == WindowState.Minimized)
frm_TaskInfo.WindowState = WindowState.Normal;
frm_TaskInfo.Activate();
}
private void Menu_device_info_Click(object sender, RoutedEventArgs e)
{
Frm_DeviceInfo frm_DeviceInfo = (Frm_DeviceInfo)windows.FirstOrDefault(t => t.Key == "frm_DeviceInfo").Value;
if (frm_DeviceInfo == null)
{
frm_DeviceInfo = new Frm_DeviceInfo();
windows.Add("frm_DeviceInfo", frm_DeviceInfo);
}
frm_DeviceInfo.Show();
if (frm_DeviceInfo.WindowState == WindowState.Minimized)
frm_DeviceInfo.WindowState = WindowState.Normal;
frm_DeviceInfo.Activate();
}
private void Menu_sys_exit_Click(object sender, RoutedEventArgs e)
{
Application.Current.Shutdown();
}
private void Window_Closed(object sender, EventArgs e)
{
Application.Current.Shutdown();
}
}
}