Beispiel #1
0
 public static void vehicleMoved(Vehicle veh, Rectangle prev)
 {
     DynamicObjectMoveCallback(veh, prev);
     keepInView();
 }
Beispiel #2
0
 public static void deleteVehicle(Vehicle veh)
 {
     DynamicObjectDeleteCallback(veh);
     m_vehicles.Remove(veh);
     veh.cleanup();
 }
Beispiel #3
0
 public bool sameAs(Vehicle other)
 {
     return Location.Equals(other.Location);
 }
Beispiel #4
0
 public static void addVehicle(Vehicle veh)
 {
     m_vehicles.Add(veh);
     DynamicObjectCreateCallback(veh);		// takes care of displaying it on LayerVehicle
 }
Beispiel #5
0
        /// <summary>
        /// build context menu on the right mouse click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void mainPictureBox_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            try
            {
                btnDown = e.Button;
                Project.ClearPopup();
                rightClickWaypoint = null;
                rightClickEarthquake = null;

                LibSys.StatusBar.Trace("mainPictureBox_MouseDown: ctrl=" + controlDown + "  shift=" + shiftDown + "  alt=" + altDown);

                m_pictureManager.pictureMouseDown(e, controlDown, shiftDown, altDown);
                m_cameraManager.pictureMouseDown(e, controlDown, shiftDown, altDown);

                bool backClick = (e.Button == MouseButtons.XButton1);
                if(backClick)
                {
                    doBack();
                }
                bool forwardClick = (e.Button == MouseButtons.XButton2);
                if(forwardClick)
                {
                    doForward();
                }
                rightClick = (e.Button == MouseButtons.Right);
                if(rightClick)
                {
                    rightClickPoint = new Point(e.X, e.Y);
                    if(m_cameraManager.pointInsideDragRectangle(rightClickPoint))
                    {
                        // process right-clicking into drag rectangle here
                        // Clear all previously added MenuItems.
                        mainPictureBox_ContextMenu.MenuItems.Clear();

                        int index = 0;
                        MenuItem menuItem = null;

                        menuItem = new MenuItem("Zoom in");
                        menuItem.Index = index++;
                        menuItem.Click += new System.EventHandler(cm_zoomToDragRectangleMenuItem_Click);
                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                        menuItem = new MenuItem("Preload Tiles");
                        menuItem.Index = index++;
                        menuItem.Click += new System.EventHandler(cm_preloadMenuItem_Click);
                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                        menuItem = new MenuItem("GoogleEarth - show selected area");
                        menuItem.Index = index++;
                        menuItem.Click += new System.EventHandler(cm_areaGoogleEarthMenuItem_Click);
                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                        menuItem = new MenuItem("-");
                        menuItem.Index = index++;
                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                        menuItem = new MenuItem("Help");
                        menuItem.Index = index++;
                        menuItem.Click += new System.EventHandler(cm_helpMenuItem_Click);
                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);
                    }
                    else
                    {
                        // generic right-click, or right-click outside the drag rectangle
                        m_cameraManager.resetDrag(true);

                        // Clear all previously added MenuItems.
                        mainPictureBox_ContextMenu.MenuItems.Clear();

                        int index = 0;
                        MenuItem menuItem = null;
                        bool putGeTrackItem = false;
                        bool putGeWptItem = false;

                        LiveObject lo = m_pictureManager.evalPictureClick(e, controlDown, shiftDown, altDown);

                        if(LayerWaypoints.This.makeRouteMode)
                        {
                            if(lo != null)
                            {
                                if(lo.GetType().Equals(Waypoint.getType()))
                                {
                                    rightClickWaypoint = (Waypoint)lo;

                                    if(rightClickWaypoint.TrackId == -1)
                                    {
                                        menuItem = new MenuItem("Add waypoint to route");
                                        menuItem.Index = index++;
                                        menuItem.Click += new System.EventHandler(cm_addWptToRouteMenuItem_Click);
                                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);
                                    }

                                    if(rightClickWaypoint.TrackId == LayerWaypoints.This.routeBeingBuilt.Id)
                                    {
                                        menuItem = new MenuItem("Edit routepoint");
                                        menuItem.Index = index++;
                                        menuItem.Click += new System.EventHandler(cm_editMenuItem_Click);
                                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                                        menuItem = new MenuItem("Move routepoint");
                                        menuItem.Index = index++;
                                        menuItem.Click += new System.EventHandler(cm_moveMenuItem_Click);
                                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                                        menuItem = new MenuItem("Remove waypoint from the route");
                                        menuItem.Index = index++;
                                        menuItem.Click += new System.EventHandler(cm_removeWptFromRouteMenuItem_Click);
                                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);
                                    }
                                }
                                else if(lo.GetType().Equals(Earthquake.getType()))
                                {
                                    rightClickEarthquake = (Earthquake)lo;

                                    menuItem = new MenuItem("Add earthquake to route");
                                    menuItem.Index = index++;
                                    menuItem.Click += new System.EventHandler(cm_addEqToRouteMenuItem_Click);
                                    mainPictureBox_ContextMenu.MenuItems.Add(menuItem);
                                }
                            }
                            menuItem = new MenuItem("End making route [Esc]");
                            menuItem.Index = index++;
                            menuItem.Click += new System.EventHandler(cm_endrouteMenuItem_Click);
                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);
                        }
                        else
                        {
                            if(lo != null)
                            {
                                if(lo.GetType().Equals(Waypoint.getType()))
                                {
                                    rightClickWaypoint = (Waypoint)lo;
                                    if(!Project.allowMapPopups)
                                    {
                                        menuItem = new MenuItem("Detail (in popup)");
                                        menuItem.Index = index++;
                                        menuItem.Click += new System.EventHandler(cm_detailMenuItem_Click);
                                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);
                                    }
                                    if((cm_trackId=rightClickWaypoint.TrackId) != -1)
                                    {
                                        Track trk = WaypointsCache.getTrackById(cm_trackId);
                                        if(trk != null)
                                        {
                                            menuItem = new MenuItem("Track Detail [" + cm_trackId + ": " + trk.Name + "]");
                                            menuItem.Index = index++;
                                            menuItem.Click += new System.EventHandler(cm_trackMenuItem_Click);
                                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                                            menuItem = new MenuItem("View Whole Trip");
                                            menuItem.Index = index++;
                                            menuItem.Click += new System.EventHandler(cm_trackZoomMenuItem_Click);
                                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                                            menuItem = new MenuItem("Hide Track");
                                            menuItem.Index = index++;
                                            menuItem.Click += new System.EventHandler(cm_trackHideMenuItem_Click);
                                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                                            menuItem = new MenuItem("Break into Trips");
                                            menuItem.Index = index++;
                                            menuItem.Click += new System.EventHandler(cm_trackUngroupMenuItem_Click);
                                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                                            menuItem = new MenuItem("Break Here");
                                            menuItem.Index = index++;
                                            menuItem.Click += new System.EventHandler(cm_trackUngroupHereMenuItem_Click);
                                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                                            menuItem = new MenuItem("Preload Tiles Along the Route");
                                            menuItem.Index = index++;
                                            menuItem.Click += new System.EventHandler(cm_preloadAlongRouteMenuItem_Click);
                                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                                            menuItem = new MenuItem("Save Track As...");
                                            menuItem.Index = index++;
                                            menuItem.Click += new System.EventHandler(cm_trackSaveAsMenuItem_Click);
                                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                                            putGeTrackItem = true;
                                        }
                                    }
                                    else
                                    {
                                        putGeWptItem = true;
                                    }

                                    if(rightClickWaypoint.Url != null && rightClickWaypoint.Url.StartsWith("http://") && Project.serverAvailable)
                                    {
                                        menuItem = new MenuItem("Detail (in browser)");
                                        menuItem.Index = index++;
                                        menuItem.Click += new System.EventHandler(cm_browseMenuItem_Click);
                                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);
                                    }

                                    if(rightClickWaypoint.ThumbImage == null)
                                    {
                                        menuItem = new MenuItem(cm_trackId < 0 ? "Edit waypoint" : "Edit trackpoint");
                                        menuItem.Index = index++;
                                        menuItem.Click += new System.EventHandler(cm_editMenuItem_Click);
                                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                                        menuItem = new MenuItem(cm_trackId < 0 ? "Move waypoint" : "Move trackpoint");
                                        menuItem.Index = index++;
                                        menuItem.Click += new System.EventHandler(cm_moveMenuItem_Click);
                                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                                        menuItem = new MenuItem(cm_trackId < 0 ? "Delete waypoint" : "Delete trackpoint");
                                        menuItem.Index = index++;
                                        menuItem.Click += new System.EventHandler(cm_deleteMenuItem_Click);
                                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);
                                    }
                                    else
                                    {
                                        menuItem = new MenuItem("View photo");
                                        menuItem.Index = index++;
                                        menuItem.Click += new System.EventHandler(cm_viewPhotoMenuItem_Click);
                                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                                        menuItem = new MenuItem("Edit/Draw over photo");
                                        menuItem.Index = index++;
                                        menuItem.Click += new System.EventHandler(cm_viewPhotoDrawMenuItem_Click);
                                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);
                                    }

                                    if(putGeTrackItem)
                                    {
                                        menuItem = new MenuItem("GoogleEarth - show trip");
                                        menuItem.Index = index++;
                                        menuItem.Click += new System.EventHandler(cm_trackGoogleEarthMenuItem_Click);
                                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);
                                    }
                                    else if(putGeWptItem)
                                    {
                                        menuItem = new MenuItem("GoogleEarth - show waypoint");
                                        menuItem.Index = index++;
                                        menuItem.Click += new System.EventHandler(cm_wptGoogleEarthMenuItem_Click);
                                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);
                                    }

                                    menuItem = new MenuItem("-");
                                    menuItem.Index = index++;
                                    mainPictureBox_ContextMenu.MenuItems.Add(menuItem);
                                }
                                else if(lo.GetType().Equals(Vehicle.getType()) || lo.GetType().Equals(VehicleGps.getType()))
                                {
                                    rightClickVehicle = (Vehicle)lo;
                                    if(!Project.allowMapPopups)
                                    {
                                        menuItem = new MenuItem("Detail (in popup)");
                                        menuItem.Index = index++;
                                        menuItem.Click += new System.EventHandler(cm_detailMenuItem_Click);
                                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);
                                    }
                                    if(rightClickVehicle.Url != null && rightClickVehicle.Url.StartsWith("http:") && Project.serverAvailable)
                                    {
                                        menuItem = new MenuItem("Detail (in browser)");
                                        menuItem.Index = index++;
                                        menuItem.Click += new System.EventHandler(cm_browseMenuItem_Click);
                                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);
                                    }

                                    menuItem = new MenuItem("Delete vehicle");
                                    menuItem.Index = index++;
                                    menuItem.Click += new System.EventHandler(cm_deleteVehicleMenuItem_Click);
                                    mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                                    menuItem = new MenuItem("-");
                                    menuItem.Index = index++;
                                    mainPictureBox_ContextMenu.MenuItems.Add(menuItem);
                                }
                                else if(lo.GetType().Equals(Earthquake.getType()))
                                {
                                    rightClickEarthquake = (Earthquake)lo;
                                    if(!Project.allowMapPopups)
                                    {
                                        menuItem = new MenuItem("Detail (in popup)");
                                        menuItem.Index = index++;
                                        menuItem.Click += new System.EventHandler(cm_detailMenuItem_Click);
                                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);
                                    }
                                    if(rightClickEarthquake.Url != null && rightClickEarthquake.Url.StartsWith("http:") && Project.serverAvailable)
                                    {
                                        menuItem = new MenuItem("Detail (in browser)");
                                        menuItem.Index = index++;
                                        menuItem.Click += new System.EventHandler(cm_browseMenuItem_Click);
                                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);
                                    }

                                    menuItem = new MenuItem("GoogleEarth - show earthquake");
                                    menuItem.Index = index++;
                                    menuItem.Click += new System.EventHandler(cm_eqGoogleEarthMenuItem_Click);
                                    mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                                    menuItem = new MenuItem("-");
                                    menuItem.Index = index++;
                                    mainPictureBox_ContextMenu.MenuItems.Add(menuItem);
                                }
                            }

                            menuItem = new MenuItem((Project.allowMapPopups ? "Disable" : "Enable") + " Popups");
                            menuItem.Index = index++;
                            menuItem.Click += new System.EventHandler(cm_popupsMenuItem_Click);
                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                            menuItem = new MenuItem("New Waypoint");
                            menuItem.Index = index++;
                            menuItem.Click += new System.EventHandler(cm_newWaypointMenuItem_Click);
                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                            menuItem = new MenuItem("New Route");
                            menuItem.Index = index++;
                            menuItem.Click += new System.EventHandler(cm_newRouteMenuItem_Click);
                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                            menuItem = new MenuItem("Waypoints Manager");
                            menuItem.Index = index++;
                            menuItem.Click += new System.EventHandler(this.trackManagerMenuItem_Click);
                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                            if(lo == null)
                            {
                                menuItem = new MenuItem("GoogleEarth - this point on map");
                                menuItem.Index = index++;
                                menuItem.Click += new System.EventHandler(cm_pointGoogleEarthMenuItem_Click);
                                mainPictureBox_ContextMenu.MenuItems.Add(menuItem);
                            }

                            menuItem = new MenuItem("-");
                            menuItem.Index = index++;
                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                            menuItem = new MenuItem("Center here (same as double click)");
                            menuItem.Index = index++;
                            menuItem.Click += new System.EventHandler(cm_centerMenuItem_Click);
                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                            menuItem = new MenuItem("Zoom In (same as +)");
                            menuItem.Index = index++;
                            menuItem.Click += new System.EventHandler(cm_zoomInMenuItem_Click);
                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                            menuItem = new MenuItem("Zoom Out (same as - or Shift/Click)");
                            menuItem.Index = index++;
                            menuItem.Click += new System.EventHandler(cm_zoomOutMenuItem_Click);
                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                            menuItem = new MenuItem((Project.trackElevColor ? "Disable tracks elevation color" : "Color code tracks elevation"));
                            menuItem.Index = index++;
                            menuItem.Click += new System.EventHandler(cm_colorCodeMenuItem_Click);
                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                            menuItem = new MenuItem((Project.trackSpeedColor ? "Disable tracks speed color" : "Color code tracks by speed"));
                            menuItem.Index = index++;
                            menuItem.Click += new System.EventHandler(cm_colorSpeedMenuItem_Click);
                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                            menuItemWptNaming.Index = index++;
                            menuItemWptNaming.MenuItems.Clear();
                            for (int i=0; i < Project.waypointNameStyleChoices.Length ;i++)
                            {
                                menuItem = new MenuItem(Project.waypointNameStyleChoices[i]);
                                menuItem.Checked = Project.waypointNameStyle == i;
                                menuItem.Click += new System.EventHandler(cm_wptNamingStyleMenuItem_Click);
                                menuItemWptNaming.MenuItems.Add(menuItem);
                            }
                            mainPictureBox_ContextMenu.MenuItems.Add(menuItemWptNaming);

                            menuItem = new MenuItem("-");
                            menuItem.Index = index++;
                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                            menuItemTools.Index = index++;
                            menuItemTools.MenuItems.Clear();
                            for (int i=0; i < Project.tools.tools.Count ;i++)
                            {
                                ToolDescr td = (ToolDescr)Project.tools.tools[i];
                                menuItem = new MenuItem(td.ToString().Replace("&", "&&"));
                                menuItem.Click += new System.EventHandler(cm_toolMenuItem_Click);
                                menuItemTools.MenuItems.Add(menuItem);
                            }
                            mainPictureBox_ContextMenu.MenuItems.Add(menuItemTools);

                            menuItem = new MenuItem("Street Map (in browser)");
                            menuItem.Index = index++;
                            menuItem.Click += new System.EventHandler(cm_streetMapMenuItem_Click);
                            if(!Project.serverAvailable)
                            {
                                // obviously disconnected, disable Internet-related function:
                                menuItem.Enabled = false;
                            }
                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                            menuItem = new MenuItem("Nearest Geocaches (in browser)");
                            menuItem.Index = index++;
                            menuItem.Click += new System.EventHandler(cm_nearestGeocachesMenuItem_Click);
                            if(!Project.serverAvailable)
                            {
                                // obviously disconnected, disable Internet-related function:
                                menuItem.Enabled = false;
                            }
                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                            menuItem = new MenuItem("Help (F1)");
                            menuItem.Index = index++;
                            menuItem.Click += new System.EventHandler(cm_helpMenuItem_Click);
                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);
                        }
                    }
                }
            }
            catch {}
        }