public void CrazyWrite()
        {
            var s = "\"123\"\t100\r\n1,2,3\t45,45'\r\n\"\"\"69,\t69\"\"\"\t\"a\t\r\nb\"\r\n";
            var m = StringMatrix.FromTsv(s);
            var t = m.Tsv;

            Assert.AreEqual(s, t);
        }
Exemple #2
0
        void PasteAt(int rowIndex, int colIndex)
        {
            if (Grid.Columns.Count == 0)
            {
                return;
            }

            var clip = Clipboard.GetDataObject();
            var data = clip.GetData(DataFormats.UnicodeText);

            if (data == null)
            {
                return;
            }
            var tsv = data.ToString();

            var m = StringMatrix.FromTsv(tsv);

            var editedRows = new List <int> ();

            for (var mri = 0; mri < m.Rows.Count; mri++)
            {
                var ri = mri + rowIndex;
                while (ri >= Grid.Rows.Count - 1)                   // -1 to keep the insert row
                {
                    Grid.Rows.Add();
                }
                editedRows.Add(ri);
                var r  = Grid.Rows[ri];
                var mr = m.Rows[mri];
                for (var mci = 0; mci < mr.Count; mci++)
                {
                    var ci = colIndex + mci;
                    if (ci >= Grid.Columns.Count)
                    {
                        continue;
                    }
                    if (Grid.Columns[ci].ReadOnly)
                    {
                        continue;
                    }
                    r.Cells[ci].Value = mr[mci];
                }
            }

            RunRows(editedRows);
        }
        public void CrazyRead()
        {
            var m = StringMatrix.FromTsv("\"123\"\t100\r\n1,2,3\t45,45'\r\n\"\"\"69,\t69\"\"\"\t\"a\t\r\nb\"\r\n");

            Assert.AreEqual(3, m.Rows.Count);

            Assert.AreEqual(2, m.Rows[0].Count);
            Assert.AreEqual("\"123\"", m.Rows[0][0]);
            Assert.AreEqual("100", m.Rows[0][1]);

            Assert.AreEqual(2, m.Rows[1].Count);
            Assert.AreEqual("1,2,3", m.Rows[1][0]);
            Assert.AreEqual("45,45'", m.Rows[1][1]);

            Assert.AreEqual(2, m.Rows[2].Count);
            Assert.AreEqual("\"69,\t69\"", m.Rows[2][0]);
            Assert.AreEqual("a\t\r\nb", m.Rows[2][1]);
        }