Skip to content

Instantly share code, notes, and snippets.

@kthompson
Created November 15, 2011 00:38
Show Gist options
  • Save kthompson/1365714 to your computer and use it in GitHub Desktop.
Save kthompson/1365714 to your computer and use it in GitHub Desktop.
public void HideProgress()
{
if (!CheckAccess())
{
Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.DataBind,
new EventHandler(delegate(object o, EventArgs e)
{
this.HideProgress();
}), this, EventArgs.Empty);
return;
}
_progressLabel.Visibility = Visibility.Hidden;
_progressLabel.Content = null;
_progressBar.Visibility = Visibility.Hidden;
_progressBar.Value = 0;
// HACK: Application.DoEvents
// RLH -- I HATE having this call here, it shouldn't need to be here, but doesn't seem to work otherwise...
System.Windows.Forms.Application.DoEvents();
}
private bool DoSearch(SearchParams searchParams)
{
bool success = false;
try
{
if (searchParams.Cameras.Count > 0)
{
ISearch search = new Search();
search.InputStreams.AddRange(searchParams.Cameras);
search.TimeEnd = searchParams.EndTime;
search.TimeStart = searchParams.StartTime;
search.ApplySourceTimeOffset = false;
_searchComplete = false;
search.SearchProgressChanged += Search_ProgressChanged;
search.SearchCompleted += Search_Completed;
_application.MainPage.ShowProgress(Properties.Resources.ModifySearch_Searching_MainInstruction, 0);
search.PerformSearchAsync();
while (!_searchComplete)
{
System.Windows.Forms.Application.DoEvents();
System.Threading.Thread.Sleep(20);
}
if (search.Cameras.Count > 0)
{
success = true;
// Finally render the output.
RenderGroup inputGroup = RenderGroupHelper.GenerateRenderGroup(search.InputStreams);
RenderGroup rg = RenderGroupHelper.GenerateSearchResultRenderGroup(search, inputGroup);
// Create a new RenderPanel output content for the new search.
RenderPanel panel = RenderPanelHelper.GenerateBasicSearchPlaybackRenderPanel(inputGroup);
RenderOutput(search, rg, panel);
// Start playing the new search, this wasn't required before
search.Play();
}
}
}
catch (Exception)
{
}
finally
{
ResetState();
}
return success;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment