コード例 #1
0
 /// <summary>
 /// 调取天气方法
 /// </summary>
 private void GetWeatherData()
 {
     Task.Factory.StartNew(() =>
     {
         string now   = "https://api.thinkpage.cn/v3/weather/now.json?key={0}&location={1}&language=zh-Hans&unit={2}";                  //实时天气
         string daily = "https://api.thinkpage.cn/v3/weather/daily.json?key={0}&location={1}&language=zh-Hans&unit={2}&start=0&days=5"; //历史天气
         now          = String.Format(now, Key, City, DegreeFormat.ToString());
         daily        = String.Format(daily, Key, City, DegreeFormat.ToString());
         Now          = WeatherManager.Instance.GetWeatherDataNow(now, City);
         DailyModel   = WeatherManager.Instance.GetWeatherDataDaily(daily, City);
         WeatherManager.Instance.WriteWeatherHistory(Now, DailyModel);
         DispatcherHelper.CheckBeginInvokeOnUI(
             () =>
         {
             if (Now != null)
             {
                 ResultCity    = Now.Results[0].Location.Name;
                 ResultDegree  = Now.Results[0].Now.Temperature;
                 ResultWeather = Now.Results[0].Now.Text;
                 IconPath      =
                     new Uri(
                         String.Format(AppDomain.CurrentDomain.BaseDirectory + "/Resources/MainWeatherImages/{0}.png",
                                       Now.Results[0].Now.Code), UriKind.RelativeOrAbsolute);
                 WeatherIcon = new BitmapImage(IconPath);
             }
         });
     }).ContinueWith(result =>
     {
         if (result.IsFaulted)
         {
             LogWriter.Instance.Error(result.Exception);
         }
     });
 }
コード例 #2
0
        /// <summary>
        /// 回调需要查询的城市
        /// </summary>
        /// <param name="searchResult"></param>
        /// <param name="degreeFormat"></param>
        private void SearchCity(string searchResult, string degreeFormat)
        {
            City         = searchResult;
            DegreeFormat = (Degree)Enum.Parse(typeof(Degree), degreeFormat);
            GetWeatherData();
            WeatherModel model = new WeatherModel();

            model.City         = City;
            model.DegreeFormat = DegreeFormat.ToString();
            DataManager.Instance.UpdateTables(model);
        }
コード例 #3
0
 private void LoadedChecked(Grid element)
 {
     foreach (var item in element.Children)
     {
         if (item is RadioButton)
         {
             if ((item as RadioButton).Content.ToString().ToLower().Contains(DegreeFormat.ToString()))
             {
                 (item as RadioButton).Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ffffff"));
             }
         }
     }
 }
コード例 #4
0
        public void TheXTest()
        {
            const string login    = "******";
            const string password = "******";
            string       login1   = "guest";

            driver = new FirefoxDriver();

            driver.Navigate().GoToUrl("http://91.143.44.249/sovzond/portal/login.aspx");
            driver.FindElement(By.Id(login)).SendKeys(login1);
            driver.FindElement(By.Id(password)).SendKeys(login1);
            driver.FindElement(By.Id("cmdLogin")).Click();


            driver.FindElement(By.ClassName("gotoCoordsButton")).Click();
            driver.FindElement(By.Id("dijit_form_NumberTextBox_0")).SendKeys("60");
            driver.FindElement(By.Id("dijit_form_NumberTextBox_1")).SendKeys("50");
            driver.FindElement(By.Id("dijit_form_NumberTextBox_2")).SendKeys("50");
            driver.FindElement(By.Id("dijit_form_NumberTextBox_3")).SendKeys("69");
            driver.FindElement(By.Id("dijit_form_NumberTextBox_4")).SendKeys("59");
            driver.FindElement(By.Id("dijit_form_NumberTextBox_5")).SendKeys("0");
            Click();



            //driver.FindElement(By.Id("OpenLayers_Layer_Vector_123_svgRoot")).
            // IMouse.MouseMove();

            IJavaScriptExecutor js = driver as IJavaScriptExecutor;

            string point = (string)js.ExecuteScript("{var projWGS84 = new OpenLayers.Projection('EPSG:4326');" +
                                                    "var proj900913 = new OpenLayers.Projection('EPSG:900913'); " +
                                                    "var point1 = window.portal.stdmap.map.getCenter(); " +
                                                    "var point2 = point1.transform(proj900913, projWGS84); " +
                                                    "return point2.toString()}");
            DegreeFormat df = new DegreeFormat(60, 49, 26);
        }
コード例 #5
0
        public void TheXTest()
        {
            const string login = "******";
            const string password = "******";
            string login1 = "guest";
            driver = new FirefoxDriver();

            driver.Navigate().GoToUrl("http://91.143.44.249/sovzond/portal/login.aspx");
            driver.FindElement(By.Id(login)).SendKeys(login1);
            driver.FindElement(By.Id(password)).SendKeys(login1);
            driver.FindElement(By.Id("cmdLogin")).Click();


            driver.FindElement(By.ClassName("gotoCoordsButton")).Click();
            driver.FindElement(By.Id("dijit_form_NumberTextBox_0")).SendKeys("60");
            driver.FindElement(By.Id("dijit_form_NumberTextBox_1")).SendKeys("50");
            driver.FindElement(By.Id("dijit_form_NumberTextBox_2")).SendKeys("50");
            driver.FindElement(By.Id("dijit_form_NumberTextBox_3")).SendKeys("69");
            driver.FindElement(By.Id("dijit_form_NumberTextBox_4")).SendKeys("59");
            driver.FindElement(By.Id("dijit_form_NumberTextBox_5")).SendKeys("0");
            Click();



            //driver.FindElement(By.Id("OpenLayers_Layer_Vector_123_svgRoot")).
           // IMouse.MouseMove();

            IJavaScriptExecutor js = driver as IJavaScriptExecutor;
         
            string point = (string)js.ExecuteScript("{var projWGS84 = new OpenLayers.Projection('EPSG:4326');" +
           "var proj900913 = new OpenLayers.Projection('EPSG:900913'); " +
           "var point1 = window.portal.stdmap.map.getCenter(); " +
           "var point2 = point1.transform(proj900913, projWGS84); " +
           "return point2.toString()}");
            DegreeFormat df = new DegreeFormat(60, 49, 26);


        }
コード例 #6
0
 /// <summary>
 /// 查询城市
 /// </summary>
 /// <param name="searchResult"></param>
 private void SearchCity(string searchResult)
 {
     SearchResult(searchResult, DegreeFormat.ToString());
 }