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;

                    // Add workingLayerName into State manager's ParamsDictionary.
                    stateManager.ParamsDictionary["WorkingLayerName"] = _workingLayerName;

                    // Put state manager into HttpSession, so we could get it later on.
                    AppStateManager.PutStateManagerInSession(stateManager);
                }

                InitWorkingLayer();

                MapInfo.Mapping.Map myMap = MapInfo.Engine.Session.Current.MapFactory[this.MapControl1.MapAlias];
                // Set the initial zoom, center and size of the map
                // This step is needed because you may get a dirty map from mapinfo Session.Current which is retrived from session pool.
                myMap.Zoom = new MapInfo.Geometry.Distance(25000, DistanceUnit.Mile);
                myMap.Center = new DPoint(27775.805792979896,-147481.33999999985);
                myMap.Size = new System.Drawing.Size((int)this.MapControl1.Width.Value, (int)this.MapControl1.Height.Value);
            }

            // Restore state.
            if(MapInfo.WebControls.StateManager.IsManualState())
            {
                MapInfo.WebControls.StateManager.GetStateManagerFromSession().RestoreState();
            }
        }
Example #2
0
        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 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;

                    // Add workingLayerName into State manager's ParamsDictionary.
                    stateManager.ParamsDictionary["WorkingLayerName"] = _workingLayerName;

                    // Put state manager into HttpSession, so we could get it later on.
                    AppStateManager.PutStateManagerInSession(stateManager);
                }

                InitWorkingLayer();

                MapInfo.Mapping.Map myMap = MapInfo.Engine.Session.Current.MapFactory[this.MapControl1.MapAlias];
                // Set the initial zoom, center and size of the map
                // This step is needed because you may get a dirty map from mapinfo Session.Current which is retrived from session pool.
                myMap.Zoom   = new MapInfo.Geometry.Distance(25000, DistanceUnit.Mile);
                myMap.Center = new DPoint(27775.805792979896, -147481.33999999985);
                myMap.Size   = new System.Drawing.Size((int)this.MapControl1.Width.Value, (int)this.MapControl1.Height.Value);
            }

            // Restore state.
            if (MapInfo.WebControls.StateManager.IsManualState())
            {
                MapInfo.WebControls.StateManager.GetStateManagerFromSession().RestoreState();
            }
        }
Example #3
0
        // Save the state
        public override void SaveState()
        {
            string mapAlias = this.ParamsDictionary[AppStateManager.ActiveMapAliasKey] as String;

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

            if (myMap == null)
            {
                return;
            }

            // Note: for performance reasons, only save the map's center and zoom.
            AppStateManager.SaveZoomCenterState(myMap);

            // Get the workingLayerName saved in WebForm1.aspx page_load.
            string workingLayerName = this.ParamsDictionary["WorkingLayerName"] as String;

            // Save the map's Working table and layer
            MapInfo.Mapping.FeatureLayer workingLayer = (MapInfo.Mapping.FeatureLayer)myMap.Layers[workingLayerName];
            MapInfo.Data.Table           workingTable = workingLayer != null ? workingLayer.Table : null;
            ManualSerializer.SaveMapXtremeObjectIntoHttpSession(workingTable, "WorkingTable");
            ManualSerializer.SaveMapXtremeObjectIntoHttpSession(workingLayer, "WorkingLayer");
        }
Example #4
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);
            }
        }