Inheritance: Block, IParagraph
Example #1
0
        public static void FixUpXaml(Paragraph paragraph)
        {
            for(int i = 0; i < paragraph.Inlines.Count; i++)
            {
                Inline inline = paragraph.Inlines[i];
                ImageInline imageInline;
                if (TryCreate(inline, out imageInline))
                {
                    BitmapImage bi = new BitmapImage(new Uri(imageInline.FilePath));
                    Image image = new Image();
                    image.Source = bi;
                    image.Stretch = Stretch.Uniform;
                    InlineUIContainer container = new InlineUIContainer();
                    image.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center;
                    image.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Center;
                    image.Stretch = Stretch.Uniform;
                    container.Child = image;
                    paragraph.Inlines[i] = container;

                    // if this is an image only paragraph. Center it
                    if (paragraph.Inlines.Count == 1)
                    {
                        paragraph.TextAlignment = Windows.UI.Xaml.TextAlignment.Center;
                    }
                }
            }
        }
        private void DisplayMessage()
        {
            ChatMessage msg = null;
            while ((msg = DequeueChatMessage()) != null)
            {
                // create the paragraph
                Paragraph p = new Paragraph();
                Run rnMyText = new Run();
                p.FontWeight = FontWeights.Bold;

                // if the message is from the currently logged in user, then set the color to gray
                if (msg.From == _username)
                {
                    p.Foreground = new SolidColorBrush(Colors.Gray);
                    rnMyText.Text = string.Format("{0} (me): {1}", msg.From, msg.MessageText);
                }
                else
                {
                    p.Foreground = new SolidColorBrush(Colors.Green);
                    rnMyText.Text = string.Format("{0}: {1}", msg.From, msg.MessageText);
                }

                // add the text to the paragraph tag
                p.Inlines.Add(rnMyText);

                // add the paragraph to the rich text box
                rtbChatLog.Blocks.Add(p);
            }
        }
Example #3
0
        public static Windows.UI.Xaml.Controls.RichTextBlock Control(this Trainer.Domain.Component item, bool isThumbnail = false)
        {
            var control = new Windows.UI.Xaml.Controls.RichTextBlock
            {
                IsTextSelectionEnabled = true,
                MinHeight = 40,
                MinWidth  = 400
            };

            if (isThumbnail)
            {
                control.FontSize = ThumbnailFontSize;
            }

            foreach (var line in item.Code.Value.Split(Environment.NewLine.ToArray()))
            {
                var par = new Xaml.Paragraph
                {
                    FontStyle  = Windows.UI.Text.FontStyle.Italic,
                    TextIndent = 4
                };
                if (isThumbnail)
                {
                    par.FontSize = ThumbnailFontSize;
                }

                foreach (var inline in GetInlines(line, isThumbnail))
                {
                    par.Inlines.Add(inline);
                }
                control.Blocks.Add(par);
            }

            return(control);
        }
 public Paragraph AddToParentParagraph(Inline text)
 {
     var paragraph = new Paragraph();
     paragraph.Inlines.Add(text);
     Add(paragraph);
     return paragraph;
 }
Example #5
0
        private static void OnStatusChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var parent = (RichTextBlock)sender;
            parent.Blocks.Clear();

            var atSomeonePattern = new Regex(@"(?<someone>\@[^#\@\s\b\n\r\0:,.;!?'""。,:;!?”“‘’]+)");
            var text = e.NewValue as string;
            var ms = atSomeonePattern.Matches(text);

            int nextOffset = 0;
            var paragraph = new Paragraph();
            parent.Blocks.Add(paragraph);

            foreach (Match m in ms)
            {
                paragraph.Inlines.Add(new Run { Text = text.Substring(nextOffset, m.Index - nextOffset) });
                paragraph.Inlines.Add(new Run { Text = m.Groups["someone"].Value, Foreground = AtPatternColorBrush });
                nextOffset = m.Index + m.Length;
            }

            if (nextOffset == 0)
            {
                paragraph.Inlines.Add(new Run { Text = text });
            }
        }
