hytos / DTI_PID / SPPIDConverter_CustomCommand / MappingForm.cs @ 1430f5a6
이력 | 보기 | 이력해설 | 다운로드 (4.17 KB)
1 | 91502a9b | gaqhf | using System; |
---|---|---|---|
2 | using System.Collections.Generic; |
||
3 | using System.ComponentModel; |
||
4 | using System.Data; |
||
5 | using System.Drawing; |
||
6 | using System.Linq; |
||
7 | using System.Text; |
||
8 | using System.Threading.Tasks; |
||
9 | using System.Windows.Forms; |
||
10 | |||
11 | namespace CustomCommand |
||
12 | { |
||
13 | public partial class MappingForm : Form |
||
14 | { |
||
15 | 8c37691c | gaqhf | Dictionary<string, string> symbolMapping; |
16 | Dictionary<string, string> attributeMapping; |
||
17 | List<string> needSymbolMapping; |
||
18 | List<string> needAttributeMapping; |
||
19 | public MappingForm(Dictionary<string, string> symbolMapping, Dictionary<string, string> attributeMapping, List<string> needSymbolMapping, List<string> needAttributeMapping) |
||
20 | 91502a9b | gaqhf | { |
21 | InitializeComponent(); |
||
22 | |||
23 | 8c37691c | gaqhf | this.symbolMapping = symbolMapping; |
24 | this.attributeMapping = attributeMapping; |
||
25 | this.needSymbolMapping = needSymbolMapping; |
||
26 | this.needAttributeMapping = needAttributeMapping; |
||
27 | 91502a9b | gaqhf | } |
28 | |||
29 | private void btnCancel_Click(object sender, EventArgs e) |
||
30 | { |
||
31 | DialogResult = DialogResult.Cancel; |
||
32 | } |
||
33 | |||
34 | private void btnOK_Click(object sender, EventArgs e) |
||
35 | { |
||
36 | 8c37691c | gaqhf | symbolMapping.Clear(); |
37 | foreach (DataGridViewRow row in dgvSymbolMapping.Rows) |
||
38 | 91502a9b | gaqhf | { |
39 | 8c37691c | gaqhf | if (row.Cells["key"].Value != null && row.Cells["value"].Value != null) |
40 | 91502a9b | gaqhf | { |
41 | string key = row.Cells["key"].Value.ToString(); |
||
42 | string value = row.Cells["value"].Value.ToString(); |
||
43 | |||
44 | if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(value)) |
||
45 | { |
||
46 | 8c37691c | gaqhf | if (symbolMapping.ContainsKey(key)) |
47 | symbolMapping[key] = value; |
||
48 | 91502a9b | gaqhf | else |
49 | 8c37691c | gaqhf | symbolMapping.Add(key, value); |
50 | 91502a9b | gaqhf | } |
51 | 8c37691c | gaqhf | |
52 | } |
||
53 | } |
||
54 | |||
55 | attributeMapping.Clear(); |
||
56 | foreach (DataGridViewRow row in dgvAttributeMapping.Rows) |
||
57 | { |
||
58 | if (row.Cells["key"].Value != null && row.Cells["value"].Value != null) |
||
59 | { |
||
60 | string key = row.Cells["key"].Value.ToString(); |
||
61 | string value = row.Cells["value"].Value.ToString(); |
||
62 | |||
63 | if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(value)) |
||
64 | { |
||
65 | if (attributeMapping.ContainsKey(key)) |
||
66 | attributeMapping[key] = value; |
||
67 | else |
||
68 | attributeMapping.Add(key, value); |
||
69 | } |
||
70 | |||
71 | 91502a9b | gaqhf | } |
72 | } |
||
73 | |||
74 | DialogResult = DialogResult.OK; |
||
75 | } |
||
76 | |||
77 | private void MappingForm_Load(object sender, EventArgs e) |
||
78 | { |
||
79 | 8c37691c | gaqhf | dgvSymbolMapping.Columns.Add("key", "value"); |
80 | dgvSymbolMapping.Columns.Add("value", "SPPID Name"); |
||
81 | foreach (var item in symbolMapping) |
||
82 | { |
||
83 | dgvSymbolMapping.Rows.Add(new object[] { item.Key, item.Value }); |
||
84 | } |
||
85 | foreach (var item in needSymbolMapping) |
||
86 | { |
||
87 | dgvSymbolMapping.Rows.Add(new object[] { item, "" }); |
||
88 | } |
||
89 | dgvSymbolMapping.Columns["key"].Width = dgvSymbolMapping.Columns["key"].GetPreferredWidth(DataGridViewAutoSizeColumnMode.AllCells, true); |
||
90 | dgvSymbolMapping.Columns["value"].Width = dgvSymbolMapping.Columns["value"].GetPreferredWidth(DataGridViewAutoSizeColumnMode.AllCells, true); |
||
91 | |||
92 | dgvAttributeMapping.Columns.Add("key", "value"); |
||
93 | dgvAttributeMapping.Columns.Add("value", "SPPID Name"); |
||
94 | foreach (var item in attributeMapping) |
||
95 | 91502a9b | gaqhf | { |
96 | 8c37691c | gaqhf | dgvAttributeMapping.Rows.Add(new object[] { item.Key, item.Value }); |
97 | 91502a9b | gaqhf | } |
98 | 8c37691c | gaqhf | foreach (var item in needAttributeMapping) |
99 | 91502a9b | gaqhf | { |
100 | 8c37691c | gaqhf | dgvAttributeMapping.Rows.Add(new object[] { item, "" }); |
101 | 91502a9b | gaqhf | } |
102 | 8c37691c | gaqhf | dgvAttributeMapping.Columns["key"].Width = dgvAttributeMapping.Columns["key"].GetPreferredWidth(DataGridViewAutoSizeColumnMode.AllCells, true); |
103 | dgvAttributeMapping.Columns["value"].Width = dgvAttributeMapping.Columns["value"].GetPreferredWidth(DataGridViewAutoSizeColumnMode.AllCells, true); |
||
104 | 91502a9b | gaqhf | } |
105 | } |
||
106 | } |