Пример #1
0
        private void CreateMapObject()
        {
            switch (comboBox.SelectedIndex)
            {
            case 0:
                Area area = new Area(textNameAdd.Text.ToString(), activePoints);
                mapObjects.Add(area);
                Map.Markers.Add(area.GetMarker());
                activePoints.Clear();
                break;

            case 1:
                Car car = new Car(textNameAdd.Text.ToString(), activePoints.Last());
                mapObjects.Add(car);
                Map.Markers.Add(car.GetMarker());
                activePoints.Clear();
                break;

            case 2:
                Classes.Route route = new Classes.Route(textNameAdd.Text.ToString(), activePoints);
                mapObjects.Add(route);
                Map.Markers.Add(route.GetMarker());
                activePoints.Clear();
                break;

            case 3:
                Human human = new Human(textNameAdd.Text.ToString(), activePoints.Last());
                mapObjects.Add(human);
                Map.Markers.Add(human.GetMarker());
                activePoints.Clear();
                break;

            case 4:
                Classes.Location location = new Classes.Location(textNameAdd.Text.ToString(), activePoints.Last());
                mapObjects.Add(location);
                Map.Markers.Add(location.GetMarker());
                activePoints.Clear();
                break;
            }
        }
Пример #2
0
        private void Map_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            PointLatLng point = Map.FromLocalToLatLng((int)e.GetPosition(Map).X, (int)e.GetPosition(Map).Y);

            mapObjects.Sort((obj1, obj2) => obj1.GetDistance(point).CompareTo(obj2.GetDistance(point)));

            if (buttonSearchMode.IsChecked == true && mapObjects.Count != 0)
            {
                if (IsHumanSet == false)
                {
                    foreach (MapObject h in mapObjects)
                    {
                        if (h is Human)
                        {
                            curHuman        = h as Human;
                            IsHumanSet      = true;
                            fromLb.Content += curHuman.GetTitle();
                            break;
                        }
                    }
                }
                else if (IsHumanSet == true)
                {
                    foreach (MapObject l in mapObjects)
                    {
                        if (l is Classes.Location)
                        {
                            curLocation = l as Classes.Location;
                            curHuman.SetDestination(curLocation.GetFocus());
                            toLb.Content += curLocation.GetTitle();
                            break;
                        }
                    }
                }
            }
        }
Пример #3
0
        private void CreateMapObject()
        {
            switch (comboBox.SelectedIndex)
            {
            case 0:
                if (activePoints.Count >= 3)
                {
                    Area area = new Area(textNameAdd.Text.ToString(), activePoints);
                    mapObjects.Add(area);
                    Map.Markers.Add(area.GetMarker());
                    activePoints.Clear();
                }
                else if (activePoints.Count < 3)
                {
                    MessageBox.Show("Count of active points must be bigger two");
                }
                activePoints.Clear();
                break;

            case 1:
                if (activePoints.Count > 0)
                {
                    Car car = new Car(textNameAdd.Text.ToString(), activePoints.Last());
                    mapObjects.Add(car);
                    Map.Markers.Add(car.GetMarker());
                    activePoints.Clear();
                }
                else if (activePoints.Count < 1)
                {
                    MessageBox.Show("Count of active points must be bigger zero");
                    activePoints.Clear();
                }
                break;

            case 2:
                if (activePoints.Count >= 2)
                {
                    Classes.Route route = new Classes.Route(textNameAdd.Text.ToString(), activePoints);
                    mapObjects.Add(route);
                    Map.Markers.Add(route.GetMarker());
                    activePoints.Clear();
                }
                else if (activePoints.Count < 2)
                {
                    MessageBox.Show("Count of active points must be bigger one");
                }
                activePoints.Clear();
                break;

            case 3:
                if (activePoints.Count > 0)
                {
                    Human human = new Human(textNameAdd.Text.ToString(), activePoints.Last());
                    mapObjects.Add(human);
                    Map.Markers.Add(human.GetMarker());
                    activePoints.Clear();
                }
                else if (activePoints.Count != 1)
                {
                    MessageBox.Show("Count of active points must be bigger zero");
                    activePoints.Clear();
                }
                break;

            case 4:
                if (activePoints.Count > 0)
                {
                    Classes.Location location = new Classes.Location(textNameAdd.Text.ToString(), activePoints.Last());
                    mapObjects.Add(location);
                    Map.Markers.Add(location.GetMarker());
                    activePoints.Clear();
                }
                else if (activePoints.Count != 1)
                {
                    MessageBox.Show("Count of active points must be bigger zero");
                    activePoints.Clear();
                }
                break;
            }
        }