public DependencyObject[] Generate(HtmlNode node, IHtmlTextBlock textBlock)
		{
			var ctrl = GenerateSingle(node, textBlock);
			if (ctrl != null)
				return new [] { ctrl };
			return null; 
		}
		private static void CreateTextBox(List<DependencyObject> list, List<Inline> current, IHtmlTextBlock textBlock)
		{
			if (current.Count > 0)
			{
				var p = new Paragraph();
				foreach (var r in current)
					p.Inlines.Add(r);

#if !WINRT
				var tb = new RichTextBox();
				tb.Background = textBlock.Background;
				tb.Margin = new Thickness(-12, textBlock.ParagraphMargin, -12, textBlock.ParagraphMargin);
#else
				var tb = new RichTextBlock();
				tb.IsTextSelectionEnabled = false;
				tb.Margin = new Thickness(0, textBlock.ParagraphMargin, 0, textBlock.ParagraphMargin);
#endif
				tb.Blocks.Add(p);
				tb.Foreground = textBlock.Foreground;
				tb.FontSize = textBlock.FontSize;
				tb.FontFamily = textBlock.FontFamily;
				
				list.Add(tb);
				current.Clear();
			}
		}
Exemple #3
0
        public DependencyObject[] Generate(HtmlNode node, IHtmlTextBlock textBlock)
        {
            var items = node.GetLeaves(textBlock).ToList();

            if (items.Count == 1 && items[0] is Panel)
            {
                items = new List <DependencyObject> {
                    items[0]
                }
            }
            ;

            if (items.Count > 0)
            {
                var elem = items.First() as FrameworkElement;
                if (elem != null)
                {
                    elem.Margin = new Thickness(elem.Margin.Left, 0, elem.Margin.Right, elem.Margin.Bottom);
                }

                elem = items.Last() as FrameworkElement;
                if (elem != null)
                {
                    elem.Margin = new Thickness(elem.Margin.Left, elem.Margin.Top, elem.Margin.Right, 0);
                }
            }

            return(items.ToArray());
        }
    }
Exemple #4
0
        public DependencyObject[] Generate(HtmlNode node, IHtmlTextBlock textBlock)
        {
            var list = new List <Grid>();

            foreach (var child in node.Children.Where(c => c.Value == "li"))
            {
                var grid = new Grid();
                grid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(20)
                });
                grid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(1, GridUnitType.Star)
                });

                var tb = new TextBlock();
                tb.Foreground = textBlock.Foreground;
                tb.FontSize   = textBlock.FontSize;
                tb.FontFamily = textBlock.FontFamily;
                tb.Margin     = new Thickness();
                tb.Text       = "• ";

                grid.Children.Add(tb);
                Grid.SetColumn(tb, 0);

                var panel = new StackPanel();

                child.ToHtmlBlock();
                foreach (var c in child.GetLeaves(textBlock).OfType <UIElement>())
                {
                    var frameworkElement = c as FrameworkElement;
                    if (frameworkElement != null)
                    {
                        frameworkElement.HorizontalAlignment = HorizontalAlignment.Stretch;
                    }
                    panel.Children.Add(c);
                }

                grid.Children.Add(panel);
                Grid.SetColumn(panel, 1);

                list.Add(grid);
            }

            var first = list.FirstOrDefault();

            if (first != null)
            {
                first.Margin = new Thickness(0, textBlock.ParagraphMargin, 0, 0);
            }

            var last = list.LastOrDefault();

            if (last != null)
            {
                last.Margin = new Thickness(0, 0, 0, textBlock.ParagraphMargin);
            }

            return(list.OfType <DependencyObject>().ToArray());
        }
