예제 #1
0
 private void Page_UnLoad(object sender, System.EventArgs e)
 {
     if (AppStateManager.IsManualState())
     {
         AppStateManager.GetStateManagerFromSession().SaveState();
     }
 }
예제 #2
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            MapInfo.Mapping.Map myMap = GetMapObj();
            if(myMap == null) return;

            // The first time in
            if (Session.IsNewSession)
            {
                //******************************************************************************//
                //*   You need to follow below lines in your own application.                  *//
                //*   You don't need this state manager if the "MapInfo.Engine.Session.State" *//
                //*   in the web.config is not set to "Manual"                                 *//
                //******************************************************************************//
                if(AppStateManager.IsManualState())
                {
                    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.
                    AppStateManager.PutStateManagerInSession(stateManager);
                }

                // Initial state.
                InitState();
            }
            // Restore state.
            if(AppStateManager.IsManualState())
            {
                AppStateManager.GetStateManagerFromSession().RestoreState();
            }
            // Add a north arrow IAdornment into the map's adornments collection.
            AddNorthArrowAdornment(myMap);
        }
예제 #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
            {
                if (myMap == null)
                {
                    return;
                }
                // Restore everything we saved explictly.
                AppStateManager.RestoreZoomCenterState(myMap);
                ManualSerializer.RestoreMapXtremeObjectFromHttpSession(GetKey("Layers"));
                ManualSerializer.RestoreMapXtremeObjectFromHttpSession("north_adornment");
            }
        }
예제 #4
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            MapInfo.Mapping.Map myMap = GetMapObj();
            if (myMap == null)
            {
                return;
            }

            // The first time in
            if (Session.IsNewSession)
            {
                //******************************************************************************//
                //*   You need to follow below lines in your own application.                  *//
                //*   You don't need this state manager if the "MapInfo.Engine.Session.State" *//
                //*   in the web.config is not set to "Manual"                                 *//
                //******************************************************************************//
                if (AppStateManager.IsManualState())
                {
                    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.
                    AppStateManager.PutStateManagerInSession(stateManager);
                }

                // Initial state.
                InitState();
            }
            // Restore state.
            if (AppStateManager.IsManualState())
            {
                AppStateManager.GetStateManagerFromSession().RestoreState();
            }
            // Add a north arrow IAdornment into the map's adornments collection.
            AddNorthArrowAdornment(myMap);
        }
예제 #5
0
        // Save the state
        public override void SaveState()
        {
            string mapAlias = this.ParamsDictionary[AppStateManager.ActiveMapAliasKey] as String;

            // Get the map
            MapInfo.Mapping.Map myMap = GetMapObj(mapAlias);
            if (myMap == null)
            {
                return;
            }

            // 1. Only if the MapInfo.Engine.Session.State is set to "Manual" in the web.config,
            // We manually save objects below.
            // 2. The MapInfo Session object will be automatically saved and you need to do nothing,
            // if the MapInfo.Engine.Session.State is set to HttpSessionState.
            AppStateManager.SaveZoomCenterState(myMap);
            ManualSerializer.SaveMapXtremeObjectIntoHttpSession(myMap.Layers, GetKey("Layers"));

            // Save NorthArrowAdornment.
            if (myMap.Adornments["north_arrow"] != null)
            {
                ManualSerializer.SaveMapXtremeObjectIntoHttpSession(myMap.Adornments["north_arrow"], "north_adornment");
            }
        }