/// <summary> /// Renders a horizontal rule element. /// </summary> /// <param name="element"></param> /// <param name="blockUIElementCollection"></param> /// <param name="context"></param> private void RenderHorizontalRule(HorizontalRuleBlock element, UIElementCollection blockUIElementCollection, RenderContext context) { var rectangle = new Rectangle(); rectangle.HorizontalAlignment = HorizontalAlignment.Stretch; rectangle.Height = HorizontalRuleThickness; rectangle.Fill = HorizontalRuleBrush ?? context.Foreground; rectangle.Margin = HorizontalRuleMargin; blockUIElementCollection.Add(rectangle); }
/// <summary> /// Renders a horizontal rule element. /// </summary> /// <param name="element"></param> /// <param name="currentBlocks"></param> private void RenderHorizontalRule(HorizontalRuleBlock element, BlockCollection currentBlocks) { // This is going to be weird. To make this work we need to make a UI element // and fill it with text to make it stretch. If we don't fill it with text I can't // make it stretch the width of the box, so for now this is an "ok" hack. InlineUIContainer contianer = new InlineUIContainer(); Grid grid = new Grid(); grid.Height = 2; grid.Background = new SolidColorBrush(Color.FromArgb(255, 153, 153, 153)); // Add the expanding text block. TextBlock magicExpandingTextBlock = new TextBlock(); magicExpandingTextBlock.Foreground = new SolidColorBrush(Color.FromArgb(255, 153, 153, 153)); magicExpandingTextBlock.Text = "This is Quinn writing magic text. You will never see this. Like a ghost! I love Marilyn Welniak! This needs to be really long! RRRRREEEEEAAAAALLLLYYYYY LLLOOOONNNGGGG. This is Quinn writing magic text. You will never see this. Like a ghost! I love Marilyn Welniak! This needs to be really long! RRRRREEEEEAAAAALLLLYYYYY LLLOOOONNNGGGG"; grid.Children.Add(magicExpandingTextBlock); // Add the grid. contianer.Child = grid; // Make the new horizontal rule paragraph Paragraph horzPara = new Paragraph(); horzPara.Margin = new Thickness(0, 12, 0, 12); horzPara.Inlines.Add(contianer); // Add it currentBlocks.Add(horzPara); }