Пример #1
0
 public SavedWindowState Write(ISettingsSection section)
 {
     section.Attribute("Bounds", Bounds);
     section.Attribute("IsFullScreen", IsFullScreen);
     section.Attribute("WindowState", WindowState);
     return this;
 }
Пример #2
0
		public static DsDocumentInfo? TryLoad(ISettingsSection section) {
			var name = section.Attribute<string>(DOCUMENTINFO_NAME_ATTR);
			var type = section.Attribute<Guid?>(DOCUMENTINFO_TYPE_ATTR) ?? DocumentConstants.DOCUMENTTYPE_FILE;
			if (string.IsNullOrEmpty(name))
				return null;
			return new DsDocumentInfo(name, type);
		}
Пример #3
0
 public SavedWindowState Read(ISettingsSection section)
 {
     Bounds = section.Attribute<Rect?>("Bounds") ?? Rect.Empty;
     IsFullScreen = section.Attribute<bool?>("IsFullScreen") ?? false;
     WindowState = section.Attribute<WindowState?>("WindowState") ?? WindowState.Normal;
     return this;
 }
Пример #4
0
 public static DnSpyFileInfo? TryLoad(ISettingsSection section)
 {
     var name = section.Attribute<string>(FILEINFO_NAME_ATTR);
     var type = section.Attribute<Guid?>(FILEINFO_TYPE_ATTR) ?? FileConstants.FILETYPE_FILE;
     if (string.IsNullOrEmpty(name))
         return null;
     return new DnSpyFileInfo(name, type);
 }
Пример #5
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));
		}
Пример #6
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;
		}
Пример #7
0
		public static void Serialize(ISettingsSection section, StackedContentState state) {
			section.Attribute(ISHORIZONTAL_ATTR, state.IsHorizontal);
			foreach (var length in state.RowsCols) {
				var lengthSect = section.CreateSection(LENGTH_SECTION);
				lengthSect.Attribute(LENGTH_ATTR, length);
			}
		}
Пример #8
0
		public DocumentTabContent Deserialize(Guid guid, ISettingsSection section, IDocumentTabContentFactoryContext context) {
			if (guid != GUID_SerializedContent)
				return null;

			var filename = section.Attribute<string>("filename");
			return hexViewDocumentTabContentCreator.Value.TryCreate(filename);
		}
		public Guid? Serialize(DocumentTabContent content, ISettingsSection section) {
			var dc = content as DecompileDocumentTabContent;
			if (dc == null)
				return null;

			section.Attribute("Language", dc.Decompiler.UniqueGuid);
			return GUID_SerializedContent;
		}
Пример #10
0
		public Guid? Serialize(DocumentTabContent content, ISettingsSection section) {
			var hb = content as HexViewDocumentTabContent;
			if (hb == null)
				return null;

			section.Attribute("filename", hb.Filename);
			return GUID_SerializedContent;
		}
		public DocumentTabContent Deserialize(Guid guid, ISettingsSection section, IDocumentTabContentFactoryContext context) {
			if (guid != GUID_SerializedContent)
				return null;

			var langGuid = section.Attribute<Guid?>("Language") ?? DecompilerConstants.LANGUAGE_CSHARP;
			var language = DecompilerService.FindOrDefault(langGuid);
			return new DecompileDocumentTabContent(this, context.Nodes, language);
		}
Пример #12
0
 public static FileList Create(ISettingsSection section)
 {
     var fileList = new FileList(section.Attribute<string>(FILELIST_NAME_ATTR));
     foreach (var fileSect in section.SectionsWithName(FILE_SECTION)) {
         var info = DnSpyFileInfoSerializer.TryLoad(fileSect);
         if (info != null)
             fileList.Files.Add(info.Value);
     }
     return fileList;
 }
Пример #13
0
		public void Load(ISettingsSection section) {
			var listName = section.Attribute<string>(CURRENT_LIST_ATTR);
			var names = new HashSet<string>(StringComparer.Ordinal);
			foreach (var listSection in section.SectionsWithName(DOCUMENT_LIST_SECTION)) {
				var documentList = DocumentList.Create(listSection);
				if (names.Contains(documentList.Name))
					continue;
				documentsList.Add(documentList);
			}
			hasLoaded = true;

			SelectList(listName);
		}
