ConvertTo() 공개 정적인 메소드

convert CityInfoString into CityInfo
public static ConvertTo ( CityInfoString cityInfoString ) : CityInfo
cityInfoString CityInfoString CityInfoString need to convert
리턴 CityInfo
예제 #1
0
        /// <summary>
        /// used when city information changed
        /// </summary>
        /// <param name="cityInfoString">city information which changed</param>
        /// <param name="cityName">city name want to get according to information</param>
        /// <param name="timeZone">city time zone gotten according to information</param>
        private void GetCityNameTimeZone(CityInfoString cityInfoString,
                                         out string cityName, out string timeZone)
        {
            CityInfo cityInfo = UnitConversion.ConvertTo(cityInfoString);
            string   tempName;
            double   tempTime;

            //try to get city name and timezone according to cityInfo
            if (m_placeInfo.TryGetCityNameTimeZone(cityInfo, out tempName, out tempTime))
            {
                cityName = tempName;

                //try to get string representing timezone according to a number
                timeZone = m_placeInfo.TryGetTimeZoneString(tempTime);

                //set current CityInfo
                m_currentCityInfo.Latitude  = cityInfo.Latitude;
                m_currentCityInfo.Longitude = cityInfo.Longitude;
                m_currentCityInfo.TimeZone  = tempTime;
                m_currentCityInfo.CityName  = tempName;
            }
            else
            {
                //set current CityInfo
                cityName = null;
                timeZone = null;
                m_currentCityInfo.Latitude  = cityInfo.Latitude;
                m_currentCityInfo.Longitude = cityInfo.Longitude;
                m_currentCityInfo.CityName  = null;
            }
        }
예제 #2
0
        /// <summary>
        /// called by some functions to do same operation
        /// </summary>
        private void DoTextBoxChanged()
        {
            //enable timezone ComboBox
            timeZoneComboBox.Enabled = true;
            CityInfoString cityInfoString = new CityInfoString(latitudeTextBox.Text, longitudeTextBox.Text);
            string         cityName;
            string         timeZone;

            //get new CityName and TimeZone
            GetCityNameTimeZone(cityInfoString, out cityName, out timeZone);

            //use new CityName to set ComboBox
            if (null != cityName)
            {
                cityNameComboBox.Text         = null;
                cityNameComboBox.SelectedItem = cityName;
                timeZoneComboBox.Enabled      = false;
            }
            else
            {
                if (m_isFormLoading)
                {
                    string userDefinedCity = "User Defined\r";
                    if (!m_placeInfo.CitiesName.Contains(userDefinedCity))
                    {
                        cityNameComboBox.DataSource = null;
                        m_placeInfo.CitiesName.Add(userDefinedCity);
                        m_placeInfo.CitiesName.Sort();
                        cityNameComboBox.DataSource = m_placeInfo.CitiesName;
                        CityInfo cityInfo = UnitConversion.ConvertTo(cityInfoString);
                        cityInfo.CityName = userDefinedCity;
                        cityInfo.TimeZone = m_siteLocation.TimeZone;
                        m_placeInfo.AddCityInfo(cityInfo);
                    }
                    cityNameComboBox.SelectedItem = userDefinedCity;
                }
                else
                {
                    cityNameComboBox.SelectedIndex = -1;
                }
            }

            //after get timeZone,set control timeZonesComboBox
            if (null != timeZone)
            {
                timeZoneComboBox.Text         = null;
                timeZoneComboBox.SelectedItem = timeZone;
            }
        }