void stationProvider_InputChanged(object sender, EventArgs e) { WebServiceTextSearchProvider provider = (WebServiceTextSearchProvider)sender; string inputString = provider.InputString; if (!string.IsNullOrEmpty(inputString)) { string p = inputString.ToLower(); var stations = this.AllStations.Where(x => x.Name.ToLower().StartsWith(p)).Take(5); if (stations.Count() < 5) { var extraStations = AllStations.Where(x => x.StartsWith(p)).Take(5 - stations.Count()); stations = stations.Union(extraStations); } provider.LoadItems(stations); } else { provider.Reset(); } }
public static void DownloadDataBase(Stream AllRoutesStream, Stream AllStationsStream, Stream RouteMatrixStream) { if (_allStations == null) { var formatter = new BinaryFormatter(); Thread potok1 = new Thread(delegate() { _allRoutes = (AllRoutes)formatter.Deserialize(AllRoutesStream); }); potok1.Start(); Thread potok2 = new Thread(delegate() { _allStations = (AllStations)formatter.Deserialize(AllStationsStream); }); potok2.Start(); Thread potok3 = new Thread(delegate() { _routeMatrix = (RouteMatrix)formatter.Deserialize(RouteMatrixStream); }); potok3.Start(); var backingFile = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData), "favorites.dat"); if (backingFile == null || !File.Exists(backingFile)) { return; } using (var reader = new FileStream(backingFile, FileMode.OpenOrCreate)) { _favoriteRoutes = new FavoriteRoutes(); _favoriteRoutes = (FavoriteRoutes)formatter.Deserialize(reader); } while (potok1.IsAlive || potok2.IsAlive || potok3.IsAlive) { continue; } } }
private void Btn_StartRoute_Click(object sender, EventArgs e) { _stationsLoader = new StationsLoader(); var transportType = comboBox_TransportType.SelectedIndex + 1; var routeNumber = textBox_RouteNumber.Text; var url = $"http://www.yargortrans.ru/config.php?vt={transportType}&nmar={routeNumber}"; var formatter = new BinaryFormatter(); using (FileStream fs = new FileStream("allstations.dat", FileMode.OpenOrCreate)) { _allStations = (AllStations)formatter.Deserialize(fs); } using (FileStream fs = new FileStream("routematrix.dat", FileMode.OpenOrCreate)) { _routeMatrix = (RouteMatrix)formatter.Deserialize(fs); } SetMarkers(); _stationsLoader.Load(url, transportType); _namesOfStationsOnCurrentRoute = _stationsLoader.StationsList; _lengthOfDirectRoute = _stationsLoader.CountOfStationsOnDirectRoute; richTextBox1.AppendText($"{_namesOfStationsOnCurrentRoute[_currentStationOnCurrentRoute]}\n"); }
public Searcher() { _htmlWorker = new HtmlWorker(); var formatter = new BinaryFormatter(); using (var fs = new FileStream(AppDomain.CurrentDomain.BaseDirectory + @"data\allroutes.dat", FileMode.Open, FileAccess.Read)) { _allRoutes = (AllRoutes)formatter.Deserialize(fs); } using (var fs = new FileStream(AppDomain.CurrentDomain.BaseDirectory + @"data\allstations.dat", FileMode.Open, FileAccess.Read)) { _allStations = (AllStations)formatter.Deserialize(fs); _stations = new List <string>(); for (int i = 0; i < _allStations.Count; i++) { _stations.Add(_allStations.GetStation(i).StationName); } _stations.Sort(); } using (var fs = new FileStream(AppDomain.CurrentDomain.BaseDirectory + @"data\routematrix.dat", FileMode.Open, FileAccess.Read)) { _routeMatrix = (RouteMatrix)formatter.Deserialize(fs); } }
public Searcher(AllRoutes allRoutes, AllStations allStations, RouteMatrix routeMatrix) { _allRoutes = allRoutes; _allStations = allStations; _routeMatrix = routeMatrix; _htmlWorker = new HtmlWorker(); }
public void RemoveStationsFromRoad(Station station) { SelectedStations.Remove(station); AllStations.Add(station); var stations = NewRoad.Stations.ToList(); stations.Remove(NewRoad.Stations.First(x => x.Id == station.Id)); NewRoad.Stations = stations; }
public void DisplayStations(string condition = null) { Console.WriteLine(); Console.WriteLine("Please select the station:"); foreach (var i in AllStations.Where(m => m.Value != condition)) { Console.WriteLine(i.Value); } }
public Station GetStationByName(string value) { var selectedStation = AllStations.Where(x => x.Name.ToLower() == value.ToLower()).FirstOrDefault(); if (selectedStation == null) { selectedStation = AllStations.Where(x => x.NamesExtra.Select(y => y.ToLower()).Contains(value.ToLower())).FirstOrDefault(); } return(selectedStation); }
public Form1() { InitializeComponent(); var formatter = new BinaryFormatter(); _allRoutes = new AllRoutes(); _allStations = new AllStations(); _routeMatrix = new RouteMatrix(); }
public OverviewViewModel( IBikeService bikeService, ILocationService locationService, IStationService stationService, INavigationService navigationService, IDialogService dialogService) { _locationService = locationService; _navigationService = navigationService; _dialogService = dialogService; _locationService = locationService; ShowBikeOnMapCommand = CreateCommand <Bike>(ShowBikeOnMap, CanShowBikeOnMap); RefreshUserLocationCommand = CreateCommand(RefreshUserLocation); ToggleMapCommand = CreateCommand(ToggleMap); ShowMap = Preferences.Get("ShowMap", false); PropertyChanged += (_, args) => { switch (args.PropertyName) { case nameof(ShowMap): OnPropertyChanged(nameof(ToggleMapText)); Preferences.Set("ShowMap", ShowMap); break; case nameof(UserLocation): OnPropertyChanged(nameof(GroupedItems)); break; case nameof(AllBikes) or nameof(AllStations): OnPropertyChanged(nameof(MapItems)); OnPropertyChanged(nameof(GroupedItems)); break; } }; var bikes = bikeService.GetAvailableBikes(); bikes.CollectionChanged += (_, _) => { AllBikes.ReplaceRange(bikes); OnPropertyChanged(nameof(AllBikes)); }; var stations = stationService.GetAvailableStations(); stations.CollectionChanged += (_, _) => { AllStations.ReplaceRange(stations); OnPropertyChanged(nameof(AllStations)); }; }
private void FillRouteSource() { if (CurStation.Name == AllStations.First().Name) { ComboBoxRoutes.ItemsSource = AllRoutes.Concat(Db.Routes.Items); } else { StationSelect(); } }
public Tuple <int, string> RouteInformation() { while (_condition == Constants.FalseCondition) { Console.WriteLine(); var selection = Console.ReadLine(); var currentMatches = AllStations.Where(i => i.Value.Contains(selection)); LogicToDisplay(currentMatches); } return(new Tuple <int, string>(_order, _station)); }
private void FillStationSource() { if (CurRoute.Name == AllRoutes.First().Name) { ComboBoxStations.ItemsSource = AllStations.Concat(Db.Stations.Items); } else { ComboBoxStations.ItemsSource = AllStations.Concat(Db.Stations.Items.Where( s => CurRoute.Stations.FirstOrDefault(st => st.StationId == s.Id) != null)); } }
public Form1() { InitializeComponent(); _allStations = new AllStations(); _routeMatrix = new RouteMatrix(); _namesOfStationsOnCurrentRoute = new List <string>(); _currentDirectRoute = new List <string>(); _currentReverseRoute = new List <string>(); _currentStationOnCurrentRoute = 0; _metrika = new Metrika(); _markersOverlay = new GMapOverlay(gMapControl1, "marker"); }
public void ShouldReturnData() { AllStations stationsMock = () => new List<Station> { new Station("Gdansk") }; var getStationsQuery = new GetStationsQueryWithDelegate(stationsMock); var result = getStationsQuery.Handle(); Assert.Contains(new Station("Gdansk"), result); }
/// <summary> 在 AutoCAD 界面中快速导航到指定的桩号 </summary> public ExternalCmdResult NavigateStation(DocumentModifier docMdf, SelectionSet impliedSelection) { _docMdf = docMdf; SubgradeSection matchedSection = null; bool? start; var wantedStation = SetStation(docMdf.acEditor, out start); // 所有的断面 var allSections = SQUtils.GetAllSections(docMdf, sort: true); if (allSections != null && allSections.Length > 0) { if (start.HasValue) { // 匹配起始或者结尾桩号 if (start.Value) { matchedSection = allSections[0]; } else { matchedSection = allSections[allSections.Length - 1]; } } else { // 匹配指定数值最近的桩号 if (wantedStation.HasValue) { var allStations = new AllStations(allSections.Select(r => r.XData.Station).ToArray()); var closestStation = allStations.MatchClosest(wantedStation.Value); matchedSection = allSections.FirstOrDefault(r => r.XData.Station == closestStation); } } // if (matchedSection != null) { var ext = matchedSection.GetExtends(); ext.TransformBy(Matrix3d.Scaling( scaleAll: 1.2, center: ext.MinPoint.Add((ext.MaxPoint - ext.MinPoint) / 2))); eZcad.Utility.Utils.ShowExtentsInView(docMdf.acEditor, ext); } } return(ExternalCmdResult.Commit); }
protected override void OnCreate(Bundle savedInstanceState) { SetTheme(Resource.Style.AppTheme); base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_main); Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); SupportActionBar.Title = "Что приедет"; favouritiesBtn = FindViewById <ImageButton>(Resource.Id.FavouritiesButton); favouritiesBtn.Click += Fbtn_Click; SearcherAdapter.DownloadDataBase(Assets.Open("allroutes.dat"), Assets.Open("allstations.dat"), Assets.Open("routematrix.dat")); SearcherAdapter.Init(); AllStations stations = SearcherAdapter.GetAllStations(); items = new List <string>(); for (int i = 0; i < stations.Count; i++) { items.Add(stations.GetStation(i).StationName.ToString()); } startSpinner = new CustomTextView(FindViewById <AutoCompleteTextView>(Resource.Id.Start), new ArrayAdapter(this, Resource.Layout.list_item, items)); startSpinner.textView.ItemClick += _ItemClick; endSpinner = new CustomTextView(FindViewById <AutoCompleteTextView>(Resource.Id.End), new ArrayAdapter(this, Resource.Layout.list_item, items)); endSpinner.textView.ItemClick += _ItemClick; text = FindViewById <ListView>(Resource.Id.Schedule); text.ItemClick += Text_ItemClick; var btn = FindViewById <Button>(Resource.Id.SearchButton); btn.Click += FindTransport; if (SearcherAdapter.St != null) { var m = SearcherAdapter.GetPoint(); startSpinner.Text = items[m[0]]; endSpinner.Text = items[m[1]]; favouritiesBtn.SetImageResource(Resource.Drawable.Contains); } FindViewById <LinearLayout>(Resource.Id.rootLayout).RequestFocus(); }
public void AddStationsToRoad(Station station) { AllStations.Remove(station); SelectedStations.Add(station); if (NewRoad.Stations != null) { var stations = NewRoad.Stations.ToList(); stations.Add(station); NewRoad.Stations = stations; } else { NewRoad.Stations = new List <Station>() { station }; } }
public MainWindow() { InitializeComponent(); SetSelectItems(); if (MessageBox.Show("Do you want to load from database?", "Loading priority", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { Db = Factory.Instance.GetDatabaseStorage(); } else { Db = Factory.Instance.GetFileStorage(false); } CurRoute = AllRoutes.First(); CurStation = AllStations.First(); FillStationSource(); FillRouteSource(); }
private void ButtonAddFavorite_Click(object sender, RoutedEventArgs e) { if (CurStation.Name != AllStations.First().Name) { if (CurrentUser.FavoriteStations.Find(st => st.StationId == CurStation.Id) != null) { MessageBox.Show("The station has already been in favorites!"); } else { AddFavoriteWindow window = new AddFavoriteWindow(this) { Owner = this }; window.ShowDialog(); } } else { MessageBox.Show("Choose a station!", "Attention"); } }
public GetStationsQueryWithDelegate(AllStations allStations) => _allStations = allStations;