Example #1
0
    public AppSettings(Configuration.SettingDataTable settingTable)
    {
        // load settings from table into a dictionary for quick access

        _configSetting = new Dictionary <string, string>();

        foreach (Configuration.SettingRow settingRow in settingTable)
        {
            _configSetting.Add(settingRow.Setting, !settingRow.IsValueNull() ? settingRow.Value : null);
        }

        // load projections

        try
        {
            string proj4String = GetConfigSetting("MapProjection");

            if (String.IsNullOrWhiteSpace(proj4String))
            {
                _mapCoordinateSystem = new CoordinateSystem("+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs");
            }
            else
            {
                _mapCoordinateSystem = new CoordinateSystem(proj4String);
            }

            proj4String = GetConfigSetting("MeasureProjection");

            if (String.IsNullOrWhiteSpace(proj4String))
            {
                _measureCoordinateSystem = MapCoordinateSystem;
            }
            else
            {
                _measureCoordinateSystem = new CoordinateSystem(proj4String);
            }
        }
        catch { }

        // extract full extent from source setting and project if necessary

        if (_configSetting["FullExtent"] != null)
        {
            try
            {
                _fullExtent = EnvelopeExtensions.FromDelimitedString(_configSetting["FullExtent"]);

                if (_mapCoordinateSystem != null && _measureCoordinateSystem != null && !_mapCoordinateSystem.Equals(_measureCoordinateSystem))
                {
                    _fullExtent = _mapCoordinateSystem.ToProjected(_measureCoordinateSystem.ToGeodetic(_fullExtent));
                }
            }
            catch { }
        }
    }
Example #2
0
        public Envelope GetFullExtentEnvelope()
        {
            Envelope fullExtent;

            if (IsFullExtentNull())
            {
                fullExtent = Configuration.AppSettings.DefaultFullExtent;
            }
            else
            {
                fullExtent = EnvelopeExtensions.FromDelimitedString(FullExtent);
                AppSettings appSettings = Configuration.AppSettings;

                if (!appSettings.MapCoordinateSystem.Equals(appSettings.MeasureCoordinateSystem))
                {
                    fullExtent = appSettings.MapCoordinateSystem.ToProjected(appSettings.MeasureCoordinateSystem.ToGeodetic(fullExtent));
                }
            }

            return(fullExtent);
        }
