コード例 #1
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");
            }
        }
コード例 #2
0
        // Save the state
        public override void SaveState()
        {
            string mapAlias = this.ParamsDictionary[AppStateManager.ActiveMapAliasKey] as String;

            MapInfo.Mapping.Map map = GetMapObj(mapAlias);

            if (map == 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(map);
            ManualSerializer.SaveMapXtremeObjectIntoHttpSession(MapInfo.Engine.Session.Current.Catalog, "Catalog");
            ManualSerializer.SaveMapXtremeObjectIntoHttpSession(map.Layers, "Layers");
        }
コード例 #3
0
ファイル: WebForm1.aspx.cs プロジェクト: jabastien/seemapcell
        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 in order to       *//
                //*   save state manually.                                                     *//
                //*   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);
                }

                // Initialize map setting.
                InitState();

                // WarningLabel is invisible in the init state
                WarningLabel.Visible = false;
            }

            // Restore state.
            if (MapInfo.WebControls.StateManager.IsManualState())
            {
                MapInfo.WebControls.StateManager.GetStateManagerFromSession().RestoreState();
            }

            if (!IsPostBack)
            {
                // DataBind named connection names to RadioButtonList.
                CheckBoxList1.DataSource = MapInfo.Engine.Session.Current.Catalog.NamedConnections.Keys;
                CheckBoxList1.DataBind();

                // Populate aliases of opened tables to Repeater web control.
                BindOpenedTablesAliasToRepeater();
            }
        }
コード例 #4
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 in order to       *//
                //*   save state manually.                                                     *//
                //*   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);
                }

                // Initialize map setting.
                InitState();

                // WarningLabel is invisible in the init state
                WarningLabel.Visible = false;
            }

            // Restore state.
            if(MapInfo.WebControls.StateManager.IsManualState())
            {
                MapInfo.WebControls.StateManager.GetStateManagerFromSession().RestoreState();
            }

            if(!IsPostBack)
            {
                // DataBind named connection names to RadioButtonList.
                CheckBoxList1.DataSource = MapInfo.Engine.Session.Current.Catalog.NamedConnections.Keys;
                CheckBoxList1.DataBind();

                // Populate aliases of opened tables to Repeater web control.
                BindOpenedTablesAliasToRepeater();
            }
        }