public MainViewModel(WpfMap map)
        {
            this.map      = map;
            map.MapClick += WpfMap_MapClick;
            menuItems     = new Collection <object>(MenuItemHelper.GetMenus());

            LoadMessageHandlers();
            SetToolbarMenuItems();

            Messenger.Default.Register <ChartMessage>(this, (m) => ChartSelectedItem = new ChartSelectedItem(string.Empty, null));
            Messenger.Default.Register <MenuItemMessage>(this, "ShowOpacityPanel", (m) => ShowOpacityPanel = true);
            Messenger.Default.Register <MenuItemMessage>(this, HandleMenuItemMessage);
            Messenger.Default.Register <ToolBarMessage>(this, HandleToolBarMessage);
            Messenger.Default.Register <ChartMessage>(this, "LoadCharts", HandleLoadChartMessage);
            Messenger.Default.Register <ChartMessage>(this, "UnloadCharts", HandleUnloadChartMessage);
            Messenger.Default.Register <ChartSelectedItemMessage>(this, HandleChartSelectedItemMessage);
            Messenger.Default.Register <SafeWaterDepthSettingMessage>(this, HandleSafeWaterDepthMessage);

            map.MapUnit      = GeographyUnit.Meter;
            map.ZoomLevelSet = new ThinkGeoCloudMapsZoomLevelSet();

            // Please input your ThinkGeo Cloud Client ID / Client Secret to enable the background map.
            //ThinkGeoCloudRasterMapsOverlay baseOverlay = new ThinkGeoCloudRasterMapsOverlay("ThinkGeo Cloud Client ID", "ThinkGeo Cloud Client Secret");
            //map.Overlays.Add(ThinkGeoCloudMapsOverlayName, baseOverlay);

            InitBoundingBoxPreviewOverlay(map);
        }
        public void SynchronizeState(WpfMap currentMap)
        {
            viewModel.SysnchCurrentZoomLevels(currentMap);
            var panZoom = currentMap.MapTools.OfType <SwitcherPanZoomBarMapTool>().FirstOrDefault();

            if (panZoom == null)
            {
                return;
            }

            panZoom.DisableModeChangedEvent = true;
            if (panZoom.SwitcherMode == SwitcherMode.None &&
                currentMap.ExtentOverlay != null &&
                !currentMap.ExtentOverlay.IsEnabled())
            {
                panZoom.SwitcherMode = SwitcherMode.None;
            }
            else if (panZoom.SwitcherMode != SwitcherMode.Identify)
            {
                if (CurrentOverlays.ExtentOverlay.LeftClickDragKey == System.Windows.Forms.Keys.None)
                {
                    panZoom.SwitcherMode = SwitcherMode.TrackZoom;
                }
                else
                {
                    panZoom.SwitcherMode = SwitcherMode.Pan;
                }
            }
            panZoom.DisableModeChangedEvent = false;
        }
 public EditableRectangleOverlayViewModel(WpfMap wpfMap)
 {
     _wpfMap = wpfMap;
     AddValidationRules(
         new ValidationRule<EditableRectangleOverlayViewModel>
         {
             PropertyName = "North",
             Description = "Must be between -90 and +90 and be greater than South",
             IsRuleValid = (target, rule) => target.North >= -90 && target.North <= 90 && target.North > target.South,
         },
         new ValidationRule<EditableRectangleOverlayViewModel>
         {
             PropertyName = "South",
             Description = "Must be between -90 and +90 and be less than North",
             IsRuleValid = (target, rule) => target.South >= -90 && target.South <= 90 && target.North > target.South,
         },
         new ValidationRule<EditableRectangleOverlayViewModel>
         {
             PropertyName = "East",
             Description = "Must be between -180 and +180 and be greater than West",
             IsRuleValid = (target, rule) => target.East >= -180 && target.East <= 180 && target.East > target.West,
         },
         new ValidationRule<EditableRectangleOverlayViewModel>
         {
             PropertyName = "West",
             Description = "Must be between -180 and +180 and be less than East",
             IsRuleValid = (target, rule) => target.West >= -180 && target.West <= 180 && target.East > target.West,
         });
 }
