Example #1
0
        public void Update(CStatus status)
        {
            Id            = status.Id;
            CreatedAt     = status.CreatedAt.LocalDateTime;
            FavoriteCount = status.FavoriteCount ?? 0;
            var extended = status.GetExtendedTweetElements();

            Text = $"{string.Join(" ",extended.HiddenPrefix.Select(x=>"@"+x.ScreenName))} {extended.TweetText.ToText()} {string.Join(" ",extended.HiddenSuffix.Select(x=>x.ExpandedUrl))}";
            InReplyToScreenName = status.InReplyToScreenName;
            InReplyToStatusId   = status.InReplyToStatusId;
            InReplyToUserId     = status.InReplyToUserId;
            Language            = status.Language;
            if (status.QuotedStatus != null)
            {
                QuotedStatusId = status.QuotedStatus.Id;
                QuotedStatus   = new Status(status.QuotedStatus);
            }
            RetweetCount = status.RetweetCount ?? 0;
            if (status.RetweetedStatus != null)
            {
                RetweetedStatusId = status.RetweetedStatus.Id;
                RetweetedStatus   = new Status(status.RetweetedStatus);
            }
            Source = status.ParseSource().Name;
            UserId = status.User.Id ?? -1;
            User   = new User(status.User);
        }
Example #2
0
 public EnemyBoss(SceneGame sc, BossPattern op, Status s)
 {
     SourceStatus = s;
     SourceUser = s.User;
     Phases = op(this);
     PhaseIndex = -1;
     MoveNextPhase();
 }
