Inheritance: System.Windows.Controls.Control
        private void RenderMap()
        {
            try
            {
                txtLoading.Visibility = Visibility.Collapsed;
                waitCursor.Visibility = Visibility.Collapsed;

                ESRI.ArcGIS.Client.Bing.TileLayer layer = new TileLayer();
                layer.InitializationFailed += new EventHandler<EventArgs>(layer_InitializationFailed);

                if (ImageryRadioButton.Visibility == System.Windows.Visibility.Collapsed)
                {
                    layer.Token = Configuration.GetNewInstance().Settings.MapServiceKey;
                    layer.LayerStyle = TileLayer.LayerType.AerialWithLabels;
                }
                else if (StreetsRadioButton.Visibility == System.Windows.Visibility.Collapsed)
                {
                    layer.Token = Configuration.GetNewInstance().Settings.MapServiceKey;
                    layer.LayerStyle = TileLayer.LayerType.Road;
                }
                else
                {
                    layer.Token = null;
                }

                GraphicsLayer pointLayer = new GraphicsLayer();
                pointLayer.ID = "pointLayer";

                GraphicsLayer zoneLayer = new GraphicsLayer();
                zoneLayer.ID = "zoneLayer";

                GraphicsLayer textLayer = new GraphicsLayer();
                textLayer.ID = "textLayer";

                ContextMenu menu = new ContextMenu();

                MenuItem mnuMarker = new MenuItem();
                mnuMarker.Header = "Add marker";
                mnuMarker.Click += new RoutedEventHandler(mnuMarker_Click);
                menu.Items.Add(mnuMarker);
                MenuItem mnuRadius = new MenuItem();
                mnuRadius.Header = "Add zone";
                mnuRadius.Click += new RoutedEventHandler(mnuRadius_Click);
                menu.Items.Add(mnuRadius);
                MenuItem mnuText = new MenuItem();
                mnuText.Header = "Add label";
                mnuText.Click += new RoutedEventHandler(mnuText_Click);
                menu.Items.Add(mnuText);
                MenuItem mnuClear = new MenuItem();
                mnuClear.Header = "Remove all layers";
                mnuClear.Click += new RoutedEventHandler(mnuClear_Click);
                menu.Items.Add(mnuClear);

                myMap = new Map();
                myMap.Background = Brushes.White;
                myMap.Height = MapContainer.ActualHeight;
                myMap.Width = MapContainer.ActualWidth;
                myMap.WrapAround = true;
                myMap.ContextMenu = menu;
                myMap.Layers.Add(layer);
                myMap.Layers.Add(pointLayer);
                myMap.Layers.Add(textLayer);
                myMap.Layers.Add(zoneLayer);

                //<esri:ArcGISDynamicMapServiceLayer ID="California" Opacity="0.4" VisibleLayers="8,10"
                //    Url="http://maverick.arcgis.com/ArcGIS/rest/services/California/MapServer" />

                //ArcGISDynamicMapServiceLayer govData = new ArcGISDynamicMapServiceLayer();
                //govData.Url = "http://services.nationalmap.gov/ArcGIS/rest/services/govunits/MapServer";
                ////govData.Url = "http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer";
                //govData.VisibleLayers = new int[] { 19,21,22 };
                //myMap.Layers.Add(govData);

                myMap.MouseMove += new MouseEventHandler(myMap_MouseMove);
                myMap.MouseRightButtonDown += new MouseButtonEventHandler(myMap_MouseRightButtonDown);
                myMap.Loaded += new RoutedEventHandler(myMap_Loaded);

                MapContainer.Children.Add(myMap);

                ESRI.ArcGIS.Client.Behaviors.ConstrainExtentBehavior extentBehavior = new ESRI.ArcGIS.Client.Behaviors.ConstrainExtentBehavior();
                extentBehavior.ConstrainedExtent = new Envelope(new MapPoint(int.MinValue, -12000000), new MapPoint(int.MaxValue, 12000000));
                System.Windows.Interactivity.Interaction.GetBehaviors(myMap).Add(extentBehavior);

                nav = new Navigation();
                nav.Margin = new Thickness(5);
                nav.HorizontalAlignment = HorizontalAlignment.Left;
                nav.VerticalAlignment = VerticalAlignment.Top;
                nav.Map = myMap;
                MapContainer.Children.Add(nav);

                slider = new TimeSlider();
                slider.Name = "slider";
                slider.PlaySpeed = new TimeSpan(0, 0, 1);
                slider.Height = 20;
                slider.TimeMode = TimeMode.CumulativeFromStart;
                slider.MinimumValue = DateTime.Now.Subtract(TimeSpan.FromDays(7)).ToUniversalTime();
                slider.MaximumValue = DateTime.Now.ToUniversalTime();
                slider.Value = new TimeExtent(slider.MinimumValue, slider.MinimumValue.AddHours(2));
                slider.Intervals = TimeSlider.CreateTimeStopsByTimeInterval(new TimeExtent(slider.MinimumValue, slider.MaximumValue), new TimeSpan(0, 2, 0, 0));
                slider.Padding = new Thickness(0, 100, 0, 0);
                slider.ValueChanged += new EventHandler<TimeSlider.ValueChangedEventArgs>(slider_ValueChanged);
                areaSeries.Loaded += new RoutedEventHandler(areaSeries_Loaded);
                stkTimeLapse.Children.Add(slider);

                //grdMapDef.Background = Brushes.Black;
                //myMap.Background = Brushes.Black;
                SetBackgroundColor(defaultBackgroundColor);

                AddLayerList();

                if (MapLoaded != null)
                {
                    MapLoaded(this, false);
                }
            }
            catch (Exception ex)
            {
                //
            }
            finally
            {
            }
        }
