예제 #1
0
        // Restore the state
        public override void RestoreState()
        {
            string mapAlias = ParamsDictionary[ActiveMapAliasKey] as string;
            Map    map      = MapInfo.Engine.Session.Current.MapFactory[mapAlias];

            // If it was user's first time and the session was not dirty then save this default state to be applied later.
            // If it was a users's first time and the session was dirty then apply the default state  saved in above step to give users a initial state.
            if (IsUsersFirstTime())
            {
                if (IsDirtySession(map))
                {
                    RestoreDefaultState(map);
                }
                else
                {
                    SaveDefaultState(map);
                }
            }
            else
            {
                // If it is not user's first time then restore the last state they saved
                RestoreZoomCenterState(map);
                // Just by setting it to temp variables the objects are serialized into session. There is no need to set them explicitly.

                ManualSerializer.RestoreMapXtremeObjectFromHttpSession("Layers");
                ManualSerializer.RestoreMapXtremeObjectFromHttpSession("Selection");
            }
        }
예제 #2
0
        // Restore the state
        public override void RestoreState()
        {
            string mapAlias = ParamsDictionary[ActiveMapAliasKey] as string;
            Map    myMap    = GetMapObj(mapAlias);

            // If it was user's first time and the session was not dirty then save this default state to be applied later.
            // If it was a users's first time and the session was dirty then apply the default state  saved in above step to give users a initial state.
            if (IsUsersFirstTime())
            {
                if (IsDirtyMapXtremeSession())
                {
                    RestoreDefaultState(myMap);
                }
                else
                {
                    SaveDefaultState(myMap);
                }
            }
            else
            {
                if (myMap == null)
                {
                    return;
                }
                // Restore everything we saved explictly.
                AppStateManager.RestoreZoomCenterState(myMap);
                ManualSerializer.RestoreMapXtremeObjectFromHttpSession("Catalog");
                ManualSerializer.RestoreMapXtremeObjectFromHttpSession("Layers");
            }
        }
예제 #3
0
        // Restore the state
        public override void RestoreState()
        {
            string mapAlias = ParamsDictionary[ActiveMapAliasKey] as string;
            Map    myMap    = GetMapObj(mapAlias);

            // If it was user's first time and the session was not dirty then save this default state to be applied later.
            // If it was a users's first time and the session was dirty then apply the default state  saved in above step to give users a initial state.
            if (IsUsersFirstTime())
            {
                if (IsDirtyMapXtremeSession())
                {
                    RestoreDefaultState(myMap);
                }
                else
                {
                    SaveDefaultState(myMap);
                }
            }
            else
            {
                AppStateManager.RestoreZoomCenterState(myMap);
                ManualSerializer.RestoreMapXtremeObjectFromHttpSession("mdb_table");
                ManualSerializer.RestoreMapXtremeObjectFromHttpSession("theme_table");
                ManualSerializer.RestoreMapXtremeObjectFromHttpSession("theme_layer");
                ManualSerializer.RestoreMapXtremeObjectFromHttpSession("group_layer");

                // Important Note:
                //   The saved theme layer, group layer and tables get restored automatically by ASP.NET serialization.
                //   By the time this method is called, this has already happened.

                // We need to move the GroupLayer to the Top, so the contents within it could be displayed.
                // This step is necessary since the GroupLayer is created on the fly and not loaded through pre-loaded workspace and
                // the position of the groupLayer inside the Layers collection is not guarantee when it get deserialized back
                // since we don't save the whole Layers collection for performance purpose in this sample.
                int indexOfGroupLayer = myMap.Layers.IndexOf(myMap.Layers[SampleConstants.GroupLayerAlias]);
                if (indexOfGroupLayer > 0)
                {
                    myMap.Layers.Move(indexOfGroupLayer, 0);
                    // Need to turn off other labellayer if we have a demo labellayer in the GroupLayer.
                    // This step is needed if "MapInfo.Engine.Session.Pooled" value="false" in the web.config,
                    // Otherwise you would see other LabelLayers show up on the map.
                    WebForm1.HandleLabelLayerVisibleStatus(myMap);
                }
            }
        }
        // Restore the users state
        public override void RestoreState()
        {
            string mapAlias = ParamsDictionary[ActiveMapAliasKey] as string;
            Map    map      = GetMapObj(mapAlias);

            // If this is a clean pooled object save the default state for new users to
            // access later.
            if (!IsDirtyMapXtremeSession(map))
            {
                SaveDefaultState(map);
            }

            // If it was user's first time and the session is dirty, restore the default state.
            if (IsUsersFirstTime())
            {
                if (IsDirtyMapXtremeSession(map))
                {
                    RestoreDefaultState(map);
                }
            }
            else
            {
                // If this is an existing user then restore the last state they saved
                // Make sure to also check if this is a clean or dirty pooled object, you may
                // have to restore some base state or tables prior to restoring users state. The best
                // practice is to save all modified or added MapXtreme objects to the users state
                // and restore them in the correct order. But in some instances clean up or
                // initialization of the pooled MapXtreme Session may be necessary
                if (IsDirtyMapXtremeSession(map))
                {
                    // TODO: Manual work to prepare the dirty Pooled MapXtreme Session instance
                }
                else
                {
                    // TODO: Manual work to prepare the clean Pooled MapXtreme Session instance
                }
                RestoreZoomCenterState(map);

                // Just by deserializing the binary stream we reset the MapFactory Deault layers collection
                // Any MapXtreme class that supports the ISerializable interface will automatically be
                // restored to the current MapXtreme Session.
                ManualSerializer.RestoreMapXtremeObjectFromHttpSession("Layers");
                ManualSerializer.RestoreMapXtremeObjectFromHttpSession("Selection");
            }
        }