Example #3
0
 public StatusViewModel(MainWindowViewModel mw, Status st, bool isinc)
 {
     Kbtter = Kbtter.Instance;
     AdditionalMenus = ViewModelHelper.CreateReadOnlyDispatcherCollection(
         Kbtter.StatusMenus,
         p => new StatusAdditionalMenuViewModel(p, st),
         DispatcherHelper.UIDispatcher);
     main = mw;
     SourceStatus = st;
     OnelineText = st.Text;
     User = new UserViewModel(st.User, mw);
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="iNavigationService"></param>
 /// <param name="s"></param>
 /// <param name="twitterClient"></param>
 public TweetItemViewModel(INavigationService iNavigationService, Status s, TwitterClient twitterClient)
 {
     this._iNavigationService       = iNavigationService;
     this._tweetClient              = twitterClient;
     this._tweetModel.Value         = new TweetModel(s);
     this.Brush.Value               = this.SetBorderBrushColor();
     this.TweetVisibility.Value     = this.GetVisibility();
     this.ProtectedVisibility.Value = this.GetProtectedVisibility();
     this.SetPictureVisibility();
     this.SetRetweetForegroundAndText();
     this.SetFavoriteForeground();
     this.SetReplyToTweetText();
 }
Example #5
0
 public EnemyUser(SceneGame sc, CoroutineFunction<EnemyUser> op, Status s)
     : this()
 {
     Game = sc;
     SourceStatus = s;
     SourceUser = s.User;
     Operation = op(this);
     TotalHealth = Health = 1000 + (SourceStatus.User.StatusesCount / 10) + (DateTime.Now - SourceStatus.User.CreatedAt.LocalDateTime).Days * 3;
     Task.Run(() =>
     {
         Image = UserImageManager.GetUserImage(SourceStatus.User);
         IsImageLoaded = true;
     });
 }
Example #6
0
        public void SetTweet(Status tweet, string inReplyTo)
        {
            this.status = tweet;
            this.label_InReplyTo.Text = inReplyTo;
            this.toolTip.Active = false;

            if (70 < inReplyTo.Length)
            {
                this.label_InReplyTo.Text = inReplyTo.Substring(0, 70) + "...";
                this.toolTip.SetToolTip(this.label_InReplyTo, inReplyTo);
                this.toolTip.Active = true;
            }
            this.textBox_Input.Text =
                this.textBox_Input.Text.Insert(0, string.Format("@{0} ", this.status.User.ScreenName));
            this.button_ResetReply.Visible = true;
        }
Example #7
0
 public Kbtter4Draft(string text, DateTime time, bool isReply, Status reply)
 {
     Text = text;
     CreatedDate = time;
     if (isReply)
     {
         IsReply = true;
         InReplyToStatusId = reply.Id;
         InReplyToStatusOnelineText = reply.Text
             .Replace("\n", " ")
             .Replace("\r", " ")
             .Replace("&gt;", ">")
             .Replace("&lt;", "<")
             .Replace("&amp;", "&");
         InReplyToUserScreenName = reply.User.ScreenName;
         InReplyToUserProfileImageUri = reply.User.ProfileImageUrlHttps;
     }
 }
Example #8
0
        public static void Add(Status status)
        {
            try
            {
                string connstr = String.Format("Data Source={0};Version=3", cachePath);
                var conn = new SQLiteConnection(connstr);
                conn.Open();

                var cmd = new SQLiteCommand(conn);

                string query = String.Empty;

                query = @"INSERT INTO [Favorites] ([Id], [CreatedAt], [UserId], [Text], [State])
                VALUES (@Id, @CreateAt, @UserId, @Text, 0)";
                cmd.CommandText = query;
                cmd.Parameters.AddWithValue("@Id", status.Id);
                cmd.Parameters.AddWithValue("@CreateAt", status.CreatedAt);
                cmd.Parameters.AddWithValue("@UserId", status.User.Id);
                cmd.Parameters.AddWithValue("@Text", status.Text);

                cmd.ExecuteNonQuery();

                if (status.ExtendedEntities != null && status.ExtendedEntities.Media != null)
                {
                    foreach (var media in status.ExtendedEntities.Media)
                    {
                        query = "INSERT INTO [MediaUris] ([Id], [Uri]) VALUES (@Id, @Uri)";

                        cmd.CommandText = query;
                        cmd.Parameters.AddWithValue("@Id", status.Id);
                        cmd.Parameters.AddWithValue("@Uri", media.MediaUrl);
                        cmd.ExecuteNonQuery();
                    }
                }

                conn.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
    private async void conv(long? Id)
    {
      status = await tokens.Statuses.ShowAsync(id => Id);
      data.Addtweet(tweet, status);
      try
      {
        //if (status.ExtendedEntities.UserMentions[0].Id != null)
        //{
        if (status.InReplyToStatusId != null)
        { 
          var rep_status = status.InReplyToStatusId;
          //checkBlock.Text = rep_status.ToString();
        conv(rep_status);
        }
        else
        {
          conveView.ItemsSource = tweet;
        }
      }
      catch(Exception ex) {
        testBlock.Text = ex.Message;
        return;
      }
/*
      if (status.ExtendedEntities.UserMentions[0].Id == null)
      {
        conveView.ItemsSource = tweet;
        return;
      }
      else
      {
        
        var rep_status = status.Entities.UserMentions[0].ScreenName;
        //tweet.Add(new TweetClass.TweetInfo
        //{
        testBlock.Text = rep_status;
        //}
 // );
      }
      */

    }
Example #10
0
 public void TryAddStatus(Status st)
 {
     try
     {
         if (HasQuery)
         {
             Query.ClearVariables();
             Query.SetVariable("Status", st);
             if (Query.Execute().AsBoolean()) Statuses.Insert(0, st);
         }
         else
         {
             Statuses.Insert(0, st);
         }
         if (Statuses.Count > Setting.Timelines.HomeStatusTimelineMax) Statuses.RemoveAt(Statuses.Count - 1);
     }
     catch (Exception e)
     {
     }
 }
Example #11
0
        private void displayTimeline(ListView lv, Status tweet)
        {
            try
            {
                if (lv.InvokeRequired)
                {
                    delegateDispayTL d = new delegateDispayTL(displayTimeline);

                    this.Invoke(d, new object[] { lv, tweet });
                }
                else
                {
                    string[] msg = 
                    {
                        (tweet.RetweetedStatus != null ? tweet.RetweetedStatus : tweet).CreatedAt.LocalDateTime.ToString("yyyy/MM/dd(ddd) HH:mm:ss"),
                        (tweet.RetweetedStatus != null ? tweet.RetweetedStatus : tweet).User.ScreenName,
                        (tweet.RetweetedStatus != null ? tweet.RetweetedStatus : tweet).User.Name,
                        (tweet.RetweetedStatus != null ? tweet.RetweetedStatus : tweet).Text,
                        (tweet.RetweetedStatus != null ? tweet.RetweetedStatus : tweet).ToString()
                    };
                    ListViewItem item = new ListViewItem(msg);
                    item.Tag = tweet;

                    changeItemColor(item);

                    lv.Items.Insert(0, item);

                    if (this.markingUser == tweet.User.Id)
                    {
                        markUserInSpecifiedItem((long)tweet.User.Id, lv.Items[0]);
                    }
                }
            }
            catch(Exception ex)
            {
                util.ShowExceptionMessageBox(ex.Message, ex.StackTrace);
            }
        }
Example #12
0
        private void listView_Timeline_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            ListView lv = getFocusedListView();

            // 左クリック判定
            if (e.Button != MouseButtons.Left)
            {
                return;
            }

            // フォーカス判定
            ListViewItem item = lv.FocusedItem;
            if (!lv.FocusedItem.Bounds.Contains(e.Location))
            {
                return;
            }

            this.status = ((Status)item.Tag).RetweetedStatus != null ?
                ((Status)item.Tag).RetweetedStatus : ((Status)item.Tag);
            string inReplyTo = string.Format(
@"{0}: 
{1}",
                this.status.User.ScreenName,
                this.status.Text.Substring(0, this.status.Text.IndexOfAny(new char[] { '\0', '\n' }) + 1 == 0 ?
                    this.status.Text.Length : this.status.Text.IndexOfAny(new char[] { '\0', '\n' }) + 1));
            this.label_InReplyTo.Text = inReplyTo;
            this.toolTip.Active = false;
            
            if (70 < inReplyTo.Length)
            {
                this.label_InReplyTo.Text = inReplyTo.Substring(0, 70) + "...";
                this.toolTip.SetToolTip(this.label_InReplyTo, inReplyTo);
                this.toolTip.Active = true;
            }
            this.textBox_Input.Text =
                this.textBox_Input.Text.Insert(0, string.Format("@{0} ", this.status.User.ScreenName));
            this.button_ResetReply.Visible = true;

            this.textBox_Input.Focus();
        }
    private async void loadTweet(long? Id)
    {
      status = await tokens.Statuses.ShowAsync(id => Id);
      var tweet = new ObservableCollection<TweetClass.TweetInfo>();
      data.Addtweet(tweet, status);
      //tweet = data.replytweetinfo2(status);
      conveView.ItemsSource = tweet;
      //show(status);

    }
Example #14
0
 public Tweet(Status status, Account account)
 {
     _status = status;
     Account = account;
 }
Example #15
0
		private void favorite(Status tweet)
		{
			if ((bool)tweet.IsFavorited)
			{
				this.tokens.Favorites.DestroyAsync(id => tweet.Id);
				string message = string.Format("Un-Favorited to @{0}: {1}",
					tweet.User.ScreenName,
                    tweet.Text);
                changeStatus(message, NotificationStatus.DoFavorite);
			}
			else
			{
				this.tokens.Favorites.CreateAsync(id => tweet.Id);
				string message = string.Format("Favorited to @{0}: {1}",
					tweet.User.ScreenName,
                    tweet.Text);
                changeStatus(message, NotificationStatus.DoUnFavorite);
			}

            ListView lv = getFocusedListView();
            int index = lv.SelectedIndices[0];
            ((Status)lv.Items[index].Tag).IsFavorited = !((Status)lv.Items[index].Tag).IsFavorited;
            lv.Items[index].Selected = false;
            lv.Items[index].Selected = true;

			showFavTimeline(this.listView_Fav);
		}
Example #16
0
 private string ShowTweet(CoreTweet.Status tweet)
 {
     return(String.Format("{0} (@{1})  -- {2}\n{3}",
                          tweet.User.Name, tweet.User.ScreenName, tweet.CreatedAt.LocalDateTime, tweet.Text));
 }
Example #17
0
 /// <summary>
 /// ツイートをリツイートのキャッシュから削除します。
 /// </summary>
 /// <param name="st">ツイート。リツイートした元ツイートではなく、リツイート自体を指定しください。</param>
 public void RemoveRetweetCache(Status st)
 {
     if (RemoveRetweetCacheCommand == null) return;
     RemoveRetweetCacheCommand.Parameters["Id"].Value = st.Id;
     RemoveRetweetCacheCommand.ExecuteNonQuery();
 }
Example #18
0
		private void retweet(Status tweet)
		{
			/*
			if ((bool)tweet.IsRetweeted)
			{
				long retweetId = this.tokens.Statuses.Show(include_my_retweet => true).Id;
				this.tokens.Statuses.Destroy(id => retweetId);
			}
			else
			{
				this.tokens.Statuses.Retweet(id => tweet.Id);
			}
			*/

			this.tokens.Statuses.RetweetAsync(id => tweet.Id);

            ListView lv = getFocusedListView();
            int index = lv.SelectedIndices[0];
            ((Status)lv.Items[index].Tag).IsRetweeted = true;
            lv.Items[index].Selected = false;
            lv.Items[index].Selected = true;

			string message = string.Format("Retweeted to @{0}: {1}",
				tweet.User.ScreenName,
				tweet.Text);
            changeStatus(message, NotificationStatus.DoRetweet);
		}
 private async void conv(long? Id)
 {
   status2 = await tokens.Statuses.ShowAsync(id => Id);
   data.Addtweet(convetweet, status2);
   try
   {
     //if (status.ExtendedEntities.UserMentions[0].Id != null)
     //{
     if (status2.InReplyToStatusId != null)
     {
       var rep_status = status2.InReplyToStatusId;
       conv(rep_status);
     }
     else
     {
       conveView.ItemsSource = convetweet;
     }
   }
   catch (Exception ex)
   {
     testBlock.Text = ex.Message;
     return;
   }
 }
    private void show(Status status)
    {
      reptweetState.Text = "";

      tweetImage1.Source = null;
      tweetImage2.Source = null;
      tweetImage3.Source = null;
      tweetImage4.Source = null;

      // var tweet = new List<TweetClass.TweetInfo>();
      //var data = new Tweets();
      // ReplyId = item.Id;
      //replyBox.Text = item.ScreenName + " ";
      //tweetIdを送ろう
      // tweet = data.replytweetinfo(item);
      //replyView.ItemsSource = tweet;
      try
      {
        if (status.Entities.Urls != null)
        {

          urlView.ItemsSource = status.Entities.Urls;
          //testBlock.Text = item.urls.Length.ToString();
        }

      }
      catch { }

      try
      {
        if (status.ExtendedEntities.Media != null)
        {
          testBlock.Text = "";
          int media_num = status.ExtendedEntities.Media.Length;
          //var media = item.media;
          //int test = media.Length;
          //testBlock.Text = media_num.ToString();
          for (int n = 0; n < media_num; n++)
          {

            //var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read);
            //BitmapImage image = new BitmapImage();
            //image.SetSource(stream);

            var mediaurl = new Uri(status.ExtendedEntities.Media[n].MediaUrl);
           // testBlock.Text += mediaurl;

            BitmapImage imageSource = new BitmapImage(mediaurl);

            switch (n)
            {
              case 0:
                tweetImage1.Source = imageSource;

                break;
              case 1:
                tweetImage2.Source = imageSource;
                break;
              case 2:
                tweetImage3.Source = imageSource;
                break;
              case 3:
                tweetImage4.Source = imageSource;
                break;

            }

          }
        }

      }
      catch { }
      //this.replyBlock.Text = "Reply to " + item.ScreenName;

    }
 public TweetViewModel(CoreTweet.Status status)
 {
     this.status = status;
 }
Example #22
0
 /// <summary>
 /// 指定したリツイートの元ツイートを現在のキャッシュのユーザーがリツイートしているか検証します。
 /// </summary>
 /// <param name="st">ツイート。リツイートした元ツイートではなく、リツイート自体を指定しください。</param>
 /// <returns>存在した場合はtrue</returns>
 public bool IsRetweetedInCache(Status st)
 {
     if (IsRetweetedCommand == null) return false;
     IsRetweetedCommand.Parameters["OriginalId"].Value = st.RetweetedStatus.Id;
     using (var dr = IsRetweetedCommand.ExecuteReader())
     {
         return dr.Read();
     }
 }
Example #23
0
        public TweetItem(Status status, Control control)
        {
            InitializeComponent();

            parentFrame = control;

            this.status = status;
            this.user = status.User;
            innerUrl = "";
            imageBox[0] = ImageBox1;
            imageBox[1] = ImageBox2;
            imageBox[2] = ImageBox3;
            imageBox[3] = ImageBox4;

            if (status.Source.IndexOf("<a") >= 0)
            {
                Match m = TwitterTools.viaReg(status.Source);
                status.Source = m.Groups["via"].Value;
            }

            // 画像が含まれていたら表示する
            if (status.Entities.Media != null)
            {
                status.Text = status.Text.Replace(status.Entities.Media[0].Url, "");
                innerUrl = status.Entities.Media[0].ExpandedUrl;

                if (status.ExtendedEntities.Media != null)
                {
                    if (status.ExtendedEntities.Media[0].Type == "animated_gif")
                    {
                        StartButton.BackColor = Color.Transparent;
                        StartButton.Parent = ImageBox1;
                        StartButton.Visible = true;
                    }

                    for (int i = 0; i < status.ExtendedEntities.Media.Length; i++)
                    {
                        mediaEntity[i] = status.ExtendedEntities.Media[i];
                        imageBox[i].Source = new BitmapImage(new Uri(status.ExtendedEntities.Media[i].MediaUrl + ":small"));
                    }

                }
            }

            // 画像のないPictureBoxを消す
            for (int i = 0; i < imageBox.Length; i++)
            {
                if (imageBox[i].Source == null)
                {
                    grid.Children.Remove(imageBox[i]);
                }
            }

            //URLを置換
            foreach (var url in status.Entities.Urls)
            {
                Match m = TwitterTools.urlReg(status.Entities.Urls.ToString());
                status.Text = status.Text.Replace(url.Url, url.DisplayUrl);
                innerUrl = url.ExpandedUrl;
            }

            //リツイート→赤、リプライ→緑、自分宛→青
            if (status.RetweetedStatus != null)
            {
                BackColor = Color.FromArgb(50, 16, 16);

                ProfileImage.ImageLocation = status.RetweetedStatus.User.ProfileImageUrl.Replace("_normal", "");
                NameLabel.Content = status.RetweetedStatus.User.Name + " @" + status.RetweetedStatus.User.ScreenName;
                TextLabel.Content = status.RetweetedStatus.Text;

                RetweetProfileImage.ImageLocation = status.User.ProfileImageUrl.Replace("_normal", "");
                RetweetNameLabel.Content = "Retweeted by " + status.User.Name + " and " + status.RetweetCount.ToString() + " Users";
            }
            else
            {
                ProfileImage.ImageLocation = status.User.ProfileImageUrl.Replace("_normal", "");
                NameLabel.Content = status.User.Name + " @" + status.User.ScreenName;
                TextLabel.Content = WebUtility.HtmlDecode(status.Text);

                grid.Children.Remove(RetweetProfileImage);
                grid.Children.Remove(RetweetNameLabel);
            }

            if (TwitterTools.IsReply(status))
            {
                if (TwitterTools.IsReplyToMe(status))
                {
                    BackColor = Color.FromArgb(16, 16, 60);
                }
                else
                {
                    BackColor = Color.FromArgb(12, 55, 16);
                }
            }

            switch (parentFrame.Name)
            {
                case "MainFrame":
                    mainFrame = (MainFrame)control.TopLevelControl;

                    TimeLabel.Content = status.CreatedAt.LocalDateTime + " (via " + status.Source + ")";
                    TimeLabel.Location = new Point(59, TextLabel.Location.Y + TextLabel.Size.Height + 3);

                    // 画像位置調整
                    for (int i = 0; i < ImageBox.Length; i++)
                    {
                        if (imageBox[i] != null)
                        {
                            switch (i)
                            {
                                case 0:
                                    ImageBox1.Location = new Point(60, TimeLabel.Location.Y + TimeLabel.Size.Height + 3);
                                    break;
                                case 1:
                                    ImageBox2.Location = new Point(216, TimeLabel.Location.Y + TimeLabel.Size.Height + 3);
                                    break;
                                case 2:
                                    ImageBox3.Location = new Point(60, ImageBox1.Location.Y + ImageBox1.Size.Height + 3);
                                    break;
                                case 3:
                                    ImageBox4.Location = new Point(216, ImageBox2.Location.Y + ImageBox2.Size.Height + 3);
                                    break;
                                default:
                                    break;
                            }
                            StartButton.Location = new Point(50, 15);
                        }
                    }

                    if (status.IsFavorited.Value) FavoriteIcon.Image = Properties.Resources.favorite_b;

                    break;

                case "ProfileFrame":
                case "MentionFrame":
                    MaximumSize = new Size(240, 5000);
                    ProfileImage.Size = new Size(30, 30);

                    NameLabel.Location = new Point(35, 3);

                    TextLabel.Location = new Point(35, 18);
                    TextLabel.MinimumSize = new Size(205, 15);
                    TextLabel.MaximumSize = new Size(205, 4500);

                    TimeLabel.Text = status.CreatedAt.LocalDateTime + "\n(via " + status.Source + ")";
                    TimeLabel.Location = new Point(35, TextLabel.Location.Y + TextLabel.Size.Height + 3);

                    ReplyIcon.Location = new Point(170, TextLabel.Location.Y + TextLabel.Size.Height + 3);

                    RetweetIcon.Location = new Point(193, TextLabel.Location.Y + TextLabel.Size.Height + 3);

                    FavoriteIcon.Location = new Point(216, TextLabel.Location.Y + TextLabel.Size.Height + 3);

                    // 画像位置調整
                    for (int i = 0; i < ImageBox.Length; i++)
                    {
                        if (imageBox[i] != null)
                        {
                            imageBox[i].Size = new Size(120, 64);
                            switch (i)
                            {
                                case 0:
                                    ImageBox1.Location =
                                        new Point(ProfileImage.Location.X, TimeLabel.Location.Y + TimeLabel.Size.Height + 3);
                                    break;
                                case 1:
                                    ImageBox2.Location =
                                        new Point(ImageBox1.Location.X + ImageBox1.Size.Width + 4, TimeLabel.Location.Y + TimeLabel.Size.Height + 3);
                                    break;
                                case 2:
                                    ImageBox3.Location =
                                        new Point(ImageBox1.Location.X, ImageBox1.Location.Y + ImageBox1.Size.Height + 3);
                                    break;
                                case 3:
                                    ImageBox4.Location =
                                        new Point(ImageBox3.Location.X + ImageBox3.Size.Width + 4, ImageBox1.Location.Y + ImageBox1.Size.Height + 3);
                                    break;
                                default:
                                    break;
                            }
                            StartButton.Location = new Point(35, 7);
                        }
                    }

                    break;

                default:
                    break;
            }

            // リツイートユーザー情報の位置調整
            if (status.Entities.Media != null && status.ExtendedEntities.Media != null)
            {
                switch (status.ExtendedEntities.Media.Length)
                {
                    case 1:
                    case 2:
                        RetweetProfileImage.Location = new Point(3, ImageBox1.Location.Y + ImageBox1.Size.Height + 3);
                        RetweetNameLabel.Location = new Point(40, ImageBox1.Location.Y + ImageBox1.Size.Height + 3);
                        break;
                    case 3:
                    case 4:
                        RetweetProfileImage.Location = new Point(3, ImageBox3.Location.Y + ImageBox3.Size.Height + 3);
                        RetweetNameLabel.Location = new Point(40, ImageBox3.Location.Y + ImageBox3.Size.Height + 3);
                        break;
                }
            }
            else
            {
                RetweetProfileImage.Location = new Point(3, TimeLabel.Location.Y + TimeLabel.Size.Height + 3);
                RetweetNameLabel.Location = new Point(40, TimeLabel.Location.Y + TimeLabel.Size.Height + 3);
            }
        }
Example #24
0
        private void streamTL(Status tweet)
        {
            logger.Trace("Streaming is enabled.");

            displayTimeline(this.listView_Home, tweet);

            if (tweet.Text.Contains(string.Format("@{0}", this.user.ScreenName)))
            {
                displayTimeline(this.listView_Mention, tweet);
                string message = string.Format("Reply from @{0}: {1}",
                    tweet.User.ScreenName,
                    tweet.Text);
                changeStatus(message, NotificationStatus.GetReply);

                if (this.enabledNotify &&
                    tweet.User.Id != this.user.Id)
				{
					showNortificationForm(NotificationStatus.GetReply, tweet);
				}
            }
        }
Example #25
0
        /// <summary>
        /// 해당 트윗에 포함된 모든 이미지 / 동영상을 찾아냄
        /// </summary>
        public static void GetMediaUris(CoreTweet.Status twt, ref List <DownloadItem> downloadItems)
        {
            // Twitter Video
            if (twt.ExtendedEntities != null)
            {
                foreach (var eachMedia in twt.ExtendedEntities.Media)
                {
                    if (eachMedia.VideoInfo != null)
                    {
                        foreach (var eachVideoVariant in eachMedia.VideoInfo.Variants)
                        {
                            Uri uri = new Uri(eachVideoVariant.Url);
                            downloadItems.Add(new DownloadItem(twt.Id, twt.User.ScreenName, uri, uri.Segments.Last()));
                        }
                    }
                }
            }

            else if (twt.Entities.Media != null)
            {
                foreach (var url in twt.Entities.Media)
                {
                    Uri uri = new Uri(url.MediaUrl);

                    IMediaProvider mediaProvider = null;

                    if (IsImageFile(uri.ToString()))
                    {
                        Uri newUri = new Uri(ModifyImageUri(uri.ToString()));

                        downloadItems.Add(new DownloadItem(twt.Id, twt.User.ScreenName, newUri, uri.Segments.Last()));
                    }
                    else
                    {
                        mediaProvider = GetMediaProvider(uri);

                        if (mediaProvider != null)
                        {
                            try
                            {
                                List <Uri> mediaUris = mediaProvider.GetUri(uri);

                                foreach (var eachUri in mediaUris)
                                {
                                    string filename = eachUri.Segments.Last();
                                    downloadItems.Add(new DownloadItem(twt.Id, twt.User.ScreenName, eachUri, filename));
                                }
                            }
                            catch
                            {
                                throw;
                            }
                        }
                    }
                }
            }

            if (twt.Entities.Urls != null)
            {
                foreach (var url in twt.Entities.Urls)
                {
                    Uri uri = new Uri(url.ExpandedUrl);

                    IMediaProvider mediaProvider = null;

                    if (IsImageFile(uri.ToString()))
                    {
                        downloadItems.Add(new DownloadItem(twt.Id, twt.User.ScreenName, uri, uri.Segments.Last()));
                    }
                    else
                    {
                        mediaProvider = GetMediaProvider(uri);

                        if (mediaProvider != null)
                        {
                            try
                            {
                                List <Uri> mediaUris = mediaProvider.GetUri(uri);

                                foreach (var eachUri in mediaUris)
                                {
                                    string filename = eachUri.Segments.Last();
                                    downloadItems.Add(new DownloadItem(twt.Id, twt.User.ScreenName, eachUri, filename));
                                }
                            }
                            catch
                            {
                                throw;
                            }
                        }
                    }
                }
            }

            if (twt.ExtendedEntities != null && twt.ExtendedEntities.Media != null)
            {
                foreach (var media in twt.ExtendedEntities.Media)
                {
                    Uri uri = new Uri(media.MediaUrl);

                    if (!IsImageFile(uri.ToString()))
                    {
                        continue;
                    }

                    Uri newUri = new Uri(ModifyImageUri(uri.ToString()));

                    downloadItems.Add(new DownloadItem(twt.Id, twt.User.ScreenName, newUri, uri.Segments.Last()));
                }
            }
        }
Example #26
0
 private void resetReply()
 {
     this.label_InReplyTo.Text = string.Empty;
     this.status = null;
     this.textBox_Input.Text = string.Empty;
     this.button_ResetReply.Visible = false;
 }
Example #27
0
 /// <summary>
 /// ツイートをリツイートのキャッシュに追加します。
 /// </summary>
 /// <param name="st">ツイート。リツイートした元ツイートではなく、リツイート自体を指定しください。</param>
 public void AddRetweetCache(Status st)
 {
     if (AddRetweetCacheCommand == null) return;
     AddRetweetCacheCommand.Parameters["Id"].Value = st.Id;
     AddRetweetCacheCommand.Parameters["OriginalId"].Value = st.RetweetedStatus.Id;
     AddRetweetCacheCommand.Parameters["Date"].Value = st.CreatedAt.DateTime;
     AddRetweetCacheCommand.Parameters["Name"].Value = st.User.ScreenName;
     AddRetweetCacheCommand.ExecuteNonQuery();
 }
Example #28
0
		private void quoteTweet(Status tweet)
		{
			this.textBox_Input.Text += string.Format(@"https://twitter.com/{0}/status/{1}",
				tweet.User.ScreenName,
				tweet.ToString());
		}
Example #29
0
        private List<Status> getTalk(Status tweet)
        {
            List<Status> talk = new List<Status>();
            talk.Add(tweet);

            while (tweet.InReplyToStatusId != null)
            {
                tweet = getTweetFromId(this.tokens, tweet.InReplyToStatusId.ToString());
                talk.Add(tweet);
            }

            return talk;
        }
Example #30
0
        public static StatusViewModel CreateStatusViewModel(this MainWindowViewModel vm, Status st)
        {
            var ret = new StatusViewModel();
            ret.status = st;
            if (st.RetweetedStatus != null)
            {
                ret.RetweetUserName = st.User.Name;
                st = st.RetweetedStatus;
                ret.IsRetweet = true;
            }
            else
            {
                ret.IsRetweet = false;
                ret.RetweetUserName = "";
            }
            ret.origin = st;
            ret.UserName = st.User.Name;
            ret.ScreenName = st.User.ScreenName;
            ret.Text = st.Text;
            ret.UserProfileImageUri = st.User.ProfileImageUrlHttps;
            ret.RetweetCount = st.RetweetCount ?? 0;
            ret._IsFavorited = (st.IsFavorited ?? false) || Kbtter.Instance.IsFavoritedInCache(st);
            ret._IsRetweeted = (st.IsRetweeted ?? false) || (ret.status.RetweetedStatus != null && Kbtter.Instance.IsRetweetedInCache(ret.status));
            ret.FavoriteCount = st.FavoriteCount ?? 0;
            ret.IsMyStatus = (Kbtter.Instance.AuthenticatedUser != null && Kbtter.Instance.AuthenticatedUser.Id == st.User.Id);
            ret.IsOthersStatus = !ret.IsMyStatus;
            ret.IsOthersStatus = !ret.IsMyStatus;
            ret._CreatedTimeText = st.CreatedAt.DateTime.ToLocalTime();
            ret.IsReplyToMe = st.Entities != null && st.Entities.UserMentions.Any(p => p.ScreenName == Kbtter.Instance.AuthenticatedUser.ScreenName);
            ret.AnalyzeText();
            ret.TryGetReply();

            var m = reg.Match(st.Source);
            ret.Via = m.Groups["client"].Value;
            if (m.Groups["url"].Value != "") ret.ViaUri = new Uri(m.Groups["url"].Value);

            ret.main = vm;

            ret.listener = new PropertyChangedEventListener(Kbtter.Instance);
            ret.listener.Add("Status", ret.UpdateTime);
            ret.CompositeDisposable.Add(ret.listener);

            return ret;
        }
Example #31
0
        private void showNortificationForm(NotificationStatus notificationType, Status tweet)
        {
            switch(notificationType)
            {
                case NotificationStatus.GetReply:
					string title = @"You got a reply from @{0}.";
                    this.notifyIcon.BalloonTipTitle = string.Format(title, tweet.User.ScreenName);
					this.notifyIcon.BalloonTipText = tweet.Text.Length < 40 ? tweet.Text : (tweet.Text.Substring(0, 40) + "...");
                    this.notifyIcon.ShowBalloonTip(5000);
                    break;
                default:
                    break;
            }
        }
Example #32
0
 /// <summary>
 /// ツイートを投稿する
 /// </summary>
 /// <param name="t">ツイート本文</param>
 /// <param name="selectedPictures">選択された画像ファイルの List</param>
 public async void PostTweetAsync(string t, IReadOnlyList<StorageFile> selectedPictures)
 {
     var mediaIds         =  await this.UploadPictures(selectedPictures);
     var replayToStatusId = this._replyToStatus?.Id;
     await this._tokens.Statuses.UpdateAsync(status => t, in_reply_to_status_id => replayToStatusId, media_ids => mediaIds);
     this._replyToStatus = null;
 }
Example #33
0
        private void favorite(Status tweet)
        {
            if ((bool)tweet.IsFavorited)
            {
                this.tokens.Favorites.DestroyAsync(id => tweet.Id);
            }
            else
            {
                this.tokens.Favorites.CreateAsync(id => tweet.Id);
            }

            int index = this.listView_Tweet.SelectedIndices[0];
            ((Status)this.listView_Tweet.Items[index].Tag).IsFavorited = !((Status)this.listView_Tweet.Items[index].Tag).IsFavorited;
            this.listView_Tweet.Items[index].Selected = false;
            this.listView_Tweet.Items[index].Selected = true;
        }
 /// <summary>
 /// Listに入れる前にtweetStatusを加工するもの
 /// </summary>
 /// <param name="tweet"></param>
 /// <returns></returns>
 private Status TweetProcessing(Status tweet)
 {
     tweet.Source = SourceHTMLParser(tweet.Source);
     if (tweet.RetweetedStatus != null)
     {
         tweet.RetweetedStatus.Text = WebUtility.HtmlDecode(tweet.RetweetedStatus.Text);
         tweet.RetweetedStatus.Source = SourceHTMLParser(tweet.RetweetedStatus.Source);
     }
     tweet.Text = WebUtility.HtmlDecode(tweet.Text);
     return tweet;
 }
Example #35
0
 public Status(CStatus status)
 {
     Update(status);
 }