Esempio n. 1
0
        private void ClearFunc()
        {
            TimerForCarAnimation.Stop();
            routeResult.Locations.Clear();
            routeResult.ManeuverPointsForDegreesAnimation.Clear();
            routeResult.RoutePathForDegreesAnimation.Clear();
            routeResult.Distance = 0;
            routeResult.Duration = 0;
            if (SearchResultsCollection != null)
            {
                SearchResultsCollection.Clear();
            }
            DriverWaiting = true;

            myMap.Focus();
            myMap.Children.Clear();
            myMap.Children.Add(UserLocationPushpin);
            AddDriversToMapService.AddDriversOnTheMap(myMap, DriversRepo.GetDrivers());
        }
Esempio n. 2
0
        private void ClearFunc()
        {
            TimerForCarAnimation.Stop();
            routeResult.Locations.Clear();
            routeResult.ManeuverPointsForDegreesAnimation.Clear();
            routeResult.RoutePathForDegreesAnimation.Clear();
            routeResult.Distance = 0;
            routeResult.Duration = 0;
            if (SearchResultsCollection != null)
            {
                SearchResultsCollection.Clear();
            }
            TempIndexForLocationCollection = 0;
            DriverWaiting = true;

            MyMap.Focus();
            MyMap.Children.Clear();
            MyMap.Children.Add(new Pushpin()
            {
                Location = GetCurrentLocationService.CurrentLocation()
            });
            AddDriversToMapService.AddDriversOnTheMap(MyMap, DriversRepo.GetDrivers());
        }
Esempio n. 3
0
        public MainViewModel(Map myMap, Button CurrentLocationBtn, Pushpin UserLocationPushpin, Button btnSearch, TextBox tbSearch, ToggleButton ToggleButtonOpen, ListView ListViewSearch, Grid GridMenu, ObservableCollection <Driver> Drivers)
        {
            MyMap = myMap;
            GetCurrentLocationService.CurrentLocation();

            MyMap.CredentialsProvider = Provider;

            AddDriversToMapService.AddDriversOnTheMap(myMap, Drivers);
            DriversVM = Drivers;

            while (true)
            {
                if (GetCurrentLocationService.CurrentLocation().ToString() != "NaN,NaN,0")
                {
                    break;
                }
            }



            CurrentLocationCommand = new RelayCommand(e =>
            {
                CurrentLocationAddress     = GetAPIResultService.CurrentLocationAddressName(GetCurrentLocationService.CurrentLocation());
                CurrentLocationBtn.ToolTip = CurrentLocationAddress;


                //User
                if (UserLocationPushpin == null)
                {
                    UserLocationPushpin = new Pushpin()
                    {
                        ToolTip  = "You are here!",
                        Template = Application.Current.FindResource("UserPushpin") as ControlTemplate,
                        Tag      = "User",
                    };
                    MapLayer.SetPositionOffset(UserLocationPushpin, new Point(0, 20));
                    myMap.Children.Add(UserLocationPushpin);
                }

                UserLocationPushpin.Location = GetCurrentLocationService.CurrentLocation();

                myMap = MyMap;

                myMap.Center    = new Location(GetCurrentLocationService.CurrentLocation().Latitude, GetCurrentLocationService.CurrentLocation().Longitude);
                myMap.ZoomLevel = 11;
                myMap.Focus();
            });
            CurrentLocationCommand.Execute(new object());

            SearchCommand = new RelayCommand(e =>
            {
                ClearFunc();

                if (String.IsNullOrWhiteSpace(tbSearch.Text) != true)
                {
                    try
                    {
                        SearchResultsCollection = GetAPIResultService.PlaceLocation(tbSearch.Text);

                        for (int i = 0; i < SearchResultsCollection.Count; i++)
                        {
                            Pushpin PlaceLocationPushpin = new Pushpin()
                            {
                                Location = SearchResultsCollection[i].Location,
                                ToolTip  = SearchResultsCollection[i].Name,
                                Tag      = "End Location",
                            };


                            PlaceLocationPushpin.MouseDown += PlaceLocationPushpin_MouseDown;

                            myMap.Children.Add(PlaceLocationPushpin);
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                        return;
                    }


                    if (SearchResultsCollection.Count > 0)
                    {
                        //FrameworkElement beginStoryboard = new FrameworkElement();
                        //beginStoryboard.BeginStoryboard((Storyboard)Application.Current.FindResource("CloseMenu"));
                        //beginStoryboard.BeginStoryboard((Storyboard)Application.Current.FindResource("RigthMenu"));



                        //BeginStoryboard((Storyboard)FindResource("CloseMenu"));
                        //BeginStoryboard((Storyboard)FindResource("RightMenu"));
                        ToggleButtonOpen.IsChecked = true;
                    }
                }
                else
                {
                    MessageBox.Show("Enter the place name");
                }

                ListViewSearch.ItemsSource = SearchResultsCollection;
            });


            DirectionCommand = new RelayCommand(e => {
                ClearFunc();
                RouteResult temprouteResult = new RouteResult();
                Route tempRoute             = new Route();

                GetAPIResultService.GetRoutePoints(GetCurrentLocationService.CurrentLocation(), DestinationLocation, temprouteResult);


                tempRoute = new Route(IdMax, temprouteResult.Distance, temprouteResult.Duration, Double.Parse(PriceRepo.GetPrice()) * temprouteResult.Distance,
                                      GetTaxiService.GiveMeDriver(Drivers), GetCurrentLocationService.CurrentLocation(),
                                      DestinationLocation, CurrentLocationAddress, GetAPIResultService.CurrentLocationAddressName(DestinationLocation));



                GetAPIResultService.GetRoutePoints(GetTaxiService.GiveMeDriver(Drivers).Location, GetCurrentLocationService.CurrentLocation(), routeResult);

                CurrentRoute = new Route(IdMax, temprouteResult.Distance, temprouteResult.Duration, Double.Parse(PriceRepo.GetPrice()) * temprouteResult.Distance,
                                         GetTaxiService.GiveMeDriver(Drivers), GetCurrentLocationService.CurrentLocation(),
                                         DestinationLocation, CurrentLocationAddress, GetAPIResultService.CurrentLocationAddressName(DestinationLocation));


                StartRouteView ACCORNOT = new StartRouteView(tempRoute);



                MapPolyline.Locations = routeResult.Locations;
                MyMap.Children.Add(MapPolyline);

                if (ACCORNOT.ShowDialog() == true)
                {
                    TimerForCarAnimation.Interval = new TimeSpan(0, 0, 0, 0, 300);
                    TimerForCarAnimation.Tick    += TimerForCarAnimation_Tick;
                    TimerForCarAnimation.Start();
                }
                else
                {
                    ClearFunc();
                }
            });


            myMap = MyMap;
        }