Beispiel #1
0
        private void SetTextBoxes(List <Tree> contentRegionBoxes, Tree root)
        {
            TextLocations.Clear();
            foreach (Tree node in contentRegionBoxes)
            {
                Tree parent = Tree.GetParent(node, root);
                var  rect   = new TextBlockRect();
                rect.TreeNode   = node;
                rect.Color      = Brushes.Black;
                rect.FontFamily = new System.Windows.Media.FontFamily("Segoe UI");
                rect.FontWeight = FontWeights.Regular;
                int leftBoundary = node.Left; //(int)GetLeftBoundary(node, parent);
                rect.Width = node.Width;      //(int)GetRightBoundary(node, parent) - leftBoundary - 4;
                int topBoundary = node.Top;   //GetTopBoundary(node, parent);
                rect.Top       = node.Top;
                rect.Height    = node.Height; //GetBottomBoundary(node, parent) - topBoundary - 8;
                rect.Left      = leftBoundary + 1;
                rect.Alignment = TextAlignment.Left;
                rect.Text      = "Hello World!";

                //}
                //else
                //{

                //    rect.Top = occurrence.TopOffset - 4;
                //    rect.Alignment = TextAlignment.Left;

                //    int toTheRight = GetToTheRight(occurrence, parent);
                //    int margin = 35;
                //    if (toTheRight < parent.LeftOffset + parent.Width)
                //        margin = 5;

                //    rect.Width += toTheRight - (rect.Left + rect.Width) - margin;

                //}



                rect.FontSize = 12;
                rect.FontSize = CalculateMaximumFontSize(rect.FontSize, rect.FontSize - 4, 1, rect.Text,
                                                         rect.FontFamily, new System.Windows.Size(rect.Width, rect.Height), new Thickness(0));

                //rect.Top = topBoundary + 4;
                //rect.Left = parent.LeftOffset + (parent.Width - rect.Width) / 2;
                //rect.Alignment = TextAlignment.Center;


                //if(rect.Width >= 30)
                TextLocations.Add(rect);
                //TextLocations.Add(   new SelectableBoundingBox.WithTreeNode(node, root, node.Left, node.Top, node.Width, node.Height, null) );
            }
        }
        private void SetTextBoxes(List<Tree> contentRegionBoxes, Tree root)
        {
            TextLocations.Clear();
            foreach(Tree node in contentRegionBoxes)
            {
                Tree parent = Tree.GetParent(node, root);
                var rect = new TextBlockRect();
                rect.TreeNode = node;
                rect.Color = Brushes.Black;
                rect.FontFamily = new System.Windows.Media.FontFamily("Segoe UI");
                rect.FontWeight = FontWeights.Regular;
                int leftBoundary = node.Left; //(int)GetLeftBoundary(node, parent);
                rect.Width = node.Width;//(int)GetRightBoundary(node, parent) - leftBoundary - 4;
                int topBoundary = node.Top;//GetTopBoundary(node, parent);
                rect.Top = node.Top;
                rect.Height = node.Height;//GetBottomBoundary(node, parent) - topBoundary - 8;
                rect.Left = leftBoundary + 1;
                rect.Alignment = TextAlignment.Left;
                rect.Text = "Hello World!";

                //}
                //else
                //{

                //    rect.Top = occurrence.TopOffset - 4;
                //    rect.Alignment = TextAlignment.Left;

                //    int toTheRight = GetToTheRight(occurrence, parent);
                //    int margin = 35;
                //    if (toTheRight < parent.LeftOffset + parent.Width)
                //        margin = 5;

                //    rect.Width += toTheRight - (rect.Left + rect.Width) - margin;

                //}



                    rect.FontSize = 12;
                    rect.FontSize = CalculateMaximumFontSize(rect.FontSize, rect.FontSize - 4, 1, rect.Text,
                         rect.FontFamily, new System.Windows.Size(rect.Width, rect.Height), new Thickness(0));

                    //rect.Top = topBoundary + 4;
                    //rect.Left = parent.LeftOffset + (parent.Width - rect.Width) / 2;
                    //rect.Alignment = TextAlignment.Center;


                //if(rect.Width >= 30)
                    TextLocations.Add(rect);
                //TextLocations.Add(   new SelectableBoundingBox.WithTreeNode(node, root, node.Left, node.Top, node.Width, node.Height, null) );
            }
        }