private GetGlobalLocationRelativeToRoot ( float &globalX, float &globalY ) : |
||
globalX | float | |
globalY | float | |
Результат |
void GetGlobalLocationRelativeToRoot(ref PointF location) { if (_justBlockRun != null) { //recursive if (_viewportX != 0 || _viewportY != 0) { } location.Offset( (int)(_justBlockRun.Left), (int)(_justBlockRun.Top + _justBlockRun.HostLine.CachedLineTop)); //recursive _justBlockRun.HostLine.OwnerBox.GetGlobalLocationRelativeToRoot(ref location); return;//*** } CssBox parentBox = _absLayerOwner ?? this.ParentBox; if (parentBox != null) { #if DEBUG if (_viewportX != 0 || _viewportY != 0) { } #endif location.Offset((int)this.LocalX - _viewportX, (int)this.LocalY - _viewportY); //recursive parentBox.GetGlobalLocationRelativeToRoot(ref location); } }
///// walk down and up ///// </summary> ///// <param name="startLine"></param> ///// <returns></returns> //static IEnumerable<CssLineBox> GetLineWalkDownAndUpIter(LineWalkVisitor visitor, CssLineBox startLine) //{ // float sx, sy; // startLine.OwnerBox.GetGlobalLocation(out sx, out sy); // CssLineBox curLine = startLine; // //walk up and down the tree // CssLineBox nextline = curLine.NextLine; // while (nextline != null) // { // visitor._globalY = sy + startLine.CachedLineTop; // yield return nextline; // nextline = nextline.NextLine; // } // //-------------------- // //no next line // //then walk up *** // CssBox curBox = startLine.OwnerBox; // RETRY://*** // CssBox level1Sibling = BoxHitUtils.GetNextSibling(curBox); // while (level1Sibling != null) // { // level1Sibling.GetGlobalLocation(out sx, out sy); // visitor._globalY = sy; // //walk down // foreach (CssLineBox line in GetLineWalkDownIter(visitor, level1Sibling)) // { // yield return line; // } // level1Sibling = BoxHitUtils.GetNextSibling(level1Sibling); // } // //-------------------- // //other further sibling // //then step to parent of lineOwner // if (curBox.ParentBox != null) // { // //if has parent // //walk up*** // curBox = curBox.ParentBox; // goto RETRY; // } //} /// walk down and up /// </summary> /// <param name="startLine"></param> /// <returns></returns> static IEnumerable <CssLineBox> GetLineWalkDownAndUpIter(LineWalkVisitor visitor, CssLineBox startLine) { PointF p = new PointF(); startLine.OwnerBox.GetGlobalLocationRelativeToRoot(ref p); CssLineBox curLine = startLine; //walk up and down the tree CssLineBox nextline = curLine.NextLine; while (nextline != null) { visitor._globalY = p.Y + startLine.CachedLineTop; yield return(nextline); nextline = nextline.NextLine; } //-------------------- //no next line //then walk up *** CssBox curBox = startLine.OwnerBox; RETRY: //*** CssBox level1Sibling = BoxHitUtils.GetNextSibling(curBox); while (level1Sibling != null) { p = new PointF(); level1Sibling.GetGlobalLocationRelativeToRoot(ref p); visitor._globalY = p.Y; //walk down foreach (CssLineBox line in GetLineWalkDownIter(visitor, level1Sibling)) { yield return(line); } level1Sibling = BoxHitUtils.GetNextSibling(level1Sibling); } //-------------------- //other further sibling //then step to parent of lineOwner if (curBox.ParentBox != null) { //if has parent //walk up*** curBox = curBox.ParentBox; goto RETRY; } }
Rectangle GetSelectionRectArea() { if (selectedLines != null) { int j = selectedLines.Count; //first if (j > 0) { CssBox ownerCssBox = null; CssBox rootbox = null; float fx1 = 0, fy1 = 0; //left top RectangleF selArea = RectangleF.Empty; //if (j ==1) //{ //} for (int i = 0; i < j; ++i) { var line = selectedLines[i]; if (line.OwnerBox != ownerCssBox) { ownerCssBox = line.OwnerBox; rootbox = ownerCssBox.GetGlobalLocationRelativeToRoot(out fx1, out fy1); } if (i == 0) { selArea = new RectangleF(fx1, fy1 + line.CachedLineTop, line.CachedLineContentWidth, line.CacheLineHeight); } else { selArea = RectangleF.Union(selArea, new RectangleF(fx1, fy1 + line.CachedLineTop, line.CachedLineContentWidth, line.CacheLineHeight)); } } //if want to debug then send a big rect //Console.WriteLine(new Rectangle((int)selArea.X, (int)selArea.Y, (int)selArea.Width, (int)selArea.Height).ToString()); //return new Rectangle(0, 0, 800, 600); return(new Rectangle((int)selArea.X, (int)selArea.Y, (int)selArea.Width, (int)selArea.Height)); } } return(Rectangle.Empty); }