コード例 #1
0
ファイル: LayoutTests.cs プロジェクト: jugglingcats/XEditNet
        public void CommentHitTestError()
        {
            string test="<p><!--OddPage--></p>";
            XmlDocument doc=new XmlDocument();
            doc.LoadXml(test);

            Stylesheet s=new Stylesheet();
            s.BindStyles(doc.NameTable);

            Rectangle rc=new Rectangle(0, 0, 500, int.MaxValue);

            using ( IGraphics gr=new DummyGraphics() )
            {
                DrawContext ctx=new DrawContext(gr, Point.Empty, rc, rc, null, new DocumentType(), null);
                LayoutEngine layoutEngine=new LayoutEngine(s);

                layoutEngine.Reflow(ctx, doc.DocumentElement);

                Console.WriteLine("Bounds {0}", layoutEngine.BoundingRect);
                for (int x=0; x< layoutEngine.BoundingRect.Width; x+=10)
                {
                    HitTestInfo hti=layoutEngine.GetHitTestInfo(gr, new Point(x,8));
                    SelectionPoint sp=hti.SelectionPoint;
                    Console.WriteLine("Hit test at {0} = {1}", x, sp);
                }
            }
        }
コード例 #2
0
ファイル: LayoutTests.cs プロジェクト: jugglingcats/XEditNet
        public void HitTestHandling()
        {
            string test="<p><b>xxxxxxxxxxxxx</b></p>";
            XmlDocument doc=new XmlDocument();
            doc.LoadXml(test);

            Stylesheet s=//Stylesheet.Load("c:/tmp/website/site.style", doc.NameTable);
            new Stylesheet();
            s.BindStyles(doc.NameTable);

            Rectangle rc=new Rectangle(0, 0, 500, int.MaxValue);

            using ( IGraphics gr=new DummyGraphics() )
            {
                DrawContext ctx=new DrawContext(gr, Point.Empty, rc, rc, null, new DocumentType(), null);
                LayoutEngine layoutEngine=new LayoutEngine(s);

                layoutEngine.Reflow(ctx, doc.DocumentElement);

                layoutEngine.GetHitTestInfo(gr, new Point(141,16));
            }
        }
コード例 #3
0
ファイル: XEditNetCtrl.cs プロジェクト: jugglingcats/XEditNet
        private void Reflow()
        {
            //			Console.WriteLine("XEditNetCtrl: Reflow");

            if ( doc == null || doc.DocumentElement == null )
                return;

            LayoutEngine le=new LayoutEngine(stylesheet);

            Size sz=new Size();

            //			Console.WriteLine("Reflow: Create graphics from control");
            using ( IGraphics gr=grFactory.CreateGraphics(this) )
            {
                Rectangle rc=VisibleRectangle;
                rc.Height=0;

                DrawContext dc=new DrawContext(gr, new Point(-OffsetX, -OffsetY), rc, rc, validationManager.InvalidNodes, validationManager.DocumentType, currentSelection.Start);
                sz=le.Reflow(dc, doc.DocumentElement);
            }

            layoutEngine=le;

            if ( currentSelection.IsRange )
            {
                layoutEngine.Selection=currentSelection;
                Invalidate(true);
            }

            UpdateCaretPosition();
            ResetScrollbars(sz);
        }
コード例 #4
0
ファイル: LayoutTests.cs プロジェクト: jugglingcats/XEditNet
        public void WhitespaceHandling1()
        {
            string test="aaaa bbbb  cccc";
            XmlDocument doc=new XmlDocument();
            doc.LoadXml("<doc>"+test+"</doc>");

            Stylesheet s=new Stylesheet();
            s.BindStyles(doc.NameTable);

            //			Rectangle rc=new Rectangle(0, 0, 480, int.MaxValue);
            Rectangle rc=new Rectangle(0, 0, 110, int.MaxValue);

            using ( IGraphics gr=new DummyGraphics() )
            {
                DrawContext ctx=new DrawContext(gr, Point.Empty, rc, rc, null, new DocumentType(), null);
                LayoutEngine layoutEngine=new LayoutEngine(s);
                layoutEngine.Reflow(ctx, doc.DocumentElement);

                SelectionPoint start=new TextSelectionPoint(doc.DocumentElement.FirstChild, 11);
                Console.WriteLine("Getting caret pos for {0}", start);
                Rectangle c=layoutEngine.GetCaretPosition(gr, start, CaretDirection.None);
                Console.WriteLine("Char {0} at {1}", start.ToString(), c);
            }
        }