Example #3
0
    public static AppState FromString(string stateString)
    {
        Queue    values   = new Queue(stateString.Split(Separator));
        AppState appState = new AppState();

        string version = ((string)values.Peek())[0] != VersionMarker ? "2.0" : ((string)values.Dequeue()).Substring(1);

        int         tab;
        FunctionTab functionTabs;

        switch (version)
        {
        case "2.0":
            appState.Application    = (string)values.Dequeue();
            appState.MapTab         = (string)values.Dequeue();
            appState.TargetLayer    = (string)values.Dequeue();
            appState.SelectionLayer = (string)values.Dequeue();
            values.Dequeue();                      // skip SelectionDistance
            appState.ActiveMapId    = (string)values.Dequeue();
            appState.ActiveDataId   = (string)values.Dequeue();
            appState.TargetIds      = StringCollection.FromString((string)values.Dequeue());
            appState.SelectionIds   = StringCollection.FromString((string)values.Dequeue());
            appState.Query          = (string)values.Dequeue();
            appState.DataTab        = (string)values.Dequeue();
            appState.MarkupCategory = (string)values.Dequeue();
            appState.MarkupGroups   = StringCollection.FromString((string)values.Dequeue());

            tab          = Convert.ToInt32((string)values.Dequeue());
            functionTabs = FunctionTab.All;

            switch (tab)
            {
            case 1: functionTabs = FunctionTab.Selection; break;

            case 2: functionTabs = FunctionTab.Markup; break;

            case 3: functionTabs = FunctionTab.None; break;
            }

            appState.FunctionTabs      = functionTabs;
            appState.ActiveFunctionTab = functionTabs == FunctionTab.All ? FunctionTab.Selection : functionTabs;
            appState.Extent            = EnvelopeExtensions.FromDelimitedString((string)values.Dequeue(), Separator2);
            break;

        case "2.1":
            appState.Application    = (string)values.Dequeue();
            appState.MapTab         = (string)values.Dequeue();
            appState.Action         = (Action)(Convert.ToInt32((string)values.Dequeue()));
            appState.TargetLayer    = (string)values.Dequeue();
            appState.TargetIds      = StringCollection.FromString((string)values.Dequeue());
            appState.ActiveMapId    = (string)values.Dequeue();
            appState.ActiveDataId   = (string)values.Dequeue();
            appState.Proximity      = (string)values.Dequeue();
            appState.SelectionLayer = (string)values.Dequeue();
            appState.SelectionIds   = StringCollection.FromString((string)values.Dequeue());
            appState.Query          = (string)values.Dequeue();
            appState.DataTab        = (string)values.Dequeue();
            appState.MarkupCategory = (string)values.Dequeue();
            appState.MarkupGroups   = StringCollection.FromString((string)values.Dequeue());

            tab          = Convert.ToInt32((string)values.Dequeue());
            functionTabs = FunctionTab.All;

            switch (tab)
            {
            case 0: functionTabs = FunctionTab.None; break;

            case 1: functionTabs = FunctionTab.Selection; break;

            case 2: functionTabs = FunctionTab.Markup; break;
            }

            appState.FunctionTabs      = functionTabs;
            appState.ActiveFunctionTab = functionTabs == FunctionTab.All ? FunctionTab.Selection : functionTabs;
            appState.Extent            = EnvelopeExtensions.FromDelimitedString((string)values.Dequeue(), Separator2);
            appState.Coordinates       = CoordinatesFromString((string)values.Dequeue());
            break;

        case "2.4":
            appState.Application       = (string)values.Dequeue();
            appState.MapTab            = (string)values.Dequeue();
            appState.Action            = (Action)(Convert.ToInt32((string)values.Dequeue()));
            appState.TargetLayer       = (string)values.Dequeue();
            appState.TargetIds         = StringCollection.FromString((string)values.Dequeue());
            appState.ActiveMapId       = (string)values.Dequeue();
            appState.ActiveDataId      = (string)values.Dequeue();
            appState.Proximity         = (string)values.Dequeue();
            appState.SelectionLayer    = (string)values.Dequeue();
            appState.SelectionIds      = StringCollection.FromString((string)values.Dequeue());
            appState.Query             = (string)values.Dequeue();
            appState.DataTab           = (string)values.Dequeue();
            appState.MarkupCategory    = (string)values.Dequeue();
            appState.MarkupGroups      = StringCollection.FromString((string)values.Dequeue());
            appState.FunctionTabs      = (FunctionTab)(Convert.ToInt32((string)values.Dequeue()));
            appState.ActiveFunctionTab = (FunctionTab)(Convert.ToInt32((string)values.Dequeue()));
            appState.Extent            = EnvelopeExtensions.FromDelimitedString((string)values.Dequeue(), Separator2);
            appState.Coordinates       = CoordinatesFromString((string)values.Dequeue());
            break;

        case "2.5":
            appState.Application       = (string)values.Dequeue();
            appState.MapTab            = (string)values.Dequeue();
            appState.Action            = (Action)(Convert.ToInt32((string)values.Dequeue()));
            appState.TargetLayer       = (string)values.Dequeue();
            appState.TargetIds         = StringCollection.FromString((string)values.Dequeue());
            appState.ActiveMapId       = (string)values.Dequeue();
            appState.ActiveDataId      = (string)values.Dequeue();
            appState.Proximity         = (string)values.Dequeue();
            appState.SelectionLayer    = (string)values.Dequeue();
            appState.SelectionIds      = StringCollection.FromString((string)values.Dequeue());
            appState.Query             = (string)values.Dequeue();
            appState.DataTab           = (string)values.Dequeue();
            appState.MarkupCategory    = (string)values.Dequeue();
            appState.MarkupGroups      = StringCollection.FromString((string)values.Dequeue());
            appState.FunctionTabs      = (FunctionTab)(Convert.ToInt32((string)values.Dequeue()));
            appState.ActiveFunctionTab = (FunctionTab)(Convert.ToInt32((string)values.Dequeue()));
            appState.Extent            = EnvelopeExtensions.FromDelimitedString((string)values.Dequeue(), Separator2);
            appState.Coordinates       = CoordinatesFromString((string)values.Dequeue());
            appState.VisibleLayers     = LayersFromString((string)values.Dequeue());
            break;

        case "3.1":
            appState.Application       = (string)values.Dequeue();
            appState.MapTab            = (string)values.Dequeue();
            appState.Action            = (Action)(Convert.ToInt32((string)values.Dequeue()));
            appState.TargetLayer       = (string)values.Dequeue();
            appState.TargetIds         = StringCollection.FromString((string)values.Dequeue());
            appState.ActiveMapId       = (string)values.Dequeue();
            appState.ActiveDataId      = (string)values.Dequeue();
            appState.Proximity         = (string)values.Dequeue();
            appState.SelectionLayer    = (string)values.Dequeue();
            appState.SelectionIds      = StringCollection.FromString((string)values.Dequeue());
            appState.Query             = (string)values.Dequeue();
            appState.DataTab           = (string)values.Dequeue();
            appState.MarkupCategory    = (string)values.Dequeue();
            appState.MarkupGroups      = StringCollection.FromString((string)values.Dequeue());
            appState.FunctionTabs      = (FunctionTab)(Convert.ToInt32((string)values.Dequeue()));
            appState.ActiveFunctionTab = (FunctionTab)(Convert.ToInt32((string)values.Dequeue()));
            appState.Extent            = EnvelopeExtensions.FromDelimitedString((string)values.Dequeue(), Separator2);
            appState.Coordinates       = CoordinatesFromString((string)values.Dequeue());
            appState.VisibleLayers     = LayersFromString((string)values.Dequeue());
            appState.Level             = (string)values.Dequeue();

            if (values.Count > 0)
            {
                appState.CoordinateLabels = StringCollection.FromString((string)values.Dequeue());
            }
            break;
        }

        return(appState);
    }
