fix progressbar

This commit is contained in:
stubbfel
2013-09-10 12:23:01 +02:00
parent 2aa1c17e02
commit b6bdac3211

View File

@@ -58,7 +58,7 @@ namespace CampusAppWP8.Pages.PlaceNews
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
this.ProgressBar.Visibility = System.Windows.Visibility.Visible;
if (NavigationMode.Back == e.NavigationMode && this.places == null)
{
this.places = new PlacesFile();
@@ -67,6 +67,7 @@ namespace CampusAppWP8.Pages.PlaceNews
}
else
{
this.ProgressBar.Visibility = System.Windows.Visibility.Visible;
Thread thread = new Thread(delegate()
{
this.InitializeApi();
@@ -132,6 +133,18 @@ namespace CampusAppWP8.Pages.PlaceNews
this.pssApi.OnLoaded += new PssApi.OnIO(this.PssApiIsReady);
this.pssApi.OnFailedLoad += new PssApi.OnFailed(this.ApiIsFail);
}
if (this.waitForApi < 1)
{
if (this.Dispatcher != null)
{
this.Dispatcher.BeginInvoke(new Action(() => this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed));
}
else
{
this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed;
}
}
}
/// <summary>Places file is fail.</summary>
@@ -162,19 +175,7 @@ namespace CampusAppWP8.Pages.PlaceNews
private void PssApiIsReady()
{
this.waitForApi--;
this.places.Model.AddPlaces(this.pssApi.Model.Places.ToList());
if (this.waitForApi < 1)
{
if (this.Dispatcher != null)
{
this.Dispatcher.BeginInvoke(new Action(() => this.SetupResultBox()));
}
else
{
this.SetupResultBox();
}
}
this.places.Model.AddPlaces(this.pssApi.Model.Places.ToList());
}
/// <summary>Pis API is ready.</summary>
@@ -184,17 +185,7 @@ namespace CampusAppWP8.Pages.PlaceNews
this.waitForApi--;
this.places.Model.AddPlaces(this.pisApi.Model.Places.ToList());
if (this.waitForApi < 1)
{
if (this.Dispatcher != null)
{
this.Dispatcher.BeginInvoke(new Action(() => this.SetupResultBox()));
}
else
{
this.SetupResultBox();
};
}
this.CheckedSetupResultBox();
}
/// <summary>API is fail.</summary>
@@ -234,17 +225,7 @@ namespace CampusAppWP8.Pages.PlaceNews
this.waitForApi++;
}
if (this.waitForApi < 1)
{
if (this.Dispatcher != null)
{
this.Dispatcher.BeginInvoke(new Action(() => this.SetupResultBox()));
}
else
{
this.SetupResultBox();
}
}
this.CheckedSetupResultBox();
}
/// <summary>Sets up the result box.</summary>
@@ -293,5 +274,21 @@ namespace CampusAppWP8.Pages.PlaceNews
private void ApplicationBarMenuItem_Click_1(object sender, EventArgs e)
{
}
/// <summary>Checked setup result box.</summary>
/// <remarks>Stubbfel, 10.09.2013.</remarks>
private void CheckedSetupResultBox() {
if (this.waitForApi < 1)
{
if (this.Dispatcher != null)
{
this.Dispatcher.BeginInvoke(new Action(() => this.SetupResultBox()));
}
else
{
this.SetupResultBox();
}
}
}
}
}