Beispiel #1
0
        /// <summary>
        /// Returns a MapIcon of IconType type if it exists.
        /// If there are more than 1 MapIcons of that type, the first encountered will be returned.
        /// </summary>
        private MapIcon GetMapIcon(IconType type)
        {
            MapIcon res = null;

            foreach (MapIcon icon in icons)
            {
                if (icon.Type == type)
                {
                    res = icon;
                }
            }

            return(res);
        }
Beispiel #2
0
        /// <summary>
        /// Adds a mapIcon to the map at the node 'location'.
        /// </summary>
        public void SetMapIcon(IconType type, Node location, MapDragButton button)
        {
            MapIcon newIcon;

            switch (type)
            {
            case IconType.Start:
                if (!isCalculatingRoute)
                {
                    MapIcon start = GetMapIcon(IconType.Start);
                    if (start != null)
                    {
                        icons.Remove(start);
                    }
                    newIcon          = new MapIcon(IconType.Start, this, button);
                    newIcon.Location = location;
                    icons.Add(newIcon);
                    CalcRoute();
                    MapIconPlaced(this, new MapDragEventArgs(button));
                }
                break;

            case IconType.End:
                if (!isCalculatingRoute)
                {
                    MapIcon end = GetMapIcon(IconType.End);
                    if (end != null)
                    {
                        icons.Remove(end);
                    }
                    newIcon          = new MapIcon(IconType.End, this, button);
                    newIcon.Location = location;
                    icons.Add(newIcon);
                    CalcRoute();
                    MapIconPlaced(this, new MapDragEventArgs(button));
                }
                break;

            case IconType.Via:
                newIcon          = new MapIcon(IconType.Via, this, button);
                newIcon.Location = location;
                icons.Add(newIcon);
                CalcRoute();
                MapIconPlaced(this, new MapDragEventArgs(button));
                break;
            }
        }
Beispiel #3
0
        private void OnMouseDown(object o, MouseEventArgs mea)
        {
            mouseDown = true;
            mousePos  = mea.Location;

            if (mea.Button == MouseButtons.Left && !isCalculatingRoute)
            {
                foreach (MapIcon icon in icons)
                {
                    if (icon.IntersectWith(mea.Location))
                    {
                        dragIcon       = icon;
                        isDraggingIcon = true;
                    }
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// Adds a myVehicle of type v to the map.
        /// </summary>
        public void AddVehicle(MyVehicle v)
        {
            myVehicles.Add(v);
            MapIcon newIcon;

            switch (v.VehicleType)
            {
            case Vehicle.Car:
                newIcon          = new MapIcon(IconType.Car, this, null, v);
                newIcon.Location = v.Location;
                icons.Add(newIcon);
                CalcRoute();
                break;

            case Vehicle.Bicycle:
                newIcon          = new MapIcon(IconType.Bike, this, null, v);
                newIcon.Location = v.Location;
                icons.Add(newIcon);
                CalcRoute();
                break;
            }
        }
Beispiel #5
0
        private void OnMouseDown(object o, MouseEventArgs mea)
        {
            mouseDown = true;
            mousePos = mea.Location;

            if (mea.Button == MouseButtons.Left && !isCalculatingRoute)
            {
                foreach (MapIcon icon in icons)
                {
                    if (icon.IntersectWith(mea.Location))
                    {
                        dragIcon = icon;
                        isDraggingIcon = true;
                    }
                }
            }
        }
Beispiel #6
0
        /// <summary>
        /// Adds a mapIcon to the map at the node 'location'.
        /// </summary>
        public void SetMapIcon(IconType type, Node location, MapDragButton button)
        {
            MapIcon newIcon;

            switch (type)
            {
                case IconType.Start:
                    if (!isCalculatingRoute)
                    {
                        MapIcon start = GetMapIcon(IconType.Start);
                        if (start != null)
                            icons.Remove(start);
                        newIcon = new MapIcon(IconType.Start, this, button);
                        newIcon.Location = location;
                        icons.Add(newIcon);
                        CalcRoute();
                        MapIconPlaced(this, new MapDragEventArgs(button));
                    }
                    break;
                case IconType.End:
                    if (!isCalculatingRoute)
                    {
                        MapIcon end = GetMapIcon(IconType.End);
                        if (end != null)
                            icons.Remove(end);
                        newIcon = new MapIcon(IconType.End, this, button);
                        newIcon.Location = location;
                        icons.Add(newIcon);
                        CalcRoute();
                        MapIconPlaced(this, new MapDragEventArgs(button));
                    }
                    break;
                case IconType.Via:
                    newIcon = new MapIcon(IconType.Via, this, button);
                    newIcon.Location = location;
                    icons.Add(newIcon);
                    CalcRoute();
                    MapIconPlaced(this, new MapDragEventArgs(button));
                    break;
            }
        }
Beispiel #7
0
 /// <summary>
 /// Adds a myVehicle of type v to the map.
 /// </summary>
 public void AddVehicle(MyVehicle v)
 {
     myVehicles.Add(v);
     MapIcon newIcon;
     switch (v.VehicleType)
     {
         case Vehicle.Car:
             newIcon = new MapIcon(IconType.Car, this, null, v);
             newIcon.Location = v.Location;
             icons.Add(newIcon);
             CalcRoute();
             break;
         case Vehicle.Bicycle:
             newIcon = new MapIcon(IconType.Bike, this, null, v);
             newIcon.Location = v.Location;
             icons.Add(newIcon);
             CalcRoute();
             break;
     }
 }