hytos / DTI_PID / SPPIDConverter_CustomCommand / MappingForm.cs @ 1cad80c1
이력 | 보기 | 이력해설 | 다운로드 (2.16 KB)
1 |
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 |
Dictionary<string, string> mapping; |
16 |
List<string> needMapping; |
17 |
public MappingForm(Dictionary<string, string> mapping, List<string> needMapping) |
18 |
{ |
19 |
InitializeComponent(); |
20 | |
21 |
this.mapping = mapping; |
22 |
this.needMapping = needMapping; |
23 |
} |
24 | |
25 |
private void btnCancel_Click(object sender, EventArgs e) |
26 |
{ |
27 |
DialogResult = DialogResult.Cancel; |
28 |
} |
29 | |
30 |
private void btnOK_Click(object sender, EventArgs e) |
31 |
{ |
32 |
mapping.Clear(); |
33 |
foreach (DataGridViewRow row in dgvMapping.Rows) |
34 |
{ |
35 |
if (row.Cells["key"].Value!=null && row.Cells["value"].Value!=null) |
36 |
{ |
37 |
string key = row.Cells["key"].Value.ToString(); |
38 |
string value = row.Cells["value"].Value.ToString(); |
39 | |
40 |
if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(value)) |
41 |
{ |
42 |
if (mapping.ContainsKey(key)) |
43 |
mapping[key] = value; |
44 |
else |
45 |
mapping.Add(key, value); |
46 |
} |
47 |
|
48 |
} |
49 |
} |
50 | |
51 |
DialogResult = DialogResult.OK; |
52 |
} |
53 | |
54 |
private void MappingForm_Load(object sender, EventArgs e) |
55 |
{ |
56 |
dgvMapping.Columns.Add("key", "value"); |
57 |
dgvMapping.Columns.Add("value", "SPPID Name"); |
58 |
foreach (var item in mapping) |
59 |
{ |
60 |
dgvMapping.Rows.Add(new object[] { item.Key, item.Value }); |
61 |
} |
62 |
foreach (var item in needMapping) |
63 |
{ |
64 |
dgvMapping.Rows.Add(new object[] { item, "" }); |
65 |
} |
66 |
dgvMapping.Columns["value"].Width = dgvMapping.Columns["value"].GetPreferredWidth(DataGridViewAutoSizeColumnMode.AllCells, true); |
67 |
} |
68 |
} |
69 |
} |