Ejemplo n.º 4
0
 /// <summary> Create the route layer. </summary>
 ///
 /// <param name="map">Map control to attach to.</param>
 /// <param name="xRouteUrl"> URL of xRoute server. </param>
 /// <param name="user"> User name. </param>
 /// <param name="password"> Password. </param>
 public RouteLayer(WpfMap map, string xRouteUrl, string user, string password) : base("Route")
 {
     Map          = map;
     xRouteClient = Route.CreateXRouteClient(xRouteUrl, user, password);
     WayPoint.WayPointMouseRightButtonDown += ShowWayPointContextMenu;
     Reset();
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Tries to create a Bing layer with specified key. Throws an exception if the key is wrong.
        /// </summary>
        /// <param name="wpfMap">WpfMap object to which the Bing layer will be added.</param>
        /// <param name="bingKey">Key for the Bing map provider.</param>
        public void CreateBingLayer(WpfMap wpfMap, string bingKey)
        {
            if (string.IsNullOrEmpty(bingKey))
            {
                // Throws an exception if no valid Bing key was specified.
                throw new Exception("Please enter a valid Microsoft Bing access key first!");
            }

            #region doc:Bing

            // Insert on top of xServer background.
            var idx = wpfMap.Layers.IndexOf(wpfMap.Layers["Background"]) + 1;

            try
            {
                // Adds a new layer called "Bing" to the WpfMap.
                wpfMap.AddBingLayer("Bing", idx, bingKey, BingImagerySet.Aerial, BingMapVersion.v1, true, .8,
                                    ResourceHelper.LoadBitmapFromResource("Ptv.XServer.Controls.Map;component/Resources/Aerials.png"));
            }
            catch (WebException we)
            {
                if (((HttpWebResponse)(we.Response)).StatusCode == HttpStatusCode.Unauthorized)
                {
                    // Throws an exception if authorization failed.
                    throw new Exception("The entered Microsoft Bing access key seems to be wrong!");
                }
            }
            #endregion // doc:Bing
        }
        private static byte[] GetCroppedMapPopupOverlayPreviewImage(WpfMap wpfMap, Int32Rect drawingRect)
        {
            Canvas rootCanvas = wpfMap.ToolsGrid.Parent as Canvas;

            byte[] imageBytes = null;
            if (rootCanvas != null)
            {
                Canvas eventCanvas = rootCanvas.FindName("EventCanvas") as Canvas;
                if (eventCanvas != null)
                {
                    RenderTargetBitmap imageSource = new RenderTargetBitmap((int)wpfMap.RenderSize.Width, (int)wpfMap.RenderSize.Height, 96, 96, PixelFormats.Pbgra32);

                    Canvas popupCanvas = eventCanvas.FindName("PopupCanvas") as Canvas;
                    if (popupCanvas != null)
                    {
                        imageSource.Render(popupCanvas);
                    }

                    CroppedBitmap    croppedSource = new CroppedBitmap(imageSource, drawingRect);
                    PngBitmapEncoder encoder       = new PngBitmapEncoder();
                    encoder.Frames.Add(BitmapFrame.Create(croppedSource));
                    using (var streamSource = new MemoryStream())
                    {
                        encoder.Save(streamSource);
                        imageBytes = streamSource.ToArray();
                    }
                }
            }

            return(imageBytes);
        }
Ejemplo n.º 7
0
        public override void Handle(Window owner, WpfMap map, MenuItemMessage message)
        {
            SymbolsEditionWindow window = new SymbolsEditionWindow();

            window.Owner = owner;
            window.ShowDialog();
        }
Ejemplo n.º 8
0
        /// <summary> <para>Adds a shape layer with selection logic to the map. The shapes are managed by SharpMap.</para>
        /// <para>See the <conceptualLink target="427ab62e-f02d-4e92-9c26-31e0f89d49c5"/> topic for an example.</para> </summary>
        /// <param name="wpfMap">The map to add the layer to.</param>
        /// <param name="name">The name of the layer.</param>
        /// <param name="shapeFilePath">The full qualified path to the shape file.</param>
        /// <param name="idx">The index where to add the layer in the hierarchy.</param>
        /// <param name="isBaseMapLayer">Specifies if the layer is a base map layer.</param>
        /// <param name="opacity">The initial opacity.</param>
        /// <param name="icon">The icon used in the layers control.</param>
        #region doc:AddShapeLayer method
        public static void AddShapeLayer(this WpfMap wpfMap, string name, string shapeFilePath, int idx, bool isBaseMapLayer, double opacity, System.Windows.Media.Imaging.BitmapImage icon)
        {
            // the collection of selected elements
            var selectedRegions = new System.Collections.ObjectModel.ObservableCollection <System.Windows.Media.Geometry>();

            // add a layer which uses SharpMap (by using SharpMapTiledProvider and ShapeSelectionCanvas)
            #region doc:create TiledLayer
            var sharpMapLayer = new TiledLayer(name)
            {
                // Create canvas categories. First one for the ordinary tile content. Second one for the selection canvas.
                CanvasCategories = new[] { CanvasCategory.Content, CanvasCategory.SelectedObjects },
                // Create delegates for the content canvas and the selection canvas.
                CanvasFactories = new BaseLayer.CanvasFactoryDelegate[]
                {
                    m => new TiledCanvas(m, new SharpMapTiledProvider(shapeFilePath))
                    {
                        IsTransparentLayer = true
                    },
                    m => new ShapeSelectionCanvas(m, shapeFilePath, selectedRegions)
                },
                // Set some more initial values...
                Opacity        = opacity,
                IsBaseMapLayer = isBaseMapLayer,
                Icon           = icon
            };
            #endregion // doc:create TiledLayer

            wpfMap.Layers.Insert(idx, sharpMapLayer);
        }
Ejemplo n.º 9
0
        public override void Handle(Window owner, WpfMap map, MenuItemMessage message)
        {
            var window = new SymbolsCreatingWindow();

            window.Owner = owner;
            window.ShowDialog();
        }
        private void CurrentMap_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            WpfMap wpfMap         = (WpfMap)sender;
            bool   boxIsOffRight  = (Margin.Left + Width) > wpfMap.ActualWidth;
            bool   boxIsOffBottom = (Margin.Top + Height) > wpfMap.ActualHeight;

            if (boxIsOffRight || boxIsOffBottom)
            {
                double leftMargin = Margin.Left;
                double topMargin  = Margin.Top;
                if (boxIsOffRight)
                {
                    leftMargin = wpfMap.ActualWidth - Width;
                    if (leftMargin < 0)
                    {
                        leftMargin = 0;
                        Width      = wpfMap.ActualWidth;
                    }
                }
                if (boxIsOffBottom)
                {
                    topMargin = wpfMap.ActualHeight - Height;
                    if (topMargin < 0)
                    {
                        topMargin = 0;
                        Height    = wpfMap.ActualHeight;
                    }
                }
                Margin = new Thickness(leftMargin, topMargin, 0, 0);
            }
        }
        public override void Handle(Window owner, WpfMap map, MenuItemMessage message)
        {
            var window = new SafeWaterDepthSettingsWindow();

            window.Owner = owner;
            window.ShowDialog();
        }
        public MapModel(WpfMap wpfMap)
        {
            mapControl = wpfMap;

            InitializeMap();
            InitializeEvents();
        }
        public override void Handle(Window owner, WpfMap map, MenuItemMessage message)
        {
            var window = new BuildingIndexWindow();

            window.Owner = owner;
            window.ShowDialog();
        }
