Ejemplo n.º 1
0
 private void mainMap_ExtentChanged(object sender, ExtentEventArgs e)
 {
     //MapPoint mp = PublicParams.pubMainMap.Extent.
     ////this.Title = mp.X.ToString() + "," + mp.Y.ToString();
     //if (mp.X < 121.25)
     //    mp.X = 121.25;
     //if (mp.X > 121.28)
     //    mp.X = 121.28;
     //if (mp.Y < 28.55)
     //    mp.Y = 28.55;
     //if (mp.Y > 28.56)
     //    mp.Y = 28.56;
     //string strCenterJson = string.Format("{{CMD:'00001',CENTX:{0},CENTY:{1},LEVEL:{2}}}", mp.X.ToString(), mp.Y.ToString(), MapMethods.GetLevel(PublicParams.pubMainMap.Resolution));
     //MapMethods.MoveAndZoomMapByJson(JObject.Parse(strCenterJson));
     MapMethods.SendCurrentPosition();
 }
Ejemplo n.º 2
0
        /// <summary>
        /// LPY 2015-9-18 添加
        /// 主要按钮单击事件处理
        /// 连接大屏按钮、回到原点、警情、警车、图层
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnMain_Click(object sender, RoutedEventArgs e)
        {
            Button btnMain = sender as Button;

            switch (btnMain.Tag.ToString())
            {
            case "NotConnected":
                if (ConnectToServer(ref socketBigMapServer, PublicParams.targetIP, PublicParams.targetPort))
                {
                    TCPServer.socketServer    = socketBigMapServer;
                    threadListenToServerByTCP = new Task(TCPServer.ListenToServer);
                    threadListenToServerByTCP.Start();
                    //Timer timer = new Timer(MapMethods.SendHeartBeatToServer, null, 0, 1000 * 60);
                    timerHeartBeat.Tick += MapMethods.SendHeartBeatToServer; timerHeartBeat.Interval = TimeSpan.FromSeconds(60 * 5); timerHeartBeat.Start();
                    PublicParams.CanSend = true;
                    switch (MessageBox.Show("同步大屏地图位置到本地吗?", "地图同步", MessageBoxButton.YesNo, MessageBoxImage.Question))
                    {
                    case MessageBoxResult.No:
                        MapMethods.SendCurrentPosition();
                        break;

                    case MessageBoxResult.Yes:
                        TCPServer.SendCMD("{\"CMD\":\"SYNC\"}");
                        break;

                    default:
                        break;
                    }
                    btnMain.Style = this.FindResource("btnConnected") as Style;
                    btnMain.Tag   = "Connected";
                }
                break;

            case "Connected":
                if (DisconnectToServer(ref socketBigMapServer))
                {
                    TCPServer.socketServer = null;
                    PublicParams.CanSend   = false;
                    btnMain.Style          = this.FindResource("btnNotConnected") as Style;
                    btnMain.Tag            = "NotConnected";
                }
                break;

            case "Origin":    //回到原点按钮
                mainMap.Extent = envelop;
                MapMethods.SendCurrentPosition();
                break;

            case "CaseOn":    //警情关闭
                PublicParams.padCaseSwitch.Visibility = Visibility.Hidden;

                btnMain.Tag = "CaseOff";
                break;

            case "CaseOff":    //警情打开
                PublicParams.padCaseSwitch.Visibility = Visibility.Visible;

                btnMain.Tag = "CaseOn";
                break;

            case "LayersOff":    //图层列表打开
                PublicParams.padLayers.Visibility = Visibility.Visible;
                //PublicParams.padLayers.BeginStoryboard(App.Current.FindResource("StoryboardForPadLayersOpen") as Storyboard);
                btnMain.Tag = "LayersOn";
                break;

            case "LayersOn":    //图层列表关闭
                PublicParams.padLayers.Visibility = Visibility.Hidden;
                //PublicParams.padLayers.BeginStoryboard(App.Current.FindResource("StoryboardForPadLayersClose") as Storyboard);
                btnMain.Tag = "LayersOff";
                break;

            case "OpenedVideosOff":
                PublicParams.padOpenedVideos.BeginStoryboard(App.Current.FindResource("StoryboardForPadOpenedVideosOpen") as Storyboard);
                btnMain.Tag = "OpenedVideosOn";
                break;

            case "OpenedVideosOn":
                PublicParams.padOpenedVideos.BeginStoryboard(App.Current.FindResource("StoryboardForPadOpenedVideosClose") as Storyboard);
                btnMain.Tag = "OpenedVideosOff";
                break;

            case "PoliceCarOff":    //警车图层打开
                MapLayers.ShowHideGraphicsLayerByID(PublicParams.gLayerPoliceCarGPS, true);
                MapMethods.SendSwitchGraphicsLayerByID(PublicParams.gLayerPoliceCarGPS, "1");
                btnMain.Tag = "PoliceCarOn";
                break;

            case "PoliceCarOn":    //警车图层关闭
                MapLayers.ShowHideGraphicsLayerByID(PublicParams.gLayerPoliceCarGPS, false);
                MapMethods.SendSwitchGraphicsLayerByID(PublicParams.gLayerPoliceCarGPS, "0");
                btnMain.Tag = "PoliceCarOff";
                break;

            case "TrafficOff":    //交通-路况和红绿灯
                MapLayers.ShowHideFeatureLayerByID(PublicParams.fLayerTrafficLight, true);
                MapLayers.ShowHideFeatureLayerByID(PublicParams.fLayerRoad, true);
                MapMethods.SendSwitchFeatureLayerByID(PublicParams.fLayerTrafficLight, "1");
                MapMethods.SendSwitchFeatureLayerByID(PublicParams.fLayerRoad, "1");
                btnMain.Style = this.Resources["btnTrafficOn"] as Style;
                btnMain.Tag   = "TrafficOn";
                break;

            case "TrafficOn":
                MapLayers.ShowHideFeatureLayerByID(PublicParams.fLayerTrafficLight, false);
                MapLayers.ShowHideFeatureLayerByID(PublicParams.fLayerRoad, false);
                MapMethods.SendSwitchFeatureLayerByID(PublicParams.fLayerTrafficLight, "0");
                MapMethods.SendSwitchFeatureLayerByID(PublicParams.fLayerRoad, "0");
                btnMain.Style = this.Resources["btnTraffic"] as Style;
                btnMain.Tag   = "TrafficOff";
                break;

            default:
                break;
            }
        }