CreateRouteMap() static private method

Creates and returns the route map as Bitmap.
static private CreateRouteMap ( int Width, int Height, bool inGame ) : Bitmap
Width int The width of the bitmap to create.
Height int The height of the bitmap to create.
inGame bool true = bitmap for in-game overlay | false = for standard window.
return System.Drawing.Bitmap
Ejemplo n.º 1
0
 internal static void LoadInformation()
 {
     if (Loading.Cancel)
     {
         return;
     }
     RouteMap         = Illustrations.CreateRouteMap(DefaultRouteInfoSize, DefaultRouteInfoSize, true);
     RouteMinX        = Illustrations.LastRouteMinX;
     RouteMaxX        = Illustrations.LastRouteMaxX;
     RouteMinZ        = Illustrations.LastRouteMinZ;
     RouteMaxZ        = Illustrations.LastRouteMaxZ;
     GradientProfile  = Illustrations.CreateRouteGradientProfile(DefaultRouteInfoSize, DefaultRouteInfoSize, true);
     GradientMinTrack = Illustrations.LastGradientMinTrack;
     GradientMaxTrack = Illustrations.LastGradientMaxTrack;
 }
Ejemplo n.º 2
0
        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.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");
                }
            }
            catch (Exception ex)
            {
                TryLoadImage(pictureboxRouteImage, "route_error.png");
                textboxRouteDescription.Text     = ex.Message;
                textboxRouteEncodingPreview.Text = "";
                pictureboxRouteMap.Image         = null;
                pictureboxRouteGradient.Image    = null;
                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;
        }
Ejemplo n.º 3
0
        private void routeWorkerThread_completed(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                TryLoadImage(pictureboxRouteImage, "route_error.png");
                textboxRouteDescription.Text  = e.Error.Message;
                pictureboxRouteMap.Image      = null;
                pictureboxRouteGradient.Image = null;
                Result.ErrorFile = Result.RouteFile;
                Result.RouteFile = null;
                if (routeWorkerThread != null)
                {
                    routeWorkerThread.Dispose();
                }

                this.Cursor = System.Windows.Forms.Cursors.Default;
                return;
            }
            try
            {
                lock (Illustrations.Locker)
                {
                    pictureboxRouteMap.BorderStyle      = BorderStyle.None;
                    pictureboxRouteGradient.BorderStyle = BorderStyle.None;
                    pictureboxRouteMap.Image            = Illustrations.CreateRouteMap(pictureboxRouteMap.Width, pictureboxRouteMap.Height, false);
                    pictureboxRouteGradient.Image       = Illustrations.CreateRouteGradientProfile(pictureboxRouteGradient.Width,
                                                                                                   pictureboxRouteGradient.Height, false);
                    pictureboxRouteMap.BorderStyle      = BorderStyle.FixedSingle;
                    pictureboxRouteGradient.BorderStyle = BorderStyle.FixedSingle;
                }
                // image
                if (Game.RouteImage.Length != 0)
                {
                    TryLoadImage(pictureboxRouteImage, Game.RouteImage);
                }
                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
                            {
                                using (var fs = new FileStream(g, FileMode.Open, FileAccess.Read))
                                {
                                    pictureboxRouteImage.Image = new Bitmap(fs);
                                }
                            }
                            catch
                            {
                                pictureboxRouteImage.Image = null;
                            }
                            break;
                        }
                    }
                    if (i == f.Length)
                    {
                        TryLoadImage(pictureboxRouteImage, "route_unknown.png");
                    }
                }

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

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

            //For RAGLINK Package Manager
            ReviewProject(2, string.Empty);
            RAGLINKCommons.RPlatform.PackagesManager.SetRouteDetailData(pictureboxRouteMap.Image, pictureboxRouteGradient.Image,
                                                                        System.IO.Path.GetFileNameWithoutExtension(Result.RouteFile), textboxRouteDescription.Text);
        }