private void ShowSearchDialog()
{
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 = Properties.Resources.SearchResults_TabName;
try
{
tabName = this._statuses.MakeTabName(tabName);
}
catch (TabException ex)
{
MessageBox.Show(this, ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
var resultTab = new LocalSearchTabModel(tabName);
this.AddNewTab(resultTab, startup: false);
this._statuses.AddTab(resultTab);
var targetTab = this._statuses.Tabs[this._curTab.Text];
Func<string, bool> stringComparer;
try
{
stringComparer = this.CreateSearchComparer(searchOptions.Query, searchOptions.UseRegex, searchOptions.CaseSensitive);
}
catch (ArgumentException)
{
MessageBox.Show(Properties.Resources.DoTabSearchText1, Properties.Resources.DoTabSearchText3, MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
var foundIndices = targetTab.SearchPostsAll(stringComparer).ToArray();
if (foundIndices.Length == 0)
{
MessageBox.Show(Properties.Resources.DoTabSearchText2, Properties.Resources.DoTabSearchText3, MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
var foundPosts = foundIndices.Select(x => targetTab[x]);
foreach (var post in foundPosts)
{
resultTab.AddPostQueue(post);
}
this._statuses.DistributePosts();
this.RefreshTimeline();
var tabPage = this.ListTab.TabPages.Cast<TabPage>()
.First(x => x.Text == tabName);
this.ListTab.SelectedTab = tabPage;
}
else
{
this.DoTabSearch(
searchOptions.Query,
searchOptions.CaseSensitive,
searchOptions.UseRegex,
SEARCHTYPE.DialogSearch);
}
}
else if (searchOptions.Type == SearchWordDialog.SearchType.Public)
{
this.AddNewTabForSearch(searchOptions.Query);
}
}