Beispiel #1
0
        public void OnEvent(object MapEvent)
        {
            if (_doc == null)
            {
                return;
            }

            IMap map = new Map();

            map.Name = "Map" + (_doc.Maps.Count + 1).ToString();

            _doc.AddMap(map);
        }
Beispiel #2
0
        public Task <bool> OnEvent(object MapEvent)
        {
            if (_doc == null)
            {
                return(Task.FromResult(true));
            }

            IMap map = new Map();

            map.Name = "Map" + (_doc.Maps.Count() + 1).ToString();

            _doc.AddMap(map);

            return(Task.FromResult(true));
        }
Beispiel #3
0
        public void OnEvent(object element, object parent)
        {
            if (_doc != null)
            {
                int    counter = _doc.Maps.Count + 1;
                string name    = LocalizedResources.GetResString("Tools.Map", "Map") + " " + (counter);

                while (_doc[name] != null)
                {
                    name = LocalizedResources.GetResString("Tools.Map", "Map") + " " + (++counter);
                }

                Map map = new Map();
                map.Name = name;

                _doc.AddMap(map);
            }
        }
Beispiel #4
0
        public Task <bool> OnEvent(object element, object parent)
        {
            if (_doc != null)
            {
                int    counter = _doc.Maps.Count() + 1;
                string name    = LocalizedResources.GetResString("Tools.Map", "Map") + " " + (counter);

                while (_doc[name] != null)
                {
                    name = LocalizedResources.GetResString("Tools.Map", "Map") + " " + (++counter);
                }

                Map map = new Map();
                map.Name = name;

                _doc.AddMap(map);
            }

            return(Task.FromResult(true));
        }
        private void btnStart_Click(object sender, EventArgs e)
        {
            txtMap.Text = txtMap.Text.ToUpper().Replace(" ", "_").Replace("Ä", "AE").Replace("Ö", "OE").Replace("Ü", "UE").Replace("ß", "SS");

            _filter = ((ExportMethodItem)cmbExport.SelectedItem).QueryFilter;

            Map migMap = new Map();

            migMap.Name                     = txtMap.Text;
            migMap.Display.refScale         = _map.Display.refScale;
            migMap.Display.MapUnits         = _map.Display.MapUnits;
            migMap.Display.DisplayUnits     = _map.Display.DisplayUnits;
            migMap.Display.SpatialReference = _map.Display.SpatialReference;

            _doc.AddMap(migMap);
            _doc.FocusMap = migMap;
            migMap.Display.ZoomTo(_map.Display.Envelope);

            List <string> migratedClassNames = new List <string>();

            foreach (IDatasetElement element in _map.MapElements)
            {
                if (!(element is IFeatureLayer) || element.Class == null)
                {
                    continue;
                }

                try
                {
                    if (element.Class is IFeatureClass)
                    {
                        IFeatureClass fc = (IFeatureClass)element.Class;
                        if (!migratedClassNames.Contains(fc.Name))
                        {
                            ExportDatasetObject(fc);
                            migratedClassNames.Add(fc.Name);
                        }
                    }
                }
                catch (Exception ex)
                {
                    if (MessageBox.Show(ex.Message + "\n\nDo you want to continue?", "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Error) != DialogResult.OK)
                    {
                        break;
                    }
                }
                IDatasetElement destDatasetElement = _dataset[(txtMap.Text + "_" + element.Class.Name).Replace(".", "_")];

                if (destDatasetElement != null)
                {
                    IFeatureLayer sourceLayer = (IFeatureLayer)element;

                    IFeatureLayer layer = LayerFactory.Create(destDatasetElement.Class) as IFeatureLayer;
                    if (layer != null)
                    {
                        if (sourceLayer.FeatureRenderer != null)
                        {
                            layer.FeatureRenderer = sourceLayer.FeatureRenderer.Clone(migMap.Display) as IFeatureRenderer;
                        }
                        if (sourceLayer.LabelRenderer != null)
                        {
                            layer.LabelRenderer = sourceLayer.LabelRenderer.Clone(migMap.Display) as ILabelRenderer;
                        }
                        if (sourceLayer.SelectionRenderer != null)
                        {
                            layer.SelectionRenderer = sourceLayer.SelectionRenderer.Clone(migMap.Display) as IFeatureRenderer;
                        }

                        layer.MinimumLabelScale = sourceLayer.MinimumLabelScale;
                        layer.MaximumLabelScale = sourceLayer.MaximumLabelScale;
                        layer.MinimumScale      = sourceLayer.MinimumScale;
                        layer.MaximumScale      = sourceLayer.MaximumScale;
                        layer.Visible           = sourceLayer.Visible;
                    }
                    layer.SID = sourceLayer.SID;

                    migMap.AddLayer(layer);

                    ITOCElement tocElement       = migMap.TOC.GetTOCElement(layer);
                    ITOCElement sourceTocElement = _map.TOC.GetTOCElement(sourceLayer);
                    if (tocElement != null && sourceTocElement != null)
                    {
                        tocElement.Name = sourceTocElement.Name;
                    }
                }
            }

            if (_doc.Application is IMapApplication)
            {
                ((IMapApplication)_doc.Application).RefreshActiveMap(DrawPhase.All);
            }
        }