Exemplo n.º 1
0
        protected static void LoadPrices()
        {
            lock (_syncLoadPrices)
            {
                if (_loadedPrices || _loadedMtgjsonPrices)
                {
                    return;
                }

                LoadCards();

                var sw = new Stopwatch();
                sw.Start();

                PriceRepo.LoadFile();
                PriceRepo.Load();
                PriceRepo.FillPrice(Repo);

                sw.Stop();
                _log.Info($"Prices loaded in {sw.ElapsedMilliseconds} ms");

                LogManager.Flush();

                _loadedPrices = true;
                if (!PriceRepo.CacheExists())
                {
                    _loadedMtgjsonPrices = true;
                }
            }
        }
Exemplo n.º 2
0
        protected static void LoadMtgjsonPrices()
        {
            lock (_syncLoadMtgjsonPrices)
            {
                if (_loadedMtgjsonPrices)
                {
                    return;
                }

                LoadCards();

                var sw = new Stopwatch();
                sw.Start();

                PriceRepo.LoadFile(ignoreCache: true);
                PriceRepo.Load(ignoreCache: true);
                if (!PriceRepo.IsLoadingPriceComplete.Signaled)
                {
                    PriceRepo.FillPrice(Repo);
                }

                sw.Stop();
                _log.Info($"Mtgjson prices loaded in {sw.ElapsedMilliseconds} ms");

                LogManager.Flush();

                _loadedMtgjsonPrices = true;
            }
        }
Exemplo n.º 3
0
 public CaseController()
 {
     _cr = new CaseRepo();
     _pp = new PriceRepo();
     _pr = new PersonRepo();
 }
Exemplo n.º 4
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;
        }