Ejemplo n.º 14
0
        public MapModel(WpfMap wpfMap)
        {
            mapControl = wpfMap;

            InitializeMap();
            InitializeEvents();
        }
Ejemplo n.º 15
0
        private void AddShapeLayer_OnClick(object sender, RoutedEventArgs e)
        {
            var ofd = new OpenFileDialog();

            ofd.Filter = @"Shapefiles (*.shp)|*.shp";
            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                var ds  = new SharpMap.Data.Providers.ShapeFile(ofd.FileName);
                var lay = new SharpMap.Layers.VectorLayer(System.IO.Path.GetFileNameWithoutExtension(ofd.FileName), ds);
                if (ds.CoordinateSystem != null)
                {
                    GeoAPI.CoordinateSystems.Transformations.ICoordinateTransformationFactory fact =
                        new ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory();

                    lay.CoordinateTransformation = fact.CreateFromCoordinateSystems(ds.CoordinateSystem,
                                                                                    ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WebMercator);
                    lay.ReverseCoordinateTransformation = fact.CreateFromCoordinateSystems(ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WebMercator,
                                                                                           ds.CoordinateSystem);
                }
                WpfMap.MapLayers.Add(lay);
                if (WpfMap.MapLayers.Count == 1)
                {
                    Envelope env = lay.Envelope;
                    WpfMap.ZoomToEnvelope(env);
                }
            }
            e.Handled = true;
        }