Exemple #5
0
 protected virtual Action CreateLinkAction(Hyperlink hyperlink, string link, IHtmlTextBlock textBlock)
 {
     if (link.StartsWith("mailto:"))
     {
         return () => new EmailComposeTask {
                    To = link.Substring(7)
         }
     }
Exemple #6
0
 protected override Action CreateLinkAction(Hyperlink hyperlink, string link, IHtmlTextBlock textBlock)
 {
     if (link.StartsWith("tel:"))
     {
         return () => new PhoneCallTask {
                    PhoneNumber = link.Substring(4)
         }
     }
Exemple #7
0
        public override DependencyObject GenerateSingle(HtmlNode node, IHtmlTextBlock textBlock)
        {
            try
            {
                var uri = node.Attributes["src"];

                var height = 0;
                if (node.Attributes.ContainsKey("height"))
                {
                    int.TryParse(node.Attributes["height"], out height);
                }

                var width = 0;
                if (node.Attributes.ContainsKey("width"))
                {
                    int.TryParse(node.Attributes["width"], out width);
                }

                if (height == 1 && width == 1)
                {
                    return(null);
                }

                var image     = new Image();
                var imgSource = new BitmapImage(new Uri(uri));
                var block     = new ImageBlock
                {
                    Image      = image,
                    UserHeight = height,
                    UserWidth  = width,
                    Source     = imgSource
                };

                imgSource.ImageOpened += delegate { block.Update(textBlock.ActualWidth); };

                image.HorizontalAlignment = HorizontalAlignment.Left;
                image.Source = imgSource;
                image.Margin = new Thickness(0, textBlock.ParagraphMargin, 0, textBlock.ParagraphMargin);

                if (width > 0)
                {
                    image.Width = width;
                }
                if (height > 0)
                {
                    image.Height = height;
                }

                textBlock.SizeDependentControls.Add(block);
                return(image);
            }
            catch
            {
                return(null);
            }
        }
		public override DependencyObject GenerateSingle(HtmlNode node, IHtmlTextBlock textBlock)
		{
			foreach (var c in node.GetLeaves(textBlock))
			{
				var element = c as TextElement;
				if (element != null)
					element.FontWeight = FontWeights.Bold;
			}
			return null;
		}
		public DependencyObject[] Generate(HtmlNode node, IHtmlTextBlock textBlock)
		{
			var list = new List<DependencyObject>();

			var addTopMargin = true; 
			var current = new List<Inline>();
			foreach (var c in node.GetLeaves(textBlock))
			{
				if (c is Run && UseTextSplitting && ((Run)c).Text.Contains("\n")) // used to avoid 2048px max control size
				{
					// split text
					var run = (Run) c;
					var splits = run.Text.Split('\n');

					// join some splits to avoid small junks 
					var currentSplit = "";
					var newSplits = new List<string>();
					for (var i = 0; i < splits.Length; i++)
					{
						var split = splits[i];
						if (i != 0 && currentSplit.Length + split.Length > 16)
						{
							newSplits.Add(currentSplit);
							currentSplit = split;
						}
						else
							currentSplit += (i != 0 ? "\n" : "") + split;
					}
					newSplits.Add(currentSplit);

					// create multiple text blocks
					splits = newSplits.ToArray();
					for (var i = 0; i < splits.Length; i++)
					{
						var split = splits[i];
						current.Add(new Run { Text = split });
						if (i < splits.Length - 1) // dont create for last
							CreateTextBox(list, current, textBlock, i == 0 && addTopMargin, false);
					}
                    addTopMargin = list.Count == 0; 
				} else if (c is Inline)
					current.Add((Inline)c);
				else
				{
					CreateTextBox(list, current, textBlock, addTopMargin, true);
					list.Add(c);
					addTopMargin = true; 
				}
			}
			CreateTextBox(list, current, textBlock, addTopMargin, true);

			if (list.Count == 0)
				return null;
			return list.ToArray();
		}
Exemple #10
0
        public DependencyObject[] Generate(HtmlNode node, IHtmlTextBlock textBlock)
        {
            var ctrl = GenerateSingle(node, textBlock);

            if (ctrl != null)
            {
                return new [] { ctrl }
            }
            ;
            return(null);
        }
Exemple #11
0
 public override DependencyObject GenerateSingle(HtmlNode node, IHtmlTextBlock textBlock)
 {
     foreach (var c in node.GetLeaves(textBlock))
     {
         var element = c as TextElement;
         if (element != null)
         {
             element.FontWeight = FontWeights.Bold;
         }
     }
     return(null);
 }
Exemple #12
0
		public DependencyObject[] GetLeaves(IHtmlTextBlock textBlock)
		{
			var list = new List<DependencyObject>();
			foreach (var c in Children)
			{
				var ctrl = c.GetControls(textBlock);
				if (ctrl != null)
					list.AddRange(ctrl);
				else
					list.AddRange(c.GetLeaves(textBlock));
			}
			return list.ToArray();
		}
Exemple #13
0
        public override DependencyObject GenerateSingle(HtmlNode node, IHtmlTextBlock textBlock)
        {
            foreach (var c in node.GetLeaves(textBlock))
            {
                var element = c as TextElement;
                if (element != null)
#if WINRT
                { element.FontStyle = FontStyle.Italic; }
#else
                { element.FontStyle = FontStyles.Italic; }
#endif
            }
            return(null);
        }
Exemple #14
0
		public override DependencyObject GenerateSingle(HtmlNode node, IHtmlTextBlock textBlock)
		{
			foreach (var c in node.GetLeaves(textBlock))
			{
				var element = c as TextElement;
				if (element != null)
#if WINRT
                    element.FontStyle = FontStyle.Italic;
#else
                    element.FontStyle = FontStyles.Italic;
#endif
			}
			return null; 
		}
Exemple #15
0
 public DependencyObject[] GetControls(IHtmlTextBlock textBlock)
 {
     if (!loaded)
     {
         var value     = IsTag ? Value : "text";
         var generator = textBlock.Generators.ContainsKey(value) ? textBlock.Generators[value] :
                         (textBlock.Generators.ContainsKey("unknown") ? textBlock.Generators["unknown"] : null);
         if (generator != null)
         {
             controls = generator.Generate(this, textBlock);
         }
         loaded = true;
     }
     return(controls);
 }
Exemple #16
0
        public DependencyObject[] Generate(HtmlNode node, IHtmlTextBlock textBlock)
        {
            try
            {
                var link = node.Attributes["href"];

                var block = new TextBlock();
                block.Foreground = Foreground;

                var element = new InlineUIContainer();
                element.Child = block;

                var hr = new Underline();
                foreach (var child in node.Children)
                {
                    var leaves = child.GetLeaves(textBlock).ToArray();
                    if (leaves.Length > 0)
                    {
                        foreach (var item in leaves.OfType <Inline>())
                        {
                            hr.Inlines.Add(item);
                        }
                    }
                    else if (!string.IsNullOrEmpty(child.Value))
                    {
                        hr.Inlines.Add(new Run {
                            Text = child.Value
                        });
                    }
                }
                block.Inlines.Add(hr);

                var action = CreateLinkAction(block, link, textBlock);
                block.Tapped += (sender, e) =>
                {
                    if (!e.Handled)
                    {
                        e.Handled = true;
                        action();
                    }
                };
                return(new DependencyObject[] { element });
            }
            catch
            {
                return(node.GetLeaves(textBlock)); // suppress link
            }
        }
Exemple #17
0
        public DependencyObject[] Generate(HtmlNode node, IHtmlTextBlock textBlock)
        {
            try
            {
                var link = node.Attributes["href"];

                var hr = new Hyperlink();
                hr.MouseOverForeground = textBlock.Foreground;
                hr.Foreground          = textBlock.Foreground;
                hr.TextDecorations     = TextDecorations.Underline;

                foreach (var child in node.Children)
                {
                    var leaves = child.GetLeaves(textBlock).ToArray();
                    if (leaves.Length > 0)
                    {
                        foreach (var item in leaves.OfType <Inline>())
                        {
                            hr.Inlines.Add(item);
                        }
                    }
                    else if (!string.IsNullOrEmpty(child.Value))
                    {
                        hr.Inlines.Add(new Run {
                            Text = child.Value
                        });
                    }
                }

                var action     = CreateLinkAction(hr, link, textBlock);
                var origAction = action;
                action = delegate
                {
                    if (!PhoneApplication.IsNavigating)
                    {
                        origAction();
                    }
                };

                hr.Command = new RelayCommand(action);
                return(new DependencyObject[] { hr });
            }
            catch
            {
                return(node.GetLeaves(textBlock));                // suppress link
            }
        }
Exemple #18
0
		public DependencyObject[] Generate(HtmlNode node, IHtmlTextBlock textBlock)
		{
			var list = new List<Grid>();
			foreach (var child in node.Children.Where(c => c.Value == "li"))
			{
				var grid = new Grid();
				grid.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
				grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });

				var tb = new TextBlock();
				tb.Foreground = textBlock.Foreground;
				tb.FontSize = textBlock.FontSize;
				tb.FontFamily = textBlock.FontFamily;
				tb.Margin = new Thickness();
				tb.Text = "• ";

				grid.Children.Add(tb);
				Grid.SetColumn(tb, 0);

				var panel = new StackPanel();

				child.ToHtmlBlock();
				foreach (var c in child.GetLeaves(textBlock).OfType<UIElement>())
				{
					var frameworkElement = c as FrameworkElement;
					if (frameworkElement != null)
						frameworkElement.HorizontalAlignment = HorizontalAlignment.Stretch;
					panel.Children.Add(c);
				}

				grid.Children.Add(panel);
				Grid.SetColumn(panel, 1);

				list.Add(grid);
			}

			var first = list.FirstOrDefault();
			if (first != null)
				first.Margin = new Thickness(0, textBlock.ParagraphMargin, 0, 0);

			var last = list.LastOrDefault();
			if (last != null)
				last.Margin = new Thickness(0, 0, 0, textBlock.ParagraphMargin);

			return list.OfType<DependencyObject>().ToArray();
		}
		public override DependencyObject GenerateSingle(HtmlNode node, IHtmlTextBlock textBlock)
		{
			try
			{
				var uri = node.Attributes["src"];

				var height = 0;
				if (node.Attributes.ContainsKey("height"))
					int.TryParse(node.Attributes["height"], out height);

				var width = 0;
				if (node.Attributes.ContainsKey("width"))
					int.TryParse(node.Attributes["width"], out width);

				if (height == 1 && width == 1)
					return null; 

				var image = new Image();
				var imgSource = new BitmapImage(new Uri(uri));
				var block = new ImageBlock
				            	{
				            		Image = image, 
				            		UserHeight = height, 
				            		UserWidth = width, 
				            		Source = imgSource
				            	};

				imgSource.ImageOpened += delegate { block.Update(textBlock.ActualWidth); };

				image.HorizontalAlignment = HorizontalAlignment.Left;
				image.Source = imgSource;
				image.Margin = new Thickness(0, textBlock.ParagraphMargin, 0, textBlock.ParagraphMargin); 

				if (width > 0)
					image.Width = width;
				if (height > 0)
					image.Height = height;

				textBlock.SizeDependentControls.Add(block);
				return image;
			}
			catch
			{
				return null;
			}
		}