Example #6
0
 protected static void ApplyParagraphStyles(Paragraph paragraph, ParagraphStyle style)
 {
     if (style != null)
     {
         BindingOperations.SetBinding(paragraph, Paragraph.MarginProperty, CreateBinding(style, "Margin"));
         ApplyTextStyles(paragraph, style);
     }
 }
 public LandingPage()
 {
     this.InitializeComponent();
     TopAppBar = NavigationBar.GetNavBar();
     var paragraph = new Paragraph();
     paragraph.Inlines.Add(new Run {Text = "Welcomming text"});
     RichTextBlock_main.Blocks.Add(paragraph);
     RichTextBlock_main.IsTextSelectionEnabled = false;
 }
 /// <summary>
 /// Helper to create log entries
 /// </summary>
 /// <param name="logEntry"></param>
 void appendLog(string logEntry, Color c)
 {
     Run r = new Run();
     r.Text = logEntry;
     Paragraph p = new Paragraph();
     p.Foreground = new SolidColorBrush(c);
     p.Inlines.Add(r);
     logResults.Blocks.Add(p);
 }
 public virtual void RenderElement(IElement element, ITextContainer parent, RenderContextBase context)
 {
     var paragraph = new Paragraph()
     {
         TextAlignment = TextAlignment.Center
     };
     parent.Add(paragraph);
     context.RenderNode(element, new ParagraphContainer(paragraph));
 }
        private void RefreshView()
        {
            // anything?
            if (string.IsNullOrEmpty(Markup))
            {
                this.Content = null;
                return;
            }

            // get the lines...
            var lines = new List<string>();
            using (var reader = new StringReader(this.Markup))
            {
                while(true)
                {
                    string buf = reader.ReadLine();
                    if (buf == null)
                        break;
                    lines.Add(buf);
                }
            }

            // walk...
            var block = new RichTextBlock();
            for (int index = 0; index < lines.Count; index++)
            {
                string nextLine = null;
                if (index < lines.Count - 1)
                    nextLine = lines[index + 1];

                // create a paragraph... and add it to the block...
                var para = new Paragraph();
                block.Blocks.Add(para);

                // create a "run" and add it to the paragraph...
                var run = new Run();
                run.Text = lines[index];
                para.Inlines.Add(run);

                // heading?
                if (nextLine != null && nextLine.StartsWith("="))
                {
                    // make it bigger, and then skip the next line...
                    para.FontSize = 20;
                    index++;
                }
                else if (nextLine != null && nextLine.StartsWith("-"))
                {
                    para.FontSize = 18;
                    index++;
                }
            }

            // set...
            this.Content = block;
        }
 /// <summary>
 /// Handles changes to the PlainText property.
 /// </summary>
 /// <param name="d">
 /// The <see cref="DependencyObject"/> on which
 /// the property has changed value.
 /// </param>
 /// <param name="e">
 /// Event data that is issued by any event that
 /// tracks changes to the effective value of this property.
 /// </param>
 private static void OnPlainTextChanged(
     DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     string oldPlainText = (string)e.OldValue;
     string newPlainText = (string)d.GetValue(PlainTextProperty);
     ((RichTextBlock)d).Blocks.Clear();
     var paragraph = new Paragraph();
     paragraph.Inlines.Add(new Run { Text = newPlainText });
     ((RichTextBlock)d).Blocks.Add(paragraph);
 }
        private Block CreateTextBlock(string content)
        {
            var para = new Paragraph();

            var run = new Run() { Text = content };

            para.Inlines.Add(run);

            return para;
        }
        void EscribirEnRichTextBox(string texto, RichTextBlock rtb)
        {
            rtb.Blocks.Clear();

            Run run = new Run();
            run.Text = texto;

            Paragraph parrafo = new Paragraph();
            parrafo.Inlines.Add(run);

            rtb.Blocks.Add(parrafo);
        }