Example #4
0
 public Envelope GetFullExtentEnvelope()
 {
     return(IsFullExtentNull() ? AppSettings.DefaultFullExtent : EnvelopeExtensions.FromDelimitedString(FullExtent));
 }
Example #5
0
    public static AppState FromString(string stateString)
    {
        Queue    values   = new Queue(stateString.Split(Separator));
        AppState appState = new AppState();

        string version = ((string)values.Peek())[0] != VersionMarker ? "2.0" : ((string)values.Dequeue()).Substring(1);

        int         tab;
        FunctionTab functionTabs;

        switch (version)
        {
        case "2.0":
            appState.Application    = (string)values.Dequeue();
            appState.MapTab         = (string)values.Dequeue();
            appState.TargetLayer    = (string)values.Dequeue();
            appState.SelectionLayer = (string)values.Dequeue();
            values.Dequeue(); // skip SelectionDistance
            appState.ActiveMapId    = (string)values.Dequeue();
            appState.ActiveDataId   = (string)values.Dequeue();
            appState.TargetIds      = StringCollection.FromString((string)values.Dequeue());
            appState.SelectionIds   = StringCollection.FromString((string)values.Dequeue());
            appState.Query          = (string)values.Dequeue();
            appState.DataTab        = (string)values.Dequeue();
            appState.MarkupCategory = (string)values.Dequeue();
            appState.MarkupGroups   = StringCollection.FromString((string)values.Dequeue());

            tab          = Convert.ToInt32((string)values.Dequeue());
            functionTabs = FunctionTab.All;

            switch (tab)
            {
            case 1: functionTabs = FunctionTab.Selection; break;

            case 2: functionTabs = FunctionTab.Markup; break;

            case 3: functionTabs = FunctionTab.None; break;
            }

            appState.FunctionTabs      = functionTabs;
            appState.ActiveFunctionTab = functionTabs == FunctionTab.All ? FunctionTab.Selection : functionTabs;
            appState.Extent            = ProjectExtent(EnvelopeExtensions.FromDelimitedString((string)values.Dequeue(), Separator2));
            break;

        case "2.1":
            appState.Application    = (string)values.Dequeue();
            appState.MapTab         = (string)values.Dequeue();
            appState.Action         = (Action)(Convert.ToInt32((string)values.Dequeue()));
            appState.TargetLayer    = (string)values.Dequeue();
            appState.TargetIds      = StringCollection.FromString((string)values.Dequeue());
            appState.ActiveMapId    = (string)values.Dequeue();
            appState.ActiveDataId   = (string)values.Dequeue();
            appState.Proximity      = (string)values.Dequeue();
            appState.SelectionLayer = (string)values.Dequeue();
            appState.SelectionIds   = StringCollection.FromString((string)values.Dequeue());
            appState.Query          = (string)values.Dequeue();
            appState.DataTab        = (string)values.Dequeue();
            appState.MarkupCategory = (string)values.Dequeue();
            appState.MarkupGroups   = StringCollection.FromString((string)values.Dequeue());

            tab          = Convert.ToInt32((string)values.Dequeue());
            functionTabs = FunctionTab.All;

            switch (tab)
            {
            case 0: functionTabs = FunctionTab.None; break;

            case 1: functionTabs = FunctionTab.Selection; break;

            case 2: functionTabs = FunctionTab.Markup; break;
            }

            appState.FunctionTabs      = functionTabs;
            appState.ActiveFunctionTab = functionTabs == FunctionTab.All ? FunctionTab.Selection : functionTabs;
            appState.Extent            = ProjectExtent(EnvelopeExtensions.FromDelimitedString((string)values.Dequeue(), Separator2));
            appState.Markup            = CoordinateMarkupFromString((string)values.Dequeue());
            break;

        case "2.4":
            appState.Application       = (string)values.Dequeue();
            appState.MapTab            = (string)values.Dequeue();
            appState.Action            = (Action)(Convert.ToInt32((string)values.Dequeue()));
            appState.TargetLayer       = (string)values.Dequeue();
            appState.TargetIds         = StringCollection.FromString((string)values.Dequeue());
            appState.ActiveMapId       = (string)values.Dequeue();
            appState.ActiveDataId      = (string)values.Dequeue();
            appState.Proximity         = (string)values.Dequeue();
            appState.SelectionLayer    = (string)values.Dequeue();
            appState.SelectionIds      = StringCollection.FromString((string)values.Dequeue());
            appState.Query             = (string)values.Dequeue();
            appState.DataTab           = (string)values.Dequeue();
            appState.MarkupCategory    = (string)values.Dequeue();
            appState.MarkupGroups      = StringCollection.FromString((string)values.Dequeue());
            appState.FunctionTabs      = (FunctionTab)(Convert.ToInt32((string)values.Dequeue()));
            appState.ActiveFunctionTab = (FunctionTab)(Convert.ToInt32((string)values.Dequeue()));
            appState.Extent            = ProjectExtent(EnvelopeExtensions.FromDelimitedString((string)values.Dequeue(), Separator2));
            appState.Markup            = CoordinateMarkupFromString((string)values.Dequeue());
            break;

        case "2.5":
            appState.Application       = (string)values.Dequeue();
            appState.MapTab            = (string)values.Dequeue();
            appState.Action            = (Action)(Convert.ToInt32((string)values.Dequeue()));
            appState.TargetLayer       = (string)values.Dequeue();
            appState.TargetIds         = StringCollection.FromString((string)values.Dequeue());
            appState.ActiveMapId       = (string)values.Dequeue();
            appState.ActiveDataId      = (string)values.Dequeue();
            appState.Proximity         = (string)values.Dequeue();
            appState.SelectionLayer    = (string)values.Dequeue();
            appState.SelectionIds      = StringCollection.FromString((string)values.Dequeue());
            appState.Query             = (string)values.Dequeue();
            appState.DataTab           = (string)values.Dequeue();
            appState.MarkupCategory    = (string)values.Dequeue();
            appState.MarkupGroups      = StringCollection.FromString((string)values.Dequeue());
            appState.FunctionTabs      = (FunctionTab)(Convert.ToInt32((string)values.Dequeue()));
            appState.ActiveFunctionTab = (FunctionTab)(Convert.ToInt32((string)values.Dequeue()));
            appState.Extent            = ProjectExtent(EnvelopeExtensions.FromDelimitedString((string)values.Dequeue(), Separator2));
            appState.Markup            = CoordinateMarkupFromString((string)values.Dequeue());
            appState.VisibleLayers     = LayersFromString((string)values.Dequeue());
            break;

        case "3.1":
            appState.Application       = (string)values.Dequeue();
            appState.MapTab            = (string)values.Dequeue();
            appState.Action            = (Action)(Convert.ToInt32((string)values.Dequeue()));
            appState.TargetLayer       = (string)values.Dequeue();
            appState.TargetIds         = StringCollection.FromString((string)values.Dequeue());
            appState.ActiveMapId       = (string)values.Dequeue();
            appState.ActiveDataId      = (string)values.Dequeue();
            appState.Proximity         = (string)values.Dequeue();
            appState.SelectionLayer    = (string)values.Dequeue();
            appState.SelectionIds      = StringCollection.FromString((string)values.Dequeue());
            appState.Query             = (string)values.Dequeue();
            appState.DataTab           = (string)values.Dequeue();
            appState.MarkupCategory    = (string)values.Dequeue();
            appState.MarkupGroups      = StringCollection.FromString((string)values.Dequeue());
            appState.FunctionTabs      = (FunctionTab)(Convert.ToInt32((string)values.Dequeue()));
            appState.ActiveFunctionTab = (FunctionTab)(Convert.ToInt32((string)values.Dequeue()));
            appState.Extent            = ProjectExtent(EnvelopeExtensions.FromDelimitedString((string)values.Dequeue(), Separator2));
            appState.Markup            = CoordinateMarkupFromString((string)values.Dequeue());
            appState.VisibleLayers     = LayersFromString((string)values.Dequeue());
            appState.Level             = (string)values.Dequeue();

            if (values.Count > 0)
            {
                var text = (string)values.Dequeue();

                if (!String.IsNullOrEmpty(text) && text != "1")
                {
                    appState.Markup[0].Text = text;
                }
            }
            break;

        case "4.2":
            appState.Application       = (string)values.Dequeue();
            appState.MapTab            = (string)values.Dequeue();
            appState.Action            = (Action)(Convert.ToInt32((string)values.Dequeue()));
            appState.TargetLayer       = (string)values.Dequeue();
            appState.TargetIds         = StringCollection.FromString((string)values.Dequeue());
            appState.ActiveMapId       = (string)values.Dequeue();
            appState.ActiveDataId      = (string)values.Dequeue();
            appState.Proximity         = (string)values.Dequeue();
            appState.SelectionLayer    = (string)values.Dequeue();
            appState.SelectionIds      = StringCollection.FromString((string)values.Dequeue());
            appState.Query             = (string)values.Dequeue();
            appState.DataTab           = (string)values.Dequeue();
            appState.MarkupCategory    = (string)values.Dequeue();
            appState.MarkupGroups      = StringCollection.FromString((string)values.Dequeue());
            appState.Markup            = FromJson <List <Markup> >((string)values.Dequeue());
            appState.FunctionTabs      = (FunctionTab)(Convert.ToInt32((string)values.Dequeue()));
            appState.ActiveFunctionTab = (FunctionTab)(Convert.ToInt32((string)values.Dequeue()));
            appState.Extent            = ProjectExtent(EnvelopeExtensions.FromDelimitedString((string)values.Dequeue(), Separator2));
            appState.VisibleLayers     = LayersFromString((string)values.Dequeue());
            appState.Level             = (string)values.Dequeue();
            break;

        case "5.0":
            appState.Application       = (string)values.Dequeue();
            appState.MapTab            = (string)values.Dequeue();
            appState.Search            = (string)values.Dequeue();
            appState.SearchCriteria    = FromJson <Dictionary <String, Object> >((string)values.Dequeue());
            appState.Action            = (Action)(Convert.ToInt32((string)values.Dequeue()));
            appState.TargetLayer       = (string)values.Dequeue();
            appState.TargetIds         = StringCollection.FromString((string)values.Dequeue());
            appState.ActiveMapId       = (string)values.Dequeue();
            appState.ActiveDataId      = (string)values.Dequeue();
            appState.Proximity         = (string)values.Dequeue();
            appState.SelectionLayer    = (string)values.Dequeue();
            appState.SelectionIds      = StringCollection.FromString((string)values.Dequeue());
            appState.Query             = (string)values.Dequeue();
            appState.DataTab           = (string)values.Dequeue();
            appState.MarkupCategory    = (string)values.Dequeue();
            appState.MarkupGroups      = StringCollection.FromString((string)values.Dequeue());
            appState.Markup            = FromJson <List <Markup> >((string)values.Dequeue());
            appState.FunctionTabs      = (FunctionTab)(Convert.ToInt32((string)values.Dequeue()));
            appState.ActiveFunctionTab = (FunctionTab)(Convert.ToInt32((string)values.Dequeue()));
            appState.Extent            = EnvelopeExtensions.FromDelimitedString((string)values.Dequeue(), Separator2);
            appState.VisibleLayers     = LayersFromString((string)values.Dequeue());
            appState.VisibleTiles      = LayersFromString((string)values.Dequeue());
            appState.Level             = (string)values.Dequeue();
            break;
        }

        return(appState);
    }