Exemplo n.º 1
0
 /// <summary>
 /// Parses the input string for variable substitution.
 /// </summary>
 /// <param name="location">Weather Forecast Location.</param>
 /// <param name="replacement">Day number replacement.</param>
 /// <param name="dt">Variable to xpath translation table.</param>
 /// <param name="input">Input string.</param>
 /// <returns></returns>
 public string Parse(WeatherRegionForecast location, string replacement, DataTable dt, string input)
 {
     this._regionForecast = location;
     this._dt = dt;
     this._xPathReplace = replacement;
     return matchExp.Replace(input, new MatchEvaluator(this.VariableLookup));
 }
Exemplo n.º 2
0
 /// <summary>
 /// Parses the input string for variable substitution.
 /// </summary>
 /// <param name="location">Weather Forecast Location.</param>
 /// <param name="replacement">Day number replacement.</param>
 /// <param name="dt">Variable to xpath translation table.</param>
 /// <param name="input">Input string.</param>
 /// <returns></returns>
 public string Parse(WeatherRegionForecast location, string replacement, DataTable dt, string input)
 {
     this._regionForecast = location;
     this._dt             = dt;
     this._xPathReplace   = replacement;
     return(matchExp.Replace(input, new MatchEvaluator(this.VariableLookup)));
 }
Exemplo n.º 3
0
        private void weatherLocations_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            // Enable and disable sections based on index selection
            bool enabled = (forecastRegions.SelectedIndex != -1);

            btnRemove.Enabled     = enabled;
            unitBox.Enabled       = enabled;
            forecastGroup.Enabled = enabled;
            radarGroup.Enabled    = enabled;

            if (forecastRegions.SelectedIndex != -1)
            {
                WeatherRegionForecast region = (WeatherRegionForecast)forecastRegions.Items[forecastRegions.SelectedIndex];
                forecastDays.Value     = Convert.ToDecimal(region.ForecastDays);
                rbUnitMetric.Checked   = region.IsMetric;
                rbUnitStandard.Checked = !region.IsMetric;

                // Find the url in the region map list
                DataTable dt = (DataTable)radarMap.DataSource;
                DataRow[] dr = dt.Select("url='" + region.RadarMap + "'");
                if (dr.Length == 1)
                {
                    radarMap.Text          = "";
                    radarMap.SelectedIndex = radarMap.FindStringExact(dr[0]["name"].ToString());
                }
                else
                {
                    radarMap.SelectedIndex = -1;
                    radarMap.Text          = region.RadarMap;
                }
            }
        }