Example #14
0
        public static void OnTextContent(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var richText = (RichTextBlock)d;
            var textContent = (string)e.NewValue;

            richText.Blocks.Clear();

            if(string.IsNullOrEmpty(textContent)) {
                return;
            }
            var paragraph = new Paragraph();
            richText.Blocks.Add(paragraph);

            var matches = UrlRegex.Matches(textContent);
            if(matches.Count == 0) {
                paragraph.Inlines.Add(new Run { Text = textContent });
                return;
            }
            int index = 0;
            foreach(Match match in matches) {
                Uri uri = null;
                Uri.TryCreate(match.Value, UriKind.Absolute, out uri);
                if(match.Index > 0) {
                    var length = match.Index - index;
                    if(length > 0) {
                        paragraph.Inlines.Add(new Run { Text = textContent.Substring(index, length) });
                    }
                }

                var underline = new Underline();
                underline.Inlines.Add(new Run { Text = uri.Host });
                var linkContent = new TextBlock();
                linkContent.Inlines.Add(underline);
                var hyperlink = new HyperlinkButton {
                    NavigateUri = uri,
                    Content = linkContent,
                    Style = (Style)Application.Current.Resources["TextButtonStyle"],
                    Margin = new Thickness(0, 0, 0, -4)
                };
                paragraph.Inlines.Add(
                    new InlineUIContainer {
                        Child = hyperlink
                    });
                index = match.Index + match.Length;
            }
            if(index < textContent.Length - 1) {
                var lastRunText = textContent.Substring(index);
                if(lastRunText.Length > 0) {
                    paragraph.Inlines.Add(new Run { Text = lastRunText });
                }
            }
        }
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            var source = (value as string) ?? string.Empty;
            try
            {
                return Parse(source);
            }
            catch (Exception uiEx) { Frontend.UIError(uiEx); }

            var p = new Paragraph();
            p.Inlines.Add(new Run() { Text = source });
            return p;
        }
 public virtual void Add(Inline inline)
 {
     var paragraph = _richTextBlock.Blocks.LastOrDefault() as Paragraph;
     if (paragraph == null)
     {
         paragraph = new Paragraph();
         paragraph.Inlines.Add(inline);
         Add(paragraph);
     }
     else
     {
         paragraph.Inlines.Add(inline);
     }
 }
        private static void OnTextChanged(DependencyObject sender,
            DependencyPropertyChangedEventArgs e)
        {
            var control = sender as RichTextBlock;
            if (control != null)
            {
                control.Blocks.Clear();
                string value = e.NewValue.ToString();

                var paragraph = new Paragraph();
                paragraph.Inlines.Add(new Run { Text = value });
                control.Blocks.Add(paragraph);
            }
        }
 protected ListContainer(Paragraph paragraph)
 {
     _grid = new Grid();
     _grid.ColumnDefinitions.Add(new ColumnDefinition
     {
         Width = GridLength.Auto
     });
     _grid.ColumnDefinitions.Add(new ColumnDefinition
     {
         Width = new GridLength(1, GridUnitType.Star)
     });
     paragraph.Inlines.Add(new InlineUIContainer
     {
         Child = _grid
     });
 }
Example #19
0
 private static void AddChildren(Paragraph p, HtmlNode node)
 {
     bool added = false;
     foreach (HtmlNode child in node.ChildNodes)
     {
         Inline i = GenerateBlockForNode(child);
         if (i != null)
         {
             p.Inlines.Add(i);
             added = true;
         }
     }
     if (!added)
     {
         p.Inlines.Add(new Run() { Text = CleanText(node.InnerText) });
     }
 }
        private static Paragraph ParagraphFromText(string text)
        {
            var paragraph = new Paragraph();
            var color = Colors.Black;
            foreach (var run in GetTokens(text))
            {
                if (run.StartsWith("</")) { color = Colors.Black; continue; }
                if (run == "<red>") { color = Colors.Red; continue; }
                if (run == "<green>") { color = Colors.Green; continue; }
                if (run == "<blue>") { color = Colors.Blue; continue; }
                if (run == "<gray>") { color = Colors.Gray; continue; }
                if (run.StartsWith("\n")) paragraph.Inlines.Add(new LineBreak());
                else paragraph.Inlines.Add(new Run { Text = run, Foreground = new SolidColorBrush(color) });
            }

            return paragraph;
        }
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            if (value != null)
            {
                Paragraph para = new Paragraph();
                var xaml = HtmlToXamlConverter.ConvertHtmlToXaml(value.ToString());

                using (MemoryStream stream = new MemoryStream((new UTF8Encoding()).GetBytes(xaml)))
                {
                    //para. text = new TextRange(para.ContentStart, para.ContentEnd);
                    //text.Load(stream, DataFormats.Xaml);
                }

                return para;
            }
            return value;
        }