Ejemplo n.º 16
0
        /// <summary> Extension method which adds a Microsoft Bing layer to the map. </summary>
        /// <param name="wpfMap"> The map to add the layer to. </param>
        /// <param name="name"> The name of the layer. </param>
        /// <param name="idx"> The index of the layer in the layer hierarchy. </param>
        /// <param name="bingKey"> The Microsoft Bing key to use. </param>
        /// <param name="set"> The imagery set to be used. </param>
        /// <param name="version"> The Microsoft Bing version. </param>
        /// <param name="isBaseMapLayer"> Specifies if the added layer should act as a base layer. </param>
        /// <param name="opacity"> The initial opacity of the layer. </param>
        /// <param name="icon"> The icon of the layer used within the layer gadget. </param>
        /// <param name="copyrightImagePanel"> The panel where the bing logo should be added. </param>
        public static void AddBingLayer(this WpfMap wpfMap, string name, int idx, string bingKey, BingImagerySet set, BingMapVersion version,
                                        bool isBaseMapLayer, double opacity, BitmapImage icon, Panel copyrightImagePanel)
        {
            var metaInfo = new BingMetaInfo(set, version, bingKey);

            // add a bing aerial layer
            var bingLayer = new TiledLayer(name)
            {
                TiledProvider  = new BingTiledProvider(metaInfo),
                IsBaseMapLayer = isBaseMapLayer,
                Opacity        = opacity,
                Icon           = icon
            };

            wpfMap.Layers.Insert(idx, bingLayer);

            try
            {
                var bingLogo = new Image
                {
                    Stretch             = Stretch.None,
                    HorizontalAlignment = HorizontalAlignment.Left,
                    Source = new BitmapImage(new Uri(metaInfo.LogoUri))
                };

                copyrightImagePanel.Children.Add(bingLogo);
                copyrightImagePanel.Visibility = Visibility.Visible;
            }
            catch (Exception)
            {
                //Just silently catch exceptions if the image cannot be displayed!
            }
        }
        public Form1()
        {
            InitializeComponent();

            // Initialize the WpfMap object and add it to the ElementHost.
            map = new WpfMap();
            elementHost1.Child = map;
        }
        public void SynchronizeState(WpfMap currentMap)
        {
            var measureOverlay = viewModel.MeasureOverlay;

            if (measureOverlay != null)
            {
                switch (measureOverlay.TrackMode)
                {
                case TrackMode.Rectangle:
                    rectangleMeasure.IsChecked = true;
                    break;

                case TrackMode.Square:
                    squareMeasure.IsChecked = true;
                    break;

                case TrackMode.Ellipse:
                    ellipseMeasure.IsChecked = true;
                    break;

                case TrackMode.Circle:
                    circleMeasure.IsChecked = true;
                    break;

                case TrackMode.Polygon:
                    polygonMeasure.IsChecked = true;
                    break;

                case TrackMode.Line:
                    lineMeasure.IsChecked = true;
                    break;

                case TrackMode.Custom:
                    selectMeasure.IsChecked = true;
                    break;

                case TrackMode.None:
                    TurnOffRadioButtons();
                    break;
                }

                if (measureOverlay.MeasureCustomeMode == MeasureCustomeMode.Move &&
                    measureOverlay.TrackMode == TrackMode.Custom)
                {
                    TurnOffRadioButtons();
                    move.IsChecked = true;
                }

                viewModel.SelectedPolygonTrackMode = measureOverlay.PolygonTrackMode;
                if (measureOverlay.ShapeLayer.MapShapes.Count > 0 && currentMap.ActualWidth > 0 && currentMap.ActualHeight > 0)
                {
                    currentMap.Refresh(measureOverlay);
                }
                DataContext = null;
                DataContext = viewModel;
                viewModel.UpdateStylePreview();
            }
        }
