示例#1
0
        private void MainForm_Load(object sender, System.EventArgs e)
        {
            LibSys.StatusBar.WriteLine("On Load");

            this.hintsLabel.Text = "Mouse tips:\n\n"
                                    + "    double click - to recenter\n"
                                    + "    drag and click inside - to zoom\n"
                                    + "    right click on map for more options\n"
                                    + "    press F1 for Help\n"
                                    + "    check out Help->Sample Files menu\n";

            #if !DEBUG
            //gridCheckBox.Visible = false;
            vehCheckBox.Visible = false;
            #endif
            Project.favoritesFirstIndex = this.favMainMenuItem.MenuItems.Count;
            Project.recentFilesFirstIndex = this.fileMainMmenuItem.MenuItems.Count;
            Project.toolsFirstIndex = this.toolsMainMenuItem.MenuItems.Count;

            backLinkLabel.Enabled = false;
            forwardLinkLabel.Enabled = false;

            ProgressMonitor.Indicator = progressButton;
            progressButton.Text = "";

            this.Text = Project.PROGRAM_NAME_HUMAN;

            //this.hintsPanel.BackColor = System.Drawing.Color.FromArgb(255, Color.Navy);

            if(m_firstTime)
            {
                this.notAssociatedButton.Visible = true;
                this.notAssociatedLabel.Visible = true;
            }
            else
            {
                // first time the greeting does not start, so HideGreeting will not set hintsPanel to visible
                this.hintsPanel.Visible = Project.showHelpAtStart && !hintsPanelClicked;
            }

            // good place to have camera coordinates set here, if supplied in command line:
            //        /lat=34.123 /lon=-117.234 /elev=5000 /map=aerial (topo,color)
            processArgs();

            // we need it as early as possible, before first web load - TileCache.init(Project.CGIBINPTR_URL) below - occured.
            Project.ApplyGlobalHTTPProxy(false);

            if(Project.mainFormMaximized)
            {
                this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
            }
            else if(Project.fitsScreen(Project.mainFormX, Project.mainFormY, Project.mainFormWidth, Project.mainFormHeight)
                && Project.mainFormWidth > 300 && Project.mainFormHeight > 200)
            {
                this.Location = new Point(Project.mainFormX, Project.mainFormY);
                this.ClientSize = new System.Drawing.Size(Project.mainFormWidth, Project.mainFormHeight);		// causes Resize()
                //this.Bounds = new System.Drawing.Rectangle(Project.mainFormX, Project.mainFormY, Project.mainFormWidth, Project.mainFormHeight);
            }

            reliefCheckBox.Checked = Project.drawRelief;
            overlayCheckBox.Checked = Project.terraUseOverlay;

            gridCheckBox.Enabled = Project.drawRelief || Project.drawTerraserver;
            citiesCheckBox.Enabled = Project.drawRelief;
            gridCheckBox.Checked = Project.drawGrid;
            if(Project.drawTerraserver)
            {
                if(Project.drawTerraserverMode.Equals("aerial"))
                {
                    aerialCheckBox.Checked = true;
                }
                else if(Project.drawTerraserverMode.Equals("color aerial"))
                {
                    colorAerialCheckBox.Checked = true;
                }
                else if(Project.drawTerraserverMode.Equals("topo"))
                {
                    topoCheckBox.Checked = true;
                    overlayCheckBox.Enabled = false;
                }
                lmCheckBox.Enabled = true;
            }
            else
            {
                Project.terraserverAvailable = false;
                aerialCheckBox.Checked = false;
                colorAerialCheckBox.Checked = false;
                topoCheckBox.Checked = false;
                lmCheckBox.Enabled = false;
            }
            //opacityPanel.Visible = Project.drawTerraserver;
            citiesCheckBox.Checked = Project.drawCities;
            lmCheckBox.Checked = Project.drawLandmarks;
            eqCheckBox.Checked = Project.drawEarthquakes;
            eqStylePanelVisible(Project.drawEarthquakes);
            wptCheckBox.Checked = Project.drawWaypoints;
            vehCheckBox.Checked = Project.drawVehicles;

            TileCache.init(Project.CGIBINPTR_URL);		// try to reach the QuakeMap server

            if(TileCache.ZipcodeServer == null)
            {
                setInternetAvailable(false);

                this.hintsLabel.Text = "\n[offline]\n\nuse Internet-->Offline\n   or Map-->Options-->Proxy menu\nif you think you should be connected\n ";

                string message = "\nWarning: couldn't reach server: " + Project.PROGRAM_MAIN_SERVER	+ "\n\nWorking offline.\n ";
                if(m_greetingForm == null)
                {
                    Project.ErrorBox(null, message);
                }
                else
                {
                    Point popupOffset = new Point(34, 230);
                    Point screenPoint = m_greetingForm.PointToScreen(popupOffset);
                    Project.ShowPopup (m_greetingForm, message, screenPoint);
                }
            }
            else
            {
                setInternetAvailable(true);
            }

            m_cameraTrack = new CameraTrack();
            m_cameraManager = new CameraManager(this, m_cameraTrack);

            m_pictureManager = new PictureManager(mainPictureBox, this, m_cameraTrack);

            m_cameraManager.init(m_pictureManager);
            m_pictureManager.init(m_cameraManager);

            if(Project.hasOldTerrafolderStyleFiles())
            {
                HideGreeting();
                Project.AttemptTerrafolderMigration();
            }

            findLinkLabel.Focus();

            // on the very first run, bring up "Find by zipcode" window and try positioning
            // the map there:
            if(m_firstTime && TileCache.ZipcodeServer != null)
            {
                Project.findKeyword = Project.zipcode;
                FindForm findForm = new FindForm(m_cameraManager, true);
                findForm.ShowDialog();
            }

            LibSys.StatusBar.WriteLine("IP: running init thread");
            //add dt worker method to the thread pool / queue a task
            //Project.threadPool.PostRequest (new WorkRequestDelegate (runInit), "MainForm init");
            //ThreadPool2.QueueUserWorkItem(new WaitCallback (runInit), "MainForm init");
            runInit("MainForm init");

            //ThreadPool2.QueueUserWorkItem(new WaitCallback (timeEater), "MainForm timeEater");

            periodicMaintenanceTimer = new System.Windows.Forms.Timer();
            periodicMaintenanceTimer.Interval = 1200;
            periodicMaintenanceTimer.Tick += new EventHandler(periodicMaintenance);
            periodicMaintenanceTimer.Start();
            LibSys.StatusBar.WriteLine("OK: Maintenance ON");

            if(!Project.showHelpAtStart)
            {
                if(!hasShownUpdateForm && Project.upgradeMessage.Length > 0)
                {
                    hasShownUpdateForm = true;
                    new DlgUpgradeMessage(Project.upgradeMessage).ShowDialog();
                }
            }

            inResize = false;

            LibSys.StatusBar.WriteLine("On Load done");
        }
示例#2
0
 private void findLinkLabel_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
 {
     if(TileCache.ZipcodeServer != null)
     {
         FindForm findForm = new FindForm(m_cameraManager, false);
         findForm.ShowDialog();
     }
     else
     {
         Point screenPoint = findLinkLabel.PointToScreen(popupOffset);
         Project.ShowPopup(null, "Cannot use Find - need Internet connection", screenPoint);
         findLinkLabel.Enabled = false;
     }
 }