Exemplo n.º 2
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:

            #line 8 "..\..\MainWindow.xaml"
                ((Jovian.ClientMap.MainWindow)(target)).Closed += new System.EventHandler(this.Window_Closed);

            #line default
            #line hidden
                return;

            case 4:
                this.LayoutRoot = ((System.Windows.Controls.Grid)(target));
                return;

            case 5:
                this.mainMap = ((ESRI.ArcGIS.Client.Map)(target));

            #line 742 "..\..\MainWindow.xaml"
                this.mainMap.ExtentChanged += new System.EventHandler <ESRI.ArcGIS.Client.ExtentEventArgs>(this.mainMap_ExtentChanged);

            #line default
            #line hidden

            #line 742 "..\..\MainWindow.xaml"
                this.mainMap.MouseClick += new System.EventHandler <ESRI.ArcGIS.Client.Map.MouseEventArgs>(this.mainMap_MouseClick);

            #line default
            #line hidden

            #line 742 "..\..\MainWindow.xaml"
                this.mainMap.MouseMove += new System.Windows.Input.MouseEventHandler(this.mainMap_MouseMove);

            #line default
            #line hidden

            #line 742 "..\..\MainWindow.xaml"
                this.mainMap.TouchDown += new System.EventHandler <System.Windows.Input.TouchEventArgs>(this.mainMap_TouchDown);

            #line default
            #line hidden
                return;

            case 6:
                this.mainNavigation = ((ESRI.ArcGIS.Client.Toolkit.Navigation)(target));
                return;

            case 7:
                this.mainInfoWindow = ((ESRI.ArcGIS.Client.Toolkit.InfoWindow)(target));
                return;

            case 8:
                this.tbPosition = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 9:

            #line 764 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.btnMain_Click);

            #line default
            #line hidden
                return;

            case 10:

            #line 765 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.btnMain_Click);

            #line default
            #line hidden
                return;

            case 11:

            #line 766 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.btnMain_Click);

            #line default
            #line hidden
                return;

            case 12:

            #line 767 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.btnMain_Click);

            #line default
            #line hidden
                return;

            case 13:

            #line 768 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.btnMain_Click);

            #line default
            #line hidden
                return;

            case 14:

            #line 769 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.btnMain_Click);

            #line default
            #line hidden
                return;

            case 15:

            #line 770 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.btnMain_Click);

            #line default
            #line hidden
                return;

            case 16:
                this.btnSwitch = ((System.Windows.Controls.Button)(target));

            #line 773 "..\..\MainWindow.xaml"
                this.btnSwitch.Click += new System.Windows.RoutedEventHandler(this.btnSwitch_Click);

            #line default
            #line hidden
                return;

            case 17:
                this.borMapTools = ((System.Windows.Controls.Border)(target));
                return;

            case 18:

            #line 793 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Tools_Click);

            #line default
            #line hidden
                return;

            case 19:

            #line 794 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Tools_Click);

            #line default
            #line hidden
                return;

            case 20:

            #line 795 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Tools_Click);

            #line default
            #line hidden
                return;

            case 21:

            #line 796 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Tools_Click);

            #line default
            #line hidden
                return;

            case 22:

            #line 797 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Tools_Click);

            #line default
            #line hidden
                return;

            case 23:

            #line 798 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Tools_Click);

            #line default
            #line hidden
                return;

            case 24:

            #line 799 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.UserTools_Click);

            #line default
            #line hidden
                return;

            case 25:
                this.borMapUserTools = ((System.Windows.Controls.Border)(target));
                return;

            case 26:

            #line 821 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.DrawLenOrArea_Click);

            #line default
            #line hidden
                return;

            case 27:

            #line 822 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.DrawLenOrArea_Click);

            #line default
            #line hidden
                return;

            case 28:

            #line 823 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.UserTools_Click);

            #line default
            #line hidden
                return;

            case 29:

            #line 824 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.UserTools_Click);

            #line default
            #line hidden
                return;

            case 30:

            #line 825 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.UserTools_Click);

            #line default
            #line hidden
                return;

            case 31:

            #line 826 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.UserTools_Click);

            #line default
            #line hidden
                return;

            case 32:

            #line 827 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.UserTools_Click);

            #line default
            #line hidden
                return;

            case 33:
                this.canvasParent = ((System.Windows.Controls.Canvas)(target));
                return;

            case 34:
                this.canvasChild1 = ((System.Windows.Controls.Canvas)(target));

            #line 831 "..\..\MainWindow.xaml"
                this.canvasChild1.MouseMove += new System.Windows.Input.MouseEventHandler(this.canvasChild1_MouseMove);

            #line default
            #line hidden

            #line 831 "..\..\MainWindow.xaml"
                this.canvasChild1.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.canvasChild1_MouseLeftButtonDown);

            #line default
            #line hidden

            #line 831 "..\..\MainWindow.xaml"
                this.canvasChild1.MouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(this.canvasChild1_MouseLeftButtonUp);

            #line default
            #line hidden
                return;
            }
            this._contentLoaded = true;
        }