コード例 #1
0
ファイル: LoadingThread.cs プロジェクト: CPutz/MyMap
 public LoadingThread(string path)
 {
     t = new Thread(new ThreadStart(() => {
         g = new Graph(path);
         Console.WriteLine("Setup done");
         t = null;
     }));
     t.Start();
 }
コード例 #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();
            }
        }
コード例 #3
0
ファイル: RouteFinder.cs プロジェクト: CPutz/MyMap
 public RouteFinder(Graph graph)
 {
     //save the graph
     this.graph = graph;
 }
コード例 #4
0
ファイル: Renderer.cs プロジェクト: CPutz/MyMap
 // Render takes graph to get it's data.
 public Renderer(Graph graph)
 {
     this.graph = graph;
 }