Пример #14
0
		public static StackedContentState TryDeserialize(ISettingsSection section) {
			var state = new StackedContentState();
			bool? b = section.Attribute<bool?>(ISHORIZONTAL_ATTR);
			if (b == null)
				return null;
			state.IsHorizontal = b.Value;
			foreach (var lengthSect in section.SectionsWithName(LENGTH_SECTION)) {
				var length = lengthSect.Attribute<GridLength?>(LENGTH_ATTR);
				if (length == null)
					return null;
				state.RowsCols.Add(length.Value);
			}
			return state;
		}
Пример #15
0
		void ReadSection(XElement xml, ISettingsSection section, int recursionCounter) {
			if (recursionCounter >= XmlSettingsConstants.MAX_CHILD_DEPTH)
				return;

			foreach (var xmlAttr in xml.Attributes()) {
				var attrName = xmlAttr.Name.LocalName;
				if (attrName == XmlSettingsConstants.SECTION_ATTRIBUTE_NAME)
					continue;
				section.Attribute(attrName, XmlUtils.UnescapeAttributeValue(xmlAttr.Value));
			}

			foreach (var xmlSect in xml.Elements(XmlSettingsConstants.SECTION_NAME)) {
				var name = XmlUtils.UnescapeAttributeValue((string)xmlSect.Attribute(XmlSettingsConstants.SECTION_ATTRIBUTE_NAME));
				if (name == null)
					continue;
				var childSection = section.CreateSection(name);
				ReadSection(xmlSect, childSection, recursionCounter + 1);
			}
		}
Пример #16
0
 void ReadSettings(ISettingsSection section)
 {
     Id                        = section.Attribute <string>(nameof(Id));
     Images                    = FilterOutImages(DeserializeImages(section.Attribute <string>(nameof(Images))) ?? Array.Empty <string>()).ToArray();
     Stretch                   = section.Attribute <Stretch?>(nameof(Stretch)) ?? DefaultRawSettings.DefaultStretch;
     StretchDirection          = section.Attribute <StretchDirection?>(nameof(StretchDirection)) ?? DefaultRawSettings.DefaultStretchDirection;
     Opacity                   = section.Attribute <double?>(nameof(Opacity)) ?? DefaultRawSettings.Opacity;
     HorizontalOffset          = section.Attribute <double?>(nameof(HorizontalOffset)) ?? DefaultRawSettings.HorizontalOffset;
     VerticalOffset            = section.Attribute <double?>(nameof(VerticalOffset)) ?? DefaultRawSettings.VerticalOffset;
     LeftMarginWidthPercent    = section.Attribute <double?>(nameof(LeftMarginWidthPercent)) ?? DefaultRawSettings.LeftMarginWidthPercent;
     RightMarginWidthPercent   = section.Attribute <double?>(nameof(RightMarginWidthPercent)) ?? DefaultRawSettings.RightMarginWidthPercent;
     TopMarginHeightPercent    = section.Attribute <double?>(nameof(TopMarginHeightPercent)) ?? DefaultRawSettings.TopMarginHeightPercent;
     BottomMarginHeightPercent = section.Attribute <double?>(nameof(BottomMarginHeightPercent)) ?? DefaultRawSettings.BottomMarginHeightPercent;
     MaxHeight                 = section.Attribute <double?>(nameof(MaxHeight)) ?? DefaultRawSettings.MaxHeight;
     MaxWidth                  = section.Attribute <double?>(nameof(MaxWidth)) ?? DefaultRawSettings.MaxWidth;
     Zoom                      = section.Attribute <double?>(nameof(Zoom)) ?? DefaultRawSettings.Zoom;
     ImagePlacement            = section.Attribute <ImagePlacement?>(nameof(ImagePlacement)) ?? DefaultRawSettings.DefaultImagePlacement;
     IsRandom                  = section.Attribute <bool?>(nameof(IsRandom)) ?? DefaultRawSettings.IsRandom;
     IsEnabled                 = section.Attribute <bool?>(nameof(IsEnabled)) ?? DefaultRawSettings.IsEnabled;
     Interval                  = section.Attribute <TimeSpan?>(nameof(Interval)) ?? DefaultRawSettings.Interval;
 }
		// Called to create a value that can be used by Deserialize(). It's read from the settings file.
		public object CreateSerialized(ISettingsSection section) {
			var value1 = section.Attribute<string>("Value1");
			var value2 = section.Attribute<bool?>("Value2");
			if (value1 == null || value2 == null)
				return null;

			return new MySerializedData(value1, value2.Value);
		}
		// Saves the value returned by Serialize(). It's saved in the settings file.
		public void SaveSerialized(ISettingsSection section, object obj) {
			var d = obj as MySerializedData;
			if (d == null)
				return;

			section.Attribute("Value1", d.Value1);
			section.Attribute("Value2", d.Value2);
		}