예제 #5
0
        // Restore the state
        public override void RestoreState()
        {
            string mapAlias = ParamsDictionary[ActiveMapAliasKey] as string;
            Map    map      = GetMapObj(mapAlias);

            if (map == null)
            {
                return;
            }

            // If it was user's first time and the session was not dirty then save this default state to be applied later.
            // If it was a users's first time and the session was dirty then apply the default state  saved in above step to give users a initial state.
            if (IsUsersFirstTime())
            {
                if (IsDirtyMapXtremeSession(map))
                {
                    RestoreDefaultState(map);
                }
                else
                {
                    SaveDefaultState(map);
                }
            }
            else
            {
                // If it is not user's first time then restore the last state they saved
                RestoreZoomCenterState(map);
                //ManualSerializer.RestoreMapXtremeObjectFromHttpSession("Layers");
                ManualSerializer.RestoreMapXtremeObjectFromHttpSession(GetKey("Selection"));

                // Just by setting it to temp variables the objects are serialized into session. There is no need to set them explicitly.
                if (StateManager.IsManualState())
                {
                    ManualSerializer.RestoreMapXtremeObjectFromHttpSession("tempTable");
                    ManualSerializer.RestoreMapXtremeObjectFromHttpSession("tempLayer");
                }
            }
        }
예제 #6
0
        // Restore the state
        public override void RestoreState()
        {
            string mapAlias = ParamsDictionary[ActiveMapAliasKey] as string;
            Map    myMap    = GetMapObj(mapAlias);

            // If it was user's first time and the session was not dirty then save this default state to be applied later.
            // If it was a users's first time and the session was dirty then apply the default state  saved in above step to give users a initial state.
            if (IsUsersFirstTime())
            {
                if (IsDirtyMapXtremeSession())
                {
                    RestoreDefaultState(myMap);
                }
                else
                {
                    SaveDefaultState(myMap);
                }
            }
            else
            {
                if (myMap == null)
                {
                    return;
                }
                // Restore everything we saved explictly.
                AppStateManager.RestoreZoomCenterState(myMap);
                ManualSerializer.RestoreMapXtremeObjectFromHttpSession("WorkingTable");
                ManualSerializer.RestoreMapXtremeObjectFromHttpSession("WorkingLayer");

                // Get the workingLayerName saved in WebForm1.aspx page_load.
                string workingLayerName = this.ParamsDictionary["WorkingLayerName"] as String;
                int    indexOfLayer     = myMap.Layers.IndexOf(myMap.Layers[workingLayerName]);
                // Move the working layer to the Top, so it can be displayed.
                myMap.Layers.Move(indexOfLayer, 0);
            }
        }