OpenBve.formMain.routeWorkerThread_completed C# (CSharp) Méthode

routeWorkerThread_completed() private méthode

private routeWorkerThread_completed ( object sender, RunWorkerCompletedEventArgs e ) : void
sender object
e RunWorkerCompletedEventArgs
Résultat void
		private void routeWorkerThread_completed(object sender, RunWorkerCompletedEventArgs e)
		{
			if (e.Error != null)
			{
				TryLoadImage(pictureboxRouteImage, "route_error.png");
				textboxRouteDescription.Text = e.Error.Message;
				textboxRouteEncodingPreview.Text = "";
				pictureboxRouteMap.Image = null;
				pictureboxRouteGradient.Image = null;
				Result.ErrorFile = Result.RouteFile;
				Result.RouteFile = null;
				checkboxTrainDefault.Text = Interface.GetInterfaceString("start_train_usedefault");
				return;
			}
			try
			{
				pictureboxRouteMap.Image = Illustrations.CreateRouteMap(pictureboxRouteMap.Width, pictureboxRouteMap.Height, false);
				pictureboxRouteGradient.Image = Illustrations.CreateRouteGradientProfile(pictureboxRouteGradient.Width,
					pictureboxRouteGradient.Height, false);
				// image
				if (Game.RouteImage.Length != 0)
				{
					try
					{
						pictureboxRouteImage.Image = Image.FromFile(Game.RouteImage);
					}
					catch
					{
						TryLoadImage(pictureboxRouteImage, "route_error.png");
					}
				}
				else
				{
					string[] f = new string[] {".png", ".bmp", ".gif", ".tiff", ".tif", ".jpeg", ".jpg"};
					int i;
					for (i = 0; i < f.Length; i++)
					{
						string g = OpenBveApi.Path.CombineFile(System.IO.Path.GetDirectoryName(Result.RouteFile),
							System.IO.Path.GetFileNameWithoutExtension(Result.RouteFile) + f[i]);
						if (System.IO.File.Exists(g))
						{
							try
							{
								pictureboxRouteImage.Image = Image.FromFile(g);
							}
							catch
							{
								pictureboxRouteImage.Image = null;
							}
							break;
						}
					}
					if (i == f.Length)
					{
						TryLoadImage(pictureboxRouteImage, "route_unknown.png");
					}
				}

				// description
				string Description = Interface.ConvertNewlinesToCrLf(Game.RouteComment);
				if (Description.Length != 0)
				{
					textboxRouteDescription.Text = Description;
				}
				else
				{
					textboxRouteDescription.Text = System.IO.Path.GetFileNameWithoutExtension(Result.RouteFile);
				}
				textboxRouteEncodingPreview.Text = Interface.ConvertNewlinesToCrLf(Description);
				if (Game.TrainName != null)
				{
					checkboxTrainDefault.Text = Interface.GetInterfaceString("start_train_usedefault") + @" (" + Game.TrainName + @")";
				}
				else
				{
					checkboxTrainDefault.Text = Interface.GetInterfaceString("start_train_usedefault");
				}
				Result.ErrorFile = null;
			}
			catch (Exception ex)
			{
				TryLoadImage(pictureboxRouteImage, "route_error.png");
				textboxRouteDescription.Text = ex.Message;
				textboxRouteEncodingPreview.Text = "";
				pictureboxRouteMap.Image = null;
				pictureboxRouteGradient.Image = null;
				Result.ErrorFile = Result.RouteFile;
				Result.RouteFile = null;
				checkboxTrainDefault.Text = Interface.GetInterfaceString("start_train_usedefault");
			}
			

			if (checkboxTrainDefault.Checked)
			{
				ShowDefaultTrain();
			}

			this.Cursor = Cursors.Default;
			//Deliberately select the tab when the process is complete
			//This hopefully fixes another instance of the 'grey tabs' bug
			
			tabcontrolRouteDetails.SelectedTab = tabpageRouteDescription;

			buttonStart.Enabled = Result.RouteFile != null & Result.TrainFolder != null;
		}
formMain