Example #1
0
        private void Map_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            buttonDoubleClick = true;
            PointLatLng point = Map.FromLocalToLatLng((int)e.GetPosition(Map).X, (int)e.GetPosition(Map).Y);

            if (objType.SelectedIndex > -1 && createFlag == true)
            {
                if (objType.SelectedIndex == 0 && objTitle.Text.Length > 0)
                {
                    CCar car = new CCar(objTitle.Text, pts[0], Map);
                    objs.Add(car);
                    cars.Add(car);
                    if (human != null)
                    {
                        //car.Arrived += human.CarArrived;
                        //  human.passSeated += car.passSeated;
                        // car.ArrivedtoDestination += human.CarArrivedToDestination;
                        // human.passRise += car.passRise;
                    }
                }
                else if (objType.SelectedIndex == 0 && objTitle.Text.Length == 0)
                {
                    MessageBox.Show("Введите имя машины");
                }
                if (objType.SelectedIndex == 1 && objTitle.Text.Length > 0)
                {
                    human = new CHuman(objTitle.Text, pts[0]);
                    objs.Add(human);
                }
                else if (objType.SelectedIndex == 1 && objTitle.Text.Length == 0)
                {
                    MessageBox.Show("Введите имя человека");
                }
                if (objType.SelectedIndex == 2 && objTitle.Text.Length > 0)
                {
                    if (human != null)
                    {
                        human.moveTo(point);

                        CLocation location = new CLocation(objTitle.Text, pts[0]);
                        objs.Add(location);
                    }
                }
                else if (objType.SelectedIndex == 2 && objTitle.Text.Length == 0)
                {
                    MessageBox.Show("Введите название место прибытия");
                }
                pts.Clear();
                Map.Markers.Clear();
                objTitle.Clear();
                objectList.Items.Clear();
                foreach (CMapObject cm in objs)
                {
                    Map.Markers.Add(cm.getMarker());
                    objectList.Items.Add(cm.getTitle());
                }
                foreach (GMapMarker cm in markerTaxi)
                {
                    Map.Markers.Add(cm);
                }
            }
        }
Example #2
0
 private void button1_Click(object sender, RoutedEventArgs e)//add obj
 {
     try
     {
         if (objType.SelectedIndex > -1 && createFlag == true)
         {
             if (objType.SelectedIndex == 0 && objTitle.Text.Length > 0)
             {
                 CCar car = new CCar(objTitle.Text, pts[0], Map);
                 objs.Add(car);
                 cars.Add(car);
             }
             else if (objType.SelectedIndex == 0 && objTitle.Text.Length == 0)
             {
                 MessageBox.Show("Введите имя машины");
             }
             if (objType.SelectedIndex == 1 && objTitle.Text.Length > 0)
             {
                 human = new CHuman(objTitle.Text, pts[0]);
                 objs.Add(human);
             }
             else if (objType.SelectedIndex == 1 && objTitle.Text.Length == 0)
             {
                 MessageBox.Show("Введите имя человека");
             }
             if (objType.SelectedIndex == 2 && objTitle.Text.Length > 0)
             {
                 CLocation location = new CLocation(objTitle.Text, pts[0]);
                 objs.Add(location);
             }
             else if (objType.SelectedIndex == 2 && objTitle.Text.Length == 0)
             {
                 MessageBox.Show("Введите название место прибытия");
             }
             if (objType.SelectedIndex == 3 && pts.Count > 2 && objTitle.Text.Length > 0)
             {
                 CArea area = new CArea(objTitle.Text, pts);
                 objs.Add(area);
             }
             else if (objType.SelectedIndex == 3 && pts.Count <= 2 && objTitle.Text.Length > 0)
             {
                 MessageBox.Show("Обозначьте площадь не менее из 3 точек");
             }
             if (objType.SelectedIndex == 4 && pts.Count > 1 && objTitle.Text.Length > 0)
             {
                 CRoude roude = new CRoude(objTitle.Text, pts);
                 objs.Add(roude);
             }
             else if (objType.SelectedIndex == 4 && pts.Count <= 1 && objTitle.Text.Length > 0)
             {
                 MessageBox.Show("Введите маршрут не менее из 2 точек");
             }
         }
         else if (objType.SelectedIndex > -1 && !createFlag)
         {
         }
         pts.Clear();
         Map.Markers.Clear();
         objTitle.Clear();
         objectList.Items.Clear();
         foreach (CMapObject cm in objs)
         {
             Map.Markers.Add(cm.getMarker());
             objectList.Items.Add(cm.getTitle());
         }
         foreach (GMapMarker cm in markerTaxi)
         {
             Map.Markers.Add(cm);
         }
     }
     catch
     {
         MessageBox.Show("Выберите место");
     }
 }