Example #22
0
        private static void OnTextChanged(DependencyObject sender,
            DependencyPropertyChangedEventArgs e)
        {
            var control = sender as RichTextBlock;
            if (control != null)
            {
                control.Blocks.Clear();

                var paragraph = new Paragraph();
                string[] values = e.NewValue.ToString().Split(new string[] { "<p>", @"</p>", "<ul>", @"</ul>", "<li>", @"</li>" }, StringSplitOptions.RemoveEmptyEntries);
                foreach (var value in values)
                {
                    paragraph.Inlines.Add(new Run { Text = value });
                }
                control.Blocks.Add(paragraph);
            }
        }
Example #23
0
 private static void Fill(RichTextBlock textblock)
 {
     var itemsSource = GetItemsSource(textblock) as IEnumerable<Models.IBlock>;
     if (itemsSource == null)
         return;
     textblock.Blocks.Clear();
     foreach (var item in itemsSource)
     {
         var paragraph = new Paragraph
         {
             Margin = new Thickness(0, 0, 0, 16d),
             FontSize = FontSize(item, textblock),
             TextIndent = Indent(item, textblock),
         };
         if (item is Models.Header)
             paragraph.Foreground = Colors.Black.ToSolidColorBrush();
         paragraph.Inlines.Add(item.ToRun());
         textblock.Blocks.Add(paragraph);
     }
 }
Example #24
0
        private static Paragraph ParseForRichTextParagraph(string message)
        {
            var ret = new Paragraph();

            var words = message.Split(" ".ToCharArray());
            foreach (var word in words)
            {
                if (word.Contains("@"))
                    ret.Inlines.Add(new Run { Text = word + " ", Foreground = greenBrush });
                else if (word.Contains("#"))
                    ret.Inlines.Add(new Run { Text = word + " ", Foreground = orangeBrush });
                else if (word.Contains("http"))
                {
                    var ul = new Underline();
                    ul.Inlines.Add(new Run { Text = word + " ", Foreground = blueBrush });
                    ret.Inlines.Add(ul);
                }
                else
                    ret.Inlines.Add(new Run { Text = word + " " });
            }

            return ret;
        }
Example #25
0
        private void itemData_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (this.itemData.SelectedItem != null)
            {
                this.itemData.Visibility = Visibility.Collapsed;

                ResultDataItem item = this.itemData.SelectedItem as ResultDataItem;
                var properties = string.Join(Environment.NewLine + Environment.NewLine,
                    item.Results
                        .Select(y => y.Key + Environment.NewLine + (y.Value == null ? "(null)" : y.Value.ToString())));

                var block = new Paragraph();
                block.Inlines.Add(new Run() { Text = properties });
                this.itemText.Blocks.Add(block);

                this.itemText.Visibility = Visibility.Visible;
            }
        }
Example #26
0
 private static Block GenerateTopIFrame(HtmlNode node)
 {
     try
     {
         Paragraph p = new Paragraph();
         InlineUIContainer iui = new InlineUIContainer();
         WebView ww = new WebView() { Source = new Uri(node.Attributes["src"].Value, UriKind.Absolute), Width = Int32.Parse(node.Attributes["width"].Value), Height = Int32.Parse(node.Attributes["height"].Value) };
         iui.Child = ww;
         p.Inlines.Add(iui);
         return p;
     }
     catch (Exception ex)
     {
         return null;
     }
 }
Example #27
0
 private static Block GenerateParagraph(HtmlNode node)
 {
     Paragraph p = new Paragraph();
     AddChildren(p, node);
     return p;
 }
 public void Add(Inline text)
 {
     var paragraph = new Paragraph();
     paragraph.Inlines.Add(text);
     Add(paragraph);
 }
