本文整理汇总了C#中OpenTween.TabClass类的典型用法代码示例。如果您正苦于以下问题:C# TabClass类的具体用法?C# TabClass怎么用?C# TabClass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TabClass类属于OpenTween命名空间,在下文中一共展示了TabClass类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UnreadCount_Test
public void UnreadCount_Test()
{
var tab = new TabClass { TabType = MyCommon.TabUsageType.UserTimeline };
tab.UnreadManage = true;
// 未読なし
Assert.Equal(0, tab.UnreadCount);
tab.AddPostToInnerStorage(new PostClass
{
StatusId = 100L,
IsRead = false, // 未読
});
tab.AddSubmit();
Assert.Equal(1, tab.UnreadCount);
tab.AddPostToInnerStorage(new PostClass
{
StatusId = 50L,
IsRead = true, // 既読
});
tab.AddSubmit();
Assert.Equal(1, tab.UnreadCount);
}
示例2: OldestUnreadId_DisabledTest
public void OldestUnreadId_DisabledTest()
{
var tab = new TabClass { TabType = MyCommon.TabUsageType.UserTimeline };
// 未読表示無効
tab.UnreadManage = false;
tab.AddPostToInnerStorage(new PostClass
{
StatusId = 100L,
IsRead = false, // 未読
});
tab.AddSubmit();
Assert.Equal(-1L, tab.OldestUnreadId);
}
示例3: NextUnreadId_SortByIdAscTest
public void NextUnreadId_SortByIdAscTest()
{
var tab = new TabClass { TabType = MyCommon.TabUsageType.UserTimeline };
tab.UnreadManage = true;
// ID の昇順でソート
tab.SetSortMode(ComparerMode.Id, SortOrder.Ascending);
// 画面には上から 100 → 200 → 300 の順に並ぶ
tab.AddPostToInnerStorage(new PostClass { StatusId = 100L, IsRead = false });
tab.AddPostToInnerStorage(new PostClass { StatusId = 200L, IsRead = false });
tab.AddPostToInnerStorage(new PostClass { StatusId = 300L, IsRead = false });
tab.AddSubmit();
// 昇順/降順に関わらず、ID の小さい順に未読の ID を返す
Assert.Equal(100L, tab.NextUnreadId);
}
示例4: RemoveFilter_Test
public void RemoveFilter_Test()
{
var tab = new TabClass();
var filter = new PostFilterRule();
tab.FilterArray = new[] { filter };
tab.FilterModified = false;
tab.RemoveFilter(filter);
Assert.Empty(tab.FilterArray);
Assert.True(tab.FilterModified);
}
示例5: OnFilterModified_Test
public void OnFilterModified_Test()
{
var tab = new TabClass();
var filter = new PostFilterRule();
tab.FilterArray = new[] { filter };
tab.FilterModified = false;
// TabClass に紐付いているフィルタを変更
filter.FilterSource = "OpenTween";
Assert.True(tab.FilterModified);
}
示例6: CreatePostsFromPhoenixSearch
private string CreatePostsFromPhoenixSearch(string content, MyCommon.WORKERTYPE gType, TabClass tab, bool read, int count, ref long minimumId, ref string nextPageQuery)
{
TwitterDataModel.SearchResult items;
try
{
items = MyCommon.CreateDataFromJson<TwitterDataModel.SearchResult>(content);
}
catch(SerializationException ex)
{
MyCommon.TraceOut(ex.Message + Environment.NewLine + content);
return "Json Parse Error(DataContractJsonSerializer)";
}
catch(Exception ex)
{
MyCommon.TraceOut(ex, MethodBase.GetCurrentMethod().Name + " " + content);
return "Invalid Json!";
}
nextPageQuery = items.NextPage;
foreach (var status in items.Statuses)
{
PostClass post = null;
post = CreatePostsFromStatusData(status);
if (post == null) continue;
if (minimumId > post.StatusId) minimumId = post.StatusId;
//二重取得回避
lock (LockObj)
{
if (tab == null)
{
if (TabInformations.GetInstance().ContainsKey(post.StatusId)) continue;
}
else
{
if (TabInformations.GetInstance().ContainsKey(post.StatusId, tab.TabName)) continue;
}
}
post.IsRead = read;
if (post.IsMe && !read && _readOwnPost) post.IsRead = true;
if (tab != null) post.RelTabName = tab.TabName;
//非同期アイコン取得&StatusDictionaryに追加
TabInformations.GetInstance().AddPost(post);
}
return string.IsNullOrEmpty(items.ErrMsg) ? string.Empty : "Err:" + items.ErrMsg;
}
示例7: FavRemoveAsync
private async Task FavRemoveAsync(IReadOnlyList<long> statusIds, TabClass tab)
{
await this.workerSemaphore.WaitAsync();
try
{
var progress = new Progress<string>(x => this.StatusLabel.Text = x);
await this.FavRemoveAsyncInternal(progress, this.workerCts.Token, statusIds, tab);
}
catch (WebApiException ex)
{
this._myStatusError = true;
this.StatusLabel.Text = ex.Message;
}
finally
{
this.workerSemaphore.Release();
}
}
示例8: GetSearch
public string GetSearch(bool read,
TabClass tab,
bool more)
{
if (MyCommon._endingFlag) return string.Empty;
HttpStatusCode res;
var content = string.Empty;
var page = 0;
var sinceId = 0;
var count = 100;
if (AppendSettingDialog.Instance.UseAdditionalCount &&
AppendSettingDialog.Instance.SearchCountApi != 0)
{
count = AppendSettingDialog.Instance.SearchCountApi;
}
else
{
count = AppendSettingDialog.Instance.CountApi;
}
if (more)
{
page = tab.GetSearchPage(count);
}
else
{
sinceId = (int)tab.SinceId;
}
try
{
// TODO:一時的に40>100件に 件数変更UI作成の必要あり
res = twCon.Search(tab.SearchWords, tab.SearchLang, count, page, sinceId, ref content);
}
catch(Exception ex)
{
return "Err:" + ex.Message;
}
switch (res)
{
case HttpStatusCode.BadRequest:
return "Invalid query";
case HttpStatusCode.NotFound:
return "Invalid query";
case HttpStatusCode.PaymentRequired: //API Documentには420と書いてあるが、該当コードがないので402にしてある
return "Search API Limit?";
case HttpStatusCode.OK:
break;
default:
return "Err:" + res.ToString() + "(" + MethodBase.GetCurrentMethod().Name + ")";
}
if (!TabInformations.GetInstance().ContainsTab(tab)) return string.Empty;
content = Regex.Replace(content, @"[\x00-\x1f-[\x0a\x0d]]+", " ");
var xdoc = new XmlDocument();
try
{
xdoc.LoadXml(content);
}
catch(Exception ex)
{
MyCommon.TraceOut(ex, MethodBase.GetCurrentMethod().Name + " " + content);
return "Invalid ATOM!";
}
var nsmgr = new XmlNamespaceManager(xdoc.NameTable);
nsmgr.AddNamespace("search", "http://www.w3.org/2005/Atom");
nsmgr.AddNamespace("twitter", "http://api.twitter.com/");
nsmgr.AddNamespace("georss", "http://www.georss.org/georss");
foreach (var xentryNode in xdoc.DocumentElement.SelectNodes("/search:feed/search:entry", nsmgr))
{
var xentry = (XmlElement)xentryNode;
var post = new PostClass();
try
{
post.StatusId = long.Parse(xentry["id"].InnerText.Split(':')[2]);
if (TabInformations.GetInstance().ContainsKey(post.StatusId, tab.TabName)) continue;
post.CreatedAt = DateTime.Parse(xentry["published"].InnerText);
//本文
post.TextFromApi = xentry["title"].InnerText;
//Source取得(htmlの場合は、中身を取り出し)
post.Source = xentry["twitter:source"].InnerText;
post.InReplyToStatusId = 0;
post.InReplyToUser = string.Empty;
post.InReplyToUserId = 0;
post.IsFav = false;
// Geoが勝手に付加されるバグがいっこうに修正されないので暫定的にGeo情報を無視する
if (xentry["twitter:geo"].HasChildNodes)
{
var pnt = ((XmlElement)xentry.SelectSingleNode("twitter:geo/georss:point", nsmgr)).InnerText.Split(' ');
post.PostGeo = new PostClass.StatusGeo {Lat = Double.Parse(pnt[0]), Lng = Double.Parse(pnt[1])};
}
//以下、ユーザー情報
var xUentry = (XmlElement)xentry.SelectSingleNode("./search:author", nsmgr);
post.UserId = 0;
post.ScreenName = xUentry["name"].InnerText.Split(' ')[0].Trim();
post.Nickname = xUentry["name"].InnerText.Substring(post.ScreenName.Length).Trim();
if (post.Nickname.Length > 2)
{
//.........这里部分代码省略.........
示例9: GetUserTimelineApi
public string GetUserTimelineApi(bool read,
int count,
string userName,
TabClass tab,
bool more)
{
if (Twitter.AccountState != MyCommon.ACCOUNT_STATE.Valid) return string.Empty;
if (MyCommon._endingFlag) return string.Empty;
HttpStatusCode res = HttpStatusCode.BadRequest;
var content = string.Empty;
if (count == 0) count = 20;
try
{
if (string.IsNullOrEmpty(userName))
{
var target = tab.User;
if (string.IsNullOrEmpty(target)) return string.Empty;
userName = target;
res = twCon.UserTimeline(0, target, count, 0, 0, ref content);
}
else
{
if (more)
{
res = twCon.UserTimeline(0, userName, count, tab.OldestId, 0, ref content);
}
else
{
res = twCon.UserTimeline(0, userName, count, 0, 0, ref content);
}
}
}
catch(Exception ex)
{
return "Err:" + ex.Message;
}
switch (res)
{
case HttpStatusCode.OK:
Twitter.AccountState = MyCommon.ACCOUNT_STATE.Valid;
break;
case HttpStatusCode.Unauthorized:
Twitter.AccountState = MyCommon.ACCOUNT_STATE.Valid;
return "Err:@" + userName + "'s Tweets are protected.";
case HttpStatusCode.BadRequest:
return "Err:API Limits?";
default:
return "Err:" + res.ToString() + "(" + MethodBase.GetCurrentMethod().Name + ")";
}
List<TwitterDataModel.Status> items;
try
{
items = MyCommon.CreateDataFromJson<List<TwitterDataModel.Status>>(content);
}
catch(SerializationException ex)
{
MyCommon.TraceOut(ex.Message + Environment.NewLine + content);
return "Json Parse Error(DataContractJsonSerializer)";
}
catch(Exception ex)
{
MyCommon.TraceOut(ex, MethodBase.GetCurrentMethod().Name + " " + content);
return "Invalid Json!";
}
foreach (var status in items)
{
var item = CreatePostsFromStatusData(status);
if (item == null) continue;
if (item.StatusId < tab.OldestId) tab.OldestId = item.StatusId;
item.IsRead = read;
if (item.IsMe && !read && _readOwnPost) item.IsRead = true;
if (tab != null) item.RelTabName = tab.TabName;
//非同期アイコン取得&StatusDictionaryに追加
TabInformations.GetInstance().AddPost(item);
}
return string.Empty;
}
示例10: FavRemoveAsyncInternal
private async Task FavRemoveAsyncInternal(IProgress<string> p, CancellationToken ct, IReadOnlyList<long> statusIds, TabClass tab)
{
if (ct.IsCancellationRequested)
return;
if (!CheckAccountValid())
throw new WebApiException("Auth error. Check your account");
var successIds = new List<long>();
await Task.Run(() =>
{
//スレッド処理はしない
var allCount = 0;
var failedCount = 0;
foreach (var statusId in statusIds)
{
allCount++;
var post = tab.Posts[statusId];
p.Report(Properties.Resources.GetTimelineWorker_RunWorkerCompletedText17 +
allCount + "/" + statusIds.Count +
Properties.Resources.GetTimelineWorker_RunWorkerCompletedText18 +
failedCount);
if (!post.IsFav)
continue;
var err = this.tw.PostFavRemove(post.RetweetedId ?? post.StatusId);
if (!string.IsNullOrEmpty(err))
{
failedCount++;
continue;
}
successIds.Add(statusId);
post.IsFav = false; // リスト再描画必要
if (this._statuses.ContainsKey(statusId))
{
this._statuses[statusId].IsFav = false;
}
// 検索,リスト,UserTimeline,Relatedの各タブに反映
foreach (var tb in this._statuses.GetTabsInnerStorageType())
{
if (tb.Contains(statusId))
tb.Posts[statusId].IsFav = false;
}
}
});
if (ct.IsCancellationRequested)
return;
this.RemovePostFromFavTab(successIds.ToArray());
this.RefreshTimeline(false);
if (this._curList != null && this._curTab != null && this._curTab.Text == tab.TabName)
{
if (tab.TabType == MyCommon.TabUsageType.Favorites)
{
// 色変えは不要
}
else
{
using (ControlTransaction.Update(this._curList))
{
foreach (var statusId in successIds)
{
var idx = tab.IndexOf(statusId);
if (idx == -1)
continue;
var post = tab.Posts[statusId];
this.ChangeCacheStyleRead(post.IsRead, idx);
}
}
if (successIds.Contains(this._curPost.StatusId))
await this.DispSelectedPost(true); // 選択アイテム再表示
}
}
}
示例11: GetUserTimelineApi
public string GetUserTimelineApi(bool read,
int count,
string userName,
TabClass tab,
bool more)
{
if (Twitter.AccountState != MyCommon.ACCOUNT_STATE.Valid) return "";
if (MyCommon._endingFlag) return "";
IList<TwitterDataModel.Status> items;
try
{
if (string.IsNullOrEmpty(userName))
{
var target = tab.User;
if (string.IsNullOrEmpty(target)) return "";
userName = target;
items = GetUserTimelineStatusApi(target, count, 0);
}
else
{
if (more)
{
items = GetUserTimelineStatusApi(userName, count, tab.OldestId);
}
else
{
items = GetUserTimelineStatusApi(userName, count, 0);
}
}
}
catch (Exception ex)
{
return ex.Message;
}
IList<PostClass> postList = StatusListToPostClassList(items);
foreach (var item in postList)
{
if (item.StatusId < tab.OldestId) tab.OldestId = item.StatusId;
item.IsRead = read;
if (item.IsMe && !read && _readOwnPost) item.IsRead = true;
if (tab != null) item.RelTabName = tab.TabName;
//非同期アイコン取得&StatusDictionaryに追加
TabInformations.GetInstance().AddPost(item);
}
return "";
}
示例12: GetUserTimelineApi
public string GetUserTimelineApi(bool read,
int count,
string userName,
TabClass tab,
bool more)
{
if (Twitter.AccountState != MyCommon.ACCOUNT_STATE.Valid) return "";
if (MyCommon._endingFlag) return "";
HttpStatusCode res;
var content = "";
if (count == 0) count = 20;
try
{
if (string.IsNullOrEmpty(userName))
{
var target = tab.User;
if (string.IsNullOrEmpty(target)) return "";
userName = target;
res = twCon.UserTimeline(null, target, count, null, null, ref content);
}
else
{
if (more)
{
res = twCon.UserTimeline(null, userName, count, tab.OldestId, null, ref content);
}
else
{
res = twCon.UserTimeline(null, userName, count, null, null, ref content);
}
}
}
catch(Exception ex)
{
return "Err:" + ex.Message;
}
if (res == HttpStatusCode.Unauthorized)
return "Err:@" + userName + "'s Tweets are protected.";
var err = this.CheckStatusCode(res, content);
if (err != null) return err;
return CreatePostsFromJson(content, MyCommon.WORKERTYPE.UserTimeline, tab, read, ref tab.OldestId);
}
示例13: CreatePostsFromSearchJson
private string CreatePostsFromSearchJson(string content, TabClass tab, bool read, int count, ref long minimumId, bool more)
{
TwitterSearchResult items;
try
{
items = TwitterSearchResult.ParseJson(content);
}
catch (SerializationException ex)
{
MyCommon.TraceOut(ex.Message + Environment.NewLine + content);
return "Json Parse Error(DataContractJsonSerializer)";
}
catch (Exception ex)
{
MyCommon.TraceOut(ex, MethodBase.GetCurrentMethod().Name + " " + content);
return "Invalid Json!";
}
foreach (var result in items.Statuses)
{
PostClass post = null;
post = CreatePostsFromStatusData(result);
if (post == null)
{
// Search API は相変わらずぶっ壊れたデータを返すことがあるため、必要なデータが欠如しているものは取得し直す
var ret = this.GetStatusApi(read, result.Id, ref post);
if (!string.IsNullOrEmpty(ret)) continue;
}
if (minimumId > post.StatusId) minimumId = post.StatusId;
if (!more && post.StatusId > tab.SinceId) tab.SinceId = post.StatusId;
//二重取得回避
lock (LockObj)
{
if (tab == null)
{
if (TabInformations.GetInstance().ContainsKey(post.StatusId)) continue;
}
else
{
if (tab.Contains(post.StatusId)) continue;
}
}
post.IsRead = read;
if ((post.IsMe && !read) && this._readOwnPost) post.IsRead = true;
if (tab != null) post.RelTabName = tab.TabName;
//非同期アイコン取得&StatusDictionaryに追加
TabInformations.GetInstance().AddPost(post);
}
return "";
}
示例14: CreatePostsFromSearchJson
private string CreatePostsFromSearchJson(string content, TabClass tab, bool read, int count, ref long minimumId, bool more)
{
TwitterDataModel.SearchResult items;
try
{
items = MyCommon.CreateDataFromJson<TwitterDataModel.SearchResult>(content);
}
catch (SerializationException ex)
{
MyCommon.TraceOut(ex.Message + Environment.NewLine + content);
return "Json Parse Error(DataContractJsonSerializer)";
}
catch (Exception ex)
{
MyCommon.TraceOut(ex, MethodBase.GetCurrentMethod().Name + " " + content);
return "Invalid Json!";
}
foreach (var result in items.Results)
{
PostClass post = null;
post = CreatePostsFromSearchResultData(result);
if (post == null) continue;
if (minimumId > post.StatusId) minimumId = post.StatusId;
if (!more && post.StatusId > tab.SinceId) tab.SinceId = post.StatusId;
//二重取得回避
lock (LockObj)
{
if (tab == null)
{
if (TabInformations.GetInstance().ContainsKey(post.StatusId)) continue;
}
else
{
if (TabInformations.GetInstance().ContainsKey(post.StatusId, tab.TabName)) continue;
}
}
post.IsRead = read;
if ((post.IsMe && !read) && this._readOwnPost) post.IsRead = true;
if (tab != null) post.RelTabName = tab.TabName;
//非同期アイコン取得&StatusDictionaryに追加
TabInformations.GetInstance().AddPost(post);
}
return "";
}
示例15: ContainsTab
public bool ContainsTab(TabClass ts)
{
return _tabs.ContainsValue(ts);
}