Ejemplo n.º 19
0
        /// <summary> Initializes a new instance of the <see cref="RoutingUseCase"/> class. Adds two way points and calculates the route. </summary>
        /// <param name="wpfMap"> The map on which the route calculation is to be displayed. </param>
        public RoutingUseCase(WpfMap wpfMap)
        {
            InitializeComponent();

            // save the map
            _wpfMap = wpfMap;

            #region doc:register mouse handler
            _wpfMap.MouseRightButtonDown += wpfMap_MapMouseRightButtonDown;
            ContextMenuService.SetContextMenu(_wpfMap, cm);
            #endregion //doc:register mouse handler

            #region doc:Add ShapeLayers
            routingLayer = new ShapeLayer("Routing")
            {
                SpatialReferenceId = "PTV_MERCATOR"
            };
            wayPointLayer = new ShapeLayer("WayPoints")
            {
                SpatialReferenceId = "PTV_MERCATOR"
            };

            wayPoints.CollectionChanged += points_CollectionChanged;

            // add before labels (if available)
            var idx = _wpfMap.Layers.IndexOf(_wpfMap.Layers["Labels"]);
            if (idx < 0)
            {
                _wpfMap.Layers.Add(routingLayer);
                _wpfMap.Layers.Add(wayPointLayer);
            }
            else
            {
                _wpfMap.Layers.Insert(idx, routingLayer);
                _wpfMap.Layers.Add(wayPointLayer);
            }
            #endregion //doc:Add ShapeLayers

            if (XServerUrl.IsDecartaBackend(XServerUrl.Complete(Properties.Settings.Default.XUrl, "XRoute")))
            {
                return;
            }

            // insert way points of Karlsruhe-Berlin
            clickPoint = new PlainPoint {
                x = 934448.8, y = 6269219.7
            };
            SetStart_Click(null, null);
            clickPoint = new PlainPoint {
                x = 1491097.3, y = 6888163.5
            };
            SetEnd_Click(null, null);

            // calculate the route
            CalculateRoute();
        }
        /// <summary>
        /// Constructs a new Tooltips plugin
        /// </summary>
        /// <param name="map">The map control</param>
        /// <param name="delay">The delay for displaying tool tips</param>
        public BaseMapToolTips(WpfMap map, int delay = 500)
        {
            this.map       = map;
            map.MouseMove += Map_MouseMove;

            toolTipTimer = new DispatcherTimer {
                Interval = new TimeSpan(0, 0, 0, 0, delay)
            };
            toolTipTimer.Tick += toolTipTimer_Tick;
        }