Example #29
0
        public static Xaml.Paragraph Control(this Trainer.Domain.Paragraph item, bool isThumbnail = false)
        {
            var control = new Xaml.Paragraph();

            if (isThumbnail)
            {
                control.FontSize = ThumbnailFontSize;
            }

            if (item.CharacterSpacing > 0)
            {
                control.CharacterSpacing = item.CharacterSpacing;
            }
            if (item.FontSize > 0 && !isThumbnail)
            {
                control.FontSize = item.FontSize;
            }
            if (!string.IsNullOrEmpty(item.FontStretch))
            {
                control.FontStretch = Helpers.ParseEnum <Windows.UI.Text.FontStretch>(item.FontStretch);
            }
            if (!string.IsNullOrEmpty(item.FontStyle))
            {
                control.FontStyle = Helpers.ParseEnum <Windows.UI.Text.FontStyle>(item.FontStyle);
            }
            if (!string.IsNullOrEmpty(item.FontWeight))
            {
                control.FontWeight = Helpers.ParseEnum <Windows.UI.Text.FontWeight>(item.FontWeight);
            }
            //if (!string.IsNullOrEmpty(item.Foreground)) control.Foreground = new SolidColorBrush(item.Foreground.GetColor());

            if (item.LineHeight > 0)
            {
                control.LineHeight = item.LineHeight;
            }
            if (!string.IsNullOrEmpty(item.LineStackingStrategy))
            {
                control.LineStackingStrategy = Helpers.ParseEnum <Windows.UI.Xaml.LineStackingStrategy>(item.LineStackingStrategy);
            }
            //if (!string.IsNullOrEmpty(item.Margin)) control.Margin = Helpers.GetThickness(item.Margin);
            if (!string.IsNullOrEmpty(item.TextAlignment))
            {
                control.TextAlignment = Helpers.ParseEnum <Windows.UI.Xaml.TextAlignment>(item.TextAlignment);
            }
            if (item.TextIndent > 0)
            {
                control.TextIndent = item.TextIndent;
            }
            if (item.Text != null && item.Text.Any())
            {
                var run = new Xaml.Run {
                    Text = string.Join(Environment.NewLine, item.Text)
                };
                if (isThumbnail)
                {
                    run.FontSize = ThumbnailFontSize;
                }

                control.Inlines.Add(run);
            }

            if (item.Bold != null && item.Bold.Any())
            {
                foreach (var bold in item.Bold)
                {
                    control.Inlines.Add(bold.Control(isThumbnail));
                }
            }

            if (item.Hyperlink != null)
            {
                control.Inlines.Add(item.Hyperlink.Control(isThumbnail));
            }

            if (item.Run != null && item.Run.Any())
            {
                foreach (var run in item.Run)
                {
                    control.Inlines.Add(run.Control(isThumbnail));
                }
            }

            if (item.InlineUIContainer != null)
            {
                control.Inlines.Add(item.InlineUIContainer.Control());
            }

            return(control);
        }
