프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / SPPIDConverter_CustomCommand / MappingForm.cs @ 1430f5a6

이력 | 보기 | 이력해설 | 다운로드 (4.17 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> 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
        {
21
            InitializeComponent();
22

    
23
            this.symbolMapping = symbolMapping;
24
            this.attributeMapping = attributeMapping;
25
            this.needSymbolMapping = needSymbolMapping;
26
            this.needAttributeMapping = needAttributeMapping;
27
        }
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
            symbolMapping.Clear();
37
            foreach (DataGridViewRow row in dgvSymbolMapping.Rows)
38
            {
39
                if (row.Cells["key"].Value != null && row.Cells["value"].Value != null)
40
                {
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
                        if (symbolMapping.ContainsKey(key))
47
                            symbolMapping[key] = value;
48
                        else
49
                            symbolMapping.Add(key, value);
50
                    }
51

    
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
                }
72
            }
73

    
74
            DialogResult = DialogResult.OK;
75
        }
76

    
77
        private void MappingForm_Load(object sender, EventArgs e)
78
        {
79
            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
            {
96
                dgvAttributeMapping.Rows.Add(new object[] { item.Key, item.Value });
97
            }
98
            foreach (var item in needAttributeMapping)
99
            {
100
                dgvAttributeMapping.Rows.Add(new object[] { item, "" });
101
            }
102
            dgvAttributeMapping.Columns["key"].Width = dgvAttributeMapping.Columns["key"].GetPreferredWidth(DataGridViewAutoSizeColumnMode.AllCells, true);
103
            dgvAttributeMapping.Columns["value"].Width = dgvAttributeMapping.Columns["value"].GetPreferredWidth(DataGridViewAutoSizeColumnMode.AllCells, true);
104
        }
105
    }
106
}
클립보드 이미지 추가 (최대 크기: 500 MB)