Ejemplo n.º 21
0
        public override void Handle(Window owner, WpfMap map, MenuItemMessage message)
        {
            switch (message.MenuItem.Action)
            {
            case "contourlabel":
                Globals.IsDepthContourTextVisible = message.MenuItem.IsChecked;
                break;

            case "soundinglabel":
                Globals.IsSoundingTextVisible = message.MenuItem.IsChecked;
                break;

            case "lightdescription":
                Globals.IsLightDescriptionVisible = message.MenuItem.IsChecked;
                break;

            case "textlabel":
                if (message.MenuItem.IsChecked)
                {
                    Globals.SymbolTextDisplayMode = NauticalChartsSymbolTextDisplayMode.English;
                }
                break;

            case "nationallanguagelabel":

                if (message.MenuItem.IsChecked)
                {
                    Globals.SymbolTextDisplayMode = NauticalChartsSymbolTextDisplayMode.NationalLanguage;
                }
                break;

            case "notextlabel":

                if (message.MenuItem.IsChecked)
                {
                    Globals.SymbolTextDisplayMode = NauticalChartsSymbolTextDisplayMode.None;
                }
                break;
            }
            if (map.Overlays.Contains(chartsOverlayName))
            {
                LayerOverlay chartsOverlay = map.Overlays[chartsOverlayName] as LayerOverlay;

                foreach (var item in chartsOverlay.Layers)
                {
                    NauticalChartsFeatureLayer nauticalChartsFeatureLayer = item as NauticalChartsFeatureLayer;
                    nauticalChartsFeatureLayer.IsDepthContourTextVisible = Globals.IsDepthContourTextVisible;
                    nauticalChartsFeatureLayer.IsLightDescriptionVisible = Globals.IsLightDescriptionVisible;
                    nauticalChartsFeatureLayer.IsSoundingTextVisible     = Globals.IsSoundingTextVisible;
                    nauticalChartsFeatureLayer.SymbolTextDisplayMode     = Globals.SymbolTextDisplayMode;
                }

                map.Refresh();
            }
        }
        private static InMemoryFeatureLayer GetInMemoryFeatureLayerByFeature(WpfMap wpfMap, Feature feature)
        {
            var result = (from featureLayer in
                          (from overlay in wpfMap.Overlays.OfType <LayerOverlay>()
                           from layer in overlay.Layers.OfType <InMemoryFeatureLayer>()
                           select layer).Concat(CollectFeatureLayersInInteractiveOverlay(wpfMap))
                          where featureLayer.InternalFeatures.Contains(feature)
                          select featureLayer).FirstOrDefault();

            return(result);
        }
Ejemplo n.º 23
0
 public void ChangeMapProfile(WpfMap wpfMap, string mapProfile)
 {
     if (mapProfile.Equals("default"))
     {
         Reset(wpfMap);
     }
     else
     {
         wpfMap.XMapStyle = mapProfile;
     }
 }
        private void InitBoundingBoxPreviewOverlay(WpfMap map)
        {
            boundingBoxPreviewLayer = new InMemoryFeatureLayer();
            boundingBoxPreviewLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle    = AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Transparent, GeoColor.StandardColors.Blue);
            boundingBoxPreviewLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            LayerOverlay boundingBoxPreviewOverlay = new LayerOverlay();

            boundingBoxPreviewOverlay.Layers.Add(boundingBoxPreviewLayer);
            map.Overlays.Add(boundingBoxPreviewOverlayName, boundingBoxPreviewOverlay);
        }
Ejemplo n.º 25
0
        /// <summary> Removes the layer containing the geocoding results from the LayerCollection. </summary>
        /// <param name="wpfMap"> The map which contains the layer. </param>
        public void Remove(WpfMap wpfMap)
        {
            ContentLayer.Shapes.Clear();

            ContentLayer?.Refresh();

            #region doc:remove result layer

            wpfMap?.Layers.Remove(ContentLayer);

            ContentLayer = null;
            #endregion
        }
Ejemplo n.º 26
0
        private void BgOSM_OnClick(object sender, RoutedEventArgs e)
        {
            WpfMap.BackgroundLayer = new SharpMap.Layers.TileAsyncLayer(BruTile.Predefined.KnownTileSources.Create(), "OSM");

            foreach (var menuItem in Menu.Items.OfType <MenuItem>())
            {
                menuItem.IsChecked = false;
            }
            BgOsm.IsChecked = true;

            WpfMap.ZoomToExtents();
            e.Handled = true;
        }
Ejemplo n.º 27
0
 /// <summary> Removes a geocoding results layer from the map. </summary>
 /// <param name="wpfMap"> The map. </param>
 /// <param name="singleField"> True if the single field geocoder should be removed, false if the multi field geocoder should be removed. </param>
 public void Remove(WpfMap wpfMap, bool singleField)
 {
     if (singleField)
     {
         sfg?.Remove(wpfMap);
         sfg = null;
     }
     else
     {
         mfg?.Remove(wpfMap);
         mfg = null;
     }
 }