Example #30
0
        private static TextElement ConvertHTMLNode(HtmlNode node)
        {
            if (node.NodeType != HtmlNodeType.Text)
            {
                switch (node.Name)
                {
                case "h1":
                    var header1 = new Windows.UI.Xaml.Documents.Paragraph()
                    {
                        FontSize = 26, FontWeight = FontWeights.Medium, TextAlignment = Windows.UI.Xaml.TextAlignment.Center
                    };
                    header1.Inlines.Add(new Run()
                    {
                        Text = node.InnerText
                    });
                    return(header1);

                case "h2":
                    var header2 = new Windows.UI.Xaml.Documents.Paragraph()
                    {
                        FontSize = 20, FontWeight = FontWeights.Medium
                    };
                    header2.Inlines.Add(new Run()
                    {
                        Text = node.InnerText
                    });
                    return(header2);

                case "p":
                    var paragraph = new Paragraph()
                    {
                        TextIndent = 17, FontSize = 16, Margin = new Windows.UI.Xaml.Thickness(6)
                    };
                    foreach (var childNode in node.ChildNodes)
                    {
                        AddChild(paragraph, ConvertHTMLNode(childNode));
                    }
                    return(paragraph);

                case "b":
                case "strong":
                    var bold = new Bold();
                    foreach (var childNode in node.ChildNodes)
                    {
                        bold.Inlines.Add(ConvertHTMLNode(childNode) as Inline);
                    }
                    return(bold);

                case "i":
                case "em":
                    var italics = new Italic();
                    foreach (var childNode in node.ChildNodes)
                    {
                        italics.Inlines.Add(ConvertHTMLNode(childNode) as Inline);
                    }
                    return(italics);

                case "u":
                    var underline = new Underline();
                    foreach (var childNode in node.ChildNodes)
                    {
                        underline.Inlines.Add(ConvertHTMLNode(childNode) as Inline);
                    }
                    return(underline);

                case "br":
                    return(new LineBreak());

                case "img":
                    var imageBlock = new Paragraph();
                    var image      = new InlineUIContainer();
                    var imageEx    = new ImageEx()
                    {
                        IsCacheEnabled = true, Stretch = Windows.UI.Xaml.Media.Stretch.Uniform, Padding = new Windows.UI.Xaml.Thickness(4)
                    };
                    imageEx.Source = node.GetAttributeValue("src", "");
                    image.Child    = imageEx;
                    imageBlock.Inlines.Add(image);
                    return(imageBlock);
                }
            }
            else
            {
                var text = new Run()
                {
                    Text = node.InnerText
                };
                return(text);
            }
            return(null);
        }
        private void UpdateContentsView(IEnumerable<LineViewModel> lines)
        {
            Uri severBaseUri = LightKindomHtmlClient.SeverBaseUri;
            ContentTextBlock.Blocks.Clear();
            bool prevLineBreakFlag = false;
            foreach (var line in lines)
            {
                var para = new Paragraph();
                para.SetValue(ParagrahViewModelProperty, line);
                if (!line.IsImage || line.Content == null)
                {
                    //if (line.HasComments)
                    //	para.Inlines.Add(new InlineUIContainer
                    //	{
                    //		Child = new SymbolIcon { Symbol = Symbol.Message },
                    //		Foreground = (SolidColorBrush)App.Current.Resources["AppAcentBrush"]
                    //	});
                    var run = new Run { Text = line.Content };
                    para.Inlines.Add(new Run { Text = CommentIndicator, FontFamily = SegoeUISymbolFontFamily, Foreground = TransparentBrush });
                    para.Inlines.Add(run);
                    //para.TextIndent = ContentTextBlock.FontSize * 1;
                    prevLineBreakFlag = true;
                    para.Margin = new Thickness(0, 0, 0, 10);
                }
                else
                {
                    //para.LineHeight = 2;
                    Size padding = new Size(ContentTextBlock.Padding.Left + ContentTextBlock.Padding.Right, ContentTextBlock.Padding.Top + ContentTextBlock.Padding.Bottom);
                    //bitmap.DownloadProgress +=
                    //var img = new Image
                    //{
                    //	Source = bitmap,
                    //	//MaxWidth = ContentColumns.ColumnWidth - padding.Width - 1,
                    //	//Height = ContentColumns.ColumnHeight - padding.Height - PictureMargin,
                    //	HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Stretch,
                    //	VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Stretch,
                    //	Stretch = Stretch.Uniform,
                    //};
                    //img.DataContext = img;
                    //Flyout.SetAttachedFlyout(img, this.Resources["ImagePreviewFlyout"] as Flyout);
                    //img.Tapped += Illustration_Tapped;
                    //GetLocalImageAsync(new Uri(severBaseUri, line.Content)).ContinueWith(async (task) =>
                    //{
                    //	await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,()=>{
                    //		if (task.IsFaulted || task.Result == null)
                    //		{
                    //			img.Source = new BitmapImage(new Uri(severBaseUri, line.Content));
                    //		}
                    //		else
                    //		{
                    //			var localUri = task.Result;
                    //			img.Source = new BitmapImage(localUri);
                    //		}
                    //	});
                    //});


                    //var illustration = new Border
                    //{
                    //	HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Stretch,
                    //	VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Stretch,
                    //	Width = ContentColumns.ColumnWidth - padding.Width - 1,
                    //	Height = ContentColumns.ColumnHeight - padding.Height - PictureMargin,
                    //	Background = null,
                    //	BorderBrush = null,
                    //	Child = img,
                    //};

                    var illustration = LineViewCCGTemplate.LoadContent() as IllustrationView;
                    illustration.DataContext = line;
                    illustration.Width = ContentColumns.ColumnWidth - padding.Width - 1;
                    illustration.Height = ContentColumns.ColumnHeight - padding.Height - PictureMargin;
                    illustration.LoadIllustrationLine(line);
                    //LoadItemIllustation(illustration, line);
                    (illustration.FindName("ImageContent") as Image).SizeChanged += Image_SizeChanged;
                    //var bitmap = (illustration.GetFirstDescendantOfType<Image>().Source as BitmapImage);
                    //var pb = illustration.GetFirstDescendantOfType<ProgressBar>();
                    //bitmap.SetValue(BitmapLoadingIndicatorProperty, pb);

                    var inlineImg = new InlineUIContainer
                    {
                        Child = illustration // img
                    };

                    //inlineImg.FontSize = 620;
                    para.TextAlignment = TextAlignment.Center;
                    if (prevLineBreakFlag)
                    {
                        para.Inlines.Add(new Run { Text = "\n" });
                        illustration.Margin = new Thickness(0, 5, 0, 0);
                        //img.Margin = new Thickness(0, 5, 0, 0);
                    }
                    else
                    {
                        para.Inlines.Add(new Run { Text = " \n", FontSize = 5 });
                    }
                    para.Inlines.Add(inlineImg);

                    prevLineBreakFlag = false;
                }
                ContentTextBlock.Blocks.Add(para);
            }
            var ptr = ContentTextBlock.ContentStart;
            //ContentColumns.Measure(new Size(ContentScrollViewer.Height, double.PositiveInfinity));
            //ContentColumns.Children.Count;
            RichTextColumns.ResetOverflowLayout(ContentColumns, null);
        }
