/// <summary> /// //台风列表初始化 /// </summary> private void typhoonlistInitial() { string reqMsg = "typhoon Time " + (DateTime.Now.Year - 2).ToString() + " Time 2014-01-01-00 2014-12-31-24"; TyphoonRequest request = new TyphoonRequest(reqMsg); typhoonList = TyphServer.GetTyphoonData(request); if (typhoonList == null) { MessageBox.Show("与服务器连接异常,没有找到所需的数据"); btnPlay.IsEnabled = false; return; } for (int i = 0; i < typhoonList.Count; i++) { Label temp = new Label(); temp.Content = typhoonList[i].header.typhName; lstboxTyphoons.Items.Add(temp); } cTyphoon = typhoonList[0]; typhoonInitial(); }
/// <summary> /// //响应搜索台风按钮的事件 /// </summary> private void Search_Click(object sender, RoutedEventArgs e) { canvasShow.Children.Clear(); string reqMsg = MySearchControl.GetRequest(); if (reqMsg == "typhoon Wrong") { MessageBox.Show("查询请求不正确"); btnPlay.IsEnabled = false; return; } else if (reqMsg.Contains("search")) { string timeText = reqMsg.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries)[1]; DateTime datetime = DateTime.Parse(timeText); if (cTyphoon.POINTSNUM != 0) { typhoonInitial(); pFTDQ = cTyphoon.FullTimeDomainInquiry(datetime); if (pFTDQ == null) { MessageBox.Show("查询过程出错", "全时域查询结果", MessageBoxButton.OK, MessageBoxImage.Error); } else { MessageBox.Show(datetime.ToString("yyyy-MM-dd HH:mm:ss") + ",台风位于(" + pFTDQ.latitude.ToString("F4") + "," + pFTDQ.longitude.ToString("F4") + ")", "全时域查询结果", MessageBoxButton.OK, MessageBoxImage.Information); Point point0 = new Point(); point0.X = (pFTDQ.longitude - minLong) / (maxLong - minLong) * canvasShow.Width; point0.Y = canvasShow.Height - (pFTDQ.latitude - minLat) / (maxLat - minLat) * canvasShow.Height; Ellipse tp = new Ellipse(); tp.Height = 10 / scale; tp.Width = 10 / scale; tp.Fill = Brushes.Red; tp.Stroke = Brushes.Black; tp.StrokeThickness = 1 / scale; Canvas.SetLeft(tp, point0.X - 5 / scale); Canvas.SetTop(tp, point0.Y - 5 / scale); Canvas.SetZIndex(tp, 2); canvasShow.Children.Add(tp); } } return; } TyphoonRequest request = new TyphoonRequest(reqMsg); ctyphoonlist = TyphServer.GetTyphoonData(request); lstBoxTyphoons.Items.Clear(); if (ctyphoonlist == null) { MessageBox.Show("没有符合查询条件的台风"); btnPlay.IsEnabled = false; return; } for (int i = 0; i < ctyphoonlist.Count; i++) { Label temp = new Label(); temp.Content = ctyphoonlist[i].header.typhName; lstBoxTyphoons.Items.Add(temp); } cTyphoon = ctyphoonlist[0]; btnPlay.IsEnabled = true; typhoonInitial(); }