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); }
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); }