Esempio n. 1
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            // Put user code to initialize the page here
            if (Session.IsNewSession)
            {
                //get default mapcontrol model from session
                MapInfo.WebControls.MapControlModel controlModel = MapControlModel.SetDefaultModelInSession();

                //add custom commands to map control model
                controlModel.Commands.Add(new CreateTheme());
                controlModel.Commands.Add(new RemoveTheme());
                controlModel.Commands.Add(new GetLegend());

                //instanciate AppStateManager class
                AppStateManager myStateManager = new AppStateManager();

                //put current map alias to state manager dictionary
                myStateManager.ParamsDictionary[StateManager.ActiveMapAliasKey] = this.MapControl1.MapAlias;

                //put state manager to session
                StateManager.PutStateManagerInSession(myStateManager);
            }

            // Now Restore State
            StateManager.GetStateManagerFromSession().RestoreState();
        }
Esempio n. 2
0
    private void Page_Load(object sender, System.EventArgs e)
    {
        if (IsPostBack == false)
        {
            // If the StateManager doesn't exist in the session put it else get it.
            if (StateManager.GetStateManagerFromSession() == null)
            {
                StateManager.PutStateManagerInSession(new AppStateManager());
                StateManager.GetStateManagerFromSession().ParamsDictionary[StateManager.ActiveMapAliasKey] = MapControl1.MapAlias;
            }
            else
            {
                MapControl1.MapAlias = StateManager.GetStateManagerFromSession().ParamsDictionary[StateManager.ActiveMapAliasKey] as string;
            }

            //   StateManager.GetStateManagerFromSession().ParamsDictionary[StateManager.ActiveMapAliasKey] = MapControl1.MapAlias;
            StateManager.GetStateManagerFromSession().RestoreState();

            if (Session.IsNewSession)
            {
                MapControlModel model = MapControlModel.SetDefaultModelInSession();
                model.Commands.Add(new WheelZoom());
                model.Commands.Add(new GetOverviewMapCommand());
                model.Commands.Add(new AddPointCommand());
                model.Commands.Add(new DelFeatureCommand());
                model.Commands.Add(new AddLineCommand());
                model.Commands.Add(new CenterCommand());
                model.Commands.Add(new ZoomAllCommand());
                InitWorkingLayer();
            }
        }
    }
Esempio n. 3
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            MapInfo.Mapping.Map myMap = GetMapObj();
            if (Session.IsNewSession)
            {
                AppStateManager stateManager = new AppStateManager();
                stateManager.ParamsDictionary[AppStateManager.ActiveMapAliasKey] = this.MapControl1.MapAlias;
                MapInfo.WebControls.StateManager.PutStateManagerInSession(stateManager);

                // Add customized web tools
                // Below line will put controlModel into HttpSessionState.
                MapInfo.WebControls.MapControlModel controlModel = MapControlModel.SetDefaultModelInSession();
                controlModel.Commands.Add(new AddPinPointCommand());
                controlModel.Commands.Add(new ClearPinPointCommand());
                controlModel.Commands.Add(new ModifiedRadiusSelectionCommand());

                /****** Set the initial state of the map  *************/
                // Clear up the temp layer left by other customer requests.
                if (myMap != null)
                {
                    if (myMap.Layers[SampleConstants.TempLayerAlias] != null)
                    {
                        myMap.Layers.Remove(SampleConstants.TempLayerAlias);
                    }
                }
                // Need to clean up "dirty" temp table left by other customer requests.
                MapInfo.Engine.Session.Current.Catalog.CloseTable(SampleConstants.TempTableAlias);
                // Need to clear the DefautlSelection.
                MapInfo.Engine.Session.Current.Selections.DefaultSelection.Clear();

                // Creat a temp table and AddPintPointCommand will add features into it.
                MapInfo.Data.TableInfoMemTable ti = new MapInfo.Data.TableInfoMemTable(SampleConstants.TempTableAlias);
                // Make the table mappable
                ti.Columns.Add(MapInfo.Data.ColumnFactory.CreateFeatureGeometryColumn(myMap.GetDisplayCoordSys()));
                ti.Columns.Add(MapInfo.Data.ColumnFactory.CreateStyleColumn());

                MapInfo.Data.Table table = MapInfo.Engine.Session.Current.Catalog.CreateTable(ti);
                // Create a new FeatureLayer based on the temp table, so we can see the temp table on the map.
                myMap.Layers.Insert(0, new FeatureLayer(table, "templayer", SampleConstants.TempLayerAlias));

                // 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, MapInfo.Geometry.DistanceUnit.Mile);
                myMap.Center = new MapInfo.Geometry.DPoint(27775.805792979896, -147481.33999999985);
            }

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