Ejemplo n.º 28
0
        private void BgMapQuest_Click(object sender, RoutedEventArgs e)
        {
            WpfMap.BackgroundLayer = new SharpMap.Layers.TileAsyncLayer(
                KnownTileSources.Create(KnownTileSource.MapQuestAerial), "MapQuest");

            foreach (var menuItem in Menu.Items.OfType <MenuItem>())
            {
                menuItem.IsChecked = false;
            }
            BgMapQuest.IsChecked = true;

            WpfMap.ZoomToExtents();
            e.Handled = true;
        }
Ejemplo n.º 29
0
        protected override void RefreshCore(GisEditorWpfMap currentMap, RefreshArgs refreshArgs)
        {
            if (lastMap != null && lastMap != currentMap)
            {
                var boundingBoxSelectTool = lastMap.MapTools.OfType <BoundingBoxSelectorMapTool>().FirstOrDefault();
                if (boundingBoxSelectTool != null)
                {
                    lastMap.MapTools.Remove(boundingBoxSelectTool);
                    currentMap.MapTools.Add(boundingBoxSelectTool);
                }
            }

            lastMap = currentMap;
        }
Ejemplo n.º 30
0
 public override void Handle(Window owner, WpfMap map, MenuItemMessage message)
 {
     Globals.IsMetaObjectsVisible = message.MenuItem.IsChecked;
     if (map.Overlays.Contains(chartsOverlayName))
     {
         LayerOverlay chartsOverlay = map.Overlays[chartsOverlayName] as LayerOverlay;
         foreach (var item in chartsOverlay.Layers)
         {
             NauticalChartsFeatureLayer maritimeFeatureLayer = item as NauticalChartsFeatureLayer;
             maritimeFeatureLayer.IsMetaObjectsVisible = Globals.IsMetaObjectsVisible;
         }
         map.Refresh();
     }
 }
        public void SysnchCurrentZoomLevels(WpfMap currentMap)
        {
            CurrentZoomLevels.Clear();
            List <ZoomLevel> zoomLevels = currentMap.ZoomLevelSet.CustomZoomLevels.Where(c => !(c is PreciseZoomLevel)).ToList();

            for (int i = 0; i < zoomLevels.Count; i++)
            {
                string number = String.Format(CultureInfo.InvariantCulture, "Level {0:D2} - Scale 1:{1:N0}", i + 1, zoomLevels[i].Scale);
                ZoomLevelItemViewModel currentLevel = new ZoomLevelItemViewModel();
                currentLevel.Name       = number;
                currentLevel.ScaleIndex = i;
                CurrentZoomLevels.Add(currentLevel);
            }
        }