Example #32
0
 /// <summary>
 /// Helper for logging
 /// </summary>
 /// <param name="logEntry"></param>
 void appendLog(string logEntry)
 {
     Run r = new Run();
     r.Text = logEntry;
     Paragraph p = new Paragraph();
     p.Inlines.Add(r);
     logResults.Blocks.Add(p);
 }
Example #33
0
        /// <summary>
        /// The methods provided in this section are simply used to allow
        /// NavigationHelper to respond to the page's navigation methods.
        /// <para>
        /// Page specific logic should be placed in event handlers for the  
        /// <see cref="NavigationHelper.LoadState"/>
        /// and <see cref="NavigationHelper.SaveState"/>.
        /// The navigation parameter is available in the LoadState method 
        /// in addition to page state preserved during an earlier session.
        /// </para>
        /// </summary>
        /// <param name="e">Provides data for navigation methods and event
        /// handlers that cannot cancel the navigation request.</param>
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            this.navigationHelper.OnNavigatedTo(e);
            var list = (List<String>)e.Parameter;
            String fileName = list.ElementAt(1);
            xmlReader = XmlReader.Create(fileName, new XmlReaderSettings());

            XmlSerializer x = new XmlSerializer(typeof(ExpertSystem), "http://tempuri.org/XMLSchema.xsd");
            expertSystem = (ExpertSystem)x.Deserialize(xmlReader);

            /*  this.WebViewDescription.NavigateToString(expertSystem.description);

              this.textBlock1.Text = expertSystem.description;

              String sourceshtml = "";

              foreach (Source s in expertSystem.sources)
              {
                  sourceshtml += s.linkDescription + "</br><font color=\"blue\">" + s.link + "</font></br></br>";
              }

              this.WebViewSources.NavigateToString(sourceshtml);*/
            DescriptionTextBlock.Blocks.Clear();
            SourcesTextBlock.Blocks.Clear();

            Run r = new Run();
            r.Text = expertSystem.description;
            Paragraph p = new Paragraph();
            p.Inlines.Add(r);

            DescriptionTextBlock.Blocks.Add(p);

            foreach (var s in expertSystem.sources)
            {
                Run description = new Run();
                description.Text = s.linkDescription + "\n";

                Run linklink = new Run();
                linklink.Text = s.link + "\n";
                
                Hyperlink link = new Hyperlink();
                link.Inlines.Add(linklink);
                link.NavigateUri = new System.Uri(s.link);

                Paragraph p1 = new Paragraph();
                p1.Inlines.Add(description);
                p1.Inlines.Add(link);

                SourcesTextBlock.Blocks.Add(p1);
            }
        }