public static ToolWindowUIState TryDeserialize(ISettingsSection section) { var location = section.Attribute <AppToolWindowLocation?>(LOCATION_ATTR); int? index = section.Attribute <int?>(INDEX_ATTR); bool?isHorizontal = section.Attribute <bool?>(ISHORIZONTAL_ATTR); if (location == null || index == null || isHorizontal == null) { return(null); } var state = new ToolWindowUIState(); state.Location = location.Value; state.Index = index.Value; state.IsHorizontal = isHorizontal.Value; foreach (var sect in section.SectionsWithName(GROUP_SECT)) { var content = ToolWindowGroupState.TryDeserialize(sect); if (content == null) { return(null); } state.Groups.Add(content); } state.StackedContentState = StackedContentStateSerializer.TryDeserialize(section.GetOrCreateSection(STACKEDCONTENTSTATE_SECTION)); if (state.StackedContentState == null) { return(null); } return(state); }
public void Write(ISettingsSection section) { Debug.Assert(HorizontalContentState != null && VerticalContentState != null); if (HorizontalContentState != null) { StackedContentStateSerializer.Serialize(section.GetOrCreateSection(HORIZONTALCONTENT_SECT), HorizontalContentState); } if (VerticalContentState != null) { StackedContentStateSerializer.Serialize(section.GetOrCreateSection(VERTICALCONTENT_SECT), VerticalContentState); } Debug.Assert(LeftState != null && RightState != null && TopState != null && BottomState != null); if (LeftState != null) { ToolWindowUIState.Serialize(section.CreateSection(TOOLWINDOWUI_SECT), LeftState); } if (RightState != null) { ToolWindowUIState.Serialize(section.CreateSection(TOOLWINDOWUI_SECT), RightState); } if (TopState != null) { ToolWindowUIState.Serialize(section.CreateSection(TOOLWINDOWUI_SECT), TopState); } if (BottomState != null) { ToolWindowUIState.Serialize(section.CreateSection(TOOLWINDOWUI_SECT), BottomState); } foreach (var kv in SavedLocations) { var sect = section.CreateSection(LOCATION_SECT); sect.Attribute(LOCATION_GUID_ATTR, kv.Key); sect.Attribute(LOCATION_ATTR, kv.Value); } }
public MainWindowControlState Read(ISettingsSection section) { HorizontalContentState = StackedContentStateSerializer.TryDeserialize(section.GetOrCreateSection(HORIZONTALCONTENT_SECT)); VerticalContentState = StackedContentStateSerializer.TryDeserialize(section.GetOrCreateSection(VERTICALCONTENT_SECT)); foreach (var twSect in section.SectionsWithName(TOOLWINDOWUI_SECT)) { var state = ToolWindowUIState.TryDeserialize(twSect); if (state == null) continue; switch (state.Location) { case AppToolWindowLocation.Left: LeftState = state; break; case AppToolWindowLocation.Right: RightState = state; break; case AppToolWindowLocation.Top: TopState = state; break; case AppToolWindowLocation.Bottom: BottomState = state; break; } } foreach (var locSect in section.SectionsWithName(LOCATION_SECT)) { var guid = locSect.Attribute<Guid?>(LOCATION_GUID_ATTR); var loc = locSect.Attribute<AppToolWindowLocation?>(LOCATION_ATTR); if (guid == null || loc == null) continue; if (!IsValid(loc.Value)) continue; SavedLocations[guid.Value] = loc.Value; } return this; }
public static void Serialize(ISettingsSection section, ToolWindowUIState state) { section.Attribute(LOCATION_ATTR, state.Location); section.Attribute(INDEX_ATTR, state.Index); section.Attribute(ISHORIZONTAL_ATTR, state.IsHorizontal); foreach (var content in state.Groups) { ToolWindowGroupState.Serialize(section.CreateSection(GROUP_SECT), content); } Debug.Assert(state.StackedContentState != null); if (state.StackedContentState != null) { StackedContentStateSerializer.Serialize(section.GetOrCreateSection(STACKEDCONTENTSTATE_SECTION), state.StackedContentState); } }
public MainWindowControlState Read(ISettingsSection section) { HorizontalContentState = StackedContentStateSerializer.TryDeserialize(section.GetOrCreateSection(HORIZONTALCONTENT_SECT)); VerticalContentState = StackedContentStateSerializer.TryDeserialize(section.GetOrCreateSection(VERTICALCONTENT_SECT)); foreach (var twSect in section.SectionsWithName(TOOLWINDOWUI_SECT)) { var state = ToolWindowUIState.TryDeserialize(twSect); if (state == null) { continue; } switch (state.Location) { case AppToolWindowLocation.Left: LeftState = state; break; case AppToolWindowLocation.Right: RightState = state; break; case AppToolWindowLocation.Top: TopState = state; break; case AppToolWindowLocation.Bottom: BottomState = state; break; } } foreach (var locSect in section.SectionsWithName(LOCATION_SECT)) { var guid = locSect.Attribute <Guid?>(LOCATION_GUID_ATTR); var loc = locSect.Attribute <AppToolWindowLocation?>(LOCATION_ATTR); if (guid == null || loc == null) { continue; } if (!IsValid(loc.Value)) { continue; } SavedLocations[guid.Value] = loc.Value; } return(this); }
public static ToolWindowUIState TryDeserialize(ISettingsSection section) { var location = section.Attribute<AppToolWindowLocation?>(LOCATION_ATTR); int? index = section.Attribute<int?>(INDEX_ATTR); bool? isHorizontal = section.Attribute<bool?>(ISHORIZONTAL_ATTR); if (location == null || index == null || isHorizontal == null) return null; var state = new ToolWindowUIState(); state.Location = location.Value; state.Index = index.Value; state.IsHorizontal = isHorizontal.Value; foreach (var sect in section.SectionsWithName(GROUP_SECT)) { var content = ToolWindowGroupState.TryDeserialize(sect); if (content == null) return null; state.Groups.Add(content); } state.StackedContentState = StackedContentStateSerializer.TryDeserialize(section.GetOrCreateSection(STACKEDCONTENTSTATE_SECTION)); if (state.StackedContentState == null) return null; return state; }
public static void Serialize(ISettingsSection section, ToolWindowUIState state) { section.Attribute(LOCATION_ATTR, state.Location); section.Attribute(INDEX_ATTR, state.Index); section.Attribute(ISHORIZONTAL_ATTR, state.IsHorizontal); foreach (var content in state.Groups) ToolWindowGroupState.Serialize(section.CreateSection(GROUP_SECT), content); Debug.Assert(state.StackedContentState != null); if (state.StackedContentState != null) StackedContentStateSerializer.Serialize(section.GetOrCreateSection(STACKEDCONTENTSTATE_SECTION), state.StackedContentState); }