public PopularStnConfigViewModel() { this.StnCollection = new ObservableCollection <string>(); this.PopularStnCollection = new ObservableCollection <string>(); string previousvalue = string.Empty; string location = string.Empty; JourneyIOController journeyController = JourneyIOController.GetInstance(); for (int i = 0; i < journeyController.GetMileageDetailsLength(); i++) { location = journeyController.GetFromStation(i); if (location != previousvalue) { this.StnCollection.Add(location); } previousvalue = location; } PopularStnIOController locationController = PopularStnIOController.GetInstance(); //ObservableCollection<string> locationList = new List<string>(); //locationList = locationController.LoadFile(); foreach (string popular in locationController.LoadFile()) { this.PopularStnCollection.Add(popular); } this.AddCmd = new CommonCommand(this.AddStn, this.CanAddStn); this.DeleteCmd = new CommonCommand(this.DeleteStn, this.CanDeleteStn); this.CompleteCmd = new CommonCommand <ICloseable>(this.SelectComplete, this.CanSelectComplete); }
/// <summary> /// InitialiseInputForm, performs all the initialisation tasks. /// 1. Get the routes data and populate the outward combobox. /// 2. Load the current days journeys. /// </summary> private void InitialiseInputForm() { string previousvalue = string.Empty; string fromString = string.Empty; this.JnyFromList = new ObservableCollection <string>(); this.JnyFromList.Add(string.Empty); this.JnyFromIndex = 0; this.Status = "Initialising"; for (int i = 0; i < journeyController.GetMileageDetailsLength(); i++) { fromString = journeyController.GetFromStation(i); if (fromString != previousvalue) { JnyFromList.Add(fromString); } previousvalue = fromString; } this.ResetInputProperties(); // load the days journeys this.Status = LoadJourneysForSelectedDay() ? "Initialised" : lastErrorString; }
/// <summary> /// Gets the collection of locations without the filter applied. /// </summary> /// <returns></returns> private ObservableCollection <string> GetStnAllCollection() { ObservableCollection <string> stnCollection = new ObservableCollection <string>(); string previousvalue = string.Empty; string str = string.Empty; JourneyIOController jc = JourneyIOController.GetInstance(); for (int i = 0; i < jc.GetMileageDetailsLength(); i++) { str = jc.GetFromStation(i); if (str != previousvalue) { stnCollection.Add(str); } previousvalue = str; } return(stnCollection); }