Exemple #20
0
        public DependencyObject[] GetLeaves(IHtmlTextBlock textBlock)
        {
            var list = new List <DependencyObject>();

            foreach (var c in Children)
            {
                var ctrl = c.GetControls(textBlock);
                if (ctrl != null)
                {
                    list.AddRange(ctrl);
                }
                else
                {
                    list.AddRange(c.GetLeaves(textBlock));
                }
            }
            return(list.ToArray());
        }
Exemple #21
0
        public DependencyObject[] Generate(HtmlNode node, IHtmlTextBlock textBlock)
        {
            try
            {
                var link = node.Attributes["href"];

                var block = new TextBlock();
                block.Foreground = Foreground;

                var element = new InlineUIContainer();
                element.Child = block;

                var hr = new Underline();
                foreach (var child in node.Children)
                {
                    var leaves = child.GetLeaves(textBlock).ToArray();
                    if (leaves.Length > 0)
                    {
                        foreach (var item in leaves.OfType<Inline>())
                            hr.Inlines.Add(item);
                    }
                    else if (!string.IsNullOrEmpty(child.Value))
                        hr.Inlines.Add(new Run { Text = child.Value });
                }
                block.Inlines.Add(hr);

                var action = CreateLinkAction(block, link, textBlock);
                block.Tapped += (sender, e) =>
                {
                    if (!e.Handled)
                    {
                        e.Handled = true;
                        action();
                    }
                };
                return new DependencyObject[] { element };
            }
            catch
            {
                return node.GetLeaves(textBlock); // suppress link 
            }
        }
		public DependencyObject[] Generate(HtmlNode node, IHtmlTextBlock textBlock)
		{
			var list = new List<DependencyObject>();

			var current = new List<Inline>();
			foreach (var c in node.GetLeaves(textBlock))
			{
				if (c is Inline)
					current.Add((Inline)c);
				else
				{
					CreateTextBox(list, current, textBlock);
					list.Add(c);
				}
			}
			CreateTextBox(list, current, textBlock);

			if (list.Count == 0)
				return null;
			return list.ToArray();
		}
