예제 #1
0
        public void TestClick()
        {
            ParaBox        para;
            RootBox        root   = ParaBuilderTests.MakeTestParaSimpleString(m_gm.VwGraphics, ParaBuilderTests.MockBreakOption.ThreeFullLines, out para);
            PaintTransform ptrans = new PaintTransform(2, 4, 96, 100, 0, 0, 120, 128);
            var            seg    = FirstMockSegment(root);

            seg.OnPointToCharReturn(4, false);
            var sel = root.GetSelectionAt(new Point(5, 10), m_gm.VwGraphics, ptrans);

            Assert.That(sel.IsInsertionPoint);
            Assert.That(((InsertionPoint)sel).StringPosition, Is.EqualTo(4));
            Assert.That(((InsertionPoint)sel).AssociatePrevious, Is.False);
            Assert.That(seg.PointToCharVg, Is.EqualTo(m_gm.VwGraphics));
            Assert.That(seg.PointToCharIchBase, Is.EqualTo(0));
            // not much of a test, but we don't have any way to offset paras yet
            Assert.That(seg.PointToCharRcDst, Is.EqualTo(ptrans.DestRect));
            Assert.That(seg.PointToCharRcSrc, Is.EqualTo(ptrans.SourceRect));
            // Should be offset by the Paint transform origin.
            Assert.That(seg.PointToCharClickPosition, Is.EqualTo(new Point(5, 10)));

            seg = SecondMockSegment(root);
            seg.OnPointToCharReturn(14, true);
            sel = root.GetSelectionAt(new Point(7, 20), m_gm.VwGraphics, ptrans);
            Assert.That(sel.IsInsertionPoint);
            Assert.That(((InsertionPoint)sel).StringPosition, Is.EqualTo(14));
            Assert.That(((InsertionPoint)sel).AssociatePrevious, Is.True);
            Assert.That(seg.PointToCharVg, Is.EqualTo(m_gm.VwGraphics));
            Assert.That(seg.PointToCharIchBase, Is.EqualTo(IchMinOfSecondStringBox(root)));
            // Should be offset by the Paint transform origin and the origin of the second box.
            var topLeft = TopLeftOfSecondStringBox(root);

            Assert.That(seg.PointToCharClickPosition, Is.EqualTo(new Point(7, 20)));
        }