Exemple #1
0
        public User()
        {
            InitializeComponent(); Loaded += (sender, e) => { if (ApplicationBar != null)
                                                              {
                                                                  ApplicationBar.MatchOverriddenTheme();
                                                              }
            };



            viewModel   = new UserModel();
            DataContext = viewModel;

            this.Loaded += (sender, e) =>
            {
                string userName;
                if (!NavigationContext.QueryString.TryGetValue("user", out userName))
                {
                    NavigationService.GoBack();
                    return;
                }
                viewModel.Loaded(userName);
            };

            viewModel.PropertyChanged += (sender, e) =>
            {
                if (e.PropertyName == "ScreenName")
                {
                    TweetList.Resource = new TwitterResource {
                        String = "Tweets:" + viewModel.ScreenName, User = DataTransfer.CurrentAccount
                    };
                    TweetList.Load();
                    MentionsList.Resource = new TwitterResource {
                        Data = "@" + viewModel.ScreenName, Type = ResourceType.Search, User = DataTransfer.CurrentAccount
                    };
                    MentionsList.Load();
                }
            };

            TweetList.Loader.PropertyChanged += (sender, e) =>
            {
                if (e.PropertyName == "IsLoading")
                {
                    viewModel.IsLoading = TweetList.Loader.IsLoading;
                }
            };

            MentionsList.Loader.PropertyChanged += (sender, e) =>
            {
                if (e.PropertyName == "IsLoading")
                {
                    viewModel.IsLoading = MentionsList.Loader.IsLoading;
                }
            };

            TweetList.Loader.Cached    = false;
            MentionsList.Loader.Cached = false;
        }
Exemple #2
0
        /// <summary>
        /// Checks if the text has any occurencies of twitter Ids, is so updates the instance, otherwise it adds it to the mention list.
        /// </summary>
        /// <param name="text"></param>
        protected void AddToMentionList(string text)
        {
            // Prevent throwing exception for empty text
            if (text.Length == 0)
            {
                return;
            }
            // Split the text in order to find each id
            // If the first char is a @ then set a flag, else leave it to zero
            var flag = 0;

            if (text[0] == '@')
            {
                flag = 1;
            }
            string[] textSplit = text.Split('@');
            for (var counter = 0; counter < textSplit.Length; counter++)
            {
                // Check if first word in order to deal with the eventual @ lost on splitting
                if (counter == 0 && flag == 0)
                {
                    continue;
                }
                var id = '@' + textSplit[counter];
                foreach (Match match in Regex.Matches(id, @"\B\@\w{1,15}\b"))
                {
                    if (MentionsList.ContainsKey(match.ToString()))
                    {
                        MentionsList[match.ToString()] += 1;
                    }
                    else
                    {
                        MentionsList.Add(match.ToString(), 1);
                    }
                }
            }
        }
Exemple #3
0
        // Open new Mentions List window
        private void MentionsListBtn_Click(object sender, RoutedEventArgs e)
        {
            MentionsList mentionsListWindow = new MentionsList();

            mentionsListWindow.Show();
        }