MapSuiteGisEditor/GisEditorInfrastructure/Managers/ProjectManager/ProjectPluginManager.cs
/// <summary>
/// Gets the deserialized maps core.
/// </summary>
/// <returns></returns>
Gets the deserialized maps core.
Gets the deserialized maps core .
protected virtual Collection<GisEditorWpfMap> GetDeserializedMapsCore()
        {
            deserializedMaps.Clear();
            if (!ProjectExists(ProjectUri))
            {
                return deserializedMaps;
            }
            var info = new ProjectStreamInfo(ProjectUri, null);
            currentProjectPlugin.LoadProjectStream(info);
            using (var zipFileAdapter = ZipFileAdapterManager.CreateInstance(info.Stream))
            {
                foreach (var document in GisEditor.DockWindowManager.DocumentWindows)
                {
                    GisEditorWpfMap wpfMap = null;
                    string projectName = Path.GetFileNameWithoutExtension(CurrentProjectPlugin.GetProjectShortName(ProjectUri));
                    string mapFileName = string.Format(CultureInfo.InvariantCulture, @"{0}.tgmap", document.Name);
                    string mapFileTitle = string.Format(CultureInfo.InvariantCulture, @"{0}.tgmap", document.Title);
                    if (!zipFileAdapter.GetEntryNames().Contains(mapFileName)) mapFileName = mapFileTitle;
                    if (zipFileAdapter.GetEntryNames().Contains(mapFileName))
                    {
                        using (var mapStream = zipFileAdapter.GetEntryStreamByName(mapFileName))
                        {
                            var mapString = new StreamReader(mapStream).ReadToEnd();
                            mapString = GetAbsoluteTempFilePath(mapString);
                            mapString = GetAbsoluteDataFilePath(mapString);
                            mapString = GetFixedMapString(mapString);
                            mapString = GetFixedMissingFileMapString(zipFileAdapter, mapString);
                            using (var wpfMapMemory = new MemoryStream(Encoding.UTF8.GetBytes(mapString)))
                            {
                                wpfMap = (GisEditorWpfMap)GisEditor.Serializer.Deserialize(wpfMapMemory);
                                wpfMap.Overlays.OfType<LayerOverlay>().ForEach(o =>
                                {
                                    var shp = o.Layers.OfType<ShapeFileFeatureLayer>().ToList();
                                    foreach (var s in shp)
                                    {
                                        if (!File.Exists(s.ShapePathFilename))
                                        {
                                            s.IsVisible = false;
                                        }
                                    }
                                });
                                wpfMap.Overlays.OfType<LayerOverlay>().SelectMany(o => o.Layers).OfType<ShapeFileFeatureLayer>()
                                    .Select(l => l.ZoomLevelSet).ForEach(zs =>
                                    {
                                        var zoomLevelsToRemove = zs.CustomZoomLevels.Where(z => z.ApplyUntilZoomLevel != ApplyUntilZoomLevel.None && z.CustomStyles.Count == 0).ToList();
                                        foreach (var z in zoomLevelsToRemove)
                                        {
                                            zs.CustomZoomLevels.Remove(z);
                                        }
                                    });
                                if (wpfMap != null) deserializedMaps.Add(wpfMap);
                            }
                        }
                    }
                }
            }
            return deserializedMaps;
        }
protected virtual Collection < GisEditorWpfMap > GetDeserializedMapsCore ( ) { deserializedMaps . Clear ( ) ; if ( ! ProjectExists ( ProjectUri ) ) { return deserializedMaps ; } var info = new ProjectStreamInfo ( ProjectUri , null ) ; currentProjectPlugin . LoadProjectStream ( info ) ; using ( var zipFileAdapter = ZipFileAdapterManager . CreateInstance ( info . Stream ) ) { foreach ( var document in GisEditor . DockWindowManager . DocumentWindows ) { GisEditorWpfMap wpfMap = null ; string projectName = Path . GetFileNameWithoutExtension ( CurrentProjectPlugin . GetProjectShortName ( ProjectUri ) ) ; string mapFileName = string . Format ( CultureInfo . InvariantCulture , @"{0}.tgmap" , document . Name ) ; string mapFileTitle = string . Format ( CultureInfo . InvariantCulture , @"{0}.tgmap" , document . Title ) ; if ( ! zipFileAdapter . GetEntryNames ( ) . Contains ( mapFileName ) ) mapFileName = mapFileTitle ; if ( zipFileAdapter . GetEntryNames ( ) . Contains ( mapFileName ) ) { using ( var mapStream = zipFileAdapter . GetEntryStreamByName ( mapFileName ) ) { var mapString = new StreamReader ( mapStream ) . ReadToEnd ( ) ; mapString = GetAbsoluteTempFilePath ( mapString ) ; mapString = GetAbsoluteDataFilePath ( mapString ) ; mapString = GetFixedMapString ( mapString ) ; mapString = GetFixedMissingFileMapString ( zipFileAdapter , mapString ) ; using ( var wpfMapMemory = new MemoryStream ( Encoding . UTF8 . GetBytes ( mapString ) ) ) { wpfMap = ( GisEditorWpfMap ) GisEditor . Serializer . Deserialize ( wpfMapMemory ) ; wpfMap . Overlays . OfType < LayerOverlay > ( ) . ForEach ( o => { var shp = o . Layers . OfType < ShapeFileFeatureLayer > ( ) . ToList ( ) ; foreach ( var s in shp ) { if ( ! File . Exists ( s . ShapePathFilename ) ) { s . IsVisible = false ; } } } ) ; wpfMap . Overlays . OfType < LayerOverlay > ( ) . SelectMany ( o => o . Layers ) . OfType < ShapeFileFeatureLayer > ( ) . Select ( l => l . ZoomLevelSet ) . ForEach ( zs => { var zoomLevelsToRemove = zs . CustomZoomLevels . Where ( z => z . ApplyUntilZoomLevel != ApplyUntilZoomLevel . None && z . CustomStyles . Count == 0 ) . ToList ( ) ; foreach ( var z in zoomLevelsToRemove ) { zs . CustomZoomLevels . Remove ( z ) ; } } ) ; if ( wpfMap != null ) deserializedMaps . Add ( wpfMap ) ; } } } } } return deserializedMaps ; }
Gets the deserialized maps core.
Gets the deserialized maps core .
//AppDomain currentDomain = AppDomain.CurrentDomain; //mapString.Replace("./", Path.GetDirectoryName(ProjectUri.LocalPath) + "/"); //currentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); //o.Layers.Remove(s); //currentDomain.AssemblyResolve -= new ResolveEventHandler(CurrentDomain_AssemblyResolve);
None