Exemple #23
0
		public DependencyObject[] Generate(HtmlNode node, IHtmlTextBlock textBlock)
		{
			try
			{
				var link = node.Attributes["href"];

				var hr = new Hyperlink();
				hr.MouseOverForeground = textBlock.Foreground; 
				hr.Foreground = textBlock.Foreground;
				hr.TextDecorations = TextDecorations.Underline;

				foreach (var child in node.Children)
				{
					var leaves = child.GetLeaves(textBlock).ToArray();
					if (leaves.Length > 0)
					{
						foreach (var item in leaves.OfType<Inline>())
							hr.Inlines.Add(item);
					} else if (!string.IsNullOrEmpty(child.Value))
						hr.Inlines.Add(new Run { Text = child.Value });
				}

				var action = CreateLinkAction(hr, link, textBlock);
				var origAction = action;
				action = delegate
				{
					if (!PhoneApplication.IsNavigating)
						origAction();
				};

				hr.Command = new RelayCommand(action);
				return new DependencyObject[] { hr };
			}
			catch
			{
				return node.GetLeaves(textBlock); // suppress link 
			}
		}
        async internal static void Generate(this IHtmlTextBlock me)
        {
            var html      = me.Html;
            var itemsCtrl = (ItemsControl)me;

            if (string.IsNullOrEmpty(html))
            {
                itemsCtrl.Items.Clear();
            }

            var tb = me as HtmlTextBlock;

            if (tb != null)
            {
                tb.UpdateHeader();
            }

            if (string.IsNullOrEmpty(html))
            {
                if (tb != null)
                {
                    tb.UpdateFooter();
                }

                if (me is HtmlTextBlock)
                {
                    ((HtmlTextBlock)me).CallHtmlLoaded();
                }
                else
                {
                    ((FixedHtmlTextBlock)me).CallHtmlLoaded();
                }
                return;
            }

            HtmlNode node = null;

#if WP7
            await Task.Factory.StartNew(() =>
#else
            await Task.Run(() =>
#endif
            {
                try
                {
                    var parser = new HtmlParser();
                    node = parser.Parse(html);
                }
                catch { }
            });

            if (html == me.Html)
            {
                if (node != null)
                {
                    try
                    {
                        itemsCtrl.Items.Clear();

                        if (tb != null)
                        {
                            tb.UpdateHeader();
                        }

                        foreach (var c in node.GetControls(me))
                        {
                            itemsCtrl.Items.Add(c);
                        }

                        if (tb != null)
                        {
                            tb.UpdateFooter();
                        }
                    }
                    catch { }
                }

                if (me is HtmlTextBlock)
                {
                    ((HtmlTextBlock)me).CallHtmlLoaded();
                }
                else
                {
                    ((FixedHtmlTextBlock)me).CallHtmlLoaded();
                }
            }
        }
Exemple #25
0
		public DependencyObject[] GetControls(IHtmlTextBlock textBlock)
		{
			if (!loaded)
			{
				var value = IsTag ? Value : "text";
				var generator = textBlock.Generators.ContainsKey(value) ? textBlock.Generators[value] :
					(textBlock.Generators.ContainsKey("unknown") ? textBlock.Generators["unknown"] : null);
				if (generator != null)
					controls = generator.Generate(this, textBlock);
				loaded = true; 
			}
			return controls;
		}
Exemple #26
0
 protected virtual Action CreateLinkAction(TextBlock hyperlink, string link, IHtmlTextBlock textBlock)
 {
     return(() => Launcher.LaunchUriAsync(new Uri(link)));
 }
Exemple #27
0
 public DependencyObject[] Generate(HtmlNode node, IHtmlTextBlock textBlock)
 {
     return(new DependencyObject[] {});
 }
Exemple #28
0
 public abstract DependencyObject GenerateSingle(HtmlNode node, IHtmlTextBlock textBlock);
		protected override Action CreateLinkAction(Hyperlink hyperlink, string link, IHtmlTextBlock textBlock)
		{
			if (link.StartsWith("tel:"))
				return () => new PhoneCallTask { PhoneNumber = link.Substring(4) }.Show();
			return base.CreateLinkAction(hyperlink, link, textBlock);
		}
Exemple #30
0
 public override DependencyObject GenerateSingle(HtmlNode node, IHtmlTextBlock textBlock)
 {
     return(new Run {
         Text = node.Value
     });
 }
Exemple #31
0
        public DependencyObject[] Generate(HtmlNode node, IHtmlTextBlock textBlock)
        {
            var list = new List <DependencyObject>();

            var addTopMargin = true;
            var current      = new List <Inline>();

            foreach (var c in node.GetLeaves(textBlock))
            {
                if (c is Run && UseTextSplitting && ((Run)c).Text.Contains("\n"))                 // used to avoid 2048px max control size
                {
                    // split text
                    var run    = (Run)c;
                    var splits = run.Text.Split('\n');

                    // join some splits to avoid small junks
                    var currentSplit = "";
                    var newSplits    = new List <string>();
                    for (var i = 0; i < splits.Length; i++)
                    {
                        var split = splits[i];
                        if (i != 0 && currentSplit.Length + split.Length > 16)
                        {
                            newSplits.Add(currentSplit);
                            currentSplit = split;
                        }
                        else
                        {
                            currentSplit += (i != 0 ? "\n" : "") + split;
                        }
                    }
                    newSplits.Add(currentSplit);

                    // create multiple text blocks
                    splits = newSplits.ToArray();
                    for (var i = 0; i < splits.Length; i++)
                    {
                        var split = splits[i];
                        current.Add(new Run {
                            Text = split
                        });
                        if (i < splits.Length - 1)                         // dont create for last
                        {
                            CreateTextBox(list, current, textBlock, i == 0 && addTopMargin, false);
                        }
                    }
                    addTopMargin = list.Count == 0;
                }
                else if (c is Inline)
                {
                    current.Add((Inline)c);
                }
                else
                {
                    CreateTextBox(list, current, textBlock, addTopMargin, true);
                    list.Add(c);
                    addTopMargin = true;
                }
            }
            CreateTextBox(list, current, textBlock, addTopMargin, true);

            if (list.Count == 0)
            {
                return(null);
            }
            return(list.ToArray());
        }
Exemple #32
0
        private void CreateTextBox(List <DependencyObject> list, List <Inline> current, IHtmlTextBlock textBlock,
                                   bool addTopMargin, bool addBottomMargin)
        {
            if (current.Count > 0)
            {
                var p = new Paragraph();
                foreach (var r in current)
                {
                    p.Inlines.Add(r);
                }

#if !WINRT
                var tb = new RichTextBox();
                tb.Background = textBlock.Background;
                tb.Margin     = new Thickness(-12, addTopMargin ? textBlock.ParagraphMargin : 0, -12, addBottomMargin ? textBlock.ParagraphMargin : 0);
#else
                var tb = new RichTextBlock();
                tb.IsTextSelectionEnabled = false;                 // TODO: when to add topmargin
                tb.Margin = new Thickness(0, /*addTopMargin ? textBlock.ParagraphMargin :*/ 0, 0, addBottomMargin ? textBlock.ParagraphMargin : 0);
#endif
                tb.Blocks.Add(p);
                tb.Foreground = Foreground ?? textBlock.Foreground;
                tb.FontSize   = FontSize == 0 ? textBlock.FontSize : FontSize;
                tb.FontFamily = FontFamily ?? textBlock.FontFamily;
                tb.FontStyle  = FontStyle;
                tb.FontWeight = FontWeight;

                list.Add(tb);
                current.Clear();
            }
        }
Exemple #33
0
		protected virtual Action CreateLinkAction(Hyperlink hyperlink, string link, IHtmlTextBlock textBlock)
		{
			if (link.StartsWith("mailto:"))
				return () => new EmailComposeTask {To = link.Substring(7)}.Show();
			// 'tel:' removed because it needs CAP_PHONEDIALER capability! Use PhoneLinkGenerator from "- Other" directory. 

			try
			{
				var uri = link.StartsWith("http://") || link.StartsWith("https://") ?
					new Uri(link, UriKind.Absolute) : new Uri(textBlock.HtmlBaseUri, link);
				return () => new WebBrowserTask { Uri = uri }.Show();
			}
			catch (Exception)
			{

			}

			return () => { };
		}
		private void CreateTextBox(List<DependencyObject> list, List<Inline> current, IHtmlTextBlock textBlock, 
			bool addTopMargin, bool addBottomMargin)
		{
			if (current.Count > 0)
			{
				var p = new Paragraph();
				foreach (var r in current)
					p.Inlines.Add(r);

#if !WINRT
				var tb = new RichTextBox();
				tb.Background = textBlock.Background;
				tb.Margin = new Thickness(-12, addTopMargin ? textBlock.ParagraphMargin : 0, -12, addBottomMargin ? textBlock.ParagraphMargin : 0);
#else
				var tb = new RichTextBlock();
				tb.IsTextSelectionEnabled = false; // TODO: when to add topmargin
				tb.Margin = new Thickness(0, /*addTopMargin ? textBlock.ParagraphMargin :*/ 0, 0, addBottomMargin ? textBlock.ParagraphMargin : 0);
#endif
				tb.Blocks.Add(p);
				tb.Foreground = Foreground ?? textBlock.Foreground;
				tb.FontSize = FontSize == 0 ? textBlock.FontSize : FontSize;
				tb.FontFamily = FontFamily ?? textBlock.FontFamily;
				tb.FontStyle = FontStyle;
				tb.FontWeight = FontWeight;
				
				list.Add(tb);
				current.Clear();
			}
		}
Exemple #35
0
		public DependencyObject[] Generate(HtmlNode node, IHtmlTextBlock textBlock)
		{
			return new DependencyObject[] {};
		}
		public abstract DependencyObject GenerateSingle(HtmlNode node, IHtmlTextBlock textBlock);
Exemple #37
0
 protected virtual Action CreateLinkAction(TextBlock hyperlink, string link, IHtmlTextBlock textBlock)
 {
     return () => Launcher.LaunchUriAsync(new Uri(link));
 }