using OpenTween.Api;
using OpenTween.Api.DataModel;
using OpenTween.Connection;
+using OpenTween.Models;
using OpenTween.OpenTweenCustomControl;
using OpenTween.Thumbnail;
//設定ファイル関連
//private SettingToConfig _cfg; //旧
- private SettingLocal _cfgLocal;
+ internal SettingLocal _cfgLocal;
private SettingCommon _cfgCommon;
//twitter解析部
private GrowlHelper gh = new GrowlHelper(Application.ProductName);
//サブ画面インスタンス
- private SearchWordDialog SearchDialog = new SearchWordDialog(); //検索画面インスタンス
+ internal SearchWordDialog SearchDialog = new SearchWordDialog(); //検索画面インスタンス
private OpenURL UrlDialog = new OpenURL();
public AtIdSupplement AtIdSupl; //@id補助
public AtIdSupplement HashSupl; //Hashtag補助
//時速表示用
private List<DateTime> _postTimestamps = new List<DateTime>();
private List<DateTime> _favTimestamps = new List<DateTime>();
- private ConcurrentDictionary<DateTime, int> _tlTimestamps = new ConcurrentDictionary<DateTime, int>();
- private int _tlCount;
// 以下DrawItem関連
private SolidBrush _brsHighLight = new SolidBrush(Color.FromKnownColor(KnownColor.Highlight));
private const int MAX_WORKER_THREADS = 20;
private SemaphoreSlim workerSemaphore = new SemaphoreSlim(MAX_WORKER_THREADS);
private CancellationTokenSource workerCts = new CancellationTokenSource();
+ private IProgress<string> workerProgress;
private int UnreadCounter = -1;
private int UnreadAtCounter = -1;
private bool osResumed = false;
//////////////////////////////////////////////////////////////////////////////////////////////////////////
- private string _postBrowserStatusText = "";
-
private bool _colorize = false;
private System.Timers.Timer TimerTimeline = new System.Timers.Timer();
- private ImageListViewItem displayItem;
-
private string recommendedStatusFooter;
//URL短縮のUndo用
private Stack<Tuple<TabPage, PostClass>> selectPostChains = new Stack<Tuple<TabPage, PostClass>>(); //ポスト選択履歴
//検索処理タイプ
- private enum SEARCHTYPE
+ internal enum SEARCHTYPE
{
DialogSearch,
NextSearch,
//Win32Api.SetProxy(HttpConnection.ProxyType.Specified, "127.0.0.1", 8080, "user", "pass")
- new InternetSecurityManager(PostBrowser);
- this.PostBrowser.AllowWebBrowserDrop = false; // COMException を回避するため、ActiveX の初期化が終わってから設定する
-
MyCommon.TwitterApiInfo.AccessLimitUpdated += TwitterApiStatus_AccessLimitUpdated;
Microsoft.Win32.SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;
if (this._cfgCommon.AutoShortUrlFirst < 0)
this._cfgCommon.AutoShortUrlFirst = MyCommon.UrlConverter.Uxnu;
- HttpTwitter.TwitterUrl = this._cfgCommon.TwitterUrl;
+ TwitterApiConnection.RestApiHost = this._cfgCommon.TwitterApiHost;
this.tw = new Twitter(this.twitterApi);
//認証関連
if (string.IsNullOrEmpty(this._cfgCommon.Token)) this._cfgCommon.UserName = "";
tw.Initialize(this._cfgCommon.Token, this._cfgCommon.TokenSecret, this._cfgCommon.UserName, this._cfgCommon.UserId);
- this.twitterApi.Initialize(this._cfgCommon.Token, this._cfgCommon.TokenSecret, this._cfgCommon.UserId, this._cfgCommon.UserName);
_initial = true;
this._cfgLocal.ProxyUser, this._cfgLocal.ProxyPassword);
Networking.ForceIPv4 = this._cfgCommon.ForceIPv4;
- HttpTwitter.TwitterUrl = this._cfgCommon.TwitterUrl;
+ TwitterApiConnection.RestApiHost = this._cfgCommon.TwitterApiHost;
tw.RestrictFavCheck = this._cfgCommon.RestrictFavCheck;
tw.ReadOwnPost = this._cfgCommon.ReadOwnPost;
tw.TrackWord = this._cfgCommon.TrackWord;
imgazyobizinet.Enabled = this._cfgCommon.EnableImgAzyobuziNet;
imgazyobizinet.DisabledInDM = this._cfgCommon.ImgAzyobuziNetDisabledInDM;
- Thumbnail.Services.TonTwitterCom.InitializeOAuthToken = x =>
- x.Initialize(ApplicationSettings.TwitterConsumerKey, ApplicationSettings.TwitterConsumerSecret,
- this.tw.AccessToken, this.tw.AccessTokenSecret, "", "");
+ Thumbnail.Services.TonTwitterCom.GetApiConnection = () => this.twitterApi.Connection;
//画像投稿サービス
ImageSelector.Initialize(tw, this.tw.Configuration, _cfgCommon.UseImageServiceName, _cfgCommon.UseImageService);
//アイコンリスト作成
this.IconCache = new ImageCache();
+ this.tweetDetailsView.IconCache = this.IconCache;
//フォント&文字色&背景色保持
_fntUnread = this._cfgLocal.FontUnread;
this.StatusText.Multiline = false; // _cfgLocal.StatusMultiline の設定は後で反映される
this.SplitContainer2.Panel2MinSize = this.StatusText.Height;
- // NameLabel のフォントを OTBaseForm.GlobalFont に変更
- this.NameLabel.Font = this.ReplaceToGlobalFont(this.NameLabel.Font);
-
// 必要であれば、発言一覧と発言詳細部・入力欄の上下を入れ替える
SplitContainer1.IsPanelInverted = !this._cfgCommon.StatusAreaAtBottom;
UnreadStripMenuItem.Enabled = false;
}
- //発言詳細部の初期化
- NameLabel.Text = "";
- DateTimeLabel.Text = "";
- SourceLinkLabel.Text = "";
-
//リンク先URL表示部の初期化(画面左下)
StatusLabelUrl.Text = "";
//状態表示部の初期化(画面右下)
SetTabAlignment();
//デフォルトタブの存在チェック、ない場合には追加
- if (_statuses.GetTabByType(MyCommon.TabUsageType.Home) == null)
- {
- TabClass tab;
- if (!_statuses.Tabs.TryGetValue(MyCommon.DEFAULTTAB.RECENT, out tab))
- {
- _statuses.AddTab(MyCommon.DEFAULTTAB.RECENT, MyCommon.TabUsageType.Home, null);
- }
- else
- {
- tab.TabType = MyCommon.TabUsageType.Home;
- }
- }
- if (_statuses.GetTabByType(MyCommon.TabUsageType.Mentions) == null)
- {
- TabClass tab;
- if (!_statuses.Tabs.TryGetValue(MyCommon.DEFAULTTAB.REPLY, out tab))
- {
- _statuses.AddTab(MyCommon.DEFAULTTAB.REPLY, MyCommon.TabUsageType.Mentions, null);
- }
- else
- {
- tab.TabType = MyCommon.TabUsageType.Mentions;
- }
- }
- if (_statuses.GetTabByType(MyCommon.TabUsageType.DirectMessage) == null)
- {
- TabClass tab;
- if (!_statuses.Tabs.TryGetValue(MyCommon.DEFAULTTAB.DM, out tab))
- {
- _statuses.AddTab(MyCommon.DEFAULTTAB.DM, MyCommon.TabUsageType.DirectMessage, null);
- }
- else
- {
- tab.TabType = MyCommon.TabUsageType.DirectMessage;
- }
- }
- if (_statuses.GetTabByType(MyCommon.TabUsageType.Favorites) == null)
- {
- TabClass tab;
- if (!_statuses.Tabs.TryGetValue(MyCommon.DEFAULTTAB.FAV, out tab))
- {
- _statuses.AddTab(MyCommon.DEFAULTTAB.FAV, MyCommon.TabUsageType.Favorites, null);
- }
- else
- {
- tab.TabType = MyCommon.TabUsageType.Favorites;
- }
- }
- if (_statuses.GetTabByType(MyCommon.TabUsageType.Mute) == null)
- {
- TabClass tab;
- if (!_statuses.Tabs.TryGetValue(MyCommon.DEFAULTTAB.MUTE, out tab))
- {
- _statuses.AddTab(MyCommon.DEFAULTTAB.MUTE, MyCommon.TabUsageType.Mute, null);
- }
- else
- {
- tab.TabType = MyCommon.TabUsageType.Mute;
- }
- }
+ if (this._statuses.GetTabByType<HomeTabModel>() == null)
+ this._statuses.AddTab(new HomeTabModel());
+
+ if (this._statuses.GetTabByType<MentionsTabModel>() == null)
+ this._statuses.AddTab(new MentionsTabModel());
+
+ if (this._statuses.GetTabByType<DirectMessagesTabModel>() == null)
+ this._statuses.AddTab(new DirectMessagesTabModel());
+
+ if (this._statuses.GetTabByType<FavoritesTabModel>() == null)
+ this._statuses.AddTab(new FavoritesTabModel());
+
+ if (this._statuses.GetTabByType<MuteTabModel>() == null)
+ this._statuses.AddTab(new MuteTabModel());
foreach (var tab in _statuses.Tabs.Values)
{
if (tab.TabType == MyCommon.TabUsageType.Mute)
continue;
- if (tab.TabType == MyCommon.TabUsageType.Undefined)
- {
- tab.TabType = MyCommon.TabUsageType.UserDefined;
- }
- if (!AddNewTab(tab.TabName, true, tab.TabType, tab.ListInfo))
+ if (!AddNewTab(tab, startup: true))
throw new TabException(Properties.Resources.TweenMain_LoadText1);
}
detailHtmlFormatHeader = detailHtmlFormatHeader
.Replace("%FONT_FAMILY%", _fntDetail.Name)
.Replace("%FONT_SIZE%", _fntDetail.Size.ToString())
- .Replace("%FONT_COLOR%", _clDetail.R.ToString() + "," + _clDetail.G.ToString() + "," + _clDetail.B.ToString())
- .Replace("%LINK_COLOR%", _clDetailLink.R.ToString() + "," + _clDetailLink.G.ToString() + "," + _clDetailLink.B.ToString())
- .Replace("%BG_COLOR%", _clDetailBackcolor.R.ToString() + "," + _clDetailBackcolor.G.ToString() + "," + _clDetailBackcolor.B.ToString())
+ .Replace("%FONT_COLOR%", $"{_clDetail.R},{_clDetail.G},{_clDetail.B}")
+ .Replace("%LINK_COLOR%", $"{_clDetailLink.R},{_clDetailLink.G},{_clDetailLink.B}")
+ .Replace("%BG_COLOR%", $"{_clDetailBackcolor.R},{_clDetailBackcolor.G},{_clDetailBackcolor.B}")
.Replace("%BG_REPLY_COLOR%", $"{_clAtTo.R}, {_clAtTo.G}, {_clAtTo.B}");
}
if (_cfgLocal.ScaleDimension.IsEmpty)
_cfgLocal.ScaleDimension = this.CurrentAutoScaleDimensions;
- List<TabClass> tabs = SettingTabs.Load().Tabs;
- foreach (TabClass tb in tabs)
+ var tabsSetting = SettingTabs.Load().Tabs;
+ foreach (var tabSetting in tabsSetting)
{
- try
+ TabModel tab;
+ switch (tabSetting.TabType)
{
- tb.FilterModified = false;
- _statuses.Tabs.Add(tb.TabName, tb);
+ case MyCommon.TabUsageType.Home:
+ tab = new HomeTabModel(tabSetting.TabName);
+ break;
+ case MyCommon.TabUsageType.Mentions:
+ tab = new MentionsTabModel(tabSetting.TabName);
+ break;
+ case MyCommon.TabUsageType.DirectMessage:
+ tab = new DirectMessagesTabModel(tabSetting.TabName);
+ break;
+ case MyCommon.TabUsageType.Favorites:
+ tab = new FavoritesTabModel(tabSetting.TabName);
+ break;
+ case MyCommon.TabUsageType.UserDefined:
+ tab = new FilterTabModel(tabSetting.TabName);
+ break;
+ case MyCommon.TabUsageType.UserTimeline:
+ tab = new UserTimelineTabModel(tabSetting.TabName, tabSetting.User);
+ break;
+ case MyCommon.TabUsageType.PublicSearch:
+ tab = new PublicSearchTabModel(tabSetting.TabName)
+ {
+ SearchWords = tabSetting.SearchWords,
+ SearchLang = tabSetting.SearchLang,
+ };
+ break;
+ case MyCommon.TabUsageType.Lists:
+ tab = new ListTimelineTabModel(tabSetting.TabName, tabSetting.ListInfo);
+ break;
+ case MyCommon.TabUsageType.Mute:
+ tab = new MuteTabModel(tabSetting.TabName);
+ break;
+ default:
+ continue;
}
- catch (Exception)
+
+ tab.UnreadManage = tabSetting.UnreadManage;
+ tab.Protected = tabSetting.Protected;
+ tab.Notify = tabSetting.Notify;
+ tab.SoundFile = tabSetting.SoundFile;
+
+ if (tab.IsDistributableTabType)
{
- tb.TabName = _statuses.MakeTabName("MyTab");
- _statuses.Tabs.Add(tb.TabName, tb);
+ var filterTab = (FilterTabModel)tab;
+ filterTab.FilterArray = tabSetting.FilterArray;
+ filterTab.FilterModified = false;
}
+
+ if (this._statuses.ContainsTab(tab.TabName))
+ tab.TabName = this._statuses.MakeTabName("MyTab");
+
+ this._statuses.AddTab(tab);
}
if (_statuses.Tabs.Count == 0)
{
- _statuses.AddTab(MyCommon.DEFAULTTAB.RECENT, MyCommon.TabUsageType.Home, null);
- _statuses.AddTab(MyCommon.DEFAULTTAB.REPLY, MyCommon.TabUsageType.Mentions, null);
- _statuses.AddTab(MyCommon.DEFAULTTAB.DM, MyCommon.TabUsageType.DirectMessage, null);
- _statuses.AddTab(MyCommon.DEFAULTTAB.FAV, MyCommon.TabUsageType.Favorites, null);
+ _statuses.AddTab(new HomeTabModel());
+ _statuses.AddTab(new MentionsTabModel());
+ _statuses.AddTab(new DirectMessagesTabModel());
+ _statuses.AddTab(new FavoritesTabModel());
}
}
if (ResetTimers.UserStream || usCounter <= 0 && this._cfgCommon.UserstreamPeriod > 0)
{
Interlocked.Exchange(ref usCounter, this._cfgCommon.UserstreamPeriod);
- if (this._isActiveUserstream)
+ if (this.tw.UserStreamActive)
this.RefreshTimeline();
ResetTimers.UserStream = false;
}
foreach (TabPage tab in ListTab.TabPages)
{
DetailsListView lst = (DetailsListView)tab.Tag;
- TabClass tabInfo = _statuses.Tabs[tab.Text];
+ TabModel tabInfo = _statuses.Tabs[tab.Text];
if (isDelete || lst.VirtualListSize != tabInfo.AllCount)
{
using (ControlTransaction.Update(lst))
/// <summary>
/// <see cref="ListView"/> のスクロール位置に関する情報を <see cref="ListViewScroll"/> として返します
/// </summary>
- private ListViewScroll SaveListViewScroll(DetailsListView listView, TabClass tab)
+ private ListViewScroll SaveListViewScroll(DetailsListView listView, TabModel tab)
{
var listScroll = new ListViewScroll
{
{
var topItem = listView.TopItem;
if (topItem != null)
- listScroll.TopItemStatusId = tab.GetId(topItem.Index);
+ listScroll.TopItemStatusId = tab.GetStatusIdAt(topItem.Index);
}
return listScroll;
return listsDict;
}
- private long[] GetSelectedStatusIds(DetailsListView listView, TabClass tab)
+ private long[] GetSelectedStatusIds(DetailsListView listView, TabModel tab)
{
var selectedIndices = listView.SelectedIndices;
if (selectedIndices.Count > 0 && selectedIndices.Count < 61)
- return tab.GetId(selectedIndices);
+ return tab.GetStatusIdAt(selectedIndices.Cast<int>());
else
return null;
}
- private long? GetFocusedStatusId(DetailsListView listView, TabClass tab)
+ private long? GetFocusedStatusId(DetailsListView listView, TabModel tab)
{
var focusedItem = listView.FocusedItem;
- return focusedItem != null ? tab.GetId(focusedItem.Index) : (long?)null;
+ return focusedItem != null ? tab.GetStatusIdAt(focusedItem.Index) : (long?)null;
}
- private long? GetSelectionMarkStatusId(DetailsListView listView, TabClass tab)
+ private long? GetSelectionMarkStatusId(DetailsListView listView, TabModel tab)
{
var selectionMarkIndex = listView.SelectionMark;
- return selectionMarkIndex != -1 ? tab.GetId(selectionMarkIndex) : (long?)null;
+ return selectionMarkIndex != -1 ? tab.GetStatusIdAt(selectionMarkIndex) : (long?)null;
}
/// <summary>
/// <see cref="SaveListViewScroll"/> によって保存されたスクロール位置を復元します
/// </summary>
- private void RestoreListViewScroll(DetailsListView listView, TabClass tab, ListViewScroll listScroll)
+ private void RestoreListViewScroll(DetailsListView listView, TabModel tab, ListViewScroll listScroll)
{
if (listView.VirtualListSize == 0)
return;
/// <summary>
/// <see cref="SaveListViewStatus"/> によって保存された選択状態を復元します
/// </summary>
- private void RestoreListViewSelection(DetailsListView listView, TabClass tab, ListViewSelection listSelection)
+ private void RestoreListViewSelection(DetailsListView listView, TabModel tab, ListViewSelection listSelection)
{
// status_id から ListView 上のインデックスに変換
int[] selectedIndices = null;
try
{
- var progress = new Progress<string>(x => this.StatusLabel.Text = x);
+ var homeTab = this._statuses.GetTabByType<HomeTabModel>();
+ await homeTab.RefreshAsync(this.tw, loadMore, this._initial, this.workerProgress);
- await this.GetHomeTimelineAsyncInternal(progress, this.workerCts.Token, loadMore);
+ this.RefreshTimeline();
}
catch (WebApiException ex)
{
this._myStatusError = true;
- this.StatusLabel.Text = ex.Message;
+ this.StatusLabel.Text = $"Err:{ex.Message}(GetTimeline)";
}
finally
{
}
}
- private async Task GetHomeTimelineAsyncInternal(IProgress<string> p, CancellationToken ct, bool loadMore)
- {
- if (ct.IsCancellationRequested)
- return;
-
- if (!CheckAccountValid())
- throw new WebApiException("Auth error. Check your account");
-
- bool read;
- if (!this._cfgCommon.UnreadManage)
- read = true;
- else
- read = this._initial && this._cfgCommon.Read;
-
- p.Report(string.Format(Properties.Resources.GetTimelineWorker_RunWorkerCompletedText5, loadMore ? -1 : 1));
-
- await Task.Run(() =>
- {
- this.tw.GetTimelineApi(read, MyCommon.WORKERTYPE.Timeline, loadMore, this._initial);
-
- // 新着時未読クリア
- if (this._cfgCommon.ReadOldPosts)
- this._statuses.SetReadHomeTab();
-
- var addCount = this._statuses.DistributePosts();
-
- if (!this._initial)
- this.UpdateTimelineSpeed(addCount);
- });
-
- if (ct.IsCancellationRequested)
- return;
-
- p.Report(Properties.Resources.GetTimelineWorker_RunWorkerCompletedText1);
-
- this.RefreshTimeline();
- }
-
- /// <summary>
- /// タイムラインに追加された発言件数を反映し、タイムラインの流速を更新します
- /// </summary>
- /// <param name="addCount">直前にタイムラインに追加した発言件数</param>
- private void UpdateTimelineSpeed(int addCount)
- {
- var now = DateTime.Now;
- this._tlTimestamps.AddOrUpdate(now, addCount, (k, v) => v + addCount);
-
- var removeKeys = new List<DateTime>();
- var oneHour = TimeSpan.FromHours(1);
- var tlCount = 0;
- foreach (var pair in this._tlTimestamps)
- {
- if (now - pair.Key > oneHour)
- removeKeys.Add(pair.Key);
- else
- tlCount += pair.Value;
- }
- Interlocked.Exchange(ref this._tlCount, tlCount);
-
- int _;
- foreach (var key in removeKeys)
- this._tlTimestamps.TryRemove(key, out _);
- }
-
private Task GetReplyAsync()
{
return this.GetReplyAsync(loadMore: false);
try
{
- var progress = new Progress<string>(x => this.StatusLabel.Text = x);
+ var replyTab = this._statuses.GetTabByType<MentionsTabModel>();
+ await replyTab.RefreshAsync(this.tw, loadMore, this._initial, this.workerProgress);
- await this.GetReplyAsyncInternal(progress, this.workerCts.Token, loadMore);
+ this.RefreshTimeline();
}
catch (WebApiException ex)
{
this._myStatusError = true;
- this.StatusLabel.Text = ex.Message;
+ this.StatusLabel.Text = $"Err:{ex.Message}(GetTimeline)";
}
finally
{
}
}
- private async Task GetReplyAsyncInternal(IProgress<string> p, CancellationToken ct, bool loadMore)
- {
- if (ct.IsCancellationRequested)
- return;
-
- if (!CheckAccountValid())
- throw new WebApiException("Auth error. Check your account");
-
- bool read;
- if (!this._cfgCommon.UnreadManage)
- read = true;
- else
- read = this._initial && this._cfgCommon.Read;
-
- p.Report(string.Format(Properties.Resources.GetTimelineWorker_RunWorkerCompletedText4, loadMore ? -1 : 1));
-
- await Task.Run(() =>
- {
- this.tw.GetTimelineApi(read, MyCommon.WORKERTYPE.Reply, loadMore, this._initial);
-
- this._statuses.DistributePosts();
- });
-
- if (ct.IsCancellationRequested)
- return;
-
- p.Report(Properties.Resources.GetTimelineWorker_RunWorkerCompletedText9);
-
- this.RefreshTimeline();
- }
-
private Task GetDirectMessagesAsync()
{
return this.GetDirectMessagesAsync(loadMore: false);
try
{
- var progress = new Progress<string>(x => this.StatusLabel.Text = x);
+ var dmTab = this._statuses.GetTabByType<DirectMessagesTabModel>();
+ await dmTab.RefreshAsync(this.tw, loadMore, this._initial, this.workerProgress);
- await this.GetDirectMessagesAsyncInternal(progress, this.workerCts.Token, loadMore);
+ this.RefreshTimeline();
}
catch (WebApiException ex)
{
this._myStatusError = true;
- this.StatusLabel.Text = ex.Message;
+ this.StatusLabel.Text = $"Err:{ex.Message}(GetDirectMessage)";
}
finally
{
}
}
- private async Task GetDirectMessagesAsyncInternal(IProgress<string> p, CancellationToken ct, bool loadMore)
- {
- if (ct.IsCancellationRequested)
- return;
-
- if (!CheckAccountValid())
- throw new WebApiException("Auth error. Check your account");
-
- bool read;
- if (!this._cfgCommon.UnreadManage)
- read = true;
- else
- read = this._initial && this._cfgCommon.Read;
-
- p.Report(string.Format(Properties.Resources.GetTimelineWorker_RunWorkerCompletedText8, loadMore ? -1 : 1));
-
- await Task.Run(() =>
- {
- this.tw.GetDirectMessageApi(read, MyCommon.WORKERTYPE.DirectMessegeRcv, loadMore);
- this.tw.GetDirectMessageApi(read, MyCommon.WORKERTYPE.DirectMessegeSnt, loadMore);
-
- this._statuses.DistributePosts();
- });
-
- if (ct.IsCancellationRequested)
- return;
-
- p.Report(Properties.Resources.GetTimelineWorker_RunWorkerCompletedText11);
-
- this.RefreshTimeline();
- }
-
private Task GetFavoritesAsync()
{
return this.GetFavoritesAsync(loadMore: false);
try
{
- var progress = new Progress<string>(x => this.StatusLabel.Text = x);
+ var favTab = this._statuses.GetTabByType<FavoritesTabModel>();
+ await favTab.RefreshAsync(this.tw, loadMore, this._initial, this.workerProgress);
- await this.GetFavoritesAsyncInternal(progress, this.workerCts.Token, loadMore);
+ this.RefreshTimeline();
}
catch (WebApiException ex)
{
}
}
- private async Task GetFavoritesAsyncInternal(IProgress<string> p, CancellationToken ct, bool loadMore)
- {
- if (ct.IsCancellationRequested)
- return;
-
- if (!CheckAccountValid())
- throw new WebApiException("Auth error. Check your account");
-
- bool read;
- if (!this._cfgCommon.UnreadManage)
- read = true;
- else
- read = this._initial && this._cfgCommon.Read;
-
- p.Report(Properties.Resources.GetTimelineWorker_RunWorkerCompletedText19);
-
- await Task.Run(() =>
- {
- this.tw.GetFavoritesApi(read, loadMore);
-
- this._statuses.DistributePosts();
- });
-
- if (ct.IsCancellationRequested)
- return;
-
- p.Report(Properties.Resources.GetTimelineWorker_RunWorkerCompletedText20);
-
- this.RefreshTimeline();
- }
-
private Task GetPublicSearchAllAsync()
{
- var tabs = this._statuses.GetTabsByType(MyCommon.TabUsageType.PublicSearch);
+ var tabs = this._statuses.GetTabsByType<PublicSearchTabModel>();
return this.GetPublicSearchAsync(tabs, loadMore: false);
}
- private Task GetPublicSearchAsync(TabClass tab)
+ private Task GetPublicSearchAsync(PublicSearchTabModel tab)
{
return this.GetPublicSearchAsync(tab, loadMore: false);
}
- private Task GetPublicSearchAsync(TabClass tab, bool loadMore)
+ private Task GetPublicSearchAsync(PublicSearchTabModel tab, bool loadMore)
{
return this.GetPublicSearchAsync(new[] { tab }, loadMore);
}
- private async Task GetPublicSearchAsync(IEnumerable<TabClass> tabs, bool loadMore)
+ private async Task GetPublicSearchAsync(IEnumerable<PublicSearchTabModel> tabs, bool loadMore)
{
await this.workerSemaphore.WaitAsync();
try
{
- var progress = new Progress<string>(x => this.StatusLabel.Text = x);
-
- await this.GetPublicSearchAsyncInternal(progress, this.workerCts.Token, tabs, loadMore);
- }
- catch (WebApiException ex)
- {
- this._myStatusError = true;
- this.StatusLabel.Text = ex.Message;
- }
- finally
- {
- this.workerSemaphore.Release();
- }
- }
-
- private async Task GetPublicSearchAsyncInternal(IProgress<string> p, CancellationToken ct, IEnumerable<TabClass> tabs, bool loadMore)
- {
- if (ct.IsCancellationRequested)
- return;
-
- if (!CheckAccountValid())
- throw new WebApiException("Auth error. Check your account");
-
- bool read;
- if (!this._cfgCommon.UnreadManage)
- read = true;
- else
- read = this._initial && this._cfgCommon.Read;
-
- p.Report("Search refreshing...");
-
- await Task.Run(() =>
- {
- WebApiException lastException = null;
-
foreach (var tab in tabs)
{
try
{
- if (string.IsNullOrEmpty(tab.SearchWords))
- continue;
-
- this.tw.GetSearch(read, tab, false);
-
- if (loadMore)
- this.tw.GetSearch(read, tab, true);
+ await tab.RefreshAsync(this.tw, loadMore, this._initial, this.workerProgress);
}
catch (WebApiException ex)
{
- lastException = ex;
+ this._myStatusError = true;
+ this.StatusLabel.Text = $"Err:{ex.Message}(GetSearch)";
}
}
- this._statuses.DistributePosts();
-
- if (lastException != null)
- throw new WebApiException(lastException.Message, lastException);
- });
-
- if (ct.IsCancellationRequested)
- return;
-
- p.Report("Search refreshed");
-
- this.RefreshTimeline();
+ this.RefreshTimeline();
+ }
+ finally
+ {
+ this.workerSemaphore.Release();
+ }
}
private Task GetUserTimelineAllAsync()
{
- var tabs = this._statuses.GetTabsByType(MyCommon.TabUsageType.UserTimeline);
+ var tabs = this._statuses.GetTabsByType<UserTimelineTabModel>();
return this.GetUserTimelineAsync(tabs, loadMore: false);
}
- private Task GetUserTimelineAsync(TabClass tab)
+ private Task GetUserTimelineAsync(UserTimelineTabModel tab)
{
return this.GetUserTimelineAsync(tab, loadMore: false);
}
- private Task GetUserTimelineAsync(TabClass tab, bool loadMore)
+ private Task GetUserTimelineAsync(UserTimelineTabModel tab, bool loadMore)
{
return this.GetUserTimelineAsync(new[] { tab }, loadMore);
}
- private async Task GetUserTimelineAsync(IEnumerable<TabClass> tabs, bool loadMore)
+ private async Task GetUserTimelineAsync(IEnumerable<UserTimelineTabModel> tabs, bool loadMore)
{
await this.workerSemaphore.WaitAsync();
try
{
- var progress = new Progress<string>(x => this.StatusLabel.Text = x);
-
- await this.GetUserTimelineAsyncInternal(progress, this.workerCts.Token, tabs, loadMore);
- }
- catch (WebApiException ex)
- {
- this._myStatusError = true;
- this.StatusLabel.Text = ex.Message;
- }
- finally
- {
- this.workerSemaphore.Release();
- }
- }
-
- private async Task GetUserTimelineAsyncInternal(IProgress<string> p, CancellationToken ct, IEnumerable<TabClass> tabs, bool loadMore)
- {
- if (ct.IsCancellationRequested)
- return;
-
- if (!CheckAccountValid())
- throw new WebApiException("Auth error. Check your account");
-
- bool read;
- if (!this._cfgCommon.UnreadManage)
- read = true;
- else
- read = this._initial && this._cfgCommon.Read;
-
- p.Report("UserTimeline refreshing...");
-
- await Task.Run(() =>
- {
- WebApiException lastException = null;
-
foreach (var tab in tabs)
{
try
{
- if (string.IsNullOrEmpty(tab.User))
- continue;
-
- this.tw.GetUserTimelineApi(read, tab.User, tab, loadMore);
+ await tab.RefreshAsync(this.tw, loadMore, this._initial, this.workerProgress);
}
catch (WebApiException ex)
{
- lastException = ex;
+ this._myStatusError = true;
+ this.StatusLabel.Text = $"Err:{ex.Message}(GetUserTimeline)";
}
}
- this._statuses.DistributePosts();
-
- if (lastException != null)
- throw new WebApiException(lastException.Message, lastException);
- });
-
- if (ct.IsCancellationRequested)
- return;
-
- p.Report("UserTimeline refreshed");
-
- this.RefreshTimeline();
+ this.RefreshTimeline();
+ }
+ finally
+ {
+ this.workerSemaphore.Release();
+ }
}
private Task GetListTimelineAllAsync()
{
- var tabs = this._statuses.GetTabsByType(MyCommon.TabUsageType.Lists);
+ var tabs = this._statuses.GetTabsByType<ListTimelineTabModel>();
return this.GetListTimelineAsync(tabs, loadMore: false);
}
- private Task GetListTimelineAsync(TabClass tab)
+ private Task GetListTimelineAsync(ListTimelineTabModel tab)
{
return this.GetListTimelineAsync(tab, loadMore: false);
}
- private Task GetListTimelineAsync(TabClass tab, bool loadMore)
+ private Task GetListTimelineAsync(ListTimelineTabModel tab, bool loadMore)
{
return this.GetListTimelineAsync(new[] { tab }, loadMore);
}
- private async Task GetListTimelineAsync(IEnumerable<TabClass> tabs, bool loadMore)
+ private async Task GetListTimelineAsync(IEnumerable<ListTimelineTabModel> tabs, bool loadMore)
{
await this.workerSemaphore.WaitAsync();
try
{
- var progress = new Progress<string>(x => this.StatusLabel.Text = x);
-
- await this.GetListTimelineAsyncInternal(progress, this.workerCts.Token, tabs, loadMore);
- }
- catch (WebApiException ex)
- {
- this._myStatusError = true;
- this.StatusLabel.Text = ex.Message;
- }
- finally
- {
- this.workerSemaphore.Release();
- }
- }
-
- private async Task GetListTimelineAsyncInternal(IProgress<string> p, CancellationToken ct, IEnumerable<TabClass> tabs, bool loadMore)
- {
- if (ct.IsCancellationRequested)
- return;
-
- if (!CheckAccountValid())
- throw new WebApiException("Auth error. Check your account");
-
- bool read;
- if (!this._cfgCommon.UnreadManage)
- read = true;
- else
- read = this._initial && this._cfgCommon.Read;
-
- p.Report("List refreshing...");
-
- await Task.Run(() =>
- {
- WebApiException lastException = null;
-
foreach (var tab in tabs)
{
try
{
- if (tab.ListInfo == null || tab.ListInfo.Id == 0)
- continue;
-
- this.tw.GetListStatus(read, tab, loadMore, this._initial);
+ await tab.RefreshAsync(this.tw, loadMore, this._initial, this.workerProgress);
}
catch (WebApiException ex)
{
- lastException = ex;
+ this._myStatusError = true;
+ this.StatusLabel.Text = $"Err:{ex.Message}(GetListStatus)";
}
}
- this._statuses.DistributePosts();
-
- if (lastException != null)
- throw new WebApiException(lastException.Message, lastException);
- });
-
- if (ct.IsCancellationRequested)
- return;
-
- p.Report("List refreshed");
-
- this.RefreshTimeline();
+ this.RefreshTimeline();
+ }
+ finally
+ {
+ this.workerSemaphore.Release();
+ }
}
- private async Task GetRelatedTweetsAsync(TabClass tab)
+ private async Task GetRelatedTweetsAsync(RelatedPostsTabModel tab)
{
await this.workerSemaphore.WaitAsync();
try
{
- var progress = new Progress<string>(x => this.StatusLabel.Text = x);
+ await tab.RefreshAsync(this.tw, this._initial, this.workerProgress);
- await this.GetRelatedTweetsAsyncInternal(progress, this.workerCts.Token, tab);
+ this.RefreshTimeline();
}
catch (WebApiException ex)
{
this._myStatusError = true;
- this.StatusLabel.Text = ex.Message;
+ this.StatusLabel.Text = $"Err:{ex.Message}(GetRelatedTweets)";
}
finally
{
}
}
- private async Task GetRelatedTweetsAsyncInternal(IProgress<string> p, CancellationToken ct, TabClass tab)
- {
- if (ct.IsCancellationRequested)
- return;
-
- if (!CheckAccountValid())
- throw new WebApiException("Auth error. Check your account");
-
- bool read;
- if (!this._cfgCommon.UnreadManage)
- read = true;
- else
- read = this._initial && this._cfgCommon.Read;
-
- p.Report("Related refreshing...");
-
- await Task.Run(async () =>
- {
- await this.tw.GetRelatedResult(read, tab)
- .ConfigureAwait(false);
-
- this._statuses.DistributePosts();
- });
-
- if (ct.IsCancellationRequested)
- return;
-
- p.Report("Related refreshed");
-
- this.RefreshTimeline();
-
- var tabPage = this.ListTab.TabPages.Cast<TabPage>()
- .FirstOrDefault(x => x.Text == tab.TabName);
-
- if (tabPage != null)
- {
- // TODO: 非同期更新中にタブが閉じられている場合を厳密に考慮したい
-
- var listView = (DetailsListView)tabPage.Tag;
- var index = tab.IndexOf(tab.RelationTargetPost.RetweetedId ?? tab.RelationTargetPost.StatusId);
-
- if (index != -1 && index < listView.Items.Count)
- {
- listView.SelectedIndices.Add(index);
- listView.Items[index].Focused = true;
- }
- }
- }
-
- private async Task FavAddAsync(long statusId, TabClass tab)
+ private async Task FavAddAsync(long statusId, TabModel tab)
{
await this.workerSemaphore.WaitAsync();
}
}
- private async Task FavAddAsyncInternal(IProgress<string> p, CancellationToken ct, long statusId, TabClass tab)
+ private async Task FavAddAsyncInternal(IProgress<string> p, CancellationToken ct, long statusId, TabModel tab)
{
if (ct.IsCancellationRequested)
return;
postTl.IsFav = true;
var favTab = this._statuses.GetTabByType(MyCommon.TabUsageType.Favorites);
- favTab.AddPostQueue(statusId, postTl.IsRead);
+ favTab.AddPostQueue(postTl);
}
// 検索,リスト,UserTimeline,Relatedの各タブに反映
}
}
- private async Task FavRemoveAsync(IReadOnlyList<long> statusIds, TabClass tab)
+ private async Task FavRemoveAsync(IReadOnlyList<long> statusIds, TabModel tab)
{
await this.workerSemaphore.WaitAsync();
}
}
- private async Task FavRemoveAsyncInternal(IProgress<string> p, CancellationToken ct, IReadOnlyList<long> statusIds, TabClass tab)
+ private async Task FavRemoveAsyncInternal(IProgress<string> p, CancellationToken ct, IReadOnlyList<long> statusIds, TabModel tab)
{
if (ct.IsCancellationRequested)
return;
if (ct.IsCancellationRequested)
return;
- this.RemovePostFromFavTab(successIds.ToArray());
+ var favTab = this._statuses.GetTabByType(MyCommon.TabUsageType.Favorites);
+ foreach (var statusId in successIds)
+ {
+ // ツイートが削除された訳ではないので IsDeleted はセットしない
+ favTab.EnqueueRemovePost(statusId, setIsDeleted: false);
+ }
this.RefreshTimeline();
catch (WebApiException ex)
{
this._myStatusError = true;
- this.StatusLabel.Text = ex.Message;
+ this.StatusLabel.Text = $"Err:{ex.Message}(PostMessage)";
}
finally
{
catch (WebApiException ex)
{
// 処理は中断せずエラーの表示のみ行う
- errMsg = ex.Message;
+ errMsg = $"Err:{ex.Message}(PostMessage)";
p.Report(errMsg);
this._myStatusError = true;
}
if (this._cfgCommon.PostAndGet)
{
- if (this._isActiveUserstream)
+ if (this.tw.UserStreamActive)
this.RefreshTimeline();
else
await this.GetHomeTimelineAsync();
catch (WebApiException ex)
{
this._myStatusError = true;
- this.StatusLabel.Text = ex.Message;
+ this.StatusLabel.Text = $"Err:{ex.Message}(PostRetweet)";
}
finally
{
p.Report("Posting...");
- await Task.Run(() =>
- {
- foreach (var statusId in statusIds)
- {
- this.tw.PostRetweet(statusId, read);
- }
- });
+ var retweetTasks = from statusId in statusIds
+ select this.tw.PostRetweet(statusId, read);
+
+ await Task.WhenAll(retweetTasks)
+ .ConfigureAwait(false);
if (ct.IsCancellationRequested)
return;
this._postTimestamps.RemoveAt(i);
}
- if (this._cfgCommon.PostAndGet && !this._isActiveUserstream)
+ if (this._cfgCommon.PostAndGet && !this.tw.UserStreamActive)
await this.GetHomeTimelineAsync();
}
{
this.StatusLabel.Text = Properties.Resources.UpdateFollowersMenuItem1_ClickText1;
- await Task.Run(() => tw.RefreshFollowerIds());
+ await this.tw.RefreshFollowerIds();
this.StatusLabel.Text = Properties.Resources.UpdateFollowersMenuItem1_ClickText3;
}
catch (WebApiException ex)
{
- this.StatusLabel.Text = ex.Message;
+ this.StatusLabel.Text = $"Err:{ex.Message}(RefreshFollowersIds)";
}
finally
{
await this.workerSemaphore.WaitAsync();
try
{
- await Task.Run(() => tw.RefreshNoRetweetIds());
+ await this.tw.RefreshNoRetweetIds();
this.StatusLabel.Text = "NoRetweetIds refreshed";
}
catch (WebApiException ex)
{
- this.StatusLabel.Text = ex.Message;
+ this.StatusLabel.Text = $"Err:{ex.Message}(RefreshNoRetweetIds)";
}
finally
{
{
this.StatusLabel.Text = Properties.Resources.UpdateBlockUserText1;
- await Task.Run(() => tw.RefreshBlockIds());
+ await this.tw.RefreshBlockIds();
this.StatusLabel.Text = Properties.Resources.UpdateBlockUserText3;
}
catch (WebApiException ex)
{
- this.StatusLabel.Text = ex.Message;
+ this.StatusLabel.Text = $"Err:{ex.Message}(RefreshBlockIds)";
}
finally
{
await this.workerSemaphore.WaitAsync();
try
{
- await Task.Run(() => tw.RefreshConfiguration());
+ await this.tw.RefreshConfiguration();
if (this.tw.Configuration.PhotoSizeLimit != 0)
{
}
catch (WebApiException ex)
{
- this.StatusLabel.Text = ex.Message;
+ this.StatusLabel.Text = $"Err:{ex.Message}(RefreshConfiguration)";
}
finally
{
this.StatusLabel.Text = Properties.Resources.UpdateMuteUserIds_Finish;
}
- private void RemovePostFromFavTab(Int64[] ids)
- {
- var favTab = this._statuses.GetTabByType(MyCommon.TabUsageType.Favorites);
- string favTabName = favTab.TabName;
- int fidx = 0;
- if (_curTab.Text.Equals(favTabName))
- {
- fidx = _curList.FocusedItem?.Index ?? _curList.TopItem?.Index ?? 0;
- }
-
- foreach (long i in ids)
- {
- try
- {
- _statuses.RemoveFavPost(i);
- }
- catch (Exception)
- {
- continue;
- }
- }
- if (_curTab != null && _curTab.Text.Equals(favTabName))
- {
- this.PurgeListViewItemCache();
- _curPost = null;
- //_curItemIndex = -1;
- }
- foreach (TabPage tp in ListTab.TabPages)
- {
- if (tp.Text == favTabName)
- {
- ((DetailsListView)tp.Tag).VirtualListSize = favTab.AllCount;
- break;
- }
- }
- if (_curTab.Text.Equals(favTabName))
- {
- do
- {
- _curList.SelectedIndices.Clear();
- }
- while (_curList.SelectedIndices.Count > 0);
-
- if (favTab.AllCount > 0)
- {
- if (favTab.AllCount - 1 > fidx && fidx > -1)
- {
- _curList.SelectedIndices.Add(fidx);
- }
- else
- {
- _curList.SelectedIndices.Add(favTab.AllCount - 1);
- }
- if (_curList.SelectedIndices.Count > 0)
- {
- _curList.EnsureVisible(_curList.SelectedIndices[0]);
- _curList.FocusedItem = _curList.Items[_curList.SelectedIndices[0]];
- }
- }
- }
- }
-
private void NotifyIcon1_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
private async Task FavoriteChange(bool FavAdd, bool multiFavoriteChangeDialogEnable = true)
{
- TabClass tab;
+ TabModel tab;
if (!this._statuses.Tabs.TryGetValue(this._curTab.Text, out tab))
return;
{
// 表示上の列の位置から ColumnHeader を求める
var col = this._curList.Columns.Cast<ColumnHeader>()
- .Where(x => x.DisplayIndex == columnIndex)
- .FirstOrDefault();
+ .FirstOrDefault(x => x.DisplayIndex == columnIndex);
if (col == null)
return;
continue;
}
- this._statuses.RemovePost(post.StatusId);
+ this._statuses.RemovePostFromAllTabs(post.StatusId, setIsDeleted: true);
}
if (lastException == null)
{
if (_curTab != null)
{
- TabClass tab;
+ TabModel tab;
if (!this._statuses.Tabs.TryGetValue(this._curTab.Text, out tab))
return;
//case MyCommon.TabUsageType.Profile:
//// TODO
case MyCommon.TabUsageType.PublicSearch:
- //// TODO
- if (string.IsNullOrEmpty(tab.SearchWords)) return;
- await this.GetPublicSearchAsync(tab);
+ var searchTab = (PublicSearchTabModel)tab;
+ if (string.IsNullOrEmpty(searchTab.SearchWords)) return;
+ await this.GetPublicSearchAsync(searchTab);
break;
case MyCommon.TabUsageType.UserTimeline:
- await this.GetUserTimelineAsync(tab);
+ await this.GetUserTimelineAsync((UserTimelineTabModel)tab);
break;
case MyCommon.TabUsageType.Lists:
- //// TODO
- if (tab.ListInfo == null || tab.ListInfo.Id == 0) return;
- await this.GetListTimelineAsync(tab);
+ var listTab = (ListTimelineTabModel)tab;
+ if (listTab.ListInfo == null || listTab.ListInfo.Id == 0) return;
+ await this.GetListTimelineAsync(listTab);
break;
default:
await this.GetHomeTimelineAsync();
//ページ指定をマイナス1に
if (_curTab != null)
{
- TabClass tab;
+ TabModel tab;
if (!this._statuses.Tabs.TryGetValue(this._curTab.Text, out tab))
return;
//// TODO
break;
case MyCommon.TabUsageType.PublicSearch:
- // TODO
- if (string.IsNullOrEmpty(tab.SearchWords)) return;
- await this.GetPublicSearchAsync(tab, loadMore: true);
+ var searchTab = (PublicSearchTabModel)tab;
+ if (string.IsNullOrEmpty(searchTab.SearchWords)) return;
+ await this.GetPublicSearchAsync(searchTab, loadMore: true);
break;
case MyCommon.TabUsageType.UserTimeline:
- await this.GetUserTimelineAsync(tab, loadMore: true);
+ await this.GetUserTimelineAsync((UserTimelineTabModel)tab, loadMore: true);
break;
case MyCommon.TabUsageType.Lists:
- //// TODO
- if (tab.ListInfo == null || tab.ListInfo.Id == 0) return;
- await this.GetListTimelineAsync(tab, loadMore: true);
+ var listTab = (ListTimelineTabModel)tab;
+ if (listTab.ListInfo == null || listTab.ListInfo.Id == 0) return;
+ await this.GetListTimelineAsync(listTab, loadMore: true);
break;
default:
await this.GetHomeTimelineAsync(loadMore: true);
ShortUrl.Instance.DisableExpanding = !this._cfgCommon.TinyUrlResolve;
ShortUrl.Instance.BitlyId = this._cfgCommon.BilyUser;
ShortUrl.Instance.BitlyKey = this._cfgCommon.BitlyPwd;
- HttpTwitter.TwitterUrl = _cfgCommon.TwitterUrl;
+ TwitterApiConnection.RestApiHost = this._cfgCommon.TwitterApiHost;
Networking.DefaultTimeout = TimeSpan.FromSeconds(this._cfgCommon.DefaultTimeOut);
Networking.SetWebProxy(this._cfgLocal.ProxyType,
{
// キャンセル時は Twitter クラスの認証情報を画面表示前の状態に戻す
this.tw.Initialize(oldUser.AccessToken, oldUser.AccessTokenSecret, oldUser.Username, oldUser.UserId);
- this.twitterApi.Initialize(oldUser.AccessToken, oldUser.AccessTokenSecret, oldUser.UserId, oldUser.Username);
}
Twitter.AccountState = MyCommon.ACCOUNT_STATE.Valid;
foreach (TabPage tab in ListTab.TabPages)
{
DetailsListView lst = (DetailsListView)tab.Tag;
- TabClass tabInfo = _statuses.Tabs[tab.Text];
+ TabModel tabInfo = _statuses.Tabs[tab.Text];
using (ControlTransaction.Update(lst))
{
// 選択位置などを復元
}
}
- private async void PostBrowser_Navigated(object sender, WebBrowserNavigatedEventArgs e)
- {
- if (e.Url.AbsoluteUri != "about:blank")
- {
- await this.DispSelectedPost();
- await this.OpenUriInBrowserAsync(e.Url.OriginalString);
- }
- }
-
- private async void PostBrowser_Navigating(object sender, WebBrowserNavigatingEventArgs e)
- {
- if (e.Url.Scheme == "data")
- {
- StatusLabelUrl.Text = PostBrowser.StatusText.Replace("&", "&&");
- }
- else if (e.Url.AbsoluteUri != "about:blank")
- {
- e.Cancel = true;
- // Ctrlを押しながらリンクを開いた場合は、設定と逆の動作をするフラグを true としておく
- await this.OpenUriAsync( e.Url, MyCommon.IsKeyDown( Keys.Control ) );
- }
- }
-
public void AddNewTabForSearch(string searchWord)
{
//同一検索条件のタブが既に存在すれば、そのタブアクティブにして終了
- foreach (TabClass tb in _statuses.GetTabsByType(MyCommon.TabUsageType.PublicSearch))
+ foreach (var tb in _statuses.GetTabsByType<PublicSearchTabModel>())
{
if (tb.SearchWords == searchWord && string.IsNullOrEmpty(tb.SearchLang))
{
break;
}
//タブ追加
- _statuses.AddTab(tabName, MyCommon.TabUsageType.PublicSearch, null);
- AddNewTab(tabName, false, MyCommon.TabUsageType.PublicSearch);
+ var tab = new PublicSearchTabModel(tabName);
+ _statuses.AddTab(tab);
+ AddNewTab(tab, startup: false);
//追加したタブをアクティブに
ListTab.SelectedIndex = ListTab.TabPages.Count - 1;
//検索条件の設定
public void AddNewTabForUserTimeline(string user)
{
//同一検索条件のタブが既に存在すれば、そのタブアクティブにして終了
- foreach (TabClass tb in _statuses.GetTabsByType(MyCommon.TabUsageType.UserTimeline))
+ foreach (var tb in _statuses.GetTabsByType<UserTimelineTabModel>())
{
- if (tb.User == user)
+ if (tb.ScreenName == user)
{
foreach (TabPage tp in ListTab.TabPages)
{
tabName += "_";
}
//タブ追加
- _statuses.AddTab(tabName, MyCommon.TabUsageType.UserTimeline, null);
- var tab = this._statuses.Tabs[tabName];
- tab.User = user;
- AddNewTab(tabName, false, MyCommon.TabUsageType.UserTimeline);
+ var tab = new UserTimelineTabModel(tabName, user);
+ this._statuses.AddTab(tab);
+ this.AddNewTab(tab, startup: false);
//追加したタブをアクティブに
ListTab.SelectedIndex = ListTab.TabPages.Count - 1;
SaveConfigsTabs();
this.GetUserTimelineAsync(tab);
}
- public bool AddNewTab(string tabName, bool startup, MyCommon.TabUsageType tabType, ListElement listInfo = null)
+ public bool AddNewTab(TabModel tab, bool startup)
{
//重複チェック
foreach (TabPage tb in ListTab.TabPages)
{
- if (tb.Text == tabName) return false;
+ if (tb.Text == tab.TabName) return false;
}
//新規タブ名チェック
- if (tabName == Properties.Resources.AddNewTabText1) return false;
-
- //タブタイプ重複チェック
- if (!startup)
- {
- if (tabType == MyCommon.TabUsageType.DirectMessage ||
- tabType == MyCommon.TabUsageType.Favorites ||
- tabType == MyCommon.TabUsageType.Home ||
- tabType == MyCommon.TabUsageType.Mentions ||
- tabType == MyCommon.TabUsageType.Related)
- {
- if (_statuses.GetTabByType(tabType) != null) return false;
- }
- }
+ if (tab.TabName == Properties.Resources.AddNewTabText1) return false;
var _tabPage = new TabPage();
var _listCustom = new DetailsListView();
_tabPage.Controls.Add(_listCustom);
/// UserTimeline関連
- if (tabType == MyCommon.TabUsageType.UserTimeline || tabType == MyCommon.TabUsageType.Lists)
+ var userTab = tab as UserTimelineTabModel;
+ var listTab = tab as ListTimelineTabModel;
+ var searchTab = tab as PublicSearchTabModel;
+
+ if (userTab != null || listTab != null)
{
var label = new Label();
label.Dock = DockStyle.Top;
label.Name = "labelUser";
label.TabIndex = 0;
- if (tabType == MyCommon.TabUsageType.Lists)
+
+ if (listTab != null)
{
- label.Text = listInfo.ToString();
+ label.Text = listTab.ListInfo.ToString();
}
- else
+ else if (userTab != null)
{
- label.Text = _statuses.Tabs[tabName].User + "'s Timeline";
+ label.Text = userTab.ScreenName + "'s Timeline";
}
label.TextAlign = ContentAlignment.MiddleLeft;
using (ComboBox tmpComboBox = new ComboBox())
_tabPage.Controls.Add(label);
}
/// 検索関連の準備
- else if (tabType == MyCommon.TabUsageType.PublicSearch)
+ else if (searchTab != null)
{
var pnl = new Panel();
btn.TabIndex = 3;
btn.Click += SearchButton_Click;
- TabClass tab;
- if (_statuses.Tabs.TryGetValue(tabName, out tab))
+ if (!string.IsNullOrEmpty(searchTab.SearchWords))
{
- if (!string.IsNullOrEmpty(tab.SearchWords))
- {
- cmb.Items.Add(tab.SearchWords);
- cmb.Text = tab.SearchWords;
- }
-
- cmbLang.Text = tab.SearchLang;
+ cmb.Items.Add(searchTab.SearchWords);
+ cmb.Text = searchTab.SearchWords;
}
+ cmbLang.Text = searchTab.SearchLang;
+
_tabPage.Controls.Add(pnl);
}
}
this.ListTab.Controls.Add(_tabPage);
_tabPage.Location = new Point(4, 4);
- _tabPage.Name = "CTab" + cnt.ToString();
+ _tabPage.Name = "CTab" + cnt;
_tabPage.Size = new Size(380, 260);
_tabPage.TabIndex = 2 + cnt;
- _tabPage.Text = tabName;
+ _tabPage.Text = tab.TabName;
_tabPage.UseVisualStyleBackColor = true;
_tabPage.AccessibleRole = AccessibleRole.PageTab;
_listCustom.HideSelection = false;
_listCustom.Location = new Point(0, 0);
_listCustom.Margin = new Padding(0);
- _listCustom.Name = "CList" + Environment.TickCount.ToString();
+ _listCustom.Name = "CList" + Environment.TickCount;
_listCustom.ShowItemToolTips = true;
_listCustom.Size = new Size(380, 260);
_listCustom.UseCompatibleStateImageBehavior = false;
{
DetailsListView lst = (DetailsListView)tp.Tag;
var count = _statuses.Tabs[tp.Text].AllCount;
- if (lst.VirtualListSize != count)
- {
- lst.VirtualListSize = count;
- }
+ lst.VirtualListSize = count;
}
return true;
if (!this._cfgCommon.TabMouseLock && e.Button == MouseButtons.Left && _tabDrag)
{
string tn = "";
- Rectangle dragEnableRectangle = new Rectangle((int)(_tabMouseDownPoint.X - (SystemInformation.DragSize.Width / 2)), (int)(_tabMouseDownPoint.Y - (SystemInformation.DragSize.Height / 2)), SystemInformation.DragSize.Width, SystemInformation.DragSize.Height);
+ Rectangle dragEnableRectangle = new Rectangle(_tabMouseDownPoint.X - (SystemInformation.DragSize.Width / 2), _tabMouseDownPoint.Y - (SystemInformation.DragSize.Height / 2), SystemInformation.DragSize.Width, SystemInformation.DragSize.Height);
if (!dragEnableRectangle.Contains(e.Location))
{
//タブが多段の場合にはMouseDownの前の段階で選択されたタブの段が変わっているので、このタイミングでカーソルの位置からタブを判定出来ない。
_isColumnChanged = false;
}
- private void PostBrowser_StatusTextChanged(object sender, EventArgs e)
- {
- try
- {
- if (PostBrowser.StatusText.StartsWith("http", StringComparison.Ordinal)
- || PostBrowser.StatusText.StartsWith("ftp", StringComparison.Ordinal)
- || PostBrowser.StatusText.StartsWith("data", StringComparison.Ordinal))
- {
- StatusLabelUrl.Text = PostBrowser.StatusText.Replace("&", "&&");
- }
- if (string.IsNullOrEmpty(PostBrowser.StatusText))
- {
- SetStatusLabelUrl();
- }
- }
- catch (Exception)
- {
- }
- }
-
private void StatusText_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == '@')
if (e.KeyCode == Keys.Space || e.KeyCode == Keys.ProcessKey)
{
bool isSpace = false;
- foreach (char c in StatusText.Text.ToCharArray())
+ foreach (char c in StatusText.Text)
{
if (c == ' ' || c == ' ')
{
//if (Post.IsMark) mk.Append("♪");
//if (Post.IsProtect) mk.Append("Ю");
//if (Post.InReplyToStatusId != null) mk.Append("⇒");
- if (Post.FavoritedCount > 0) mk.Append("+" + Post.FavoritedCount.ToString());
+ if (Post.FavoritedCount > 0) mk.Append("+" + Post.FavoritedCount);
ImageListViewItem itm;
if (Post.RetweetedId == null)
{
// }
//}
- private void DoTabSearch(string searchWord, bool caseSensitive, bool useRegex, SEARCHTYPE searchType)
+ internal void DoTabSearch(string searchWord, bool caseSensitive, bool useRegex, SEARCHTYPE searchType)
{
var tab = this._statuses.Tabs[this._curTab.Text];
MessageBox.Show(this, ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
- this.AddNewTab(tabName, false, MyCommon.TabUsageType.SearchResults);
- this._statuses.AddTab(tabName, MyCommon.TabUsageType.SearchResults, null);
+ var resultTab = new LocalSearchTabModel(tabName);
+ this.AddNewTab(resultTab, startup: false);
+ this._statuses.AddTab(resultTab);
var targetTab = this._statuses.Tabs[this._curTab.Text];
}
var foundPosts = foundIndices.Select(x => targetTab[x]);
-
- var resultTab = this._statuses.Tabs[tabName];
foreach (var post in foundPosts)
{
- resultTab.AddPostToInnerStorage(post);
+ resultTab.AddPostQueue(post);
}
this._statuses.DistributePosts();
return detailHtmlFormatHeader + orgdata + detailHtmlFormatFooter;
}
- private async void DisplayItemImage_Downloaded(object sender, EventArgs e)
- {
- if (sender.Equals(displayItem))
- {
- this.ClearUserPicture();
-
- var img = displayItem.Image;
- try
- {
- if (img != null)
- img = await img.CloneAsync();
-
- UserPicture.Image = img;
- }
- catch (Exception)
- {
- UserPicture.ShowErrorImage();
- }
- }
- }
-
private Task DispSelectedPost()
{
return this.DispSelectedPost(false);
if (!forceupdate && this._curPost.Equals(oldDisplayPost))
return;
- if (displayItem != null)
- {
- displayItem.ImageDownloaded -= this.DisplayItemImage_Downloaded;
- displayItem = null;
- }
- displayItem = (ImageListViewItem)_curList.Items[_curList.SelectedIndices[0]];
- displayItem.ImageDownloaded += this.DisplayItemImage_Downloaded;
-
- using (ControlTransaction.Update(this.TableLayoutPanel1))
- {
- SourceLinkLabel.Text = this._curPost.Source;
- SourceLinkLabel.Tag = this._curPost.SourceUri;
- SourceLinkLabel.TabStop = false; // Text を更新すると勝手に true にされる
-
- string nameText;
- if (_curPost.IsDm)
- {
- if (_curPost.IsOwl)
- nameText = "DM FROM <- ";
- else
- nameText = "DM TO -> ";
- }
- else
- {
- nameText = "";
- }
- nameText += _curPost.ScreenName + "/" + _curPost.Nickname;
- if (_curPost.RetweetedId != null)
- nameText += " (RT:" + _curPost.RetweetedBy + ")";
-
- NameLabel.Text = nameText;
- NameLabel.Tag = _curPost.ScreenName;
-
- var nameForeColor = SystemColors.ControlText;
- if (_curPost.IsOwl && (this._cfgCommon.OneWayLove || _curPost.IsDm))
- nameForeColor = this._clOWL;
- if (_curPost.RetweetedId != null)
- nameForeColor = this._clRetweet;
- if (_curPost.IsFav)
- nameForeColor = this._clFav;
- NameLabel.ForeColor = nameForeColor;
-
- this.ClearUserPicture();
-
- if (!string.IsNullOrEmpty(_curPost.ImageUrl))
- {
- var image = IconCache.TryGetFromCache(_curPost.ImageUrl);
- try
- {
- UserPicture.Image = image?.Clone();
- }
- catch (Exception)
- {
- UserPicture.ShowErrorImage();
- }
- }
-
- DateTimeLabel.Text = _curPost.CreatedAt.ToString();
- }
-
- if (DumpPostClassToolStripMenuItem.Checked)
+ var loadTasks = new List<Task>
{
- StringBuilder sb = new StringBuilder(512);
-
- sb.Append("-----Start PostClass Dump<br>");
- sb.AppendFormat("TextFromApi : {0}<br>", _curPost.TextFromApi);
- sb.AppendFormat("(PlainText) : <xmp>{0}</xmp><br>", _curPost.TextFromApi);
- sb.AppendFormat("StatusId : {0}<br>", _curPost.StatusId.ToString());
- //sb.AppendFormat("ImageIndex : {0}<br>", _curPost.ImageIndex.ToString());
- sb.AppendFormat("ImageUrl : {0}<br>", _curPost.ImageUrl);
- sb.AppendFormat("InReplyToStatusId : {0}<br>", _curPost.InReplyToStatusId.ToString());
- sb.AppendFormat("InReplyToUser : {0}<br>", _curPost.InReplyToUser);
- sb.AppendFormat("IsDM : {0}<br>", _curPost.IsDm.ToString());
- sb.AppendFormat("IsFav : {0}<br>", _curPost.IsFav.ToString());
- sb.AppendFormat("IsMark : {0}<br>", _curPost.IsMark.ToString());
- sb.AppendFormat("IsMe : {0}<br>", _curPost.IsMe.ToString());
- sb.AppendFormat("IsOwl : {0}<br>", _curPost.IsOwl.ToString());
- sb.AppendFormat("IsProtect : {0}<br>", _curPost.IsProtect.ToString());
- sb.AppendFormat("IsRead : {0}<br>", _curPost.IsRead.ToString());
- sb.AppendFormat("IsReply : {0}<br>", _curPost.IsReply.ToString());
-
- foreach (string nm in _curPost.ReplyToList)
- {
- sb.AppendFormat("ReplyToList : {0}<br>", nm);
- }
-
- sb.AppendFormat("ScreenName : {0}<br>", _curPost.ScreenName);
- sb.AppendFormat("NickName : {0}<br>", _curPost.Nickname);
- sb.AppendFormat("Text : {0}<br>", _curPost.Text);
- sb.AppendFormat("(PlainText) : <xmp>{0}</xmp><br>", _curPost.Text);
- sb.AppendFormat("CreatedAt : {0}<br>", _curPost.CreatedAt.ToString());
- sb.AppendFormat("Source : {0}<br>", _curPost.Source);
- sb.AppendFormat("UserId : {0}<br>", _curPost.UserId);
- sb.AppendFormat("FilterHit : {0}<br>", _curPost.FilterHit);
- sb.AppendFormat("RetweetedBy : {0}<br>", _curPost.RetweetedBy);
- sb.AppendFormat("RetweetedId : {0}<br>", _curPost.RetweetedId);
-
- sb.AppendFormat("Media.Count : {0}<br>", _curPost.Media.Count);
- if (_curPost.Media.Count > 0)
- {
- for (int i = 0; i < _curPost.Media.Count; i++)
- {
- var info = _curPost.Media[i];
- sb.AppendFormat("Media[{0}].Url : {1}<br>", i, info.Url);
- sb.AppendFormat("Media[{0}].VideoUrl : {1}<br>", i, info.VideoUrl ?? "---");
- }
- }
- sb.Append("-----End PostClass Dump<br>");
-
- PostBrowser.DocumentText = detailHtmlFormatHeader + sb.ToString() + detailHtmlFormatFooter;
- return;
- }
+ this.tweetDetailsView.ShowPostDetails(this._curPost),
+ };
- var loadTasks = new List<Task>();
+ this.SplitContainer3.Panel2Collapsed = true;
- // 同じIDのツイートであれば WebBrowser とサムネイルの更新を行わない
- // (同一ツイートの RT は文面が同じであるため同様に更新しない)
- if (_curPost.StatusId != oldDisplayPost.StatusId)
+ if (this._cfgCommon.PreviewEnable)
{
- using (ControlTransaction.Update(this.PostBrowser))
- {
- this.PostBrowser.DocumentText =
- this.createDetailHtml(_curPost.IsDeleted ? "(DELETED)" : _curPost.Text);
-
- this.PostBrowser.Document.Window.ScrollTo(0, 0);
- }
-
- this.SplitContainer3.Panel2Collapsed = true;
-
- if (this._cfgCommon.PreviewEnable)
- {
- var oldTokenSource = Interlocked.Exchange(ref this.thumbnailTokenSource, new CancellationTokenSource());
- oldTokenSource?.Cancel();
-
- var token = this.thumbnailTokenSource.Token;
- loadTasks.Add(this.tweetThumbnail1.ShowThumbnailAsync(_curPost, token));
- }
+ var oldTokenSource = Interlocked.Exchange(ref this.thumbnailTokenSource, new CancellationTokenSource());
+ oldTokenSource?.Cancel();
- loadTasks.Add(this.AppendQuoteTweetAsync(this._curPost));
+ var token = this.thumbnailTokenSource.Token;
+ loadTasks.Add(this.tweetThumbnail1.ShowThumbnailAsync(_curPost, token));
}
try
catch (OperationCanceledException) { }
}
- /// <summary>
- /// 発言詳細欄のツイートURLを展開する
- /// </summary>
- private async Task AppendQuoteTweetAsync(PostClass post)
- {
- var quoteStatusIds = post.QuoteStatusIds;
- if (quoteStatusIds.Length == 0 && post.InReplyToStatusId == null)
- return;
-
- // 「読み込み中」テキストを表示
- var loadingQuoteHtml = quoteStatusIds.Select(x => FormatQuoteTweetHtml(x, Properties.Resources.LoadingText, isReply: false));
-
- var loadingReplyHtml = string.Empty;
- if (post.InReplyToStatusId != null)
- loadingReplyHtml = FormatQuoteTweetHtml(post.InReplyToStatusId.Value, Properties.Resources.LoadingText, isReply: true);
-
- var body = post.Text + string.Concat(loadingQuoteHtml) + loadingReplyHtml;
-
- using (ControlTransaction.Update(this.PostBrowser))
- this.PostBrowser.DocumentText = this.createDetailHtml(body);
-
- // 引用ツイートを読み込み
- var loadTweetTasks = quoteStatusIds.Select(x => this.CreateQuoteTweetHtml(x, isReply: false)).ToList();
-
- if (post.InReplyToStatusId != null)
- loadTweetTasks.Add(this.CreateQuoteTweetHtml(post.InReplyToStatusId.Value, isReply: true));
-
- var quoteHtmls = await Task.WhenAll(loadTweetTasks);
-
- // 非同期処理中に表示中のツイートが変わっていたらキャンセルされたものと扱う
- if (this._curPost != post || this._curPost.IsDeleted)
- return;
-
- body = post.Text + string.Concat(quoteHtmls);
-
- using (ControlTransaction.Update(this.PostBrowser))
- this.PostBrowser.DocumentText = this.createDetailHtml(body);
- }
-
- private async Task<string> CreateQuoteTweetHtml(long statusId, bool isReply)
- {
- PostClass post = this._statuses[statusId];
- if (post == null)
- {
- try
- {
- post = await this.tw.GetStatusApi(false, statusId)
- .ConfigureAwait(false);
- }
- catch (WebApiException ex)
- {
- return FormatQuoteTweetHtml(statusId, WebUtility.HtmlEncode(ex.Message), isReply);
- }
-
- post.IsRead = true;
- if (!this._statuses.AddQuoteTweet(post))
- return FormatQuoteTweetHtml(statusId, "This Tweet is unavailable.", isReply);
- }
-
- return FormatQuoteTweetHtml(post, isReply);
- }
-
- internal static string FormatQuoteTweetHtml(PostClass post, bool isReply)
- {
- var innerHtml = "<p>" + StripLinkTagHtml(post.Text) + "</p>" +
- " — " + WebUtility.HtmlEncode(post.Nickname) +
- " (@" + WebUtility.HtmlEncode(post.ScreenName) + ") " +
- WebUtility.HtmlEncode(post.CreatedAt.ToString());
-
- return FormatQuoteTweetHtml(post.StatusId, innerHtml, isReply);
- }
-
- internal static string FormatQuoteTweetHtml(long statusId, string innerHtml, bool isReply)
- {
- var blockClassName = "quote-tweet";
-
- if (isReply)
- blockClassName += " reply";
-
- return "<a class=\"quote-tweet-link\" href=\"//opentween/status/" + statusId + "\">" +
- $"<blockquote class=\"{blockClassName}\">{innerHtml}</blockquote>" +
- "</a>";
- }
-
- /// <summary>
- /// 指定されたHTMLからリンクを除去します
- /// </summary>
- internal static string StripLinkTagHtml(string html)
- {
- // a 要素はネストされていない前提の正規表現パターン
- return Regex.Replace(html, @"<a[^>]*>(.*?)</a>", "$1");
- }
-
private async void MatomeMenuItem_Click(object sender, EventArgs e)
{
await this.OpenApplicationWebsite();
.Do(() => this.doShowUserStatus(_curPost.ScreenName, ShowInputDialog: false)),
ShortcutCommand.Create(Keys.Alt | Keys.Up)
- .Do(() => this.ScrollDownPostBrowser(forward: false)),
+ .Do(() => this.tweetDetailsView.ScrollDownPostBrowser(forward: false)),
ShortcutCommand.Create(Keys.Alt | Keys.Down)
- .Do(() => this.ScrollDownPostBrowser(forward: true)),
+ .Do(() => this.tweetDetailsView.ScrollDownPostBrowser(forward: true)),
ShortcutCommand.Create(Keys.Alt | Keys.PageUp)
- .Do(() => this.PageDownPostBrowser(forward: false)),
+ .Do(() => this.tweetDetailsView.PageDownPostBrowser(forward: false)),
ShortcutCommand.Create(Keys.Alt | Keys.PageDown)
- .Do(() => this.PageDownPostBrowser(forward: true)),
+ .Do(() => this.tweetDetailsView.PageDownPostBrowser(forward: true)),
// 別タブの同じ書き込みへ(ALT+←/→)
ShortcutCommand.Create(Keys.Alt | Keys.Right)
ShortcutCommand.Create(Keys.Alt | Keys.Shift | Keys.T)
.OnlyWhen(() => this.ExistCurrentPost)
- .Do(() => this.doTranslation(_curPost.TextFromApi)),
+ .Do(() => this.tweetDetailsView.DoTranslation()),
ShortcutCommand.Create(Keys.Alt | Keys.Shift | Keys.R)
.Do(() => this.doReTweetUnofficial()),
};
}
- private bool CommonKeyDown(Keys keyData, FocusedControl focusedOn, out Task asyncTask)
+ internal bool CommonKeyDown(Keys keyData, FocusedControl focusedOn, out Task asyncTask)
{
// Task を返す非同期処理があれば asyncTask に代入する
asyncTask = null;
return false;
}
- private void ScrollDownPostBrowser(bool forward)
- {
- var doc = PostBrowser.Document;
- if (doc == null) return;
-
- var tags = doc.GetElementsByTagName("html");
- if (tags.Count > 0)
- {
- if (forward)
- tags[0].ScrollTop += this._fntDetail.Height;
- else
- tags[0].ScrollTop -= this._fntDetail.Height;
- }
- }
-
- private void PageDownPostBrowser(bool forward)
- {
- var doc = PostBrowser.Document;
- if (doc == null) return;
-
- var tags = doc.GetElementsByTagName("html");
- if (tags.Count > 0)
- {
- if (forward)
- tags[0].ScrollTop += PostBrowser.ClientRectangle.Height - this._fntDetail.Height;
- else
- tags[0].ScrollTop -= PostBrowser.ClientRectangle.Height - this._fntDetail.Height;
- }
- }
-
private void GoNextTab(bool forward)
{
int idx = ListTab.SelectedIndex;
{
if (_curPost == null) return;
- TabClass curTabClass = _statuses.Tabs[_curTab.Text];
+ TabModel curTabClass = _statuses.Tabs[_curTab.Text];
if (curTabClass.TabType == MyCommon.TabUsageType.PublicSearch && _curPost.InReplyToStatusId == null && _curPost.TextFromApi.Contains("@"))
{
}
catch (WebApiException ex)
{
- this.StatusLabel.Text = ex.Message;
+ this.StatusLabel.Text = $"Err:{ex.Message}(GetStatus)";
}
}
}
catch (WebApiException ex)
{
- this.StatusLabel.Text = ex.Message;
- await this.OpenUriInBrowserAsync("https://twitter.com/" + inReplyToUser + "/statuses/" + inReplyToId.ToString());
+ this.StatusLabel.Text = $"Err:{ex.Message}(GetStatus)";
+ await this.OpenUriInBrowserAsync(MyCommon.GetStatusUrl(inReplyToUser, inReplyToId));
return;
}
inReplyPost = inReplyToPosts.FirstOrDefault();
if (inReplyPost == null)
{
- await this.OpenUriInBrowserAsync("https://twitter.com/" + inReplyToUser + "/statuses/" + inReplyToId.ToString());
+ await this.OpenUriInBrowserAsync(MyCommon.GetStatusUrl(inReplyToUser, inReplyToId));
return;
}
}
{
if (_curPost == null) return;
- TabClass curTabClass = _statuses.Tabs[_curTab.Text];
+ TabModel curTabClass = _statuses.Tabs[_curTab.Text];
//Dictionary<long, PostClass> curTabPosts = curTabClass.Posts;
if (parallel)
{
_cfgCommon.UserName = tw.Username;
_cfgCommon.UserId = tw.UserId;
- _cfgCommon.Password = tw.Password;
_cfgCommon.Token = tw.AccessToken;
_cfgCommon.TokenSecret = tw.AccessTokenSecret;
private void SaveConfigsTabs()
{
- SettingTabs tabSetting = new SettingTabs();
- for (int i = 0; i < ListTab.TabPages.Count; i++)
+ var tabsSetting = new SettingTabs();
+
+ var tabs = this.ListTab.TabPages.Cast<TabPage>()
+ .Select(x => this._statuses.Tabs[x.Text])
+ .Concat(new[] { this._statuses.GetTabByType(MyCommon.TabUsageType.Mute) });
+
+ foreach (var tab in tabs)
{
- var tab = _statuses.Tabs[ListTab.TabPages[i].Text];
- if (tab.TabType != MyCommon.TabUsageType.Related && tab.TabType != MyCommon.TabUsageType.SearchResults)
- tabSetting.Tabs.Add(tab);
+ if (!tab.IsPermanentTabType)
+ continue;
+
+ var tabSetting = new SettingTabs.SettingTabItem
+ {
+ TabName = tab.TabName,
+ TabType = tab.TabType,
+ UnreadManage = tab.UnreadManage,
+ Protected = tab.Protected,
+ Notify = tab.Notify,
+ SoundFile = tab.SoundFile,
+ };
+
+ var filterTab = tab as FilterTabModel;
+ if (filterTab != null)
+ tabSetting.FilterArray = filterTab.FilterArray;
+
+ var userTab = tab as UserTimelineTabModel;
+ if (userTab != null)
+ tabSetting.User = userTab.ScreenName;
+
+ var searchTab = tab as PublicSearchTabModel;
+ if (searchTab != null)
+ {
+ tabSetting.SearchWords = searchTab.SearchWords;
+ tabSetting.SearchLang = searchTab.SearchLang;
+ }
+
+ var listTab = tab as ListTimelineTabModel;
+ if (listTab != null)
+ tabSetting.ListInfo = listTab.ListInfo;
+
+ tabsSetting.Tabs.Add(tabSetting);
}
- tabSetting.Tabs.Add(this._statuses.GetTabByType(MyCommon.TabUsageType.Mute));
- tabSetting.Save();
+
+ tabsSetting.Save();
}
private async void OpenURLFileMenuItem_Click(object sender, EventArgs e)
if (post.IsProtect) protect = "Protect";
sw.WriteLine(post.Nickname + "\t" +
"\"" + post.TextFromApi.Replace("\n", "").Replace("\"", "\"\"") + "\"" + "\t" +
- post.CreatedAt.ToString() + "\t" +
+ post.CreatedAt + "\t" +
post.ScreenName + "\t" +
- post.StatusId.ToString() + "\t" +
+ post.StatusId + "\t" +
post.ImageUrl + "\t" +
"\"" + post.Text.Replace("\n", "").Replace("\"", "\"\"") + "\"" + "\t" +
protect);
if (post.IsProtect) protect = "Protect";
sw.WriteLine(post.Nickname + "\t" +
"\"" + post.TextFromApi.Replace("\n", "").Replace("\"", "\"\"") + "\"" + "\t" +
- post.CreatedAt.ToString() + "\t" +
+ post.CreatedAt + "\t" +
post.ScreenName + "\t" +
- post.StatusId.ToString() + "\t" +
+ post.StatusId + "\t" +
post.ImageUrl + "\t" +
"\"" + post.Text.Replace("\n", "").Replace("\"", "\"\"") + "\"" + "\t" +
protect);
}
}
}
- }
- this.TopMost = this._cfgCommon.AlwaysTop;
- }
-
- private async void PostBrowser_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
- {
- Task asyncTask;
- bool KeyRes = CommonKeyDown(e.KeyData, FocusedControl.PostBrowser, out asyncTask);
- if (KeyRes)
- {
- e.IsInputKey = true;
- }
- else
- {
- if (Enum.IsDefined(typeof(Shortcut), (Shortcut)e.KeyData))
- {
- var shortcut = (Shortcut)e.KeyData;
- switch (shortcut)
- {
- case Shortcut.CtrlA:
- case Shortcut.CtrlC:
- case Shortcut.CtrlIns:
- // 既定の動作を有効にする
- break;
- default:
- // その他のショートカットキーは無効にする
- e.IsInputKey = true;
- break;
- }
- }
- }
-
- if (asyncTask != null)
- await asyncTask;
+ }
+ this.TopMost = this._cfgCommon.AlwaysTop;
}
+
public bool TabRename(ref string tabName)
{
//タブ名変更
private void ListTab_MouseDown(object sender, MouseEventArgs e)
{
if (this._cfgCommon.TabMouseLock) return;
- Point cpos = new Point(e.X, e.Y);
if (e.Button == MouseButtons.Left)
{
for (int i = 0; i < ListTab.TabPages.Count; i++)
return;
}
- TabClass tb = _statuses.GetTabByType(MyCommon.TabUsageType.Mentions);
+ TabModel tb = _statuses.GetTabByType(MyCommon.TabUsageType.Mentions);
if (this._cfgCommon.ReplyIconState != MyCommon.REPLY_ICONSTATE.None && tb != null && tb.UnreadCount > 0)
{
if (blinkCnt > 0) return;
if (_statuses == null) return;
if (_statuses.Tabs == null) return;
- TabClass tb = _statuses.Tabs[_rclickTabName];
+ TabModel tb = _statuses.Tabs[_rclickTabName];
if (tb == null) return;
NotifyDispMenuItem.Checked = tb.Notify;
list = listAvail.SelectedList;
}
}
- if (!_statuses.AddTab(tabName, tabUsage, list) || !AddNewTab(tabName, false, tabUsage, list))
+
+ TabModel tab;
+ switch (tabUsage)
+ {
+ case MyCommon.TabUsageType.UserDefined:
+ tab = new FilterTabModel(tabName);
+ break;
+ case MyCommon.TabUsageType.PublicSearch:
+ tab = new PublicSearchTabModel(tabName);
+ break;
+ case MyCommon.TabUsageType.Lists:
+ tab = new ListTimelineTabModel(tabName, list);
+ break;
+ default:
+ return;
+ }
+
+ if (!_statuses.AddTab(tab) || !AddNewTab(tab, startup: false))
{
string tmp = string.Format(Properties.Resources.AddTabMenuItem_ClickText1, tabName);
MessageBox.Show(tmp, Properties.Resources.AddTabMenuItem_ClickText2, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
if (tabUsage == MyCommon.TabUsageType.Lists)
{
ListTab.SelectedIndex = ListTab.TabPages.Count - 1;
- var tab = this._statuses.Tabs[this._curTab.Text];
- this.GetListTimelineAsync(tab);
+ var listTab = (ListTimelineTabModel)this._statuses.Tabs[this._curTab.Text];
+ this.GetListTimelineAsync(listTab);
}
}
}
private void IDRuleMenuItem_Click(object sender, EventArgs e)
{
- string tabName;
-
//未選択なら処理終了
if (_curList.SelectedIndices.Count == 0) return;
+ var tab = this._statuses.Tabs[this._curTab.Text];
+ var screenNameArray = this._curList.SelectedIndices.Cast<int>()
+ .Select(x => tab[x])
+ .Select(x => x.RetweetedId != null ? x.RetweetedBy : x.ScreenName)
+ .ToArray();
+
+ this.AddFilterRuleByScreenName(screenNameArray);
+
+ if (screenNameArray.Length != 0)
+ {
+ List<string> atids = new List<string>();
+ foreach (var screenName in screenNameArray)
+ {
+ atids.Add("@" + screenName);
+ }
+ int cnt = AtIdSupl.ItemCount;
+ AtIdSupl.AddRangeItem(atids.ToArray());
+ if (AtIdSupl.ItemCount != cnt) ModifySettingAtId = true;
+ }
+ }
+
+ private void SourceRuleMenuItem_Click(object sender, EventArgs e)
+ {
+ if (this._curList.SelectedIndices.Count == 0)
+ return;
+
+ var tab = this._statuses.Tabs[this._curTab.Text];
+ var sourceArray = this._curList.SelectedIndices.Cast<int>()
+ .Select(x => tab[x].Source).ToArray();
+
+ this.AddFilterRuleBySource(sourceArray);
+ }
+
+ public void AddFilterRuleByScreenName(params string[] screenNameArray)
+ {
//タブ選択(or追加)
+ string tabName;
if (!SelectTab(out tabName)) return;
- var tab = this._statuses.Tabs[tabName];
+ var tab = (FilterTabModel)this._statuses.Tabs[tabName];
bool mv;
bool mk;
mk = false;
}
- List<string> ids = new List<string>();
- foreach (int idx in _curList.SelectedIndices)
- {
- PostClass post = _statuses.Tabs[_curTab.Text][idx];
- if (!ids.Contains(post.ScreenName))
- {
- PostFilterRule fc = new PostFilterRule();
- ids.Add(post.ScreenName);
- if (post.RetweetedId == null)
- {
- fc.FilterName = post.ScreenName;
- }
- else
- {
- fc.FilterName = post.RetweetedBy;
- }
- fc.UseNameField = true;
- fc.MoveMatches = mv;
- fc.MarkMatches = mk;
- fc.UseRegex = false;
- fc.FilterByUrl = false;
- tab.AddFilter(fc);
- }
- }
- if (ids.Count != 0)
+ foreach (var screenName in screenNameArray)
{
- List<string> atids = new List<string>();
- foreach (string id in ids)
+ tab.AddFilter(new PostFilterRule
{
- atids.Add("@" + id);
- }
- int cnt = AtIdSupl.ItemCount;
- AtIdSupl.AddRangeItem(atids.ToArray());
- if (AtIdSupl.ItemCount != cnt) ModifySettingAtId = true;
+ FilterName = screenName,
+ UseNameField = true,
+ MoveMatches = mv,
+ MarkMatches = mk,
+ UseRegex = false,
+ FilterByUrl = false,
+ });
}
this.ApplyPostFilters();
SaveConfigsTabs();
}
- private void SourceRuleMenuItem_Click(object sender, EventArgs e)
+ public void AddFilterRuleBySource(params string[] sourceArray)
{
- if (this._curList.SelectedIndices.Count == 0)
- return;
-
// タブ選択ダイアログを表示(or追加)
string tabName;
if (!this.SelectTab(out tabName))
return;
- var currentTab = this._statuses.Tabs[this._curTab.Text];
- var filterTab = this._statuses.Tabs[tabName];
+ var filterTab = (FilterTabModel)this._statuses.Tabs[tabName];
bool mv;
bool mk;
}
// 振り分けルールに追加するSource
- var sources = new HashSet<string>();
-
- foreach (var idx in this._curList.SelectedIndices.Cast<int>())
+ foreach (var source in sourceArray)
{
- var post = currentTab[idx];
- var filterSource = post.Source;
-
- if (sources.Add(filterSource))
+ filterTab.AddFilter(new PostFilterRule
{
- var filter = new PostFilterRule
- {
- FilterSource = filterSource,
- MoveMatches = mv,
- MarkMatches = mk,
- UseRegex = false,
- FilterByUrl = false,
- };
- filterTab.AddFilter(filter);
- }
+ FilterSource = source,
+ MoveMatches = mv,
+ MarkMatches = mk,
+ UseRegex = false,
+ FilterByUrl = false,
+ });
}
this.ApplyPostFilters();
this.TopMost = this._cfgCommon.AlwaysTop;
if (!string.IsNullOrEmpty(tabName))
{
- if (!_statuses.AddTab(tabName, MyCommon.TabUsageType.UserDefined, null) || !AddNewTab(tabName, false, MyCommon.TabUsageType.UserDefined))
+ var tab = new FilterTabModel(tabName);
+ if (!_statuses.AddTab(tab) || !AddNewTab(tab, startup: false))
{
string tmp = string.Format(Properties.Resources.IDRuleMenuItem_ClickText2, tabName);
MessageBox.Show(tmp, Properties.Resources.IDRuleMenuItem_ClickText3, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
private async void OpenURLMenuItem_Click(object sender, EventArgs e)
{
- var linkElements = this.PostBrowser.Document.Links.Cast<HtmlElement>()
- .Where(x => x.GetAttribute("className") != "tweet-quote-link") // 引用ツイートで追加されたリンクを除く
- .ToArray();
+ var linkElements = this.tweetDetailsView.GetLinkElements();
if (linkElements.Length > 0)
{
//ステータス欄にカウント表示
//タブ未読数/タブ発言数 全未読数/総発言数 (未読@+未読DM数)
if (_statuses == null) return "";
- TabClass tbRep = _statuses.GetTabByType(MyCommon.TabUsageType.Mentions);
- TabClass tbDm = _statuses.GetTabByType(MyCommon.TabUsageType.DirectMessage);
+ TabModel tbRep = _statuses.GetTabByType(MyCommon.TabUsageType.Mentions);
+ TabModel tbDm = _statuses.GetTabByType(MyCommon.TabUsageType.DirectMessage);
if (tbRep == null || tbDm == null) return "";
int urat = tbRep.UnreadCount + tbDm.UnreadCount;
int ur = 0;
UnreadCounter = ur;
UnreadAtCounter = urat;
- slbl.AppendFormat(Properties.Resources.SetStatusLabelText1, tur, tal, ur, al, urat, _postTimestamps.Count, _favTimestamps.Count, _tlCount);
+ var homeTab = this._statuses.GetTabByType<HomeTabModel>();
+
+ slbl.AppendFormat(Properties.Resources.SetStatusLabelText1, tur, tal, ur, al, urat, _postTimestamps.Count, _favTimestamps.Count, homeTab.TweetsPerHour);
if (this._cfgCommon.TimelinePeriod == 0)
{
slbl.Append(Properties.Resources.SetStatusLabelText2);
return slbl.ToString();
}
- private void TwitterApiStatus_AccessLimitUpdated(object sender, EventArgs e)
+ private async void TwitterApiStatus_AccessLimitUpdated(object sender, EventArgs e)
{
try
{
if (this.InvokeRequired && !this.IsDisposed)
{
- this.Invoke((MethodInvoker)(() => this.TwitterApiStatus_AccessLimitUpdated(sender, e)));
+ await this.InvokeAsync(() => this.TwitterApiStatus_AccessLimitUpdated(sender, e));
}
else
{
if (_statuses.ContainsKey(_curPost.InReplyToStatusId.Value))
{
PostClass repPost = _statuses[_curPost.InReplyToStatusId.Value];
- MessageBox.Show(repPost.ScreenName + " / " + repPost.Nickname + " (" + repPost.CreatedAt.ToString() + ")" + Environment.NewLine + repPost.TextFromApi);
+ MessageBox.Show($"{repPost.ScreenName} / {repPost.Nickname} ({repPost.CreatedAt})" + Environment.NewLine + repPost.TextFromApi);
}
else
{
- foreach (TabClass tb in _statuses.GetTabsByType(MyCommon.TabUsageType.Lists | MyCommon.TabUsageType.PublicSearch))
+ foreach (TabModel tb in _statuses.GetTabsByType(MyCommon.TabUsageType.Lists | MyCommon.TabUsageType.PublicSearch))
{
if (tb == null || !tb.Contains(_curPost.InReplyToStatusId.Value)) break;
PostClass repPost = _statuses[_curPost.InReplyToStatusId.Value];
- MessageBox.Show(repPost.ScreenName + " / " + repPost.Nickname + " (" + repPost.CreatedAt.ToString() + ")" + Environment.NewLine + repPost.TextFromApi);
+ MessageBox.Show($"{repPost.ScreenName} / {repPost.Nickname} ({repPost.CreatedAt})" + Environment.NewLine + repPost.TextFromApi);
return;
}
await this.OpenUriInBrowserAsync(MyCommon.GetStatusUrl(_curPost.InReplyToUser, _curPost.InReplyToStatusId.Value));
await this.doRepliedStatusOpen();
}
- /// <summary>
- /// UserPicture.Image に設定されている画像を破棄します。
- /// </summary>
- private void ClearUserPicture()
- {
- if (this.UserPicture.Image != null)
- {
- var oldImage = this.UserPicture.Image;
- this.UserPicture.Image = null;
- oldImage.Dispose();
- }
- }
-
- private void ContextMenuUserPicture_Opening(object sender, CancelEventArgs e)
- {
- //発言詳細のアイコン右クリック時のメニュー制御
- if (_curList.SelectedIndices.Count > 0 && _curPost != null)
- {
- string name = _curPost.ImageUrl;
- if (name != null && name.Length > 0)
- {
- int idx = name.LastIndexOf('/');
- if (idx != -1)
- {
- name = Path.GetFileName(name.Substring(idx));
- if (name.Contains("_normal.") || name.EndsWith("_normal", StringComparison.Ordinal))
- {
- name = name.Replace("_normal", "");
- this.IconNameToolStripMenuItem.Text = name;
- this.IconNameToolStripMenuItem.Enabled = true;
- }
- else
- {
- this.IconNameToolStripMenuItem.Enabled = false;
- this.IconNameToolStripMenuItem.Text = Properties.Resources.ContextMenuStrip3_OpeningText1;
- }
- }
- else
- {
- this.IconNameToolStripMenuItem.Enabled = false;
- this.IconNameToolStripMenuItem.Text = Properties.Resources.ContextMenuStrip3_OpeningText1;
- }
-
- this.ReloadIconToolStripMenuItem.Enabled = true;
-
- if (this.IconCache.TryGetFromCache(_curPost.ImageUrl) != null)
- {
- this.SaveIconPictureToolStripMenuItem.Enabled = true;
- }
- else
- {
- this.SaveIconPictureToolStripMenuItem.Enabled = false;
- }
- }
- else
- {
- this.IconNameToolStripMenuItem.Enabled = false;
- this.ReloadIconToolStripMenuItem.Enabled = false;
- this.SaveIconPictureToolStripMenuItem.Enabled = false;
- this.IconNameToolStripMenuItem.Text = Properties.Resources.ContextMenuStrip3_OpeningText1;
- }
- }
- else
- {
- this.IconNameToolStripMenuItem.Enabled = false;
- this.ReloadIconToolStripMenuItem.Enabled = false;
- this.SaveIconPictureToolStripMenuItem.Enabled = false;
- this.IconNameToolStripMenuItem.Text = Properties.Resources.ContextMenuStrip3_OpeningText2;
- }
- if (NameLabel.Tag != null)
- {
- string id = (string)NameLabel.Tag;
- if (id == tw.Username)
- {
- FollowToolStripMenuItem.Enabled = false;
- UnFollowToolStripMenuItem.Enabled = false;
- ShowFriendShipToolStripMenuItem.Enabled = false;
- ShowUserStatusToolStripMenuItem.Enabled = true;
- SearchPostsDetailNameToolStripMenuItem.Enabled = true;
- SearchAtPostsDetailNameToolStripMenuItem.Enabled = false;
- ListManageUserContextToolStripMenuItem3.Enabled = true;
- }
- else
- {
- FollowToolStripMenuItem.Enabled = true;
- UnFollowToolStripMenuItem.Enabled = true;
- ShowFriendShipToolStripMenuItem.Enabled = true;
- ShowUserStatusToolStripMenuItem.Enabled = true;
- SearchPostsDetailNameToolStripMenuItem.Enabled = true;
- SearchAtPostsDetailNameToolStripMenuItem.Enabled = true;
- ListManageUserContextToolStripMenuItem3.Enabled = true;
- }
- }
- else
- {
- FollowToolStripMenuItem.Enabled = false;
- UnFollowToolStripMenuItem.Enabled = false;
- ShowFriendShipToolStripMenuItem.Enabled = false;
- ShowUserStatusToolStripMenuItem.Enabled = false;
- SearchPostsDetailNameToolStripMenuItem.Enabled = false;
- SearchAtPostsDetailNameToolStripMenuItem.Enabled = false;
- ListManageUserContextToolStripMenuItem3.Enabled = false;
- }
- }
-
- private async void IconNameToolStripMenuItem_Click(object sender, EventArgs e)
- {
- if (_curPost == null) return;
- string name = _curPost.ImageUrl;
- await this.OpenUriInBrowserAsync(name.Remove(name.LastIndexOf("_normal"), 7)); // "_normal".Length
- }
-
- private async void ReloadIconToolStripMenuItem_Click(object sender, EventArgs e)
- {
- if (this._curPost == null) return;
-
- await this.UserPicture.SetImageFromTask(async () =>
- {
- var imageUrl = this._curPost.ImageUrl;
-
- var image = await this.IconCache.DownloadImageAsync(imageUrl, force: true)
- .ConfigureAwait(false);
-
- return await image.CloneAsync()
- .ConfigureAwait(false);
- });
- }
-
- private void SaveOriginalSizeIconPictureToolStripMenuItem_Click(object sender, EventArgs e)
- {
- if (_curPost == null) return;
- string name = _curPost.ImageUrl;
- name = Path.GetFileNameWithoutExtension(name.Substring(name.LastIndexOf('/')));
-
- this.SaveFileDialog1.FileName = name.Substring(0, name.Length - 8); // "_normal".Length + 1
-
- if (this.SaveFileDialog1.ShowDialog() == DialogResult.OK)
- {
- // STUB
- }
- }
-
- private void SaveIconPictureToolStripMenuItem_Click(object sender, EventArgs e)
- {
- if (_curPost == null) return;
- string name = _curPost.ImageUrl;
-
- this.SaveFileDialog1.FileName = name.Substring(name.LastIndexOf('/') + 1);
-
- if (this.SaveFileDialog1.ShowDialog() == DialogResult.OK)
- {
- try
- {
- using (Image orgBmp = new Bitmap(IconCache.TryGetFromCache(name).Image))
- {
- using (Bitmap bmp2 = new Bitmap(orgBmp.Size.Width, orgBmp.Size.Height))
- {
- using (Graphics g = Graphics.FromImage(bmp2))
- {
- g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
- g.DrawImage(orgBmp, 0, 0, orgBmp.Size.Width, orgBmp.Size.Height);
- }
- bmp2.Save(this.SaveFileDialog1.FileName);
- }
- }
- }
- catch (Exception)
- {
- //処理中にキャッシュアウトする可能性あり
- }
- }
- }
-
private void SplitContainer2_Panel2_Resize(object sender, EventArgs e)
{
var multiline = this.SplitContainer2.Panel2.Height > this.SplitContainer2.Panel2MinSize + 2;
{
_cfgLocal.Width7 = lst.Columns[6].Width;
ModifySettingLocal = true;
- _isColumnChanged = true;
- }
- if (_cfgLocal.Width8 != lst.Columns[7].Width)
- {
- _cfgLocal.Width8 = lst.Columns[7].Width;
- ModifySettingLocal = true;
- _isColumnChanged = true;
- }
- }
- // 非表示の時にColumnChangedが呼ばれた場合はForm初期化処理中なので保存しない
- //if (changed)
- //{
- // SaveConfigsLocal();
- //}
- }
-
- private void SelectionCopyContextMenuItem_Click(object sender, EventArgs e)
- {
- //発言詳細で「選択文字列をコピー」
- string _selText = this.PostBrowser.GetSelectedText();
- try
- {
- Clipboard.SetDataObject(_selText, false, 5, 100);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
-
- private async Task doSearchToolStrip(string url)
- {
- //発言詳細で「選択文字列で検索」(選択文字列取得)
- string _selText = this.PostBrowser.GetSelectedText();
-
- if (_selText != null)
- {
- if (url == Properties.Resources.SearchItem4Url)
- {
- //公式検索
- AddNewTabForSearch(_selText);
- return;
- }
-
- string tmp = string.Format(url, Uri.EscapeDataString(_selText));
- await this.OpenUriInBrowserAsync(tmp);
- }
- }
-
- private void SelectionAllContextMenuItem_Click(object sender, EventArgs e)
- {
- //発言詳細ですべて選択
- PostBrowser.Document.ExecCommand("SelectAll", false, null);
- }
-
- private async void SearchWikipediaContextMenuItem_Click(object sender, EventArgs e)
- {
- await this.doSearchToolStrip(Properties.Resources.SearchItem1Url);
- }
-
- private async void SearchGoogleContextMenuItem_Click(object sender, EventArgs e)
- {
- await this.doSearchToolStrip(Properties.Resources.SearchItem2Url);
- }
-
- private async void SearchPublicSearchContextMenuItem_Click(object sender, EventArgs e)
- {
- await this.doSearchToolStrip(Properties.Resources.SearchItem4Url);
- }
-
- private void UrlCopyContextMenuItem_Click(object sender, EventArgs e)
- {
- try
- {
- foreach (var link in this.PostBrowser.Document.Links.Cast<HtmlElement>())
- {
- if (link.GetAttribute("href") == this._postBrowserStatusText)
- {
- var linkStr = link.GetAttribute("title");
- if (string.IsNullOrEmpty(linkStr))
- linkStr = link.GetAttribute("href");
-
- Clipboard.SetDataObject(linkStr, false, 5, 100);
- return;
- }
- }
-
- Clipboard.SetDataObject(this._postBrowserStatusText, false, 5, 100);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
-
- private void ContextMenuPostBrowser_Opening(object ender, CancelEventArgs e)
- {
- // URLコピーの項目の表示/非表示
- if (PostBrowser.StatusText.StartsWith("http", StringComparison.Ordinal))
- {
- this._postBrowserStatusText = PostBrowser.StatusText;
- string name = GetUserId();
- UrlCopyContextMenuItem.Enabled = true;
- if (name != null)
- {
- FollowContextMenuItem.Enabled = true;
- RemoveContextMenuItem.Enabled = true;
- FriendshipContextMenuItem.Enabled = true;
- ShowUserStatusContextMenuItem.Enabled = true;
- SearchPostsDetailToolStripMenuItem.Enabled = true;
- IdFilterAddMenuItem.Enabled = true;
- ListManageUserContextToolStripMenuItem.Enabled = true;
- SearchAtPostsDetailToolStripMenuItem.Enabled = true;
- }
- else
- {
- FollowContextMenuItem.Enabled = false;
- RemoveContextMenuItem.Enabled = false;
- FriendshipContextMenuItem.Enabled = false;
- ShowUserStatusContextMenuItem.Enabled = false;
- SearchPostsDetailToolStripMenuItem.Enabled = false;
- IdFilterAddMenuItem.Enabled = false;
- ListManageUserContextToolStripMenuItem.Enabled = false;
- SearchAtPostsDetailToolStripMenuItem.Enabled = false;
- }
-
- if (Regex.IsMatch(this._postBrowserStatusText, @"^https?://twitter.com/search\?q=%23"))
- UseHashtagMenuItem.Enabled = true;
- else
- UseHashtagMenuItem.Enabled = false;
- }
- else
- {
- this._postBrowserStatusText = "";
- UrlCopyContextMenuItem.Enabled = false;
- FollowContextMenuItem.Enabled = false;
- RemoveContextMenuItem.Enabled = false;
- FriendshipContextMenuItem.Enabled = false;
- ShowUserStatusContextMenuItem.Enabled = false;
- SearchPostsDetailToolStripMenuItem.Enabled = false;
- SearchAtPostsDetailToolStripMenuItem.Enabled = false;
- UseHashtagMenuItem.Enabled = false;
- IdFilterAddMenuItem.Enabled = false;
- ListManageUserContextToolStripMenuItem.Enabled = false;
- }
- // 文字列選択されていないときは選択文字列関係の項目を非表示に
- string _selText = this.PostBrowser.GetSelectedText();
- if (_selText == null)
- {
- SelectionSearchContextMenuItem.Enabled = false;
- SelectionCopyContextMenuItem.Enabled = false;
- SelectionTranslationToolStripMenuItem.Enabled = false;
- }
- else
- {
- SelectionSearchContextMenuItem.Enabled = true;
- SelectionCopyContextMenuItem.Enabled = true;
- SelectionTranslationToolStripMenuItem.Enabled = true;
- }
- //発言内に自分以外のユーザーが含まれてればフォロー状態全表示を有効に
- MatchCollection ma = Regex.Matches(this.PostBrowser.DocumentText, @"href=""https?://twitter.com/(#!/)?(?<ScreenName>[a-zA-Z0-9_]+)(/status(es)?/[0-9]+)?""");
- bool fAllFlag = false;
- foreach (Match mu in ma)
- {
- if (mu.Result("${ScreenName}").ToLowerInvariant() != tw.Username.ToLowerInvariant())
- {
- fAllFlag = true;
- break;
- }
- }
- this.FriendshipAllMenuItem.Enabled = fAllFlag;
-
- if (_curPost == null)
- TranslationToolStripMenuItem.Enabled = false;
- else
- TranslationToolStripMenuItem.Enabled = true;
-
- e.Cancel = false;
- }
-
- private void CurrentTabToolStripMenuItem_Click(object sender, EventArgs e)
- {
- //発言詳細の選択文字列で現在のタブを検索
- string _selText = this.PostBrowser.GetSelectedText();
-
- if (_selText != null)
- {
- var searchOptions = new SearchWordDialog.SearchOptions(
- SearchWordDialog.SearchType.Timeline,
- _selText,
- newTab: false,
- caseSensitive: false,
- useRegex: false);
-
- this.SearchDialog.ResultOptions = searchOptions;
-
- this.DoTabSearch(
- searchOptions.Query,
- searchOptions.CaseSensitive,
- searchOptions.UseRegex,
- SEARCHTYPE.NextSearch);
+ _isColumnChanged = true;
+ }
+ if (_cfgLocal.Width8 != lst.Columns[7].Width)
+ {
+ _cfgLocal.Width8 = lst.Columns[7].Width;
+ ModifySettingLocal = true;
+ _isColumnChanged = true;
+ }
}
+ // 非表示の時にColumnChangedが呼ばれた場合はForm初期化処理中なので保存しない
+ //if (changed)
+ //{
+ // SaveConfigsLocal();
+ //}
}
private void SplitContainer2_SplitterMoved(object sender, SplitterEventArgs e)
tw.PostDeleted += tw_PostDeleted;
tw.UserStreamEventReceived += tw_UserStreamEventArrived;
- MenuItemUserStream.Text = "&UserStream ■";
- MenuItemUserStream.Enabled = true;
- StopToolStripMenuItem.Text = "&Start";
- StopToolStripMenuItem.Enabled = true;
- if (this._cfgCommon.UserstreamStartup) tw.StartUserStream();
+ this.RefreshUserStreamsMenu();
+
+ if (this._cfgCommon.UserstreamStartup)
+ tw.StartUserStream();
}
private async void TweenMain_Shown(object sender, EventArgs e)
{
- try
- {
- using (ControlTransaction.Update(this.PostBrowser))
- {
- PostBrowser.Url = new Uri("about:blank");
- PostBrowser.DocumentText = ""; //発言詳細部初期化
- }
- }
- catch (Exception)
- {
- }
-
NotifyIcon1.Visible = true;
if (this.IsNetworkAvailable())
private async void DumpPostClassToolStripMenuItem_Click(object sender, EventArgs e)
{
+ this.tweetDetailsView.DumpPostClass = this.DumpPostClassToolStripMenuItem.Checked;
+
if (_curPost != null)
await this.DispSelectedPost(true);
}
try
{
- var task = Task.Run(() => this.tw.GetInfoApi());
+ var task = this.tw.GetInfoApi();
apiStatus = await dialog.WaitForAsync(this, task);
}
catch (WebApiException)
await this.FollowCommand(id);
}
- private async Task FollowCommand(string id)
+ internal async Task FollowCommand(string id)
{
using (var inputName = new InputTabName())
{
await this.RemoveCommand(id, false);
}
- private async Task RemoveCommand(string id, bool skipInput)
+ internal async Task RemoveCommand(string id, bool skipInput)
{
if (!skipInput)
{
await this.ShowFriendship(id);
}
- private async Task ShowFriendship(string id)
+ internal async Task ShowFriendship(string id)
{
using (var inputName = new InputTabName())
{
catch (WebApiException ex)
{
if (!cancellationToken.IsCancellationRequested)
- MessageBox.Show(ex.Message);
+ MessageBox.Show($"Err:{ex.Message}(FriendshipsShow)");
return;
}
MessageBox.Show(result);
}
- private async Task ShowFriendship(string[] ids)
+ internal async Task ShowFriendship(string[] ids)
{
foreach (string id in ids)
{
catch (WebApiException ex)
{
if (!cancellationToken.IsCancellationRequested)
- MessageBox.Show(ex.Message);
+ MessageBox.Show($"Err:{ex.Message}(FriendshipsShow)");
return;
}
return !this.tw.Configuration.NonUsernamePaths.Contains(name.ToLowerInvariant());
}
- private string GetUserId()
- {
- Match m = Regex.Match(this._postBrowserStatusText, @"^https?://twitter.com/(#!/)?(?<ScreenName>[a-zA-Z0-9_]+)(/status(es)?/[0-9]+)?$");
- if (m.Success && IsTwitterId(m.Result("${ScreenName}")))
- return m.Result("${ScreenName}");
- else
- return null;
- }
-
- private async void FollowContextMenuItem_Click(object sender, EventArgs e)
- {
- string name = GetUserId();
- if (name != null)
- await this.FollowCommand(name);
- }
-
- private async void RemoveContextMenuItem_Click(object sender, EventArgs e)
- {
- string name = GetUserId();
- if (name != null)
- await this.RemoveCommand(name, false);
- }
-
- private async void FriendshipContextMenuItem_Click(object sender, EventArgs e)
- {
- string name = GetUserId();
- if (name != null)
- await this.ShowFriendship(name);
- }
-
- private async void FriendshipAllMenuItem_Click(object sender, EventArgs e)
- {
- MatchCollection ma = Regex.Matches(this.PostBrowser.DocumentText, @"href=""https?://twitter.com/(#!/)?(?<ScreenName>[a-zA-Z0-9_]+)(/status(es)?/[0-9]+)?""");
- List<string> ids = new List<string>();
- foreach (Match mu in ma)
- {
- if (mu.Result("${ScreenName}").ToLower() != tw.Username.ToLower())
- {
- ids.Add(mu.Result("${ScreenName}"));
- }
- }
-
- await this.ShowFriendship(ids.ToArray());
- }
-
- private async void ShowUserStatusContextMenuItem_Click(object sender, EventArgs e)
- {
- string name = GetUserId();
- if (name != null)
- await this.ShowUserStatus(name);
- }
-
- private void SearchPostsDetailToolStripMenuItem_Click(object sender, EventArgs e)
- {
- string name = GetUserId();
- if (name != null) AddNewTabForUserTimeline(name);
- }
-
- private void SearchAtPostsDetailToolStripMenuItem_Click(object sender, EventArgs e)
- {
- string name = GetUserId();
- if (name != null) AddNewTabForSearch("@" + name);
- }
-
private void IdeographicSpaceToSpaceToolStripMenuItem_Click(object sender, EventArgs e)
{
ModifySettingCommon = true;
Control pnl = ((Control)sender).Parent;
if (pnl == null) return;
string tbName = pnl.Parent.Text;
- TabClass tb = _statuses.Tabs[tbName];
+ var tb = (PublicSearchTabModel)_statuses.Tabs[tbName];
ComboBox cmb = (ComboBox)pnl.Controls["comboSearch"];
ComboBox cmbLang = (ComboBox)pnl.Controls["comboLang"];
cmb.Text = cmb.Text.Trim();
var listView = (DetailsListView)pnl.Parent.Tag;
+ var queryChanged = tb.SearchWords != cmb.Text || tb.SearchLang != cmbLang.Text;
+
tb.SearchWords = cmb.Text;
tb.SearchLang = cmbLang.Text;
if (string.IsNullOrEmpty(cmb.Text))
SaveConfigsTabs();
return;
}
- if (tb.IsSearchQueryChanged)
+ if (queryChanged)
{
int idx = cmb.Items.IndexOf(tb.SearchWords);
if (idx > -1) cmb.Items.RemoveAt(idx);
{
DetailsListView listView = null;
- TabClass tb = _statuses.RemovedTab.Pop();
+ TabModel tb = _statuses.RemovedTab.Pop();
if (tb.TabType == MyCommon.TabUsageType.Related)
{
var relatedTab = _statuses.GetTabByType(MyCommon.TabUsageType.Related);
for (int i = 2; i <= 100; i++)
{
if (!_statuses.ContainsTab(renamed)) break;
- renamed = TabName + i.ToString();
+ renamed = TabName + i;
}
tb.TabName = renamed;
- AddNewTab(renamed, false, tb.TabType, tb.ListInfo);
- _statuses.Tabs.Add(renamed, tb); // 後に
+
+ _statuses.AddTab(tb);
+ AddNewTab(tb, startup: false);
var tabPage = ListTab.TabPages[ListTab.TabPages.Count - 1];
listView = (DetailsListView)tabPage.Tag;
for (int i = 1; i < int.MaxValue; i++)
{
if (!_statuses.ContainsTab(renamed)) break;
- renamed = tb.TabName + "(" + i.ToString() + ")";
+ renamed = tb.TabName + "(" + i + ")";
}
tb.TabName = renamed;
- _statuses.Tabs.Add(renamed, tb); // 先に
- AddNewTab(renamed, false, tb.TabType, tb.ListInfo);
+
+ _statuses.AddTab(tb);
+ AddNewTab(tb, startup: false);
var tabPage = ListTab.TabPages[ListTab.TabPages.Count - 1];
listView = (DetailsListView)tabPage.Tag;
await this.doMoveToRTHome();
}
- private void IdFilterAddMenuItem_Click(object sender, EventArgs e)
+ private async void ListManageUserContextToolStripMenuItem_Click(object sender, EventArgs e)
{
- string name = GetUserId();
- if (name != null)
- {
- string tabName;
-
- //未選択なら処理終了
- if (_curList.SelectedIndices.Count == 0) return;
-
- //タブ選択(or追加)
- if (!SelectTab(out tabName)) return;
-
- var tab = this._statuses.Tabs[tabName];
-
- bool mv;
- bool mk;
- if (tab.TabType != MyCommon.TabUsageType.Mute)
- {
- this.MoveOrCopy(out mv, out mk);
- }
- else
- {
- // ミュートタブでは常に MoveMatches を true にする
- mv = true;
- mk = false;
- }
-
- PostFilterRule fc = new PostFilterRule();
- fc.FilterName = name;
- fc.UseNameField = true;
- fc.MoveMatches = mv;
- fc.MarkMatches = mk;
- fc.UseRegex = false;
- fc.FilterByUrl = false;
- tab.AddFilter(fc);
-
- this.ApplyPostFilters();
- SaveConfigsTabs();
- }
+ var screenName = this._curPost?.ScreenName;
+ if (screenName != null)
+ await this.ListManageUserContext(screenName);
}
- private void ListManageUserContextToolStripMenuItem_Click(object sender, EventArgs e)
+ public async Task ListManageUserContext(string screenName)
{
- string user;
-
- ToolStripMenuItem menuItem = (ToolStripMenuItem)sender;
-
- if (menuItem.Owner == this.ContextMenuPostBrowser)
- {
- user = GetUserId();
- if (user == null) return;
- }
- else if (this._curPost != null)
- {
- user = this._curPost.ScreenName;
- }
- else
- {
- return;
- }
-
- if (TabInformations.GetInstance().SubscribableLists.Count == 0)
+ if (this._statuses.SubscribableLists.Count == 0)
{
try
{
- this.tw.GetListsApi();
+ using (var dialog = new WaitingDialog(Properties.Resources.ListsGetting))
+ {
+ var cancellationToken = dialog.EnableCancellation();
+
+ var task = this.tw.GetListsApi();
+ await dialog.WaitForAsync(this, task);
+
+ cancellationToken.ThrowIfCancellationRequested();
+ }
}
+ catch (OperationCanceledException) { return; }
catch (WebApiException ex)
{
MessageBox.Show("Failed to get lists. (" + ex.Message + ")");
}
}
- using (MyLists listSelectForm = new MyLists(user, this.tw))
+ using (MyLists listSelectForm = new MyLists(screenName, this.tw))
{
listSelectForm.ShowDialog(this);
}
}
}
- private void UseHashtagMenuItem_Click(object sender, EventArgs e)
- {
- Match m = Regex.Match(this._postBrowserStatusText, @"^https?://twitter.com/search\?q=%23(?<hash>.+)$");
- if (m.Success)
- {
- HashMgr.SetPermanentHash("#" + Uri.UnescapeDataString(m.Result("${hash}")));
- HashStripSplitButton.Text = HashMgr.UseHash;
- HashToggleMenuItem.Checked = true;
- HashToggleToolStripMenuItem.Checked = true;
- //使用ハッシュタグとして設定
- ModifySettingCommon = true;
- }
- }
-
private void StatusLabel_DoubleClick(object sender, EventArgs e)
{
MessageBox.Show(StatusLabel.TextHistory, "Logs", MessageBoxButtons.OK, MessageBoxIcon.None);
HashToggleMenuItem_Click(null, null);
}
+ public void SetPermanentHashtag(string hashtag)
+ {
+ HashMgr.SetPermanentHash("#" + hashtag);
+ HashStripSplitButton.Text = HashMgr.UseHash;
+ HashToggleMenuItem.Checked = true;
+ HashToggleToolStripMenuItem.Checked = true;
+ //使用ハッシュタグとして設定
+ ModifySettingCommon = true;
+ }
+
private void MenuItemOperate_DropDownOpening(object sender, EventArgs e)
{
if (ListTab.SelectedTab == null) return;
catch (WebApiException ex)
{
if (!cancellationToken.IsCancellationRequested)
- MessageBox.Show(ex.Message);
+ MessageBox.Show($"Err:{ex.Message}(UsersShow)");
return;
}
}
}
- private Task ShowUserStatus(string id, bool ShowInputDialog)
+ internal Task ShowUserStatus(string id, bool ShowInputDialog)
{
return this.doShowUserStatus(id, ShowInputDialog);
}
- private Task ShowUserStatus(string id)
+ internal Task ShowUserStatus(string id)
{
return this.doShowUserStatus(id, true);
}
- private async void FollowToolStripMenuItem_Click(object sender, EventArgs e)
- {
- if (NameLabel.Tag != null)
- {
- string id = (string)NameLabel.Tag;
- if (id != tw.Username)
- {
- await this.FollowCommand(id);
- }
- }
- }
-
- private async void UnFollowToolStripMenuItem_Click(object sender, EventArgs e)
- {
- if (NameLabel.Tag != null)
- {
- string id = (string)NameLabel.Tag;
- if (id != tw.Username)
- {
- await this.RemoveCommand(id, false);
- }
- }
- }
-
- private async void ShowFriendShipToolStripMenuItem_Click(object sender, EventArgs e)
- {
- if (NameLabel.Tag != null)
- {
- string id = (string)NameLabel.Tag;
- if (id != tw.Username)
- {
- await this.ShowFriendship(id);
- }
- }
- }
-
- private async void ShowUserStatusToolStripMenuItem_Click(object sender, EventArgs e)
- {
- if (NameLabel.Tag != null)
- {
- string id = (string)NameLabel.Tag;
- await this.ShowUserStatus(id, false);
- }
- }
-
- private void SearchPostsDetailNameToolStripMenuItem_Click(object sender, EventArgs e)
- {
- if (NameLabel.Tag != null)
- {
- string id = (string)NameLabel.Tag;
- AddNewTabForUserTimeline(id);
- }
- }
-
- private void SearchAtPostsDetailNameToolStripMenuItem_Click(object sender, EventArgs e)
- {
- if (NameLabel.Tag != null)
- {
- string id = (string)NameLabel.Tag;
- AddNewTabForSearch("@" + id);
- }
- }
-
private async void ShowProfileMenuItem_Click(object sender, EventArgs e)
{
if (_curPost != null)
catch (WebApiException ex)
{
if (!cancellationToken.IsCancellationRequested)
- MessageBox.Show(Properties.Resources.RtCountText2 + Environment.NewLine + ex.Message);
+ MessageBox.Show(Properties.Resources.RtCountText2 + Environment.NewLine + "Err:" + ex.Message);
return;
}
this.StatusText.Dock = DockStyle.Fill;
}
+ this.tweetDetailsView.Owner = this;
+
this.TimerTimeline.Elapsed += this.TimerTimeline_Elapsed;
this._hookGlobalHotkey.HotkeyPressed += _hookGlobalHotkey_HotkeyPressed;
this.gh.NotifyClicked += GrowlHelper_Callback;
this.ImageSelector.Enabled = false;
this.ImageSelector.FilePickDialog = OpenFileDialog1;
+ this.workerProgress = new Progress<string>(x => this.StatusLabel.Text = x);
+
this.ReplaceAppName();
this.InitializeShortcuts();
}
}
}
- private void UserPicture_MouseEnter(object sender, EventArgs e)
- {
- this.UserPicture.Cursor = Cursors.Hand;
- }
-
- private void UserPicture_MouseLeave(object sender, EventArgs e)
- {
- this.UserPicture.Cursor = Cursors.Default;
- }
-
- private async void UserPicture_DoubleClick(object sender, EventArgs e)
- {
- if (NameLabel.Tag != null)
- {
- await this.OpenUriInBrowserAsync(MyCommon.TwitterUrl + NameLabel.Tag.ToString());
- }
- }
-
private void SplitContainer2_MouseDoubleClick(object sender, MouseEventArgs e)
{
this.MultiLineMenuItem.PerformClick();
public bool ModifySettingLocal { get; set; }
public bool ModifySettingAtId { get; set; }
- private async void SourceLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
- {
- var sourceUri = (Uri)this.SourceLinkLabel.Tag;
- if (sourceUri != null && e.Button == MouseButtons.Left)
- {
- await this.OpenUriInBrowserAsync(sourceUri.AbsoluteUri);
- }
- }
-
- private void SourceLinkLabel_MouseEnter(object sender, EventArgs e)
- {
- var sourceUri = (Uri)this.SourceLinkLabel.Tag;
- if (sourceUri != null)
- {
- StatusLabelUrl.Text = MyCommon.ConvertToReadableUrl(sourceUri.AbsoluteUri);
- }
- }
-
- private void SourceLinkLabel_MouseLeave(object sender, EventArgs e)
- {
- SetStatusLabelUrl();
- }
-
private void MenuItemCommand_DropDownOpening(object sender, EventArgs e)
{
if (this.ExistCurrentPost && !_curPost.IsDm)
}
catch (WebApiException ex)
{
- this.StatusLabel.Text = ex.Message;
+ this.StatusLabel.Text = $"Err:{ex.Message}(GetStatus)";
return;
}
}
/// <exception cref="TabException">名前の重複が多すぎてタブを作成できない場合</exception>
private async Task OpenRelatedTab(PostClass post)
{
- var tabRelated = this._statuses.GetTabByType(MyCommon.TabUsageType.Related);
- string tabName;
-
- if (tabRelated == null)
+ var tabRelated = this._statuses.GetTabByType<RelatedPostsTabModel>();
+ if (tabRelated != null)
{
- tabName = this._statuses.MakeTabName("Related Tweets");
+ this.RemoveSpecifiedTab(tabRelated.TabName, confirm: false);
+ }
- this.AddNewTab(tabName, false, MyCommon.TabUsageType.Related);
- this._statuses.AddTab(tabName, MyCommon.TabUsageType.Related, null);
+ var tabName = this._statuses.MakeTabName("Related Tweets");
- tabRelated = this._statuses.GetTabByType(MyCommon.TabUsageType.Related);
- tabRelated.UnreadManage = false;
- tabRelated.Notify = false;
- }
- else
- {
- tabName = tabRelated.TabName;
- }
+ tabRelated = new RelatedPostsTabModel(tabName, post);
+ tabRelated.UnreadManage = false;
+ tabRelated.Notify = false;
- tabRelated.RelationTargetPost = post;
- this.ClearTab(tabName, false);
+ this._statuses.AddTab(tabRelated);
+ this.AddNewTab(tabRelated, startup: false);
+ TabPage tabPage;
for (int i = 0; i < this.ListTab.TabPages.Count; i++)
{
- var tabPage = this.ListTab.TabPages[i];
+ tabPage = this.ListTab.TabPages[i];
if (tabName == tabPage.Text)
{
this.ListTab.SelectedIndex = i;
}
await this.GetRelatedTweetsAsync(tabRelated);
+
+ tabPage = this.ListTab.TabPages.Cast<TabPage>()
+ .FirstOrDefault(x => x.Text == tabRelated.TabName);
+
+ if (tabPage != null)
+ {
+ // TODO: 非同期更新中にタブが閉じられている場合を厳密に考慮したい
+
+ var listView = (DetailsListView)tabPage.Tag;
+ var targetPost = tabRelated.TargetPost;
+ var index = tabRelated.IndexOf(targetPost.RetweetedId ?? targetPost.StatusId);
+
+ if (index != -1 && index < listView.Items.Count)
+ {
+ listView.SelectedIndices.Add(index);
+ listView.Items[index].Focused = true;
+ }
+ }
}
private void CacheInfoMenuItem_Click(object sender, EventArgs e)
}
#region "Userstream"
- private bool _isActiveUserstream = false;
-
private void tw_PostDeleted(object sender, PostDeletedEventArgs e)
{
try
{
Invoke((Action) (async () =>
{
- _statuses.RemovePostReserve(e.StatusId);
+ this._statuses.RemovePostFromAllTabs(e.StatusId, setIsDeleted: true);
if (_curTab != null && _statuses.Tabs[_curTab.Text].Contains(e.StatusId))
{
this.PurgeListViewItemCache();
_statuses.SetReadHomeTab(); //新着時未読クリア
}
- int rsltAddCount = _statuses.DistributePosts();
-
- this.UpdateTimelineSpeed(rsltAddCount);
+ this._statuses.DistributePosts();
if (this._cfgCommon.UserstreamPeriod > 0) return;
private void tw_UserStreamStarted(object sender, EventArgs e)
{
- this._isActiveUserstream = true;
try
{
if (InvokeRequired && !IsDisposed)
return;
}
- MenuItemUserStream.Text = "&UserStream ▶";
- MenuItemUserStream.Enabled = true;
- StopToolStripMenuItem.Text = "&Stop";
- StopToolStripMenuItem.Enabled = true;
+ this.RefreshUserStreamsMenu();
+ this.MenuItemUserStream.Enabled = true;
StatusLabel.Text = "UserStream Started.";
}
private void tw_UserStreamStopped(object sender, EventArgs e)
{
- this._isActiveUserstream = false;
try
{
if (InvokeRequired && !IsDisposed)
return;
}
- MenuItemUserStream.Text = "&UserStream ■";
- MenuItemUserStream.Enabled = true;
- StopToolStripMenuItem.Text = "&Start";
- StopToolStripMenuItem.Enabled = true;
+ this.RefreshUserStreamsMenu();
+ this.MenuItemUserStream.Enabled = true;
StatusLabel.Text = "UserStream Stopped.";
}
+ private void RefreshUserStreamsMenu()
+ {
+ if (this.tw.UserStreamActive)
+ {
+ this.MenuItemUserStream.Text = "&UserStream ▶";
+ this.StopToolStripMenuItem.Text = "&Stop";
+ }
+ else
+ {
+ this.MenuItemUserStream.Text = "&UserStream ■";
+ this.StopToolStripMenuItem.Text = "&Start";
+ }
+ }
+
private void tw_UserStreamEventArrived(object sender, UserStreamEventReceivedEventArgs e)
{
try
}
if (ev.Event == "unfavorite" && ev.Username.ToLowerInvariant().Equals(tw.Username.ToLowerInvariant()))
{
- RemovePostFromFavTab(new long[] {ev.Id});
+ var favTab = this._statuses.GetTabByType(MyCommon.TabUsageType.Favorites);
+ favTab.EnqueueRemovePost(ev.Id, setIsDeleted: false);
}
}
}
title.Append("] by ");
if (!string.IsNullOrEmpty(ev.Username))
{
- title.Append(ev.Username.ToString());
+ title.Append(ev.Username);
}
else
{
StopRefreshAllMenuItem.Checked = false;
return;
}
- if (this._isActiveUserstream)
+ if (this.tw.UserStreamActive)
{
tw.StopUserStream();
}
await this.OpenUriInBrowserAsync(MyCommon.TwitterUrl + tw.Username);
}
- private async Task doTranslation(string str)
- {
- if (string.IsNullOrEmpty(str))
- return;
-
- var bing = new Bing();
- try
- {
- var translatedText = await bing.TranslateAsync(str,
- langFrom: null,
- langTo: this._cfgCommon.TranslateLanguage);
-
- this.PostBrowser.DocumentText = this.createDetailHtml(translatedText);
- }
- catch (HttpRequestException e)
- {
- this.StatusLabel.Text = "Err:" + e.Message;
- }
- catch (OperationCanceledException)
- {
- this.StatusLabel.Text = "Err:Timeout";
- }
- }
-
- private async void TranslationToolStripMenuItem_Click(object sender, EventArgs e)
- {
- if (!this.ExistCurrentPost)
- return;
-
- await this.doTranslation(this._curPost.TextFromApi);
- }
-
- private async void SelectionTranslationToolStripMenuItem_Click(object sender, EventArgs e)
- {
- var text = this.PostBrowser.GetSelectedText();
- await this.doTranslation(text);
- }
-
private bool ExistCurrentPost
{
get
await this.OpenUserAppointUrl();
}
- private void SourceCopyMenuItem_Click(object sender, EventArgs e)
- {
- string selText = SourceLinkLabel.Text;
- try
- {
- Clipboard.SetDataObject(selText, false, 5, 100);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
-
- private void SourceUrlCopyMenuItem_Click(object sender, EventArgs e)
- {
- var sourceUri = (Uri)this.SourceLinkLabel.Tag;
- try
- {
- Clipboard.SetDataObject(sourceUri.AbsoluteUri, false, 5, 100);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
-
- private void ContextMenuSource_Opening(object sender, CancelEventArgs e)
- {
- if (_curPost == null || !ExistCurrentPost || _curPost.IsDm)
- {
- SourceCopyMenuItem.Enabled = false;
- SourceUrlCopyMenuItem.Enabled = false;
- }
- else
- {
- SourceCopyMenuItem.Enabled = true;
- SourceUrlCopyMenuItem.Enabled = true;
- }
- }
-
private void GrowlHelper_Callback(object sender, GrowlHelper.NotifyCallbackEventArgs e)
{
if (Form.ActiveForm == null)
ModifySettingCommon = true;
}
+
+ private void tweetDetailsView_StatusChanged(object sender, TweetDetailsViewStatusChengedEventArgs e)
+ {
+ if (!string.IsNullOrEmpty(e.StatusText))
+ {
+ this.StatusLabelUrl.Text = e.StatusText;
+ }
+ else
+ {
+ this.SetStatusLabelUrl();
+ }
+ }
}
}