示例#1
0
        public void CreateInlineTextWithLinks()
        {
            string search = @"A bit of text here www.google.co.uk. and more.https://www.google.co.uk oh 
                              wow here's another one http://www.pjcsoftware.co.uk/. here's some more";

            Inline[] lines = WPFHelper.CreateInlineTextWithLinks(search, (o, e) => { });
            Assert.IsTrue(lines[0] is Run);
            Assert.IsFalse(lines[1] is Run);
            Assert.IsTrue(lines[2] is Run);
            Assert.IsFalse(lines[3] is Run);
            Assert.IsTrue(lines[4] is Run);
            Assert.IsFalse(lines[5] is Run);
            Assert.IsTrue(lines[6] is Run);
            Assert.AreEqual(7, lines.Length);
        }
示例#2
0
        /// <summary> Display list of tweets inside the Grid control </summary>
        private void AddResultsToGrid(List <TwitterStatus> StatusList)
        {
            grdTweets.RowDefinitions.Clear();
            grdTweets.Children.Clear();

            foreach (TwitterStatus Status in StatusList)
            {
                grdTweets.RowDefinitions.Add(new RowDefinition()
                {
                    Height = GridLength.Auto
                });

                // Create the text for grid
                TextBlock TextBlock = new TextBlock();
                TextBlock.Margin       = new Thickness(4);
                TextBlock.TextWrapping = TextWrapping.Wrap;

                if (Status.RetweetedStatus != null)
                {
                    TextBlock.Inlines.Add(new Italic(new Run(Environment.NewLine +
                                                             "Retweeted by " +
                                                             Status.User.ScreenName +
                                                             Environment.NewLine)));
                }

                TextBlock.Inlines.AddRange(WPFHelper.CreateInlineTextWithLinks(Status.Text, Hyperlink_RequestNavigate));
                string displayDate = Twitter.ConvertTwitterDateDisplay(Status.CreatedDate);
                TextBlock.Inlines.Add(new Italic(new Run(Environment.NewLine + displayDate)));
                Grid.SetColumn(TextBlock, 1);
                Grid.SetRow(TextBlock, grdTweets.RowDefinitions.Count - 1);
                grdTweets.Children.Add(TextBlock);

                Image ProfileImage = new Image();
                ProfileImage.Source  = WPFHelper.CreateImage(Status.User.ProfileImageUrl);
                ProfileImage.ToolTip = Status.User.Name;
                TwitterUser user = Status.User;

                ProfileImage.MouseDown += (o, e) => {
                    Profile ProfileWindow = new Profile(user);
                    ProfileWindow.ShowDialog();
                };

                Grid.SetColumn(ProfileImage, 0);
                Grid.SetRow(ProfileImage, grdTweets.RowDefinitions.Count - 1);
                grdTweets.Children.Add(ProfileImage);
            }
        }