1 // OpenTween - Client of Twitter
2 // Copyright (c) 2007-2011 kiri_feather (@kiri_feather) <kiri.feather@gmail.com>
3 // (c) 2008-2011 Moz (@syo68k)
4 // (c) 2008-2011 takeshik (@takeshik) <http://www.takeshik.org/>
5 // (c) 2010-2011 anis774 (@anis774) <http://d.hatena.ne.jp/anis774/>
6 // (c) 2010-2011 fantasticswallow (@f_swallow) <http://twitter.com/f_swallow>
7 // (c) 2011 kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/>
8 // All rights reserved.
10 // This file is part of OpenTween.
12 // This program is free software; you can redistribute it and/or modify it
13 // under the terms of the GNU General Public License as published by the Free
14 // Software Foundation; either version 3 of the License, or (at your option)
17 // This program is distributed in the hope that it will be useful, but
18 // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 // You should have received a copy of the GNU General Public License along
23 // with this program. If not, see <http://www.gnu.org/licenses/>, or write to
24 // the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
25 // Boston, MA 02110-1301, USA.
28 using System.Collections.Generic;
29 using System.ComponentModel;
34 using System.Threading.Tasks;
35 using System.Windows.Forms;
36 using System.Text.RegularExpressions;
43 public partial class ShowUserInfo : OTBaseForm
45 private new TweenMain Owner
47 get { return (TweenMain)base.Owner; }
50 private Twitter Twitter
52 get { return this.Owner.TwitterInstance; }
57 InitializeComponent();
59 private TwitterDataModel.User userInfo = null;
60 private UserInfo _info = new UserInfo();
61 private Image icondata = null;
62 private List<string> atlist = new List<string>();
63 private string recentPostTxt;
65 private const string Mainpath = "https://twitter.com/";
66 private const string Followingpath = "/following";
67 private const string Followerspath = "/followers";
68 private const string Favpath = "/favorites";
71 private string Following;
72 private string Followers;
73 private string Favorites;
74 private string FriendshipResult = "";
76 private void InitPath()
78 Home = Mainpath + _info.ScreenName;
79 Following = Home + Followingpath;
80 Followers = Home + Followerspath;
81 Favorites = Home + Favpath;
84 private void InitTooltip()
86 ToolTip1.SetToolTip(LinkLabelTweet, Home);
87 ToolTip1.SetToolTip(LinkLabelFollowing, Following);
88 ToolTip1.SetToolTip(LinkLabelFollowers, Followers);
89 ToolTip1.SetToolTip(LinkLabelFav, Favorites);
92 private bool AnalizeUserInfo(TwitterDataModel.User user)
94 if (user == null) return false;
99 _info.Name = WebUtility.HtmlDecode(user.Name).Trim();
100 _info.ScreenName = user.ScreenName;
101 _info.Location = WebUtility.HtmlDecode(user.Location);
102 _info.Description = WebUtility.HtmlDecode(user.Description);
103 _info.ImageUrl = new Uri(user.ProfileImageUrlHttps);
104 _info.Url = user.Url;
105 _info.Protect = user.Protected;
106 _info.FriendsCount = user.FriendsCount;
107 _info.FollowersCount = user.FollowersCount;
108 _info.FavoriteCount = user.FavouritesCount;
109 _info.CreatedAt = MyCommon.DateTimeParse(user.CreatedAt);
110 _info.StatusesCount = user.StatusesCount;
111 _info.Verified = user.Verified;
114 _info.RecentPost = user.Status.Text;
115 _info.PostCreatedAt = MyCommon.DateTimeParse(user.Status.CreatedAt);
116 _info.PostSource = user.Status.Source;
117 if (!_info.PostSource.Contains("</a>"))
119 _info.PostSource += "</a>";
124 _info.RecentPost = null;
125 _info.PostCreatedAt = new DateTime();
126 _info.PostSource = null;
136 private async Task SetLinklabelWebAsync(string data)
140 webtext = this.Twitter.PreProcessUrl("<a href=\"" + data + "\">Dummy</a>");
141 webtext = await ShortUrl.Instance.ExpandUrlHtmlAsync(webtext);
142 jumpto = Regex.Match(webtext, @"<a href=""(?<url>.*?)""").Groups["url"].Value;
143 ToolTip1.SetToolTip(LinkLabelWeb, jumpto);
144 LinkLabelWeb.Tag = jumpto;
145 LinkLabelWeb.Text = data;
148 private async Task SetDescriptionAsync(string descriptionText)
150 var html = WebUtility.HtmlEncode(descriptionText);
151 html = await this.Twitter.CreateHtmlAnchorAsync(html, this.atlist, null);
152 html = this.Owner.createDetailHtml(html);
154 this.DescriptionBrowser.DocumentText = html;
157 private void ShowUserInfo_FormClosed(object sender, FormClosedEventArgs e)
159 //TweenMain.TopMost = !TweenMain.TopMost;
160 //TweenMain.TopMost = !TweenMain.TopMost;
163 private async void ShowUserInfo_Load(object sender, EventArgs e)
165 if (!AnalizeUserInfo(userInfo))
167 MessageBox.Show(Properties.Resources.ShowUserInfo1);
172 // LabelScreenName のフォントを OTBaseForm.GlobalFont に変更
173 this.LabelScreenName.Font = this.ReplaceToGlobalFont(this.LabelScreenName.Font);
176 BackgroundWorkerImageLoader.RunWorkerAsync();
180 this.Text = this.Text.Insert(0, _info.ScreenName + " ");
181 LabelId.Text = _info.Id.ToString();
182 LabelScreenName.Text = _info.ScreenName;
183 LabelName.Text = _info.Name;
185 LabelLocation.Text = _info.Location;
187 var linkTask = this.SetLinklabelWebAsync(this._info.Url);
189 RecentPostBrowser.Visible = false;
190 if (_info.RecentPost != null)
192 recentPostTxt = this.Owner.createDetailHtml(
193 this.Twitter.CreateHtmlAnchor(_info.RecentPost, atlist, userInfo.Status.Entities, null) +
194 " Posted at " + _info.PostCreatedAt.ToString() +
195 " via " + _info.PostSource);
198 LinkLabelFollowing.Text = _info.FriendsCount.ToString();
199 LinkLabelFollowers.Text = _info.FollowersCount.ToString();
200 LinkLabelFav.Text = _info.FavoriteCount.ToString();
201 LinkLabelTweet.Text = _info.StatusesCount.ToString();
203 LabelCreatedAt.Text = _info.CreatedAt.ToString();
206 LabelIsProtected.Text = Properties.Resources.Yes;
208 LabelIsProtected.Text = Properties.Resources.No;
211 LabelIsVerified.Text = Properties.Resources.Yes;
213 LabelIsVerified.Text = Properties.Resources.No;
215 if (this.Twitter.Username == _info.ScreenName)
217 ButtonEdit.Enabled = true;
218 ChangeIconToolStripMenuItem.Enabled = true;
219 ButtonBlock.Enabled = false;
220 ButtonReportSpam.Enabled = false;
221 ButtonBlockDestroy.Enabled = false;
225 ButtonEdit.Enabled = false;
226 ChangeIconToolStripMenuItem.Enabled = false;
227 ButtonBlock.Enabled = true;
228 ButtonReportSpam.Enabled = true;
229 ButtonBlockDestroy.Enabled = true;
235 private void ButtonClose_Click(object sender, EventArgs e)
240 public TwitterDataModel.User User
242 set { this.userInfo = value; }
245 private void LinkLabelWeb_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
247 if (_info.Url != null)
248 this.Owner.OpenUriAsync(LinkLabelWeb.Text);
251 private void LinkLabelFollowing_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
253 this.Owner.OpenUriAsync(Following);
256 private void LinkLabelFollowers_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
258 this.Owner.OpenUriAsync(Followers);
261 private void LinkLabelTweet_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
263 this.Owner.OpenUriAsync(Home);
266 private void LinkLabelFav_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
268 this.Owner.OpenUriAsync(Favorites);
271 private void ButtonFollow_Click(object sender, EventArgs e)
273 string ret = this.Twitter.PostFollowCommand(_info.ScreenName);
274 if (!string.IsNullOrEmpty(ret))
276 MessageBox.Show(Properties.Resources.FRMessage2 + ret);
280 MessageBox.Show(Properties.Resources.FRMessage3);
281 LabelIsFollowing.Text = Properties.Resources.GetFriendshipInfo1;
282 ButtonFollow.Enabled = false;
283 ButtonUnFollow.Enabled = true;
287 private void ButtonUnFollow_Click(object sender, EventArgs e)
289 if (MessageBox.Show(_info.ScreenName + Properties.Resources.ButtonUnFollow_ClickText1,
290 Properties.Resources.ButtonUnFollow_ClickText2,
291 MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
293 string ret = this.Twitter.PostRemoveCommand(_info.ScreenName);
294 if (!string.IsNullOrEmpty(ret))
296 MessageBox.Show(Properties.Resources.FRMessage2 + ret);
300 MessageBox.Show(Properties.Resources.FRMessage3);
301 LabelIsFollowing.Text = Properties.Resources.GetFriendshipInfo2;
302 ButtonFollow.Enabled = true;
303 ButtonUnFollow.Enabled = false;
308 private void ShowUserInfo_Activated(object sender, EventArgs e)
310 //画面が他画面の裏に隠れると、アイコン画像が再描画されない問題の対応
311 if (UserPicture.Image != null)
312 UserPicture.Invalidate(false);
315 private void ShowUserInfo_FormClosing(object sender, FormClosingEventArgs e)
317 UserPicture.Image = null;
318 if (icondata != null)
322 private void BackgroundWorkerImageLoader_DoWork(object sender, DoWorkEventArgs e)
324 string name = _info.ImageUrl.ToString();
325 icondata = (new HttpVarious()).GetImage(name.Replace("_normal", "_bigger"));
326 if (this.Twitter.Username == _info.ScreenName) return;
328 _info.isFollowing = false;
329 _info.isFollowed = false;
330 FriendshipResult = this.Twitter.GetFriendshipInfo(_info.ScreenName, ref _info.isFollowing, ref _info.isFollowed);
333 private void BackgroundWorkerImageLoader_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
337 if (icondata != null)
338 UserPicture.Image = icondata;
342 UserPicture.Image = null;
345 if (this.Twitter.Username == _info.ScreenName)
348 LabelIsFollowing.Text = "";
349 LabelIsFollowed.Text = "";
350 ButtonFollow.Enabled = false;
351 ButtonUnFollow.Enabled = false;
355 if (string.IsNullOrEmpty(FriendshipResult))
357 if (_info.isFollowing)
359 LabelIsFollowing.Text = Properties.Resources.GetFriendshipInfo1;
363 LabelIsFollowing.Text = Properties.Resources.GetFriendshipInfo2;
365 ButtonFollow.Enabled = !_info.isFollowing;
366 if (_info.isFollowed)
368 LabelIsFollowed.Text = Properties.Resources.GetFriendshipInfo3;
372 LabelIsFollowed.Text = Properties.Resources.GetFriendshipInfo4;
374 ButtonUnFollow.Enabled = _info.isFollowing;
378 MessageBox.Show(FriendshipResult);
379 ButtonUnFollow.Enabled = false;
380 ButtonFollow.Enabled = false;
381 LabelIsFollowed.Text = Properties.Resources.GetFriendshipInfo6;
382 LabelIsFollowing.Text = Properties.Resources.GetFriendshipInfo6;
388 private async void ShowUserInfo_Shown(object sender, EventArgs e)
390 var descriptionTask = this.SetDescriptionAsync(this._info.Description);
392 if (_info.RecentPost != null)
394 RecentPostBrowser.DocumentText = recentPostTxt;
395 RecentPostBrowser.Visible = true;
399 LabelRecentPost.Text = Properties.Resources.ShowUserInfo2;
403 await descriptionTask;
406 private void WebBrowser_Navigating(object sender, WebBrowserNavigatingEventArgs e)
408 if (e.Url.AbsoluteUri != "about:blank")
412 if (e.Url.AbsoluteUri.StartsWith("http://twitter.com/search?q=%23") ||
413 e.Url.AbsoluteUri.StartsWith("https://twitter.com/search?q=%23"))
416 string urlStr = Uri.UnescapeDataString(e.Url.AbsoluteUri);
417 string hash = urlStr.Substring(urlStr.IndexOf("#"));
418 this.Owner.HashSupl.AddItem(hash);
419 this.Owner.HashMgr.AddHashToHistory(hash.Trim(), false);
420 this.Owner.AddNewTabForSearch(hash);
425 Match m = Regex.Match(e.Url.AbsoluteUri, @"^https?://twitter.com/(#!/)?(?<ScreenName>[a-zA-Z0-9_]+)$");
426 if (AppendSettingDialog.Instance.OpenUserTimeline && m.Success && this.Owner.IsTwitterId(m.Result("${ScreenName}")))
428 this.Owner.AddNewTabForUserTimeline(m.Result("${ScreenName}"));
432 this.Owner.OpenUriAsync(e.Url.OriginalString);
438 private void WebBrowser_StatusTextChanged(object sender, EventArgs e)
440 WebBrowser ComponentInstance = (WebBrowser)sender;
441 if (ComponentInstance.StatusText.StartsWith("http"))
443 ToolTip1.Show(ComponentInstance.StatusText, this, PointToClient(MousePosition));
445 else if (string.IsNullOrEmpty(DescriptionBrowser.StatusText))
451 private void SelectAllToolStripMenuItem_Click(object sender, EventArgs e)
453 WebBrowser sc = ContextMenuRecentPostBrowser.SourceControl as WebBrowser;
455 sc.Document.ExecCommand("SelectAll", false, null);
458 private void SelectionCopyToolStripMenuItem_Click(object sender, EventArgs e)
460 WebBrowser sc = ContextMenuRecentPostBrowser.SourceControl as WebBrowser;
463 string _selText = this.Owner.WebBrowser_GetSelectionText(ref sc);
464 if (_selText != null)
468 Clipboard.SetDataObject(_selText, false, 5, 100);
472 MessageBox.Show(ex.Message);
478 private void ContextMenuStrip1_Opening(object sender, CancelEventArgs e)
480 WebBrowser sc = ContextMenuRecentPostBrowser.SourceControl as WebBrowser;
483 string _selText = this.Owner.WebBrowser_GetSelectionText(ref sc);
484 if (_selText == null)
485 SelectionCopyToolStripMenuItem.Enabled = false;
487 SelectionCopyToolStripMenuItem.Enabled = true;
491 private void ShowUserInfo_MouseEnter(object sender, EventArgs e)
496 private void LinkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
498 this.Owner.OpenUriAsync("https://support.twitter.com/groups/31-twitter-basics/topics/111-features/articles/268350-x8a8d-x8a3c-x6e08-x307f-x30a2-x30ab-x30a6-x30f3-x30c8-x306b-x3064-x3044-x3066");
501 private void LinkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
503 this.Owner.OpenUriAsync("https://support.twitter.com/groups/31-twitter-basics/topics/107-my-profile-account-settings/articles/243055-x516c-x958b-x3001-x975e-x516c-x958b-x30a2-x30ab-x30a6-x30f3-x30c8-x306b-x3064-x3044-x3066");
506 private void ButtonSearchPosts_Click(object sender, EventArgs e)
508 this.Owner.AddNewTabForUserTimeline(_info.ScreenName);
511 private void UserPicture_DoubleClick(object sender, EventArgs e)
513 if (UserPicture.Image != null)
515 string name = _info.ImageUrl.ToString();
516 this.Owner.OpenUriAsync(name.Remove(name.LastIndexOf("_normal"), 7));
520 private void UserPicture_MouseEnter(object sender, EventArgs e)
522 UserPicture.Cursor = Cursors.Hand;
525 private void UserPicture_MouseLeave(object sender, EventArgs e)
527 UserPicture.Cursor = Cursors.Default;
530 private class UpdateProfileArgs
534 public string location;
536 public string description;
539 private void UpdateProfile_Dowork(object sender, DoWorkEventArgs e)
541 UpdateProfileArgs arg = (UpdateProfileArgs)e.Argument;
542 e.Result = arg.tw.PostUpdateProfile(arg.name,
548 private void UpddateProfile_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
550 string res = (string)e.Result;
551 if (res.StartsWith("err:", StringComparison.CurrentCultureIgnoreCase))
553 MessageBox.Show(res);
557 private bool IsEditing = false;
558 private string ButtonEditText = "";
560 private async void ButtonEdit_Click(object sender, EventArgs e)
562 // 自分以外のプロフィールは変更できない
563 if (this.Twitter.Username != _info.ScreenName) return;
565 this.ButtonEdit.Enabled = false;
569 ButtonEditText = ButtonEdit.Text;
570 ButtonEdit.Text = Properties.Resources.UserInfoButtonEdit_ClickText1;
573 TextBoxName.Location = LabelName.Location;
574 TextBoxName.Height = LabelName.Height;
575 TextBoxName.Width = LabelName.Width;
576 TextBoxName.BackColor = this.Owner.InputBackColor;
577 TextBoxName.MaxLength = 20;
578 TextBoxName.Text = LabelName.Text;
579 TextBoxName.TabStop = true;
580 TextBoxName.Visible = true;
581 LabelName.Visible = false;
583 TextBoxLocation.Location = LabelLocation.Location;
584 TextBoxLocation.Height = LabelLocation.Height;
585 TextBoxLocation.Width = LabelLocation.Width;
586 TextBoxLocation.BackColor = this.Owner.InputBackColor;
587 TextBoxLocation.MaxLength = 30;
588 TextBoxLocation.Text = LabelLocation.Text;
589 TextBoxLocation.TabStop = true;
590 TextBoxLocation.Visible = true;
591 LabelLocation.Visible = false;
593 TextBoxWeb.Location = LinkLabelWeb.Location;
594 TextBoxWeb.Height = LinkLabelWeb.Height;
595 TextBoxWeb.Width = LinkLabelWeb.Width;
596 TextBoxWeb.BackColor = this.Owner.InputBackColor;
597 TextBoxWeb.MaxLength = 100;
598 TextBoxWeb.Text = _info.Url;
599 TextBoxWeb.TabStop = true;
600 TextBoxWeb.Visible = true;
601 LinkLabelWeb.Visible = false;
603 TextBoxDescription.Location = DescriptionBrowser.Location;
604 TextBoxDescription.Height = DescriptionBrowser.Height;
605 TextBoxDescription.Width = DescriptionBrowser.Width;
606 TextBoxDescription.BackColor = this.Owner.InputBackColor;
607 TextBoxDescription.MaxLength = 160;
608 TextBoxDescription.Text = _info.Description;
609 TextBoxDescription.Multiline = true;
610 TextBoxDescription.ScrollBars = ScrollBars.Vertical;
611 TextBoxDescription.TabStop = true;
612 TextBoxDescription.Visible = true;
613 DescriptionBrowser.Visible = false;
616 TextBoxName.Select(TextBoxName.Text.Length, 0);
622 UpdateProfileArgs arg = new UpdateProfileArgs();
624 if (TextBoxName.Modified ||
625 TextBoxLocation.Modified ||
626 TextBoxWeb.Modified ||
627 TextBoxDescription.Modified)
629 arg.tw = this.Twitter;
630 arg.name = TextBoxName.Text.Trim();
631 arg.url = TextBoxWeb.Text.Trim();
632 arg.location = TextBoxLocation.Text.Trim();
633 arg.description = TextBoxDescription.Text.Trim();
635 using (FormInfo dlg = new FormInfo(this, Properties.Resources.UserInfoButtonEdit_ClickText2,
636 UpdateProfile_Dowork,
637 UpddateProfile_RunWorkerCompleted,
641 if (!string.IsNullOrEmpty(dlg.Result.ToString()))
649 LabelName.Text = TextBoxName.Text;
650 _info.Name = LabelName.Text;
651 TextBoxName.TabStop = false;
652 TextBoxName.Visible = false;
653 LabelName.Visible = true;
655 LabelLocation.Text = TextBoxLocation.Text;
656 _info.Location = LabelLocation.Text;
657 TextBoxLocation.TabStop = false;
658 TextBoxLocation.Visible = false;
659 LabelLocation.Visible = true;
661 var linkTask = this.SetLinklabelWebAsync(this.TextBoxWeb.Text);
662 _info.Url = TextBoxWeb.Text;
663 TextBoxWeb.TabStop = false;
664 TextBoxWeb.Visible = false;
665 LinkLabelWeb.Visible = true;
667 var descriptionTask = this.SetDescriptionAsync(this.TextBoxDescription.Text);
669 _info.Description = TextBoxDescription.Text;
670 TextBoxDescription.TabStop = false;
671 TextBoxDescription.Visible = false;
672 DescriptionBrowser.Visible = true;
674 ButtonEdit.Text = ButtonEditText;
678 await Task.WhenAll(new[] { linkTask, descriptionTask });
681 this.ButtonEdit.Enabled = true;
684 class UpdateProfileImageArgs
687 public string FileName;
690 private void UpdateProfileImage_Dowork(object sender, DoWorkEventArgs e)
692 UpdateProfileImageArgs arg = (UpdateProfileImageArgs)e.Argument;
693 e.Result = arg.tw.PostUpdateProfileImage(arg.FileName);
696 private void UpdateProfileImage_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
699 TwitterDataModel.User user = null;
701 if (e.Result == null)
708 // が、古いアイコンのユーザーデータが返ってくるため反映/判断できない
712 res = this.Twitter.GetUserInfo(_info.ScreenName, ref user);
713 Image img = (new HttpVarious()).GetImage(user.ProfileImageUrlHttps);
716 UserPicture.Image = img;
724 private void doChangeIcon(string filename)
727 UpdateProfileImageArgs arg = new UpdateProfileImageArgs() { tw = this.Twitter, FileName = filename };
729 using (FormInfo dlg = new FormInfo(this, Properties.Resources.ChangeIconToolStripMenuItem_ClickText3,
730 UpdateProfileImage_Dowork,
731 UpdateProfileImage_RunWorkerCompleted,
735 res = dlg.Result as string;
736 if (!string.IsNullOrEmpty(res))
738 // "Err:"が付いたエラーメッセージが返ってくる
739 MessageBox.Show(res + "\r\n" + Properties.Resources.ChangeIconToolStripMenuItem_ClickText4);
743 MessageBox.Show(Properties.Resources.ChangeIconToolStripMenuItem_ClickText5);
748 private void ChangeIconToolStripMenuItem_Click(object sender, EventArgs e)
750 OpenFileDialogIcon.Filter = Properties.Resources.ChangeIconToolStripMenuItem_ClickText1;
751 OpenFileDialogIcon.Title = Properties.Resources.ChangeIconToolStripMenuItem_ClickText2;
752 OpenFileDialogIcon.FileName = "";
754 DialogResult rslt = OpenFileDialogIcon.ShowDialog();
756 if (rslt != DialogResult.OK)
761 string fn = OpenFileDialogIcon.FileName;
762 if (isValidIconFile(new FileInfo(fn)))
768 MessageBox.Show(Properties.Resources.ChangeIconToolStripMenuItem_ClickText6);
772 private void ButtonBlock_Click(object sender, EventArgs e)
774 if (MessageBox.Show(_info.ScreenName + Properties.Resources.ButtonBlock_ClickText1,
775 Properties.Resources.ButtonBlock_ClickText2,
776 MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
778 string res = this.Twitter.PostCreateBlock(_info.ScreenName);
779 if (!string.IsNullOrEmpty(res))
781 MessageBox.Show(res + Environment.NewLine + Properties.Resources.ButtonBlock_ClickText3);
785 MessageBox.Show(Properties.Resources.ButtonBlock_ClickText4);
790 private void ButtonReportSpam_Click(object sender, EventArgs e)
792 if (MessageBox.Show(_info.ScreenName + Properties.Resources.ButtonReportSpam_ClickText1,
793 Properties.Resources.ButtonReportSpam_ClickText2,
794 MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
796 string res = this.Twitter.PostReportSpam(_info.ScreenName);
797 if (!string.IsNullOrEmpty(res))
799 MessageBox.Show(res + Environment.NewLine + Properties.Resources.ButtonReportSpam_ClickText3);
803 MessageBox.Show(Properties.Resources.ButtonReportSpam_ClickText4);
808 private void ButtonBlockDestroy_Click(object sender, EventArgs e)
810 if (MessageBox.Show(_info.ScreenName + Properties.Resources.ButtonBlockDestroy_ClickText1,
811 Properties.Resources.ButtonBlockDestroy_ClickText2,
812 MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
814 string res = this.Twitter.PostDestroyBlock(_info.ScreenName);
815 if (!string.IsNullOrEmpty(res))
817 MessageBox.Show(res + Environment.NewLine + Properties.Resources.ButtonBlockDestroy_ClickText3);
821 MessageBox.Show(Properties.Resources.ButtonBlockDestroy_ClickText4);
826 private bool isValidExtension(string ext)
828 return ext.Equals(".jpg") || ext.Equals(".jpeg") || ext.Equals(".png") || ext.Equals(".gif");
831 private bool isValidIconFile(FileInfo info)
833 string ext = info.Extension.ToLower();
834 return isValidExtension(ext) && info.Length < 700 * 1024 && !MyCommon.IsAnimatedGif(info.FullName);
837 private void ShowUserInfo_DragOver(object sender, DragEventArgs e)
839 if (e.Data.GetDataPresent(DataFormats.FileDrop))
841 string filename = ((string[])e.Data.GetData(DataFormats.FileDrop, false))[0];
842 FileInfo fl = new FileInfo(filename);
844 e.Effect = DragDropEffects.None;
845 if (isValidIconFile(fl))
847 e.Effect = DragDropEffects.Copy;
852 e.Effect = DragDropEffects.None;
856 private void ShowUserInfo_DragDrop(object sender, DragEventArgs e)
858 if (e.Data.GetDataPresent(DataFormats.FileDrop))
860 string filename = ((string[])e.Data.GetData(DataFormats.FileDrop, false))[0];
861 doChangeIcon(filename);