public MgLegendControlPresenter(ILegendView legend, MgMapViewerProvider provider)
 {
     _legend = legend;
     _provider = provider;
     _map = _provider.GetMap();
     InitInitialSelectabilityStates();
     _resSvc = (MgResourceService)_provider.CreateService(MgServiceType.ResourceService);
     _selectableIcon = Properties.Resources.lc_select;
     _unselectableIcon = Properties.Resources.lc_unselect;
 }
Exemple #2
0
        private void printDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            MgMapViewerProvider provider  = _viewer.GetProvider();
            MgSelectionBase     selection = _viewer.GetSelection();
            MgMapBase           map       = _viewer.GetMap();
            MgPoint             pt        = map.ViewCenter;
            MgCoordinate        coord     = pt.Coordinate;
            float leftMargin = e.MarginBounds.Left;
            float topMargin  = e.MarginBounds.Top;
            float yPos       = topMargin;
            float pageHeight = e.MarginBounds.Height;

            //Write title
            var titleFont = new Font(FontFamily.GenericSansSerif, 18.0f, GraphicsUnit.Point);
            var sizeTitle = e.Graphics.MeasureString(txtTitle.Text, titleFont);

            e.Graphics.DrawString(txtTitle.Text, titleFont, Brushes.Black, new PointF(leftMargin, yPos));

            yPos += (sizeTitle.Height * 1.1f);

            var scaleFont = SystemFonts.CaptionFont;
            var scaleStr  = string.Format("{0} 1 : {1}", Strings.TextScale, _viewer.GetMap().ViewScale); //NOXLATE
            var sizeScale = e.Graphics.MeasureString(scaleStr, scaleFont);

            //Scale to fit within this page
            var imgHeight = (int)(pageHeight - (sizeTitle.Height * 1.1f) - (sizeScale.Height * 1.1f));
            var imgWidth  = e.MarginBounds.Width;

            using (var state = provider.CreateTransientState())
            {
                var tempState = new MgMapDisplayParameters(coord.X, coord.Y, map.ViewScale, imgWidth, imgHeight, (int)numDPI.Value);
                state.PushState(tempState);
                MgByteReader br = provider.RenderMap(selection, "PNG"); //NOXLATE
                using (MgReadOnlyStream stream = new MgReadOnlyStream(br))
                {
                    Image img = Image.FromStream(stream);
                    e.Graphics.DrawImage(img, leftMargin, yPos, imgWidth, imgHeight);
                    img.Dispose();
                }
            }

            yPos += imgHeight;

            //Render scale
            if (chkScale.Checked)
            {
                e.Graphics.DrawString(scaleStr, scaleFont, Brushes.Black, new PointF(leftMargin, yPos));
            }

            e.HasMorePages = false;
        }
Exemple #3
0
        internal MgSelectionSet(MgSelectionBase selection, MgMapViewerProvider provider)
        {
            _agfRw    = new MgAgfReaderWriter();
            _features = new Dictionary <string, List <MgFeature> >();
            var selLayers = selection.GetLayers();

            if (selLayers != null)
            {
                for (int i = 0; i < selLayers.GetCount(); i++)
                {
                    var layer    = selLayers.GetItem(i);
                    var clsName  = layer.GetFeatureClassName();
                    int selCount = selection.GetSelectedFeaturesCount(layer, clsName);
                    if (selCount == 0)
                    {
                        System.Diagnostics.Trace.TraceWarning("No items in selection set for this layer (" + layer.GetName() + "). Layer shouldn't be here then");
                        continue;
                    }

                    NameValueCollection mappings = (provider != null) ? provider.GetPropertyMappings(layer) : null;
                    _features[layer.Name] = new List <MgFeature>();

                    var reader = selection.GetSelectedFeatures(layer, layer.GetFeatureClassName(), false);
                    while (reader.ReadNext())
                    {
                        var feature = CreateFeatureFromReader(reader);
                        if (mappings != null)
                        {
                            PerformDisplayNameSubstitution(feature, mappings);
                        }
                        _features[layer.Name].Add(feature);
                    }
                    reader.Close();
                }
            }
        }
Exemple #4
0
 public void LoadMap(MgMapViewerProvider provider)
 {
     mapViewer.Init(provider);
 }
Exemple #5
0
        internal MgSelectionSet(MgSelectionBase selection, MgMapViewerProvider provider)
        {
            _agfRw = new MgAgfReaderWriter();
            _features = new Dictionary<string, List<MgFeature>>();
            var selLayers = selection.GetLayers();
            if (selLayers != null)
            {
                for (int i = 0; i < selLayers.GetCount(); i++)
                {
                    var layer = selLayers.GetItem(i);
                    var clsName = layer.GetFeatureClassName();
                    int selCount = selection.GetSelectedFeaturesCount(layer, clsName);
                    if (selCount == 0)
                    {
                        System.Diagnostics.Trace.TraceWarning("No items in selection set for this layer (" + layer.GetName() + "). Layer shouldn't be here then");
                        continue;
                    }

                    NameValueCollection mappings = (provider != null) ? provider.GetPropertyMappings(layer) : null;
                    _features[layer.Name] = new List<MgFeature>();
                    
                    var reader = selection.GetSelectedFeatures(layer, layer.GetFeatureClassName(), false);
                    while (reader.ReadNext())
                    {
                        var feature = CreateFeatureFromReader(reader);
                        if (mappings != null)
                            PerformDisplayNameSubstitution(feature, mappings);
                        _features[layer.Name].Add(feature);
                    }
                    reader.Close();
                }
            }
        }
Exemple #6
0
        /// <summary>
        /// Initializes this viewer with the specified viewer provider, if the provider contains a map
        /// it will load that as well. Otherwise a call to <see cref="LoadMap"/> is required afterwards
        /// </summary>
        /// <param name="provider">The provider.</param>
        public void Init(MgMapViewerProvider provider)
        {
            if (_agfRW == null)
                _agfRW = new MgAgfReaderWriter();

            if (_wktRW == null)
                _wktRW = new MgWktReaderWriter();

            if (_geomFact == null)
                _geomFact = new MgGeometryFactory();

            _provider = provider;

            if (_resSvc != null) //Forward looking, dispose the existing one as it may be of a different implementation
            {
                _resSvc.Dispose();
                _resSvc = null;
            }
            _resSvc = (MgResourceService)_provider.CreateService(MgServiceType.ResourceService);

            _overlayRenderOpts = CreateMapRenderingOptions(0, 0, 255);
            _selectionRenderOpts = CreateSelectionRenderingOptions(0, 0, 255);

            if (_provider != null)
            {
                _provider.MapLoaded -= OnMapSetOnProvider;
                _provider = null;
            }

            _provider = provider;
            _provider.MapLoaded += OnMapSetOnProvider;
            var map = _provider.GetMap();
            if (map != null)
                OnMapSetOnProvider(this, EventArgs.Empty);
        }
Exemple #7
0
 internal void Init(MgMapViewerProvider provider)
 {
     _presenter = new MgLegendControlPresenter(this, provider);
     RefreshLegend();
 }
Exemple #8
0
 internal void Init(MgMapViewerProvider provider)
 {
     _presenter = new MgLegendControlPresenter(this, provider);
     RefreshLegend();
 }