Exemplo n.º 4
0
 private void searchButton_Click(object sender, System.EventArgs e)
 {
     if (xHelper != null && xHelper.SendCommand("connectedToInternet") == "false")
     {
         Error("Unable to search for location - You are not connected to the Internet");
         return;
     }
     if (searchText.Text == "")
     {
         MessageBox.Show("Enter a valid search string", "Weather Plugin",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         string text = searchButton.Text;
         searchButton.Text        = "Searching...";
         searchButton.Enabled     = false;
         searchResults.DataSource = WeatherRegionForecast.SearchForLocations(searchText.Text);
         if (searchResults.Items.Count == 0)
         {
             MessageBox.Show("No locations were found for '" + searchText.Text + "'", "Weather Plugin",
                             MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else
         {
             searchText.Text = "";
         }
         searchButton.Enabled = true;
         searchButton.Text    = text;
     }
 }
Exemplo n.º 5
0
        private void forecastRegions_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
        {
            WeatherRegionForecast loc = (WeatherRegionForecast)e.Data.GetData(typeof(WeatherLocation));

            loc.ForecastDays = Convert.ToInt16(forecastDays.Value);
            loc.IsMetric     = rbUnitMetric.Checked;
            forecastRegions.Items.Add(loc);
        }
Exemplo n.º 6
0
 private void GetDefaultMap_Click(object sender, System.EventArgs e)
 {
     if (forecastRegions.SelectedIndex != -1)
     {
         WeatherRegionForecast region = (WeatherRegionForecast)forecastRegions.SelectedItem;
         radarMap.Text = XoapProvider.Instance.GetRadarUrl(region.LocationId);
     }
 }
Exemplo n.º 7
0
 private void unitBox_Leave(object sender, System.EventArgs e)
 {
     if (forecastRegions.SelectedIndex != -1)
     {
         WeatherRegionForecast region = (WeatherRegionForecast)forecastRegions.SelectedItem;
         region.IsMetric = rbUnitMetric.Checked;
     }
 }
Exemplo n.º 8
0
 private void forecastDays_Leave(object sender, System.EventArgs e)
 {
     if (forecastRegions.SelectedIndex != -1)
     {
         WeatherRegionForecast region = (WeatherRegionForecast)forecastRegions.SelectedItem;
         region.ForecastDays = Convert.ToInt16(forecastDays.Value);
     }
 }
Exemplo n.º 9
0
        private void searchResults_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            ListBox lb    = (ListBox)sender;
            int     index = lb.IndexFromPoint(e.X, e.Y);

            if (index >= 0)
            {
                WeatherRegionForecast src = (WeatherRegionForecast)lb.Items[index];
                lb.DoDragDrop(src, DragDropEffects.Move);
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Searches the for location string specified and returns an array of
        /// instances of WeatherRegionForecast.
        /// </summary>
        /// <param name="searchString">Search string.</param>
        /// <returns>WeatherRegionForecast[] array.</returns>
        public static WeatherRegionForecast[] SearchForLocations(string searchString)
        {
            WeatherRegionForecast[] locationList;

            Hashtable results = DefaultWeatherProvider.GetLocationID(searchString);

            locationList = new WeatherRegionForecast[results.Count];
            int i = 0;

            foreach (DictionaryEntry entry in results)
            {
                locationList[i++] = new WeatherRegionForecast(entry.Key as string, entry.Value as string);
            }
            return(locationList);
        }
Exemplo n.º 11
0
 private void radarMap_Leave(object sender, System.EventArgs e)
 {
     if (forecastRegions.SelectedIndex != -1)
     {
         WeatherRegionForecast region = (WeatherRegionForecast)forecastRegions.SelectedItem;
         if (radarMap.SelectedIndex != -1)
         {
             region.RadarMap = (string)radarMap.SelectedValue;
         }
         else
         {
             region.RadarMap = radarMap.Text;
         }
     }
 }
Exemplo n.º 12
0
        private void btnAdd_Click(object sender, System.EventArgs e)
        {
            if (searchResults.SelectedIndex != -1)
            {
                WeatherLocation       srcLoc = (WeatherLocation)searchResults.Items[searchResults.SelectedIndex];
                WeatherRegionForecast dstLoc = new WeatherRegionForecast();

                dstLoc.LocationId   = srcLoc.LocationId;
                dstLoc.Description  = srcLoc.Description;
                dstLoc.ForecastDays = Convert.ToInt16(forecastDays.Value);
                dstLoc.IsMetric     = rbUnitMetric.Checked;
                dstLoc.RadarMap     = XoapProvider.Instance.GetRadarUrl(srcLoc.LocationId);
                forecastRegions.Items.Add(dstLoc);
                forecastRegions.SelectedIndex = forecastRegions.FindStringExact(dstLoc.Description);
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Searches the for location string specified and returns an array of
        /// instances of WeatherRegionForecast.
        /// </summary>
        /// <param name="searchString">Search string.</param>
        /// <returns>WeatherRegionForecast[] array.</returns>
        public static WeatherRegionForecast[] SearchForLocations(string searchString)
        {
            WeatherRegionForecast[] locationList;

            Hashtable results = DefaultWeatherProvider.GetLocationID(searchString);
            locationList = new WeatherRegionForecast[results.Count];
            int i = 0;
            foreach (DictionaryEntry entry in results)
                locationList[i++] = new WeatherRegionForecast(entry.Key as string, entry.Value as string);
            return locationList;
        }
Exemplo n.º 14
0
        private void btnAdd_Click(object sender, System.EventArgs e)
        {
            if (searchResults.SelectedIndex != -1)
            {
                WeatherLocation srcLoc = (WeatherLocation) searchResults.Items[searchResults.SelectedIndex];
                WeatherRegionForecast dstLoc = new WeatherRegionForecast();

                dstLoc.LocationId = srcLoc.LocationId;
                dstLoc.Description = srcLoc.Description;
                dstLoc.ForecastDays = Convert.ToInt16(forecastDays.Value);
                dstLoc.IsMetric = rbUnitMetric.Checked;
                dstLoc.RadarMap = XoapProvider.Instance.GetRadarUrl(srcLoc.LocationId);
                forecastRegions.Items.Add(dstLoc);
                forecastRegions.SelectedIndex = forecastRegions.FindStringExact(dstLoc.Description);
            }
        }