Browse Source

fixed forum-8378 and changed data structure from ArrayList to List<byte>.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3555 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Siegfried Pammer 18 years ago
parent
commit
8fe2b48a0a
  1. 4
      src/AddIns/DisplayBindings/HexEditor/Project/Src/Editor.cs
  2. 16
      src/AddIns/DisplayBindings/HexEditor/Project/Src/Util/BufferManager.cs
  3. 2
      src/AddIns/DisplayBindings/HexEditor/Project/Src/View/HexEditDisplayBinding.cs
  4. 4
      src/AddIns/DisplayBindings/HexEditor/Project/Src/View/HexEditOptionsPanel.cs

4
src/AddIns/DisplayBindings/HexEditor/Project/Src/Editor.cs

@ -5,6 +5,7 @@
// <version>$Revision$</version> // <version>$Revision$</version>
// </file> // </file>
using ICSharpCode.Core;
using System; using System;
using System.Collections; using System.Collections;
using System.ComponentModel; using System.ComponentModel;
@ -13,7 +14,6 @@ using System.IO;
using System.Text; using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using System.Xml; using System.Xml;
using HexEditor.Util; using HexEditor.Util;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
@ -123,7 +123,7 @@ namespace HexEditor
/// </summary> /// </summary>
public void LoadSettings() public void LoadSettings()
{ {
string configpath = Path.GetDirectoryName(typeof(Editor).Assembly.Location) + Path.DirectorySeparatorChar + "config.xml"; string configpath = Path.Combine(PropertyService.ConfigDirectory, "hexeditor-config.xml");
if (!File.Exists(configpath)) { if (!File.Exists(configpath)) {
this.settings = Settings.CreateDefault(); this.settings = Settings.CreateDefault();

16
src/AddIns/DisplayBindings/HexEditor/Project/Src/Util/BufferManager.cs

@ -6,7 +6,7 @@
// </file> // </file>
using System; using System;
using System.Collections; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
@ -27,7 +27,7 @@ namespace HexEditor.Util
/// <summary> /// <summary>
/// Currently used, but not good for really big files (like 590 MB) /// Currently used, but not good for really big files (like 590 MB)
/// </summary> /// </summary>
private ArrayList buffer; List<byte> buffer;
/// <summary> /// <summary>
/// Creates a new BufferManager and attaches it to a control. /// Creates a new BufferManager and attaches it to a control.
@ -37,7 +37,7 @@ namespace HexEditor.Util
{ {
this.parent = parent; this.parent = parent;
this.buffer = new ArrayList(); this.buffer = new List<byte>();
} }
/// <summary> /// <summary>
@ -102,7 +102,7 @@ namespace HexEditor.Util
public void Save(OpenedFile file, Stream stream) public void Save(OpenedFile file, Stream stream)
{ {
BinaryWriter writer = new BinaryWriter(stream); BinaryWriter writer = new BinaryWriter(stream);
writer.Write((byte[])this.buffer.ToArray( typeof (byte) )); writer.Write(this.buffer.ToArray());
writer.Flush(); writer.Flush();
} }
@ -141,7 +141,7 @@ namespace HexEditor.Util
public byte[] Buffer { public byte[] Buffer {
get { get {
if (buffer == null) return new byte[0]; if (buffer == null) return new byte[0];
return (byte[]) buffer.ToArray( typeof ( byte ) ); return buffer.ToArray();
} }
} }
@ -161,7 +161,7 @@ namespace HexEditor.Util
if (start >= buffer.Count) start = buffer.Count; if (start >= buffer.Count) start = buffer.Count;
if (count < 1) count = 1; if (count < 1) count = 1;
if (count >= (buffer.Count - start)) count = (buffer.Count - start); if (count >= (buffer.Count - start)) count = (buffer.Count - start);
return (byte[])(buffer.GetRange(start, count).ToArray( typeof ( byte ) )); return buffer.GetRange(start, count).ToArray();
} }
public byte GetByte(int offset) public byte GetByte(int offset)
@ -199,12 +199,12 @@ namespace HexEditor.Util
return false; return false;
} }
/// <remarks>Not Tested!</remarks>
public void SetBytes(int start, byte[] bytes, bool overwrite) public void SetBytes(int start, byte[] bytes, bool overwrite)
{ {
if (overwrite) { if (overwrite) {
if (bytes.Length > buffer.Count) buffer.AddRange(new byte[bytes.Length - buffer.Count]); if (bytes.Length > buffer.Count) buffer.AddRange(new byte[bytes.Length - buffer.Count]);
buffer.SetRange(start, bytes); for (int i = start; i < start + bytes.Length; i++)
buffer[i] = bytes[i - start];
} else { } else {
buffer.InsertRange(start, bytes); buffer.InsertRange(start, bytes);
} }

2
src/AddIns/DisplayBindings/HexEditor/Project/Src/View/HexEditDisplayBinding.cs

@ -43,7 +43,7 @@ namespace HexEditor.View
{ {
if (supportedExtensions == null) { if (supportedExtensions == null) {
System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
string configpath = Path.GetDirectoryName(typeof(Editor).Assembly.Location) + Path.DirectorySeparatorChar + "config.xml"; string configpath = Path.Combine(PropertyService.ConfigDirectory, "hexeditor-config.xml");
if (!File.Exists(configpath)) if (!File.Exists(configpath))
return new string[] {".exe",".dll"}; return new string[] {".exe",".dll"};

4
src/AddIns/DisplayBindings/HexEditor/Project/Src/View/HexEditOptionsPanel.cs

@ -62,7 +62,7 @@ namespace HexEditor.View
{ {
SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("HexEditor.Resources.HexEditOptions.xfrm")); SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("HexEditor.Resources.HexEditOptions.xfrm"));
this.InitializeComponents(); this.InitializeComponents();
string configpath = Path.GetDirectoryName(typeof(Editor).Assembly.Location) + Path.DirectorySeparatorChar + "config.xml"; string configpath = Path.Combine(PropertyService.ConfigDirectory, "hexeditor-config.xml");
if (!File.Exists(configpath)) return; if (!File.Exists(configpath)) return;
@ -140,7 +140,7 @@ namespace HexEditor.View
public override bool StorePanelContents() public override bool StorePanelContents()
{ {
string configpath = Path.GetDirectoryName(typeof(Editor).Assembly.Location) + Path.DirectorySeparatorChar + "config.xml"; string configpath = Path.Combine(PropertyService.ConfigDirectory, "hexeditor-config.xml");
XmlDocument file = new XmlDocument(); XmlDocument file = new XmlDocument();
file.LoadXml("<Config></Config>"); file.LoadXml("<Config></Config>");

Loading…
Cancel
Save