Пример #19
0
		public override object DeserializeUIState(ISettingsSection section) {
			if (isDisposed)
				throw new ObjectDisposedException(nameof(IDocumentViewer));
			if (section == null)
				throw new ArgumentNullException(nameof(section));
			var caretAffinity = section.Attribute<PositionAffinity?>("CaretAffinity");
			var caretVirtualSpaces = section.Attribute<int?>("CaretVirtualSpaces");
			var caretPosition = section.Attribute<int?>("CaretPosition");
			var viewportLeft = section.Attribute<double?>("ViewportLeft");
			var topLinePosition = section.Attribute<int?>("TopLinePosition");
			var topLineVerticalDistance = section.Attribute<double?>("TopLineVerticalDistance");

			if (caretAffinity == null || caretVirtualSpaces == null || caretPosition == null)
				return null;
			if (viewportLeft == null || topLinePosition == null || topLineVerticalDistance == null)
				return null;
			return new EditorPositionState(caretAffinity.Value, caretVirtualSpaces.Value, caretPosition.Value, viewportLeft.Value, topLinePosition.Value, topLineVerticalDistance.Value);
		}
Пример #20
0
        string[] LoadLabels(ISettingsSection section)
        {
            var labels = section.Attribute <string>("Labels") ?? string.Empty;

            return(labels.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(a => a.Trim()).ToArray());
        }
Пример #21
0
 public static void Serialize(ISettingsSection section, ToolWindowGroupState state)
 {
     section.Attribute(INDEX_ATTR, state.Index);
     foreach (var content in state.Contents)
         ToolWindowContentState.Serialize(section.CreateSection(CONTENT_SECT), content);
 }
Пример #22
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);
 }
Пример #23
0
 public void DeserializeUI(ISettingsSection tabContentUI)
 {
     double? scale = tabContentUI.Attribute<double?>(SCALE_ATTR);
     elementScaler.ScaleValue = scale ?? 1.0;
 }
Пример #24
0
 public static void Serialize(ISettingsSection section, ToolWindowContentState state)
 {
     section.Attribute(GUID_ATTR, state.Guid);
 }
Пример #25
0
 void Save(ISettingsSection section, DbgCodeBreakpointCondition settings)
 {
     section.Attribute("Kind", settings.Kind);
     section.Attribute("Condition", settings.Condition);
 }
Пример #26
0
 void Save(ISettingsSection section, DbgCodeBreakpointHitCount settings)
 {
     section.Attribute("Kind", settings.Kind);
     section.Attribute("Count", settings.Count);
 }
Пример #27
0
 public void SaveSettings(ISettingsSection section)
 {
     section.Attribute(nameof(Id), Id);
     section.Attribute(nameof(Images), SerializeImages(Images));
     section.Attribute(nameof(Stretch), Stretch);
     section.Attribute(nameof(StretchDirection), StretchDirection);
     section.Attribute(nameof(Opacity), Opacity);
     section.Attribute(nameof(HorizontalOffset), HorizontalOffset);
     section.Attribute(nameof(VerticalOffset), VerticalOffset);
     section.Attribute(nameof(LeftMarginWidthPercent), LeftMarginWidthPercent);
     section.Attribute(nameof(RightMarginWidthPercent), RightMarginWidthPercent);
     section.Attribute(nameof(TopMarginHeightPercent), TopMarginHeightPercent);
     section.Attribute(nameof(BottomMarginHeightPercent), BottomMarginHeightPercent);
     section.Attribute(nameof(MaxHeight), MaxHeight);
     section.Attribute(nameof(MaxWidth), MaxWidth);
     section.Attribute(nameof(Zoom), Zoom);
     section.Attribute(nameof(ImagePlacement), ImagePlacement);
     section.Attribute(nameof(IsRandom), IsRandom);
     section.Attribute(nameof(IsEnabled), IsEnabled);
     section.Attribute(nameof(Interval), Interval);
 }
