Example #1
0
 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);
     }
 }
Example #2
0
        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);
        }
Example #3
0
		public void Save(ISettingsSection section) {
			section.Attribute(NAME_ATTR, Name);
			section.Attribute(INDEX_ATTR, Index);
			section.Attribute(ISHORIZONTAL_ATTR, IsHorizontal);

			if (StackedContentState != null)
				StackedContentStateSerializer.Serialize(section.GetOrCreateSection(STACKEDCONTENTSTATE_SECTION), StackedContentState);

			foreach (var stg in TabGroups)
				stg.Save(section.CreateSection(TABGROUP_SECTION));
		}
Example #4
0
		public static SerializedTabGroupWindow Load(ISettingsSection section) {
			var name = section.Attribute<string>(NAME_ATTR) ?? MAIN_NAME;
			int index = section.Attribute<int?>(INDEX_ATTR) ?? -1;
			bool isHorizontal = section.Attribute<bool?>(ISHORIZONTAL_ATTR) ?? false;
			var stackedContentState = StackedContentStateSerializer.TryDeserialize(section.GetOrCreateSection(STACKEDCONTENTSTATE_SECTION));
			var tgw = new SerializedTabGroupWindow(name, index, isHorizontal, stackedContentState);

			foreach (var tgSection in section.SectionsWithName(TABGROUP_SECTION))
				tgw.TabGroups.Add(SerializedTabGroup.Load(tgSection));

			return tgw;
		}
Example #5
0
 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);
     }
 }
Example #6
0
        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);
        }