Ejemplo n.º 32
0
 public override void Handle(Window owner, WpfMap map, MenuItemMessage message)
 {
     Globals.CurrentDrawingMode = (NauticalChartsDrawingMode)Enum.Parse(typeof(NauticalChartsDrawingMode), message.MenuItem.Action, true);
     if (map.Overlays.Contains(chartsOverlayName))
     {
         LayerOverlay chartsOverlay = map.Overlays[chartsOverlayName] as LayerOverlay;
         foreach (var item in chartsOverlay.Layers)
         {
             NauticalChartsFeatureLayer maritimeFeatureLayer = item as NauticalChartsFeatureLayer;
             maritimeFeatureLayer.DrawingMode = Globals.CurrentDrawingMode;
         }
         map.Refresh();
     }
 }
        void ViewLoaded()
        {
            if (Designer.IsInDesignMode) return;

            _wpfMap = ((MainView)Globals.ViewAwareStatusService.View).MapView.WpfMap;

            CreateMouseEventStreams();
            SubscribeToMouseEventStreams();
            
            EditableRectangleOverlayViewModel = new EditableRectangleOverlayViewModel(_wpfMap);
            EditablePolygonOverlayViewModel = new EditablePolygonOverlayViewModel(_wpfMap);
            //SoundSpeedProfileViewModel = new SoundSpeedProfileViewModel(((MainView)_viewAwareStatus.View).MapView.SoundSpeedProfileView);
            MapDLLVersion = WpfMap.GetVersion();
            _wpfMap.MapUnit = GeographyUnit.DecimalDegree;
            _wpfMap.MapTools.PanZoomBar.HorizontalAlignment = HorizontalAlignment.Left;
            _wpfMap.MapTools.PanZoomBar.VerticalAlignment = VerticalAlignment.Top;
            _wpfMap.MapTools.Logo.IsEnabled = false;

            _wpfMap.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.StandardColors.Black);
            _wpfMap.AdornmentOverlay.Layers.Add("Grid", new MyGraticuleAdornmentLayer());
            _wpfMap.AdornmentOverlay.Layers["Grid"].IsVisible = Settings.Default.ShowGrid;
            _wpfMap.CurrentExtent = new RectangleShape(-180, 90, 180, -90);
            
            //var localizedName = ((MainView)_viewAwareStatus.View).FontFamily.FamilyNames[XmlLanguage.GetLanguage(CultureInfo.CurrentUICulture.Name)];
            const string localizedName = "Segoe UI";

            var customUnitScaleBarAdornmentLayer = new CustomUnitScaleBarAdornmentLayer
                                                   {
                                                       // Text to be displayed on the scale bar
                                                       UnitText = "Km",
                                                       //Ratio of meters to specified units
                                                       MeterToUnit = 1000,
                                                       GeoFont = new GeoFont(localizedName, 10),
                                                       GeoSolidBrush = new GeoSolidBrush(GeoColor.StandardColors.White),
                                                   };
            _wpfMap.AdornmentOverlay.Layers.Add("Scale", customUnitScaleBarAdornmentLayer);
            _wpfMap.AdornmentOverlay.Layers["Scale"].IsVisible = Settings.Default.ShowScaleBar;
            _wpfMap.ExtentOverlay.DoubleLeftClickMode = MapDoubleLeftClickMode.Disabled;
            _wpfMap.ExtentOverlay.DoubleRightClickMode = MapDoubleRightClickMode.Disabled;

            _wpfMap.MapTools.PanZoomBar.Visibility = Settings.Default.ShowPanZoom ? Visibility.Visible : Visibility.Hidden;
            _mainViewModel.LayerTreeViewModel.MapViewModel = this;
        }
        public MainWindowViewModel(WpfMap map)
        {
            dispatcherTimer = new DispatcherTimer();
            dispatcherTimer.Interval = TimeSpan.FromMilliseconds(5000);
            dispatcherTimer.Tick += AutoRefreshTimer_Tick;

            vehicles = new ObservableCollection<VehicleViewModel>();
            unitSystems = new Collection<UnitSystem>();
            unitSystems.Add(UnitSystem.Imperial);
            unitSystems.Add(UnitSystem.Metric);
            selectedUnitSystem = UnitSystem.Metric;
            autoRefreshMode = AutoRefreshMode.On;
            autoRefresh = true;
            drawFenceMode = DrawFenceMode.DrawNewFence;
            measureMode = MeasureMode.Line;
            mapMode = ControlMapMode.Pan;
            measurePanelVisibility = Visibility.Collapsed;
            editPanelVisibility = Visibility.Collapsed;

            MapControl = map;

            dispatcherTimer.Start();
        }
 public EditablePolygonOverlayViewModel(WpfMap wpfMap)
 {
     _wpfMap = wpfMap;
 }
 public OverlaySwitcher(WpfMap wpfMap)
 {
     InitializeComponent();
     this.wpfMap = wpfMap;
 }
Ejemplo n.º 37
0
 public MapModel(WpfMap map)
 {
     MapControl = map;
 }
Ejemplo n.º 38
0
 public MapModel(WpfMap map)
 {
     mapControl = map;
     InitializeMap();
 }
 public MainWindowViewModel(WpfMap wpfMap)
 {
     MapControl = wpfMap;
 }