示例#1
0
        /// <summary>
        /// Creates a RouteFinder and a Renderer when needed.
        /// Starts and stops the UpdateThread if needed.
        /// </summary>
        private void DoUpdate()
        {
            if (graph == null)
            {
                graph = loadingThread.Graph;

                if (graph != null)
                {
                    // Set bounds to filebounds.
                    BBox fileBounds = graph.FileBounds;

                    Point p1 = CoordToPoint(fileBounds.XMax, fileBounds.YMax);
                    Point p2 = CoordToPoint(fileBounds.XMin, fileBounds.YMin);

                    int w = Math.Abs(p1.X - p2.X);
                    int h = Math.Abs(p1.Y - p2.Y);

                    if ((float)h / w > (float)this.Height / this.Width)
                    {
                        this.bounds = new BBox(fileBounds.XMin, fileBounds.YMax, fileBounds.XMin + LonFromX(h), fileBounds.YMin);
                    }
                    else
                    {
                        this.bounds = new BBox(fileBounds.XMin, fileBounds.YMax, fileBounds.XMax,
                                               fileBounds.YMax - LatFromY(LonToX(fileBounds.YMin) + h));
                    }

                    zoomWidth.Add(bounds.Width);
                    zoomHeight.Add(bounds.Height);
                }
            }
            else
            {
                if (rf == null || render == null)
                {
                    rf     = new RouteFinder(graph);
                    render = new Renderer(graph);
                    loadingTimer.Stop();
                    logo.Stop();
                    this.Controls.Remove(logo);

                    updateThread.Start();
                }

                // If the updateThread is running and this method is called,
                // just let the thread restart when it's finished the current tile.
                if (forceUpdate && updateThread.ThreadState == ThreadState.Running)
                {
                    restartUpdateThread = true;
                    forceUpdate         = false;
                }

                // If the updateThread is stopped and this method is called,
                // then just start the thread.
                if (updateThread.ThreadState == ThreadState.Stopped)
                {
                    updateThread = new Thread(new ThreadStart(this.UpdateTiles));
                    updateThread.Start();
                }

                this.Invalidate();
            }
        }
示例#2
0
文件: MapDisplay.cs 项目: CPutz/MyMap
        /// <summary>
        /// Creates a RouteFinder and a Renderer when needed.
        /// Starts and stops the UpdateThread if needed.
        /// </summary>
        private void DoUpdate()
        {
            if (graph == null)
            {
                graph = loadingThread.Graph;

                if (graph != null)
                {
                    // Set bounds to filebounds.
                    BBox fileBounds = graph.FileBounds;

                    Point p1 = CoordToPoint(fileBounds.XMax, fileBounds.YMax);
                    Point p2 = CoordToPoint(fileBounds.XMin, fileBounds.YMin);

                    int w = Math.Abs(p1.X - p2.X);
                    int h = Math.Abs(p1.Y - p2.Y);

                    if ((float)h / w > (float)this.Height / this.Width)
                    {
                        this.bounds = new BBox(fileBounds.XMin, fileBounds.YMax, fileBounds.XMin + LonFromX(h), fileBounds.YMin);
                    }
                    else
                    {
                        this.bounds = new BBox(fileBounds.XMin, fileBounds.YMax, fileBounds.XMax,
                                               fileBounds.YMax - LatFromY(LonToX(fileBounds.YMin) + h));
                    }

                    zoomWidth.Add(bounds.Width);
                    zoomHeight.Add(bounds.Height);
                }
            }
            else
            {
                if (rf == null || render == null)
                {
                    rf = new RouteFinder(graph);
                    render = new Renderer(graph);
                    loadingTimer.Stop();
                    logo.Stop();
                    this.Controls.Remove(logo);

                    updateThread.Start();
                }

                // If the updateThread is running and this method is called,
                // just let the thread restart when it's finished the current tile.
                if (forceUpdate && updateThread.ThreadState == ThreadState.Running)
                {
                    restartUpdateThread = true;
                    forceUpdate = false;
                }

                // If the updateThread is stopped and this method is called,
                // then just start the thread.
                if (updateThread.ThreadState == ThreadState.Stopped)
                {
                    updateThread = new Thread(new ThreadStart(this.UpdateTiles));
                    updateThread.Start();
                }

                this.Invalidate();
            }
        }