// 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);
                }
            }
        }
Beispiel #2
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            // The first time in
            if (Session.IsNewSession)
            {
                //************************************************************//
                //*   You need to follow below lines in your own application. //
                //************************************************************//
                AppStateManager stateManager = new AppStateManager();
                // tell the state manager which map alias you want to use.
                // You could also add your own key/value pairs, the value should be serializable.
                stateManager.ParamsDictionary[AppStateManager.ActiveMapAliasKey] = this.MapControl1.MapAlias;
                // Put state manager into HttpSession, so we could get it later on from different class and requests.
                AppStateManager.PutStateManagerInSession(stateManager);

                InitState();
            }
            MapInfo.WebControls.StateManager.GetStateManagerFromSession().RestoreState();
            PrepareData();
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            // The first time in
            if (Session.IsNewSession)
            {
                //************************************************************//
                //*   You need to follow below lines in your own application. //
                //************************************************************//
                AppStateManager stateManager = new AppStateManager();
                // tell the state manager which map alias you want to use.
                // You could also add your own key/value pairs, the value should be serializable.
                stateManager.ParamsDictionary[AppStateManager.ActiveMapAliasKey] = this.MapControl1.MapAlias;
                // Put state manager into HttpSession, so we could get it later on from different class and requests.
                AppStateManager.PutStateManagerInSession(stateManager);

                InitState();
            }
            MapInfo.WebControls.StateManager.GetStateManagerFromSession().RestoreState();
            PrepareData();
        }