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 @@ @@ -5,6 +5,7 @@
// <version>$Revision$</version>
// </file>
using ICSharpCode.Core;
using System;
using System.Collections;
using System.ComponentModel;
@ -13,7 +14,6 @@ using System.IO; @@ -13,7 +14,6 @@ using System.IO;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using HexEditor.Util;
using ICSharpCode.SharpDevelop;
@ -123,7 +123,7 @@ namespace HexEditor @@ -123,7 +123,7 @@ namespace HexEditor
/// </summary>
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)) {
this.settings = Settings.CreateDefault();

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

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

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

@ -43,7 +43,7 @@ namespace HexEditor.View @@ -43,7 +43,7 @@ namespace HexEditor.View
{
if (supportedExtensions == null) {
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))
return new string[] {".exe",".dll"};

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

@ -62,7 +62,7 @@ namespace HexEditor.View @@ -62,7 +62,7 @@ namespace HexEditor.View
{
SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("HexEditor.Resources.HexEditOptions.xfrm"));
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;
@ -140,7 +140,7 @@ namespace HexEditor.View @@ -140,7 +140,7 @@ namespace HexEditor.View
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();
file.LoadXml("<Config></Config>");

Loading…
Cancel
Save