コード例 #1
0
            public VectorLayer(LayerBase owner)
                : base(owner)
            {
#if !DYN
                _vectorLayer = new C1.WPF.Maps.C1VectorLayer();
#else
                _vectorLayer = DynLoader.CreateC1MapsInstance("C1.WPF.Maps.C1VectorLayer");
#endif
                _vectorLayer.Name = MapLayer.Key;
                // AutoHide may yield unexpected results:
#if !DYN
                _vectorLayer.LabelVisibility = WPF.Maps.LabelVisibility.Visible;
#else
                _vectorLayer.LabelVisibility = DynLoader.GetC1MapsEnumValue("C1.WPF.Maps.LabelVisibility.Visible");
#endif
            }
コード例 #2
0
        /// <summary>
        /// Gets a System.Drawing.Image representing the current map.
        /// </summary>
        /// <param name="dpiX">The horizontal resolution of the image.</param>
        /// <param name="dpiY">The vertical resolution of the image.</param>
        /// <returns>The image (bitmap).</returns>
        public System.Drawing.Image GetImage(double dpiX, double dpiY)
        {
            if (_doingEvents)
            {
                return(null);
            }

            RefreshTileSource();

            // apply layer-wide properties:
            foreach (MapsLayerBase lb in _layers)
            {
                lb.UpdateLayerProperties();
            }

            // clear old legends:
            for (int i = _grid.Children.Count - 1; i >= 0; --i)
            {
                if (_grid.Children[i] is MapperLegend)
                {
                    _grid.Children.RemoveAt(i);
                }
            }

            // add new ones:
            if (_owner != null)
            {
                foreach (Legend ml in _owner.Legends)
                {
                    if (ml.Visible)
                    {
                        var l = new MapperLegend();
                        _grid.Children.Add(l);
                        l.Visibility = System.Windows.Visibility.Visible;
                        l.UpdateFromOwner(_owner, ml);
                    }
                }
            }

            this.Measure(new System.Windows.Size(this.Width, this.Height));
            this.Arrange(new System.Windows.Rect(new System.Windows.Size(this.Width, this.Height)));
            this.UpdateLayout();

            // there's no TilesMode in WPF Maps anymore, as its probably the only mode now(?).
            // NOTE: we must DoEvents() at least once even if _tilesRemaining==0, otherwise
            // we don't get the image.
#if skip_dima
#if !DYN
            if (_c1maps.TilesMode == MapTilesMode.Native)
#else
            if (_c1maps.TilesMode == DynLoader.GetC1MapsEnumValue("C1.WPF.Maps.MapTilesMode.Native"))
#endif
#endif
            {
                int oldTilesRemaining = _tilesRemaining;
                DoEvents();
                const int MAX_WAIT_LOOPS     = 200;
                const int MAX_NOCHANGE_LOOPS = 30;
                int       nochange_loops     = 0;
                for (int i = 0; i < MAX_WAIT_LOOPS && nochange_loops < MAX_NOCHANGE_LOOPS && _tilesRemaining > 0; ++i)
                {
                    System.Threading.Thread.Sleep(300);
                    DoEvents();
                    if (oldTilesRemaining == _tilesRemaining)
                    {
                        ++nochange_loops;
                    }
                }
            }
            return(MakeImage(dpiX, dpiY));
        }