Example #1
0
        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);
        }
Example #2
0
        public static PopularStnIOController GetInstance()
        {
            if (m_instance == null)
            {
                m_instance = new PopularStnIOController();
            }

            return(m_instance);
        }
Example #3
0
        /// <summary>
        /// Select the Ok command.
        /// </summary>
        private void SelectComplete(ICloseable window)
        {
            this.Result = MessageBoxResult.OK;

            PopularStnIOController locationController = PopularStnIOController.GetInstance();

            locationController.SaveFile(this.PopularStnCollection.ToList());

            window?.CloseObject();
        }