ConvertFrom() public static method

convert CityInfo into CityInfoString
public static ConvertFrom ( CityInfo cityInfo ) : CityInfoString
cityInfo CityInfo CityInfo need to convert
return CityInfoString
Exemplo n.º 1
0
        /// <summary>
        /// display the location information on the form
        /// </summary>
        private void DisplayInformation()
        {
            //initialize the listbox
            locationListBox.Items.Clear();
            foreach (string itemName in m_data.LocationNames)
            {
                if (itemName == m_data.LocationName)
                {
                    m_currentName = itemName + " (current)"; //indicate the current project location
                    locationListBox.Items.Add(m_currentName);
                }
                else
                {
                    locationListBox.Items.Add(itemName);
                }
            }

            //set the selected item to current location
            for (int i = 0; i < locationListBox.Items.Count; i++)
            {
                string itemName = null;
                itemName = locationListBox.Items[i].ToString();
                if (itemName.Contains("(current)"))
                {
                    locationListBox.SelectedIndex = i;
                }
            }

            //get the offset values of the selected item
            string selecteName = locationListBox.SelectedItem.ToString();

            m_data.GetOffset(selecteName);
            this.ShowOffsetValue();

            //set control in placeTabPage
            //convert values get from API and set them to controls
            CityInfo       cityInfo       = new CityInfo(m_siteLocation.Latitude, m_siteLocation.Longitude);
            CityInfoString cityInfoString = UnitConversion.ConvertFrom(cityInfo);

            //set Text of Latitude and Longitude TextBox
            latitudeTextBox.Text  = cityInfoString.Latitude;
            longitudeTextBox.Text = cityInfoString.Longitude;

            //set DataSource of CitiesName ComboBox and TimeZones ComboBox
            cityNameComboBox.DataSource = m_placeInfo.CitiesName;
            timeZoneComboBox.DataSource = m_placeInfo.TimeZones;

            //try use Method DoTextBoxChanged to Set CitiesName ComboBox
            DoTextBoxChanged();
            m_isFormLoading = false;

            //get timezone from double value and set control
            string timeZoneString = m_placeInfo.TryGetTimeZoneString(m_siteLocation.TimeZone);

            //set selectItem of TimeZones ComboBox
            timeZoneComboBox.SelectedItem = timeZoneString;
            timeZoneComboBox.Enabled      = false;
        }
Exemplo n.º 2
0
        /// <summary>
        /// used when city name changed
        /// </summary>
        /// <param name="cityName">city name which changed</param>
        /// <param name="cityInfoString">city information want to get according to city name</param>
        /// <returns>check whether is successful</returns>
        private bool GetCityInfo(string cityName, out CityInfoString cityInfoString)
        {
            CityInfo cityInfo = new CityInfo();

            //try to get CityInfo according to cityName
            if (m_placeInfo.TryGetCityInfo(cityName, out cityInfo))
            {
                //do conversion from CityInfo to CityInfoString
                cityInfoString = UnitConversion.ConvertFrom(cityInfo);

                //do TimeZone conversion from double to string
                cityInfoString.TimeZone = m_placeInfo.TryGetTimeZoneString(cityInfo.TimeZone);

                //set current CityInfo
                m_currentCityInfo          = cityInfo;
                m_currentCityInfo.CityName = cityName;
                return(true);
            }

            //if failed, also set current CityInfo
            m_currentCityInfo.CityName = null;
            cityInfoString             = new CityInfoString();
            return(false);
        }