本文整理汇总了C#中OpenTween.PostFilterRule类的典型用法代码示例。如果您正苦于以下问题:C# PostFilterRule类的具体用法?C# PostFilterRule怎么用?C# PostFilterRule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PostFilterRule类属于OpenTween命名空间,在下文中一共展示了PostFilterRule类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExcludeOnlyTest
public void ExcludeOnlyTest()
{
var filter = new PostFilterRule { ExFilterName = "hogehoge" };
var post = new PostClass { ScreenName = "hogehoge" };
Assert.Equal(MyCommon.HITRESULT.Exclude, filter.ExecFilter(post));
}
示例2: EmptyRuleTest
public void EmptyRuleTest()
{
var filter = new PostFilterRule { };
var post = new PostClass { ScreenName = "hogehoge" };
Assert.Equal(MyCommon.HITRESULT.None, filter.ExecFilter(post));
}
示例3: MatchAndExcludeTest
public void MatchAndExcludeTest()
{
var filter = new PostFilterRule { FilterName = "hogehoge", ExFilterSource = "tetete" };
var post = new PostClass { ScreenName = "hogehoge", Source = "tetete" };
Assert.Equal(MyCommon.HITRESULT.None, filter.ExecFilter(post));
}
示例4: MatchOnlyTest
public void MatchOnlyTest()
{
var filter = new PostFilterRule { FilterName = "hogehoge" };
var post = new PostClass { ScreenName = "hogehoge" };
Assert.Equal(MyCommon.HITRESULT.CopyAndMark, filter.ExecFilter(post));
}
示例5: NullTest
public void NullTest()
{
var filter = new PostFilterRule
{
FilterName = null,
FilterSource = null,
ExFilterName = null,
ExFilterSource = null,
};
var post = new PostClass { ScreenName = "hogehoge" };
Assert.Equal(MyCommon.HITRESULT.None, filter.ExecFilter(post));
Assert.Throws<ArgumentNullException>(() => filter.FilterBody = null);
Assert.Throws<ArgumentNullException>(() => filter.ExFilterBody = null);
}
示例6: FieldNullAwareTest
public void FieldNullAwareTest()
{
var nullPost = new PostClass { Source = null };
// Source が null であっても ArgumentNullException 等を投げない
var filter1 = new PostFilterRule
{
FilterSource = "(hoge){2}",
UseRegex = true,
};
Assert.Equal(MyCommon.HITRESULT.None, filter1.ExecFilter(nullPost));
// null は空文字列と同じ扱いにする
var filter2 = new PostFilterRule
{
FilterSource = "^$",
UseRegex = true,
};
Assert.Equal(MyCommon.HITRESULT.CopyAndMark, filter2.ExecFilter(nullPost));
}
示例7: ShowSearchDialog
/// <summary>
/// 検索ダイアログを表示し、検索を実行します
/// </summary>
private void ShowSearchDialog()
{
// Recentタブの検索時以外では「新規タブに表示」ボタンを無効化する
if (this._statuses.Tabs[this._curTab.Text].TabType == MyCommon.TabUsageType.Home)
this.SearchDialog.DisableNewTabButton = false;
else
this.SearchDialog.DisableNewTabButton = true;
if (this.SearchDialog.ShowDialog(this) != DialogResult.OK)
{
this.TopMost = this._cfgCommon.AlwaysTop;
return;
}
this.TopMost = this._cfgCommon.AlwaysTop;
var searchOptions = this.SearchDialog.ResultOptions;
if (searchOptions.Type == SearchWordDialog.SearchType.Timeline)
{
if (searchOptions.NewTab)
{
var tabName = searchOptions.Query;
try
{
tabName = this._statuses.MakeTabName(tabName);
}
catch (TabException ex)
{
MessageBox.Show(this, ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
this.AddNewTab(tabName, false, MyCommon.TabUsageType.UserDefined);
this._statuses.AddTab(tabName, MyCommon.TabUsageType.UserDefined, null);
var filter = new PostFilterRule
{
FilterBody = new[] { searchOptions.Query },
UseRegex = searchOptions.UseRegex,
CaseSensitive = searchOptions.CaseSensitive,
};
this._statuses.Tabs[tabName].AddFilter(filter);
var tabPage = this.ListTab.TabPages.Cast<TabPage>()
.First(x => x.Text == tabName);
this.ListTab.SelectedTab = tabPage;
this.ListTabSelect(tabPage);
this.ApplyPostFilters();
this.SaveConfigsTabs();
}
else
{
this.DoTabSearch(
searchOptions.Query,
searchOptions.CaseSensitive,
searchOptions.UseRegex,
SEARCHTYPE.DialogSearch);
}
}
else if (searchOptions.Type == SearchWordDialog.SearchType.Public)
{
this.AddNewTabForSearch(searchOptions.Query);
}
}
示例8: IDRuleMenuItem_Click
private void IDRuleMenuItem_Click(object sender, EventArgs e)
{
string tabName;
//未選択なら処理終了
if (_curList.SelectedIndices.Count == 0) return;
//タブ選択(or追加)
if (!SelectTab(out tabName)) return;
bool mv = false;
bool mk = false;
MoveOrCopy(ref mv, ref mk);
List<string> ids = new List<string>();
foreach (int idx in _curList.SelectedIndices)
{
PostClass post = _statuses[_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;
_statuses.Tabs[tabName].AddFilter(fc);
}
}
if (ids.Count != 0)
{
List<string> atids = new List<string>();
foreach (string id in ids)
{
atids.Add("@" + id);
}
int cnt = AtIdSupl.ItemCount;
AtIdSupl.AddRangeItem(atids.ToArray());
if (AtIdSupl.ItemCount != cnt) _modifySettingAtId = true;
}
try
{
this.Cursor = Cursors.WaitCursor;
this.PurgeListViewItemCache();
_curPost = null;
_curItemIndex = -1;
_statuses.FilterAll();
foreach (TabPage tb in ListTab.TabPages)
{
((DetailsListView)tb.Tag).VirtualListSize = _statuses.Tabs[tb.Text].AllCount;
if (_statuses.ContainsTab(tb.Text))
{
if (_statuses.Tabs[tb.Text].UnreadCount > 0)
{
if (SettingDialog.TabIconDisp)
tb.ImageIndex = 0;
}
else
{
if (SettingDialog.TabIconDisp)
tb.ImageIndex = -1;
}
}
}
if (!SettingDialog.TabIconDisp) ListTab.Refresh();
}
finally
{
this.Cursor = Cursors.Default;
}
SaveConfigsTabs();
}
示例9: IdFilterAddMenuItem_Click
private void IdFilterAddMenuItem_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;
bool mv = false;
bool mk = false;
MoveOrCopy(ref mv, ref mk);
PostFilterRule fc = new PostFilterRule();
fc.FilterName = name;
fc.UseNameField = true;
fc.MoveMatches = mv;
fc.MarkMatches = mk;
fc.UseRegex = false;
fc.FilterByUrl = false;
_statuses.Tabs[tabName].AddFilter(fc);
this.ApplyPostFilters();
SaveConfigsTabs();
}
}
示例10: 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);
}
示例11: Disabled_Test
public void Disabled_Test()
{
var filter = new PostFilterRule { FilterName = "hogehoge" };
var post = new PostClass { ScreenName = "hogehoge" };
filter.Enabled = false;
Assert.Equal(MyCommon.HITRESULT.None, filter.ExecFilter(post));
}
示例12: AddFilter
public bool AddFilter(PostFilterRule filter)
{
lock (this._lockObj)
{
if (_filters.Contains(filter)) return false;
filter.PropertyChanged += this.OnFilterModified;
_filters.Add(filter);
this.FilterModified = true;
return true;
}
}
示例13: AddFilter_Test
public void AddFilter_Test()
{
var tab = new TabClass();
var filter = new PostFilterRule();
tab.AddFilter(filter);
Assert.Equal(new[] { filter }, tab.FilterArray);
Assert.True(tab.FilterModified);
}
示例14: SetProperty_SameValueTest
public void SetProperty_SameValueTest()
{
var filter = new PostFilterRule();
filter.FilterName = "hogehoge";
filter.Compile();
string changedPropeyty = null;
// 値に変化がないので PropertyChanged イベントは発生しない
filter.PropertyChanged += (_, x) => changedPropeyty = x.PropertyName;
filter.FilterName = "hogehoge";
Assert.Null(changedPropeyty);
Assert.False(filter.IsDirty);
}
示例15: ExFilterBody_ByUrlRegexTest
public void ExFilterBody_ByUrlRegexTest()
{
var filter = new PostFilterRule();
PostClass post;
// ExFilterByUrl = true の場合は TextFromApi ではなく Text がマッチ対象になる
filter.ExFilterByUrl = true;
filter.ExUseRegex = true;
filter.ExFilterBody = new[] { "a{3}", "b{3}" };
post = new PostClass { Text = "<a href='http://example.com/123'>t.co/hoge</a>" };
Assert.Equal(MyCommon.HITRESULT.None, filter.ExecFilter(post));
// 片方だけではマッチしない
post = new PostClass { Text = "<a href='http://example.com/aaa'>t.co/hoge</a>" };
Assert.Equal(MyCommon.HITRESULT.None, filter.ExecFilter(post));
// ExFilterBody の文字列が全て含まれている
post = new PostClass { Text = "<a href='http://example.com/aaabbb'>t.co/hoge</a>" };
Assert.Equal(MyCommon.HITRESULT.Exclude, filter.ExecFilter(post));
// ScreenName にはマッチしない (ExUseNameField = true の場合)
post = new PostClass { ScreenName = "aaabbb", Text = "<a href='http://example.com/123'>t.co/hoge</a>" };
Assert.Equal(MyCommon.HITRESULT.None, filter.ExecFilter(post));
// 大小文字を区別する
filter.ExCaseSensitive = true;
post = new PostClass { Text = "<a href='http://example.com/AaaBbb'>t.co/hoge</a>" };
Assert.Equal(MyCommon.HITRESULT.None, filter.ExecFilter(post));
// 大小文字を区別しない
filter.ExCaseSensitive = false;
post = new PostClass { Text = "<a href='http://example.com/AaaBbb'>t.co/hoge</a>" };
Assert.Equal(MyCommon.HITRESULT.Exclude, filter.ExecFilter(post));
}