コード例 #1
0
        private void AddSensor(double x, double y, double r, double a)
        {
            Sensor2 ss = new Sensor2();

            ss.ptSource   = new Point3D(x, y, 0.0);
            ss.resistance = r;
            ss.a          = a;

            DataContainerTower.Instance.sensorList.Add(ss);

            DataGridView view = dataGridView;
            DataTable    dt   = view.DataSource as DataTable;

            if (dt == null)
            {
                MakeTable(view);
                dt = view.DataSource as DataTable;
            }

            if (dt != null)
            {
                DataRow row = dt.NewRow();

                row[0] = (dt.Rows.Count + 1).ToString();
                row[1] = string.Format("{0:F2}", ss.a);
                row[2] = string.Format("{0:F2}", ss.ptSource.x);
                row[3] = string.Format("{0:F2}", ss.ptSource.y);
                row[4] = ss.resistance.ToString();
                row[5] = ss.GetXML();

                dt.Rows.Add(row);
            }
        }
コード例 #2
0
        private void SaveDataGrid(DataGridView view, List <Sensor2> sensorList)
        {
            DataTable table = view.DataSource as DataTable;

            if (table == null || table.Rows.Count == 0)
            {
                return;
            }


            sensorList.Clear();

            for (int i = 0; i < table.Rows.Count; i++)
            {
                DataRow row = table.Rows[i];

                string xml = row[5].ToString();
                System.Xml.XmlDocument xdoc = new System.Xml.XmlDocument();
                xdoc.InnerXml = xml;

                Sensor2 slocal = (Sensor2)Sensor2.DeSerializeObject(xdoc, typeof(Sensor2));

                sensorList.Add(slocal);
            }

            int s = sensorList.Count;
        }
コード例 #3
0
ファイル: CSVReader2.cs プロジェクト: Yeokangdong/PowerTower
        public void ReadSensorList(List <Sensor2> list, bool type2)
        {
            if (sr == null)
            {
                return;
            }

            if (list != null && list.Count > 0)
            {
                list.Clear();
            }

            string[] lines = sr.ReadToEnd().Split('\r');
            sr.Close();

            foreach (string s in lines)
            {
                if (s.Trim().Length == 0)
                {
                    continue;
                }

                Sensor2 ab = new Sensor2();

                if (type2)
                {
                    ab.LoadCSV(s.Trim(), type2);
                }
                else
                {
                    ab.LoadCSV(s.Trim());
                }

                list.Add(ab);
            }
        }