/** * Returns a List of BoundingBox objects for an indicated page. * Primarily used to check whether coordinates indicated in the LayoutXML are accurate. * */ public static List<BoundingBox> getGhostBoxes(String page) { List<BoundingBox> boxes = new List<BoundingBox>(); try { // Looks at every box in layoutXml XmlNodeList foundNodes = SurfaceWindow1.layoutXml.DocumentElement.SelectNodes("//surface[@id='" + page + "']/zone/box"); foreach (XmlNode node in foundNodes) { String tag = node.ParentNode.Attributes["id"].Value; Point topL = new Point(Convert.ToDouble(node.Attributes["ulx"].Value), Convert.ToDouble(node.Attributes["uly"].Value)); Point bottomR = new Point(Convert.ToDouble(node.Attributes["lrx"].Value), Convert.ToDouble(node.Attributes["lry"].Value)); BoundingBox newBB = new BoundingBox(tag, topL, bottomR); boxes.Add(newBB); } } catch (Exception e) { Console.Write(e.StackTrace); Console.Read(); } return boxes; }
/** * Establishes a Grid for the BoundingBox coordinate information on a given page (i.e. location of objects). * */ public static Grid getGrid(BoundingBox bb) { double width, x, y, height; x = bb.topL.X; y = bb.topL.Y; width = (bb.bottomR.X - bb.topL.X); height = (bb.bottomR.Y - bb.topL.Y); Grid g = new Grid(); ColumnDefinition c1 = new ColumnDefinition(); c1.Width = new GridLength(x, GridUnitType.Star); ColumnDefinition c2 = new ColumnDefinition(); c2.Width = new GridLength(width, GridUnitType.Star); ColumnDefinition c3 = new ColumnDefinition(); c3.Width = new GridLength(SurfaceWindow1.maxPageWidth - x - width, GridUnitType.Star); RowDefinition r1 = new RowDefinition(); r1.Height = new GridLength(y, GridUnitType.Star); RowDefinition r2 = new RowDefinition(); r2.Height = new GridLength(height, GridUnitType.Star); RowDefinition r3 = new RowDefinition(); r3.Height = new GridLength(SurfaceWindow1.maxPageHeight - y - height, GridUnitType.Star); g.ColumnDefinitions.Add(c1); g.ColumnDefinitions.Add(c2); g.ColumnDefinitions.Add(c3); g.RowDefinitions.Add(r1); g.RowDefinitions.Add(r2); g.RowDefinitions.Add(r3); Border B = new Border(); B.BorderBrush = blockBrush; B.BorderThickness = new Thickness(2); Grid filla = new Grid(); Grid.SetRow(B, 1); Grid.SetColumn(B, 1); g.Children.Add(B); B.Child = filla; filla.Background = blockFillerBrush; return g; }