MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
DictionaryParameterEditorControl.cs
1using System;
2using System.Collections.Generic;
4using System.Drawing;
5using System.Data;
6using System.Linq;
7using System.Text;
8using System.Threading.Tasks;
9using System.Windows.Forms;
10using System.Windows.Forms.Design;
11
12namespace MyCaffe.param.ui
13{
14#pragma warning disable 1591
15
16 public partial class DictionaryParameterEditorControl : UserControl
17 {
18 IWindowsFormsEditorService m_svc;
19 string m_strVal;
20
21 public DictionaryParameterEditorControl(string strVal, IWindowsFormsEditorService svc)
22 {
23 m_svc = svc;
24 m_strVal = strVal;
25 InitializeComponent();
26 }
27
28 public string Value
29 {
30 get
31 {
32 m_strVal = "";
33
34 foreach (DataGridViewRow row in dgvItems.Rows)
35 {
36 if (row.Cells[0].Value != null)
37 {
38 string strItem = row.Cells[0].Value.ToString() + "=";
39 if (row.Cells[1].Value != null)
40 strItem += row.Cells[1].Value.ToString();
41
42 m_strVal += strItem + ";";
43 }
44 }
45
46 return m_strVal.TrimEnd(';');
47 }
48 }
49
50 private void SolverParameterEditorControl_Load(object sender, EventArgs e)
51 {
52 string[] rgstrItem = m_strVal.Split(';');
53
54 for (int i = 0; i < rgstrItem.Length; i++)
55 {
56 string[] rgstrVal = rgstrItem[i].Split('=');
57
58 if (rgstrVal.Count() == 2)
59 dgvItems.Rows.Add(rgstrVal[0], rgstrVal[1]);
60 }
61 }
62 }
63
64#pragma warning restore 1591
65}