Пример #28
0
 public void SerializeUI(ISettingsSection tabContentUI) =>
 tabContentUI.Attribute(ZOOM_ATTR, elementZoomer.ZoomValue);
Пример #29
0
        public void DeserializeUI(ISettingsSection tabContentUI)
        {
            double?zoom = tabContentUI.Attribute <double?>(ZOOM_ATTR);

            elementZoomer.ZoomValue = zoom ?? 1.0;
        }
Пример #30
0
        public static HexViewUIState Write(ISettingsSection section, HexViewUIState s)
        {
            section.Attribute("ShowOffsetColumn", s.ShowOffsetColumn);
            section.Attribute("ShowValuesColumn", s.ShowValuesColumn);
            section.Attribute("ShowAsciiColumn", s.ShowAsciiColumn);
            section.Attribute("StartPosition", s.StartPosition);
            section.Attribute("EndPosition", s.EndPosition);
            section.Attribute("BasePosition", s.BasePosition);
            section.Attribute("UseRelativePositions", s.UseRelativePositions);
            section.Attribute("OffsetBitSize", s.OffsetBitSize);
            section.Attribute("HexValuesDisplayFormat", s.HexValuesDisplayFormat);
            section.Attribute("BytesPerLine", s.BytesPerLine);

            section.Attribute("ActiveColumn", s.ActiveColumn);
            section.Attribute("ValuesPosition", s.ValuesPosition);
            section.Attribute("ValuesCellPosition", s.ValuesCellPosition);
            section.Attribute("AsciiPosition", s.AsciiPosition);
            section.Attribute("ViewportLeft", s.ViewportLeft);
            section.Attribute("TopLinePosition", s.TopLinePosition);
            section.Attribute("TopLineVerticalDistance", s.TopLineVerticalDistance);
            section.Attribute("AnchorPoint", s.AnchorPoint);
            section.Attribute("ActivePoint", s.ActivePoint);

            return(s);
        }
Пример #31
0
        public static HexBoxUIState Read(ISettingsSection section, HexBoxUIState s)
        {
            if (s.HexBoxState == null)
            {
                return(s);
            }

            s.BytesGroupCount = section.Attribute <int?>("BytesGroupCount");
            s.BytesPerLine    = section.Attribute <int?>("BytesPerLine");
            s.UseHexPrefix    = section.Attribute <bool?>("UseHexPrefix");
            s.ShowAscii       = section.Attribute <bool?>("ShowAscii");
            s.LowerCaseHex    = section.Attribute <bool?>("LowerCaseHex");
            s.AsciiEncoding   = section.Attribute <AsciiEncoding?>("AsciiEncoding");

            s.HexOffsetSize      = section.Attribute <int?>("HexOffsetSize") ?? 0;
            s.UseRelativeOffsets = section.Attribute <bool?>("UseRelativeOffsets") ?? false;
            s.BaseOffset         = section.Attribute <ulong?>("BaseOffset") ?? 0;

            s.HexBoxState.TopOffset                  = section.Attribute <ulong?>("HexBoxState-TopOffset") ?? 0;
            s.HexBoxState.Column                     = section.Attribute <int?>("HexBoxState-Column") ?? 0;
            s.HexBoxState.StartOffset                = section.Attribute <ulong?>("HexBoxState-StartOffset") ?? 0;
            s.HexBoxState.EndOffset                  = section.Attribute <ulong?>("HexBoxState-EndOffset") ?? 0;
            s.HexBoxState.CaretPosition.Offset       = section.Attribute <ulong?>("HexBoxState-HexBoxPosition-Offset") ?? 0;
            s.HexBoxState.CaretPosition.Kind         = section.Attribute <HexBoxPositionKind?>("HexBoxState-HexBoxPosition-Kind") ?? 0;
            s.HexBoxState.CaretPosition.KindPosition = section.Attribute <byte?>("HexBoxState-HexBoxPosition-KindPosition") ?? 0;

            var from = section.Attribute <ulong?>("HexBoxState-Selection-From");
            var to   = section.Attribute <ulong?>("HexBoxState-Selection-To");

            if (from != null && to != null)
            {
                s.HexBoxState.Selection = new HexSelection((ulong)from, (ulong)to);
            }

            return(s);
        }
Пример #32
0
 public void SerializeUI(ISettingsSection tabContentUI)
 {
     tabContentUI.Attribute(SCALE_ATTR, elementScaler.ScaleValue);
 }
