Esempio n. 1
0
        public void Setup()
        {
            MyMultiLineDoc <string> myMultiLineDoc = new MyMultiLineDoc <string>();

            string[] simpleDoc = new string[] { "A", "B", "CDE", "F" };//
            myMultiLineDoc.LoadLines(simpleDoc);
            heightTree = new HeightTree(myMultiLineDoc);
            heightTree.Rebuild();

            int line_index = 1;

            foreach (string mytext in simpleDoc)
            {
                heightTree.SetLineHeight(line_index, 16);
                line_index++;
            }
            double ypos0 = heightTree.LineNumberToY(1);
            double ypos1 = heightTree.LineNumberToY(2);

            //document = new TextDocument();
            //document.Text = "1\n2\n3\n4\n5\n6\n7\n8\n9\n10";
            //heightTree = new HeightTree(document, 10);
            //foreach (DocumentLine line in document.Lines)
            //{
            //    heightTree.SetHeight(line, line.LineNumber);
            //}
        }
Esempio n. 2
0
        public void TestSetLineHeight()
        {
            var editor = new TextEditorData();

            editor.Text = "1\n2\n3\n4\n5\n6\n7";
            HeightTree heightTree = new HeightTree(editor);

            heightTree.Rebuild();
            for (int i = 1; i <= editor.LineCount; i += 2)
            {
                heightTree.SetLineHeight(i, editor.LineHeight * 2);
            }

            double y = 0;

            for (int i = 1; i <= editor.LineCount; i++)
            {
                Assert.AreEqual(y, heightTree.LineNumberToY(i));
                y += i % 2 == 0 ? editor.LineHeight : editor.LineHeight * 2;
            }

            y = 0;
            for (int i = 1; i <= editor.LineCount; i++)
            {
                Assert.AreEqual(i, heightTree.YToLineNumber(y));
                y += i % 2 == 0 ? editor.LineHeight : editor.LineHeight * 2;
            }
        }
Esempio n. 3
0
		public void TestSetLineHeight ()
		{
			var editor = new TextEditorData ();
			editor.Text = "1\n2\n3\n4\n5\n6\n7";
			HeightTree heightTree = new HeightTree (editor);
			heightTree.Rebuild ();
			for (int i = 1; i <= editor.LineCount; i += 2) {
				heightTree.SetLineHeight (i, editor.LineHeight * 2);
			}
			
			double y = 0;
			for (int i = 1; i <= editor.LineCount; i++) {
				Assert.AreEqual (y, heightTree.LineNumberToY (i));
				y += i % 2 == 0 ? editor.LineHeight : editor.LineHeight * 2;
			}
			
			y = 0;
			for (int i = 1; i <= editor.LineCount; i++) {
				Assert.AreEqual (i, heightTree.YToLineNumber (y));
				y += i % 2 == 0 ? editor.LineHeight : editor.LineHeight * 2;
			}
			
		}