Пример #33
0
 public static void Save(ISettingsSection section, DnSpyFileInfo info)
 {
     section.Attribute(FILEINFO_NAME_ATTR, info.Name);
     if (info.Type != FileConstants.FILETYPE_FILE)
         section.Attribute(FILEINFO_TYPE_ATTR, info.Type);
 }
Пример #34
0
        public static ToolWindowContentState TryDeserialize(ISettingsSection section)
        {
            var guid = section.Attribute<Guid?>(GUID_ATTR);
            if (guid == null)
                return null;

            return new ToolWindowContentState(guid.Value);
        }
Пример #35
0
        public static HexBoxUIState Write(ISettingsSection section, HexBoxUIState s)
        {
            if (s.HexBoxState == null)
            {
                return(s);
            }

            section.Attribute("BytesGroupCount", s.BytesGroupCount);
            section.Attribute("BytesPerLine", s.BytesPerLine);
            section.Attribute("UseHexPrefix", s.UseHexPrefix);
            section.Attribute("ShowAscii", s.ShowAscii);
            section.Attribute("LowerCaseHex", s.LowerCaseHex);
            section.Attribute("AsciiEncoding", s.AsciiEncoding);

            section.Attribute("HexOffsetSize", s.HexOffsetSize);
            section.Attribute("UseRelativeOffsets", s.UseRelativeOffsets);
            section.Attribute("BaseOffset", s.BaseOffset);

            section.Attribute("HexBoxState-TopOffset", s.HexBoxState.TopOffset);
            section.Attribute("HexBoxState-Column", s.HexBoxState.Column);
            section.Attribute("HexBoxState-StartOffset", s.HexBoxState.StartOffset);
            section.Attribute("HexBoxState-EndOffset", s.HexBoxState.EndOffset);
            section.Attribute("HexBoxState-HexBoxPosition-Offset", s.HexBoxState.CaretPosition.Offset);
            section.Attribute("HexBoxState-HexBoxPosition-Kind", s.HexBoxState.CaretPosition.Kind);
            section.Attribute("HexBoxState-HexBoxPosition-KindPosition", s.HexBoxState.CaretPosition.KindPosition);
            if (s.HexBoxState.Selection != null)
            {
                section.Attribute("HexBoxState-Selection-From", s.HexBoxState.Selection.Value.From);
                section.Attribute("HexBoxState-Selection-To", s.HexBoxState.Selection.Value.To);
            }

            return(s);
        }
Пример #36
0
        public static ToolWindowGroupState TryDeserialize(ISettingsSection section)
        {
            int? index = section.Attribute<int?>(INDEX_ATTR);
            if (index == null)
                return null;
            var state = new ToolWindowGroupState();
            state.Index = index.Value;

            foreach (var sect in section.SectionsWithName(CONTENT_SECT)) {
                var content = ToolWindowContentState.TryDeserialize(sect);
                if (content == null)
                    return null;
                state.Contents.Add(content);
            }

            return state;
        }
Пример #37
0
		public void DeserializeUI(ISettingsSection tabContentUI) {
			double? zoom = tabContentUI.Attribute<double?>(ZOOM_ATTR);
			elementZoomer.ZoomValue = zoom ?? 1.0;
		}
Пример #38
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;
        }
Пример #39
0
		public void SerializeUI(ISettingsSection tabContentUI) =>
			tabContentUI.Attribute(ZOOM_ATTR, elementZoomer.ZoomValue);
Пример #40
0
		public override void SerializeUIState(ISettingsSection section, object obj) {
			if (isDisposed)
				throw new ObjectDisposedException(nameof(IDocumentViewer));
			if (section == null)
				throw new ArgumentNullException(nameof(section));
			var state = obj as EditorPositionState;
			Debug.Assert(state != null);
			if (state == null)
				return;

			section.Attribute("CaretAffinity", state.CaretAffinity);
			section.Attribute("CaretVirtualSpaces", state.CaretVirtualSpaces);
			section.Attribute("CaretPosition", state.CaretPosition);
			section.Attribute("ViewportLeft", state.ViewportLeft);
			section.Attribute("TopLinePosition", state.TopLinePosition);
			section.Attribute("TopLineVerticalDistance", state.TopLineVerticalDistance);
		}
Пример #41
0
 public static void Serialize(ISettingsSection section, ToolWindowContentState state) => section.Attribute(GUID_ATTR, state.Guid);