From 6ed850767f95dc745fb2e3aa6b1767954622da9e Mon Sep 17 00:00:00 2001 From: alcexhim Date: Fri, 18 Jul 2014 08:49:11 -0400 Subject: [PATCH] Tabify --- .../CompressionMethod.cs | 4 +- .../CompressionModules.cs | 16 +- .../RLEW/RLEWCompressionModule.cs | 250 ++-- .../UniversalEditor.Core/Accessor.cs | 108 +- .../Accessors/MemoryAccessor.cs | 10 +- .../Accessors/StringAccessor.cs | 4 +- .../Modules/Adler32/Adler32ChecksumModule.cs | 8 +- .../Modules/CRC32/CRC32ChecksumModule.cs | 192 +-- .../StrangeCRC/StrangeCRCChecksumModule.cs | 4 +- .../UniversalEditor.Core/Document.cs | 102 +- .../UniversalEditor.Core/ExtensionMethods.cs | 4 +- .../UniversalEditor.Core/IO/Encoding.cs | 100 +- .../UniversalEditor.Core/IO/Writer.cs | 1028 ++++++++--------- .../Localization/StringTable.cs | 28 +- .../Common/Reflection.cs | 8 +- .../UniversalEditor.UserInterface/Engine.cs | 20 +- .../IHostApplicationWindow.cs | 2 +- .../UniversalEditor.UserInterface/MenuBar.cs | 310 ++--- .../UniversalEditor.UserInterface/Toolbar.cs | 44 +- .../UniversalEditor.UserInterface/Toolbox.cs | 54 +- 20 files changed, 1148 insertions(+), 1148 deletions(-) diff --git a/CSharp/Libraries/UniversalEditor.Compression/CompressionMethod.cs b/CSharp/Libraries/UniversalEditor.Compression/CompressionMethod.cs index 96fb17b2..f884dd05 100644 --- a/CSharp/Libraries/UniversalEditor.Compression/CompressionMethod.cs +++ b/CSharp/Libraries/UniversalEditor.Compression/CompressionMethod.cs @@ -15,8 +15,8 @@ namespace UniversalEditor.Compression Gzip, LZMA, LZMASolid, - LZSS, - LZH, + LZSS, + LZH, LZW, LZX, PPPMd, diff --git a/CSharp/Libraries/UniversalEditor.Compression/CompressionModules.cs b/CSharp/Libraries/UniversalEditor.Compression/CompressionModules.cs index 604c09e0..eac0aa1d 100644 --- a/CSharp/Libraries/UniversalEditor.Compression/CompressionModules.cs +++ b/CSharp/Libraries/UniversalEditor.Compression/CompressionModules.cs @@ -6,18 +6,18 @@ using System.Text; namespace UniversalEditor.Compression { public static class CompressionModules - { + { - private static Modules.Bzip2.Bzip2CompressionModule mvarBzip2 = new Modules.Bzip2.Bzip2CompressionModule(); - public static Modules.Bzip2.Bzip2CompressionModule Bzip2 { get { return mvarBzip2; } } + private static Modules.Bzip2.Bzip2CompressionModule mvarBzip2 = new Modules.Bzip2.Bzip2CompressionModule(); + public static Modules.Bzip2.Bzip2CompressionModule Bzip2 { get { return mvarBzip2; } } - private static Modules.Deflate.DeflateCompressionModule mvarDeflate = new Modules.Deflate.DeflateCompressionModule(); - public static Modules.Deflate.DeflateCompressionModule Deflate { get { return mvarDeflate; } } + private static Modules.Deflate.DeflateCompressionModule mvarDeflate = new Modules.Deflate.DeflateCompressionModule(); + public static Modules.Deflate.DeflateCompressionModule Deflate { get { return mvarDeflate; } } private static Modules.Gzip.GzipCompressionModule mvarGzip = new Modules.Gzip.GzipCompressionModule(); - public static Modules.Gzip.GzipCompressionModule Gzip { get { return mvarGzip; } } + public static Modules.Gzip.GzipCompressionModule Gzip { get { return mvarGzip; } } - private static Modules.Zlib.ZlibCompressionModule mvarZlib = new Modules.Zlib.ZlibCompressionModule(); - public static Modules.Zlib.ZlibCompressionModule Zlib { get { return mvarZlib; } } + private static Modules.Zlib.ZlibCompressionModule mvarZlib = new Modules.Zlib.ZlibCompressionModule(); + public static Modules.Zlib.ZlibCompressionModule Zlib { get { return mvarZlib; } } } } diff --git a/CSharp/Libraries/UniversalEditor.Compression/RLEW/RLEWCompressionModule.cs b/CSharp/Libraries/UniversalEditor.Compression/RLEW/RLEWCompressionModule.cs index 3f6d8a0d..693409c1 100644 --- a/CSharp/Libraries/UniversalEditor.Compression/RLEW/RLEWCompressionModule.cs +++ b/CSharp/Libraries/UniversalEditor.Compression/RLEW/RLEWCompressionModule.cs @@ -6,147 +6,147 @@ using UniversalEditor.Accessors; namespace UniversalEditor.Compression.RLEW { - public class RLEWCompressionModule : CompressionModule - { - public override string Name - { - get { return "RLEW"; } - } + public class RLEWCompressionModule : CompressionModule + { + public override string Name + { + get { return "RLEW"; } + } - private short mvarRLEWTag = 0; - public short RLEWTag { get { return mvarRLEWTag; } set { mvarRLEWTag = value; } } + private short mvarRLEWTag = 0; + public short RLEWTag { get { return mvarRLEWTag; } set { mvarRLEWTag = value; } } protected override void CompressInternal(System.IO.Stream inputStream, System.IO.Stream outputStream) - { - IO.Reader br = new IO.Reader(new StreamAccessor(inputStream)); - IO.Writer bw = new IO.Writer(new StreamAccessor(outputStream)); - - short lastWord = 0; - short wordCount = 0; - bool hasLastWord = false; + { + IO.Reader br = new IO.Reader(new StreamAccessor(inputStream)); + IO.Writer bw = new IO.Writer(new StreamAccessor(outputStream)); + + short lastWord = 0; + short wordCount = 0; + bool hasLastWord = false; - while (!br.EndOfStream) - { - // to make this work efficiently, we need to have at least four equal words - // (RLEWtag + count + value = 3 words) + while (!br.EndOfStream) + { + // to make this work efficiently, we need to have at least four equal words + // (RLEWtag + count + value = 3 words) - // read the next value in - short word = 0; - if (br.Remaining == 0) - { - break; - } - else if (br.Remaining == 1) - { - word = br.ReadByte(); - } - else if (br.Remaining >= 2) - { - word = br.ReadInt16(); - } + // read the next value in + short word = 0; + if (br.Remaining == 0) + { + break; + } + else if (br.Remaining == 1) + { + word = br.ReadByte(); + } + else if (br.Remaining >= 2) + { + word = br.ReadInt16(); + } - if (!hasLastWord) - { - lastWord = word; - hasLastWord = true; - wordCount++; - continue; - } + if (!hasLastWord) + { + lastWord = word; + hasLastWord = true; + wordCount++; + continue; + } - if (word == lastWord) - { - // it's equal to the last word, so increment our word count - wordCount++; + if (word == lastWord) + { + // it's equal to the last word, so increment our word count + wordCount++; - if (wordCount == 4) - { - // we have at least four equal words, so push out an RLEWtag... - bw.WriteInt16(mvarRLEWTag); - } - } - else - { - // word is not equal, flush the remaining words... - if (wordCount <= 3) - { - // we do not have at least four equal words, it would be more efficient to - // just store the values as-is, so flush the remaining words - for (ushort i = 0; i < wordCount; i++) - { - bw.WriteInt16(word); - } + if (wordCount == 4) + { + // we have at least four equal words, so push out an RLEWtag... + bw.WriteInt16(mvarRLEWTag); + } + } + else + { + // word is not equal, flush the remaining words... + if (wordCount <= 3) + { + // we do not have at least four equal words, it would be more efficient to + // just store the values as-is, so flush the remaining words + for (ushort i = 0; i < wordCount; i++) + { + bw.WriteInt16(word); + } - bw.WriteInt16(lastWord); + bw.WriteInt16(lastWord); - lastWord = 0; - wordCount = 0; - } - else - { - bw.WriteInt16(wordCount); - bw.WriteInt16(lastWord); - } + lastWord = 0; + wordCount = 0; + } + else + { + bw.WriteInt16(wordCount); + bw.WriteInt16(lastWord); + } - // ... and clear the word count - lastWord = 0; - wordCount = 0; + // ... and clear the word count + lastWord = 0; + wordCount = 0; - // finally, set the last word to the current word - lastWord = word; - } - } + // finally, set the last word to the current word + lastWord = word; + } + } - // word is not equal, flush the remaining words... - if (wordCount <= 3) - { - // we do not have at least four equal words, it would be more efficient to - // just store the values as-is, so flush the remaining words - for (ushort i = 0; i < wordCount; i++) - { - bw.WriteInt16(lastWord); - } + // word is not equal, flush the remaining words... + if (wordCount <= 3) + { + // we do not have at least four equal words, it would be more efficient to + // just store the values as-is, so flush the remaining words + for (ushort i = 0; i < wordCount; i++) + { + bw.WriteInt16(lastWord); + } - lastWord = 0; - wordCount = 0; - } - else - { - bw.WriteInt16(wordCount); - bw.WriteInt16(lastWord); - } + lastWord = 0; + wordCount = 0; + } + else + { + bw.WriteInt16(wordCount); + bw.WriteInt16(lastWord); + } - bw.Flush(); - } + bw.Flush(); + } protected override void DecompressInternal(System.IO.Stream inputStream, System.IO.Stream outputStream, int inputLength, int outputLength) - { - IO.Reader br = new IO.Reader(new StreamAccessor(inputStream)); - IO.Writer bw = new IO.Writer(new StreamAccessor(outputStream)); - - while (!br.EndOfStream) - { - // read one word from compressed block - short word = br.ReadInt16(); - if (word == mvarRLEWTag) - { - // next two words are a compressed run of data, first word is number - // of words to write - short count = br.ReadInt16(); - short value = br.ReadInt16(); - for (short i = 0; i < count; i++) - { - bw.WriteInt16(value); - } - } - else - { - // if word is not equal to RLEWtag, then simply write that word out - bw.WriteInt16(word); - } - } + { + IO.Reader br = new IO.Reader(new StreamAccessor(inputStream)); + IO.Writer bw = new IO.Writer(new StreamAccessor(outputStream)); + + while (!br.EndOfStream) + { + // read one word from compressed block + short word = br.ReadInt16(); + if (word == mvarRLEWTag) + { + // next two words are a compressed run of data, first word is number + // of words to write + short count = br.ReadInt16(); + short value = br.ReadInt16(); + for (short i = 0; i < count; i++) + { + bw.WriteInt16(value); + } + } + else + { + // if word is not equal to RLEWtag, then simply write that word out + bw.WriteInt16(word); + } + } - bw.Flush(); - bw.Close(); - } - } + bw.Flush(); + bw.Close(); + } + } } diff --git a/CSharp/Libraries/UniversalEditor.Core/Accessor.cs b/CSharp/Libraries/UniversalEditor.Core/Accessor.cs index bb0c75ca..08999a33 100644 --- a/CSharp/Libraries/UniversalEditor.Core/Accessor.cs +++ b/CSharp/Libraries/UniversalEditor.Core/Accessor.cs @@ -7,74 +7,74 @@ using System.Diagnostics; namespace UniversalEditor { - [DebuggerNonUserCode()] - public abstract class Accessor - { - public Accessor() - { - mvarReader = new Reader(this); - mvarWriter = new Writer(this); - } + [DebuggerNonUserCode()] + public abstract class Accessor + { + public Accessor() + { + mvarReader = new Reader(this); + mvarWriter = new Writer(this); + } - public abstract long Length { get; set; } + public abstract long Length { get; set; } protected abstract long GetPosition(); - public virtual long Position { get { return GetPosition(); } set { Seek(value, SeekOrigin.Begin); } } + public virtual long Position { get { return GetPosition(); } set { Seek(value, SeekOrigin.Begin); } } - public long Remaining - { - get - { - long r = Length - Position; - if (r <= 0) return 0; - return r; - } - } + public long Remaining + { + get + { + long r = Length - Position; + if (r <= 0) return 0; + return r; + } + } - public void Seek(int length, SeekOrigin position) - { - Seek((long)length, position); - } - public abstract void Seek(long length, SeekOrigin position); + public void Seek(int length, SeekOrigin position) + { + Seek((long)length, position); + } + public abstract void Seek(long length, SeekOrigin position); - internal abstract int ReadInternal(byte[] buffer, int start, int count); - internal abstract int WriteInternal(byte[] buffer, int start, int count); + internal abstract int ReadInternal(byte[] buffer, int start, int count); + internal abstract int WriteInternal(byte[] buffer, int start, int count); - internal virtual void FlushInternal() - { - } + internal virtual void FlushInternal() + { + } - private bool mvarIsOpen = false; - public bool IsOpen { get { return mvarIsOpen; } protected set { mvarIsOpen = value; } } + private bool mvarIsOpen = false; + public bool IsOpen { get { return mvarIsOpen; } protected set { mvarIsOpen = value; } } - public void Open() - { - if (mvarIsOpen) return; + public void Open() + { + if (mvarIsOpen) return; - OpenInternal(); - mvarIsOpen = true; - } - public void Close() - { - if (!mvarIsOpen) return; + OpenInternal(); + mvarIsOpen = true; + } + public void Close() + { + if (!mvarIsOpen) return; - CloseInternal(); - mvarIsOpen = false; - } + CloseInternal(); + mvarIsOpen = false; + } - protected abstract void OpenInternal(); - protected abstract void CloseInternal(); + protected abstract void OpenInternal(); + protected abstract void CloseInternal(); - private Encoding mvarDefaultEncoding = Encoding.Default; - /// - /// The default to use when reading and writing strings. - /// - public Encoding DefaultEncoding { get { return mvarDefaultEncoding; } set { mvarDefaultEncoding = value; } } + private Encoding mvarDefaultEncoding = Encoding.Default; + /// + /// The default to use when reading and writing strings. + /// + public Encoding DefaultEncoding { get { return mvarDefaultEncoding; } set { mvarDefaultEncoding = value; } } - private Reader mvarReader = null; - public Reader Reader { get { return mvarReader; } } - private Writer mvarWriter = null; - public Writer Writer { get { return mvarWriter; } } + private Reader mvarReader = null; + public Reader Reader { get { return mvarReader; } } + private Writer mvarWriter = null; + public Writer Writer { get { return mvarWriter; } } public virtual string Title { diff --git a/CSharp/Libraries/UniversalEditor.Core/Accessors/MemoryAccessor.cs b/CSharp/Libraries/UniversalEditor.Core/Accessors/MemoryAccessor.cs index a29c507e..c02cbf60 100644 --- a/CSharp/Libraries/UniversalEditor.Core/Accessors/MemoryAccessor.cs +++ b/CSharp/Libraries/UniversalEditor.Core/Accessors/MemoryAccessor.cs @@ -40,7 +40,7 @@ namespace UniversalEditor.Accessors _data = data; } - // [DebuggerNonUserCode()] + // [DebuggerNonUserCode()] public override void Seek(long length, SeekOrigin position) { long start = 0; @@ -81,8 +81,8 @@ namespace UniversalEditor.Accessors internal override int ReadInternal(byte[] buffer, int start, int count) { - System.Array.Copy(_data, Position, buffer, start, count); - Position += count; + System.Array.Copy(_data, Position, buffer, start, count); + Position += count; return count; } internal override int WriteInternal(byte[] buffer, int start, int count) @@ -92,10 +92,10 @@ namespace UniversalEditor.Accessors return count; } - protected override void OpenInternal() + protected override void OpenInternal() { } - protected override void CloseInternal() + protected override void CloseInternal() { } } diff --git a/CSharp/Libraries/UniversalEditor.Core/Accessors/StringAccessor.cs b/CSharp/Libraries/UniversalEditor.Core/Accessors/StringAccessor.cs index afde7ddc..5242e4bf 100644 --- a/CSharp/Libraries/UniversalEditor.Core/Accessors/StringAccessor.cs +++ b/CSharp/Libraries/UniversalEditor.Core/Accessors/StringAccessor.cs @@ -102,10 +102,10 @@ namespace UniversalEditor.Accessors return count; } - protected override void OpenInternal() + protected override void OpenInternal() { } - protected override void CloseInternal() + protected override void CloseInternal() { } } diff --git a/CSharp/Libraries/UniversalEditor.Core/Checksum/Modules/Adler32/Adler32ChecksumModule.cs b/CSharp/Libraries/UniversalEditor.Core/Checksum/Modules/Adler32/Adler32ChecksumModule.cs index 67916cbc..e7e9fbb0 100644 --- a/CSharp/Libraries/UniversalEditor.Core/Checksum/Modules/Adler32/Adler32ChecksumModule.cs +++ b/CSharp/Libraries/UniversalEditor.Core/Checksum/Modules/Adler32/Adler32ChecksumModule.cs @@ -76,10 +76,10 @@ namespace UniversalEditor.Checksum.Modules.Adler32 /// public sealed class Adler32 : ChecksumModule { - public override string Name - { - get { return "Adler32"; } - } + public override string Name + { + get { return "Adler32"; } + } /// /// largest prime smaller than 65536 diff --git a/CSharp/Libraries/UniversalEditor.Core/Checksum/Modules/CRC32/CRC32ChecksumModule.cs b/CSharp/Libraries/UniversalEditor.Core/Checksum/Modules/CRC32/CRC32ChecksumModule.cs index 92eb133b..7fceba7b 100644 --- a/CSharp/Libraries/UniversalEditor.Core/Checksum/Modules/CRC32/CRC32ChecksumModule.cs +++ b/CSharp/Libraries/UniversalEditor.Core/Checksum/Modules/CRC32/CRC32ChecksumModule.cs @@ -40,40 +40,40 @@ using System; namespace UniversalEditor.Checksum.Modules.CRC32 { - /// - /// Generate a table for a byte-wise 32-bit CRC calculation on the polynomial: - /// x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. - /// - /// Polynomials over GF(2) are represented in binary, one bit per coefficient, - /// with the lowest powers in the most significant bit. Then adding polynomials - /// is just exclusive-or, and multiplying a polynomial by x is a right shift by - /// one. If we call the above polynomial p, and represent a byte as the - /// polynomial q, also with the lowest power in the most significant bit (so the - /// byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p, - /// where a mod b means the remainder after dividing a by b. - /// - /// This calculation is done using the shift-register method of multiplying and - /// taking the remainder. The register is initialized to zero, and for each - /// incoming bit, x^32 is added mod p to the register if the bit is a one (where - /// x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by - /// x (which is shifting right by one and adding x^32 mod p if the bit shifted - /// out is a one). We start with the highest power (least significant bit) of - /// q and repeat for all eight bits of q. - /// - /// The table is simply the CRC of all possible eight bit values. This is all - /// the information needed to generate CRC's on data a byte at a time for all - /// combinations of CRC register values and incoming bytes. - /// - public sealed class CRC32ChecksumModule : ChecksumModule - { - const uint CrcSeed = 0xFFFFFFFF; + /// + /// Generate a table for a byte-wise 32-bit CRC calculation on the polynomial: + /// x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. + /// + /// Polynomials over GF(2) are represented in binary, one bit per coefficient, + /// with the lowest powers in the most significant bit. Then adding polynomials + /// is just exclusive-or, and multiplying a polynomial by x is a right shift by + /// one. If we call the above polynomial p, and represent a byte as the + /// polynomial q, also with the lowest power in the most significant bit (so the + /// byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p, + /// where a mod b means the remainder after dividing a by b. + /// + /// This calculation is done using the shift-register method of multiplying and + /// taking the remainder. The register is initialized to zero, and for each + /// incoming bit, x^32 is added mod p to the register if the bit is a one (where + /// x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by + /// x (which is shifting right by one and adding x^32 mod p if the bit shifted + /// out is a one). We start with the highest power (least significant bit) of + /// q and repeat for all eight bits of q. + /// + /// The table is simply the CRC of all possible eight bit values. This is all + /// the information needed to generate CRC's on data a byte at a time for all + /// combinations of CRC register values and incoming bytes. + /// + public sealed class CRC32ChecksumModule : ChecksumModule + { + const uint CrcSeed = 0xFFFFFFFF; - public override string Name - { - get { return "CRC32"; } - } + public override string Name + { + get { return "CRC32"; } + } - readonly static uint[] CrcTable = new uint[] { + readonly static uint[] CrcTable = new uint[] { 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, @@ -128,81 +128,81 @@ namespace UniversalEditor.Checksum.Modules.CRC32 0x2D02EF8D }; - private static uint ComputeCrc32(uint oldCrc, byte value) - { - return (uint)(CrcTable[(oldCrc ^ value) & 0xFF] ^ (oldCrc >> 8)); - } + private static uint ComputeCrc32(uint oldCrc, byte value) + { + return (uint)(CrcTable[(oldCrc ^ value) & 0xFF] ^ (oldCrc >> 8)); + } - /// - /// The crc data checksum so far. - /// - uint crc; + /// + /// The crc data checksum so far. + /// + uint crc; - /// - /// Returns the CRC32 data checksum computed so far. - /// - public override long Value - { - get - { - return (long)crc; - } - } + /// + /// Returns the CRC32 data checksum computed so far. + /// + public override long Value + { + get + { + return (long)crc; + } + } - /// - /// Updates the checksum with the int bval. - /// - /// - /// the byte is taken as the lower 8 bits of value - /// - public override void Update(int value) - { - crc ^= CrcSeed; - crc = CrcTable[(crc ^ value) & 0xFF] ^ (crc >> 8); - crc ^= CrcSeed; - } + /// + /// Updates the checksum with the int bval. + /// + /// + /// the byte is taken as the lower 8 bits of value + /// + public override void Update(int value) + { + crc ^= CrcSeed; + crc = CrcTable[(crc ^ value) & 0xFF] ^ (crc >> 8); + crc ^= CrcSeed; + } - /// - /// Adds the byte array to the data checksum. - /// - /// - /// The buffer which contains the data - /// - /// - /// The offset in the buffer where the data starts - /// - /// - /// The number of data bytes to update the CRC with. - /// - public override void Update(byte[] buffer, int offset, int count) - { - if (buffer == null) - { - throw new ArgumentNullException("buffer"); - } + /// + /// Adds the byte array to the data checksum. + /// + /// + /// The buffer which contains the data + /// + /// + /// The offset in the buffer where the data starts + /// + /// + /// The number of data bytes to update the CRC with. + /// + public override void Update(byte[] buffer, int offset, int count) + { + if (buffer == null) + { + throw new ArgumentNullException("buffer"); + } - if (count < 0) - { + if (count < 0) + { #if NETCF_1_0 throw new ArgumentOutOfRangeException("count"); #else - throw new ArgumentOutOfRangeException("count", "Count cannot be less than zero"); + throw new ArgumentOutOfRangeException("count", "Count cannot be less than zero"); #endif - } + } - if (offset < 0 || offset + count > buffer.Length) - { - throw new ArgumentOutOfRangeException("offset"); - } + if (offset < 0 || offset + count > buffer.Length) + { + throw new ArgumentOutOfRangeException("offset"); + } - crc ^= CrcSeed; + crc ^= CrcSeed; - while (--count >= 0) - { - crc = CrcTable[(crc ^ buffer[offset++]) & 0xFF] ^ (crc >> 8); - } + while (--count >= 0) + { + crc = CrcTable[(crc ^ buffer[offset++]) & 0xFF] ^ (crc >> 8); + } - crc ^= CrcSeed; - } - } + crc ^= CrcSeed; + } + } } diff --git a/CSharp/Libraries/UniversalEditor.Core/Checksum/Modules/StrangeCRC/StrangeCRCChecksumModule.cs b/CSharp/Libraries/UniversalEditor.Core/Checksum/Modules/StrangeCRC/StrangeCRCChecksumModule.cs index 70868113..917ee79b 100644 --- a/CSharp/Libraries/UniversalEditor.Core/Checksum/Modules/StrangeCRC/StrangeCRCChecksumModule.cs +++ b/CSharp/Libraries/UniversalEditor.Core/Checksum/Modules/StrangeCRC/StrangeCRCChecksumModule.cs @@ -45,10 +45,10 @@ namespace UniversalEditor.Checksum.Modules.StrangeCRC /// public class StrangeCRCChecksumModule : ChecksumModule { - public override string Name { get { return "StrangeCRC"; } } + public override string Name { get { return "StrangeCRC"; } } readonly static uint[] crc32Table = - { + { 0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b, 0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61, diff --git a/CSharp/Libraries/UniversalEditor.Core/Document.cs b/CSharp/Libraries/UniversalEditor.Core/Document.cs index 54222ccb..31e2db9c 100644 --- a/CSharp/Libraries/UniversalEditor.Core/Document.cs +++ b/CSharp/Libraries/UniversalEditor.Core/Document.cs @@ -5,19 +5,19 @@ using System.Text; namespace UniversalEditor { - /// - /// Represents a combination of , , and - /// that allows you to easily manipulate documents. The Accessor determines WHERE the data is read from and written - /// to, the DataFormat determines HOW the data is written, and the ObjectModel contains the actual data in a format- - /// agnostic representation. - /// - public class Document - { - private Accessor mvarInputAccessor = null; - /// - /// The which determines where the data is read from. - /// - public Accessor InputAccessor { get { return mvarInputAccessor; } set { mvarInputAccessor = value; } } + /// + /// Represents a combination of , , and + /// that allows you to easily manipulate documents. The Accessor determines WHERE the data is read from and written + /// to, the DataFormat determines HOW the data is written, and the ObjectModel contains the actual data in a format- + /// agnostic representation. + /// + public class Document + { + private Accessor mvarInputAccessor = null; + /// + /// The which determines where the data is read from. + /// + public Accessor InputAccessor { get { return mvarInputAccessor; } set { mvarInputAccessor = value; } } private Accessor mvarOutputAccessor = null; /// @@ -25,11 +25,11 @@ namespace UniversalEditor /// public Accessor OutputAccessor { get { return mvarOutputAccessor; } set { mvarOutputAccessor = value; } } - private DataFormat mvarInputDataFormat = null; - /// + private DataFormat mvarInputDataFormat = null; + /// /// The which determines how the data is read from the accessor. - /// - public DataFormat InputDataFormat { get { return mvarInputDataFormat; } set { mvarInputDataFormat = value; } } + /// + public DataFormat InputDataFormat { get { return mvarInputDataFormat; } set { mvarInputDataFormat = value; } } private DataFormat mvarOutputDataFormat = null; /// @@ -37,57 +37,57 @@ namespace UniversalEditor /// public DataFormat OutputDataFormat { get { return mvarOutputDataFormat; } set { mvarOutputDataFormat = value; } } - private ObjectModel mvarObjectModel = null; - /// - /// The , which stores the actual data in a format-agnostic representation. - /// - public ObjectModel ObjectModel { get { return mvarObjectModel; } set { mvarObjectModel = value; } } + private ObjectModel mvarObjectModel = null; + /// + /// The , which stores the actual data in a format-agnostic representation. + /// + public ObjectModel ObjectModel { get { return mvarObjectModel; } set { mvarObjectModel = value; } } - /// - /// Reads data into the current from the using the - /// current . - /// - public void Load() - { - mvarInputDataFormat.Accessor = mvarInputAccessor; - mvarObjectModel.Accessor = mvarInputAccessor; + /// + /// Reads data into the current from the using the + /// current . + /// + public void Load() + { + mvarInputDataFormat.Accessor = mvarInputAccessor; + mvarObjectModel.Accessor = mvarInputAccessor; mvarInputDataFormat.Load(ref mvarObjectModel); mvarLastUsedAccessor = LastUsedAccessor.Input; - } - /// - /// Writes the data contained in the to the using the - /// current . - /// - public void Save() - { - mvarOutputDataFormat.Accessor = mvarOutputAccessor; - mvarObjectModel.Accessor = mvarOutputAccessor; + } + /// + /// Writes the data contained in the to the using the + /// current . + /// + public void Save() + { + mvarOutputDataFormat.Accessor = mvarOutputAccessor; + mvarObjectModel.Accessor = mvarOutputAccessor; mvarOutputDataFormat.Save(mvarObjectModel); mvarLastUsedAccessor = LastUsedAccessor.Output; - } + } - public Document(ObjectModel objectModel, DataFormat dataFormat) : this(objectModel, dataFormat, null) - { - } - public Document(ObjectModel objectModel, DataFormat dataFormat, Accessor accessor) : this(objectModel, dataFormat, dataFormat, accessor) + public Document(ObjectModel objectModel, DataFormat dataFormat) : this(objectModel, dataFormat, null) + { + } + public Document(ObjectModel objectModel, DataFormat dataFormat, Accessor accessor) : this(objectModel, dataFormat, dataFormat, accessor) { } public Document(ObjectModel objectModel, DataFormat inputDataFormat, DataFormat outputDataFormat, Accessor accessor) : this(objectModel, inputDataFormat, outputDataFormat, accessor, accessor) { } public Document(ObjectModel objectModel, DataFormat inputDataFormat, DataFormat outputDataFormat, Accessor inputAccessor, Accessor outputAccessor) - { - mvarObjectModel = objectModel; + { + mvarObjectModel = objectModel; mvarInputDataFormat = inputDataFormat; mvarOutputDataFormat = outputDataFormat; - mvarInputAccessor = inputAccessor; + mvarInputAccessor = inputAccessor; mvarOutputAccessor = outputAccessor; - } + } public static Document Load(ObjectModel objectModel, DataFormat dataFormat, Accessor accessor, bool autoClose = true) { Document document = new Document(objectModel, dataFormat, accessor); - objectModel.Accessor = document.InputAccessor; + objectModel.Accessor = document.InputAccessor; document.InputAccessor.Open(); document.Load(); if (autoClose) document.InputAccessor.Close(); @@ -95,8 +95,8 @@ namespace UniversalEditor } public static Document Save(ObjectModel objectModel, DataFormat dataFormat, Accessor accessor, bool autoClose = true) { - Document document = new Document(objectModel, dataFormat, accessor); - objectModel.Accessor = document.OutputAccessor; + Document document = new Document(objectModel, dataFormat, accessor); + objectModel.Accessor = document.OutputAccessor; document.OutputAccessor.Open(); document.Save(); if (autoClose) document.OutputAccessor.Close(); diff --git a/CSharp/Libraries/UniversalEditor.Core/ExtensionMethods.cs b/CSharp/Libraries/UniversalEditor.Core/ExtensionMethods.cs index c939d3e9..384a419a 100644 --- a/CSharp/Libraries/UniversalEditor.Core/ExtensionMethods.cs +++ b/CSharp/Libraries/UniversalEditor.Core/ExtensionMethods.cs @@ -528,13 +528,13 @@ namespace UniversalEditor } public static byte[] ToByteArray(this System.IO.Stream stream) { - long oldpos = stream.Position; + long oldpos = stream.Position; byte[] array = new byte[(int)((IntPtr)stream.Length)]; stream.Position = 0L; stream.Read(array, 0, array.Length); - stream.Position = oldpos; + stream.Position = oldpos; return array; } #endregion diff --git a/CSharp/Libraries/UniversalEditor.Core/IO/Encoding.cs b/CSharp/Libraries/UniversalEditor.Core/IO/Encoding.cs index 94e3d2ef..f35e66bc 100644 --- a/CSharp/Libraries/UniversalEditor.Core/IO/Encoding.cs +++ b/CSharp/Libraries/UniversalEditor.Core/IO/Encoding.cs @@ -17,12 +17,12 @@ namespace UniversalEditor.IO { - public abstract class Encoding - { - private static Encoding _Default = new DefaultEncoding(); - public static Encoding Default - { - get { return _Default; } + public abstract class Encoding + { + private static Encoding _Default = new DefaultEncoding(); + public static Encoding Default + { + get { return _Default; } } private static Encoding _ASCII = new ASCIIEncoding(); public static Encoding ASCII @@ -62,32 +62,32 @@ namespace UniversalEditor.IO get { return _ShiftJIS; } } - public byte[] GetBytes(string value) - { - return GetBytes(value.ToCharArray()); - } - public byte[] GetBytes(char[] chars) - { - return GetBytes(chars, 0, chars.Length); - } - public abstract byte[] GetBytes(char[] chars, int index, int count); + public byte[] GetBytes(string value) + { + return GetBytes(value.ToCharArray()); + } + public byte[] GetBytes(char[] chars) + { + return GetBytes(chars, 0, chars.Length); + } + public abstract byte[] GetBytes(char[] chars, int index, int count); - public string GetString(byte[] bytes) - { - return GetString(bytes, 0, bytes.Length); - } - public string GetString(byte[] bytes, int index, int count) - { - char[] chars = GetChars(bytes, index, count); + public string GetString(byte[] bytes) + { + return GetString(bytes, 0, bytes.Length); + } + public string GetString(byte[] bytes, int index, int count) + { + char[] chars = GetChars(bytes, index, count); string retval = new string(chars); - return retval; - } + return retval; + } - public char[] GetChars(byte[] bytes) - { - return GetChars(bytes, 0, bytes.Length); - } - public abstract char[] GetChars(byte[] bytes, int index, int count); + public char[] GetChars(byte[] bytes) + { + return GetChars(bytes, 0, bytes.Length); + } + public abstract char[] GetChars(byte[] bytes, int index, int count); public virtual int GetMaxByteCount(int count) { @@ -115,27 +115,27 @@ namespace UniversalEditor.IO return GetByteCount(chars, 0, chars.Length); } } - public class DefaultEncoding : Encoding - { - public override byte[] GetBytes(char[] chars, int index, int count) - { - byte[] bytes = new byte[count]; - for (int i = 0; i < chars.Length; i++) - { - bytes[i] = (byte)(chars[i]); - } - return bytes; - } - public override char[] GetChars(byte[] bytes, int index, int count) - { - char[] retval = new char[count]; - for (int i = 0; i < count; i++) - { - retval[i] = (char)bytes[i]; - } - return retval; - } - } + public class DefaultEncoding : Encoding + { + public override byte[] GetBytes(char[] chars, int index, int count) + { + byte[] bytes = new byte[count]; + for (int i = 0; i < chars.Length; i++) + { + bytes[i] = (byte)(chars[i]); + } + return bytes; + } + public override char[] GetChars(byte[] bytes, int index, int count) + { + char[] retval = new char[count]; + for (int i = 0; i < count; i++) + { + retval[i] = (char)bytes[i]; + } + return retval; + } + } public class ASCIIEncoding : Encoding { private System.Text.Encoding _encoding = System.Text.Encoding.ASCII; diff --git a/CSharp/Libraries/UniversalEditor.Core/IO/Writer.cs b/CSharp/Libraries/UniversalEditor.Core/IO/Writer.cs index 57c1e8b9..90372328 100644 --- a/CSharp/Libraries/UniversalEditor.Core/IO/Writer.cs +++ b/CSharp/Libraries/UniversalEditor.Core/IO/Writer.cs @@ -21,9 +21,9 @@ using System.IO; namespace UniversalEditor.IO { - public class Writer + public class Writer { - private Accessor mvarAccessor = null; + private Accessor mvarAccessor = null; public Accessor Accessor { get { return mvarAccessor; } } private Endianness mvarEndianness = Endianness.LittleEndian; @@ -33,71 +33,71 @@ namespace UniversalEditor.IO set { mvarEndianness = value; } } - private NewLineSequence mvarNewLineSequence = NewLineSequence.Default; - public NewLineSequence NewLineSequence { get { return mvarNewLineSequence; } set { mvarNewLineSequence = value; } } - public string GetNewLineSequence() - { - string newline = System.Environment.NewLine; - switch (mvarNewLineSequence) - { - case IO.NewLineSequence.CarriageReturn: - { - newline = "\r"; - break; - } - case IO.NewLineSequence.LineFeed: - { - newline = "\n"; - break; - } - case IO.NewLineSequence.CarriageReturnLineFeed: - { - newline = "\r\n"; - break; - } - } - return newline; - } + private NewLineSequence mvarNewLineSequence = NewLineSequence.Default; + public NewLineSequence NewLineSequence { get { return mvarNewLineSequence; } set { mvarNewLineSequence = value; } } + public string GetNewLineSequence() + { + string newline = System.Environment.NewLine; + switch (mvarNewLineSequence) + { + case IO.NewLineSequence.CarriageReturn: + { + newline = "\r"; + break; + } + case IO.NewLineSequence.LineFeed: + { + newline = "\n"; + break; + } + case IO.NewLineSequence.CarriageReturnLineFeed: + { + newline = "\r\n"; + break; + } + } + return newline; + } - public void SwapEndianness() - { - if (mvarEndianness == IO.Endianness.LittleEndian) - { - mvarEndianness = IO.Endianness.BigEndian; - } - else - { - mvarEndianness = IO.Endianness.LittleEndian; - } - } + public void SwapEndianness() + { + if (mvarEndianness == IO.Endianness.LittleEndian) + { + mvarEndianness = IO.Endianness.BigEndian; + } + else + { + mvarEndianness = IO.Endianness.LittleEndian; + } + } - public Writer(Accessor accessor) - { - mvarAccessor = accessor; - } + public Writer(Accessor accessor) + { + mvarAccessor = accessor; + } - public void Write(byte[] buffer, int start, int count) - { - mvarAccessor.WriteInternal(buffer, start, count); - } + public void Write(byte[] buffer, int start, int count) + { + mvarAccessor.WriteInternal(buffer, start, count); + } public void WriteBoolean(bool value) { WriteByte(value ? (byte)1 : (byte)0); } - public void WriteByte(byte value) - { - WriteBytes(new byte[] { value }); - } - public void WriteSByte(sbyte value) - { - WriteBytes(new byte[] { (byte)value }); - } - public void WriteBytes(byte[] data) - { - if (data == null) return; - Write(data, 0, data.Length); - } + public void WriteByte(byte value) + { + WriteBytes(new byte[] { value }); + } + public void WriteSByte(sbyte value) + { + WriteBytes(new byte[] { (byte)value }); + } + public void WriteBytes(byte[] data) + { + if (data == null) return; + Write(data, 0, data.Length); + } public void WriteFixedLengthBytes(byte[] data, int count) { @@ -106,163 +106,163 @@ namespace UniversalEditor.IO WriteBytes(realdata); } - public void WriteChar(char value) - { - WriteChar(value, mvarAccessor.DefaultEncoding); - } - public void WriteChar(char value, Encoding encoding) - { - byte[] data = encoding.GetBytes(new char[] { value }); - WriteBytes(data); - } + public void WriteChar(char value) + { + WriteChar(value, mvarAccessor.DefaultEncoding); + } + public void WriteChar(char value, Encoding encoding) + { + byte[] data = encoding.GetBytes(new char[] { value }); + WriteBytes(data); + } - public void Write(char value) - { - Write(value.ToString()); - } - public void Write(string value) - { - WriteFixedLengthString(value); - } - public void WriteLine() - { - WriteLine(String.Empty); - } - public void WriteLine(char value) - { - WriteLine(value.ToString()); - } - public void WriteLine(string value) - { - WriteFixedLengthString(value + GetNewLineSequence()); - } + public void Write(char value) + { + Write(value.ToString()); + } + public void Write(string value) + { + WriteFixedLengthString(value); + } + public void WriteLine() + { + WriteLine(String.Empty); + } + public void WriteLine(char value) + { + WriteLine(value.ToString()); + } + public void WriteLine(string value) + { + WriteFixedLengthString(value + GetNewLineSequence()); + } - public void WriteGuid(Guid guid) - { - WriteBytes(guid.ToByteArray()); - } - public void WriteFixedLengthString(string value) - { - WriteFixedLengthString(value, mvarAccessor.DefaultEncoding); - } - public void WriteFixedLengthString(string value, int length) - { - WriteFixedLengthString(value, mvarAccessor.DefaultEncoding, length); - } - public void WriteFixedLengthString(string value, uint length) - { + public void WriteGuid(Guid guid) + { + WriteBytes(guid.ToByteArray()); + } + public void WriteFixedLengthString(string value) + { + WriteFixedLengthString(value, mvarAccessor.DefaultEncoding); + } + public void WriteFixedLengthString(string value, int length) + { WriteFixedLengthString(value, mvarAccessor.DefaultEncoding, length); - } - public void WriteFixedLengthString(string value, Encoding encoding) - { - byte[] data = encoding.GetBytes(value); - WriteBytes(data); - } - public void WriteFixedLengthString(string value, int length, char paddingChar) - { + } + public void WriteFixedLengthString(string value, uint length) + { + WriteFixedLengthString(value, mvarAccessor.DefaultEncoding, length); + } + public void WriteFixedLengthString(string value, Encoding encoding) + { + byte[] data = encoding.GetBytes(value); + WriteBytes(data); + } + public void WriteFixedLengthString(string value, int length, char paddingChar) + { WriteFixedLengthString(value, mvarAccessor.DefaultEncoding, length, paddingChar); - } - public void WriteFixedLengthString(string value, uint length, char paddingChar) - { + } + public void WriteFixedLengthString(string value, uint length, char paddingChar) + { this.WriteFixedLengthString(value, mvarAccessor.DefaultEncoding, length, paddingChar); - } - public void WriteFixedLengthString(string value, Encoding encoding, int length) - { - this.WriteFixedLengthString(value, encoding, length, '\0'); - } - public void WriteFixedLengthString(string value, Encoding encoding, uint length) - { - WriteFixedLengthString(value, encoding, length, '\0'); - } - public void WriteFixedLengthString(string value, Encoding encoding, int length, char paddingChar) - { - WriteFixedLengthString(value, encoding, (uint)length, paddingChar); - } - public void WriteFixedLengthString(string value, Encoding encoding, uint length, char paddingChar) - { - string v = value; + } + public void WriteFixedLengthString(string value, Encoding encoding, int length) + { + this.WriteFixedLengthString(value, encoding, length, '\0'); + } + public void WriteFixedLengthString(string value, Encoding encoding, uint length) + { + WriteFixedLengthString(value, encoding, length, '\0'); + } + public void WriteFixedLengthString(string value, Encoding encoding, int length, char paddingChar) + { + WriteFixedLengthString(value, encoding, (uint)length, paddingChar); + } + public void WriteFixedLengthString(string value, Encoding encoding, uint length, char paddingChar) + { + string v = value; if (v == null) v = String.Empty; - byte[] data = encoding.GetBytes(v); - byte[] realData = new byte[length]; + byte[] data = encoding.GetBytes(v); + byte[] realData = new byte[length]; - uint realLength = length; - if (data.Length < realLength) - { - realLength = (uint)data.Length; - } - Array.Copy(data, 0, realData, 0, realLength); + uint realLength = length; + if (data.Length < realLength) + { + realLength = (uint)data.Length; + } + Array.Copy(data, 0, realData, 0, realLength); - for (int i = data.Length; i < realData.Length; i++) - { - realData[i] = (byte)paddingChar; - } - WriteBytes(realData); - } + for (int i = data.Length; i < realData.Length; i++) + { + realData[i] = (byte)paddingChar; + } + WriteBytes(realData); + } - public void WriteLengthPrefixedString(string value) - { - WriteLengthPrefixedString(value, mvarAccessor.DefaultEncoding); - } - public void WriteLengthPrefixedString(string value, Encoding encoding) - { - throw new NotImplementedException(); - } + public void WriteLengthPrefixedString(string value) + { + WriteLengthPrefixedString(value, mvarAccessor.DefaultEncoding); + } + public void WriteLengthPrefixedString(string value, Encoding encoding) + { + throw new NotImplementedException(); + } - public void WriteNullTerminatedString(string sz) - { - if (sz != null) - { - for (int i = 0; i < sz.Length; i++) - { - WriteChar(sz[i]); - } - } - WriteChar('\0'); - } - public void WriteNullTerminatedString(string sz, Encoding encoding) - { + public void WriteNullTerminatedString(string sz) + { + if (sz != null) + { + for (int i = 0; i < sz.Length; i++) + { + WriteChar(sz[i]); + } + } + WriteChar('\0'); + } + public void WriteNullTerminatedString(string sz, Encoding encoding) + { byte[] values = encoding.GetBytes(sz); WriteBytes(values); WriteInt16(0); - } - public void WriteNullTerminatedString(string sz, int length) - { - this.WriteFixedLengthString(sz, length); - } - - public void WriteInt16(short value) - { - byte[] _buffer = BitConverter.GetBytes(value); - byte[] buffer = new byte[2]; - if (mvarEndianness == Endianness.BigEndian) - { - buffer[1] = _buffer[0]; - buffer[0] = _buffer[1]; - } - else - { - buffer[0] = _buffer[0]; - buffer[1] = _buffer[1]; - } - WriteBytes(buffer); - } - public void WriteUInt16(ushort value) - { - byte[] _buffer = BitConverter.GetBytes(value); - byte[] buffer = new byte[2]; - if (mvarEndianness == Endianness.BigEndian) - { - buffer[1] = _buffer[0]; - buffer[0] = _buffer[1]; - } - else - { - buffer[0] = _buffer[0]; - buffer[1] = _buffer[1]; - } - WriteBytes(buffer); - } + } + public void WriteNullTerminatedString(string sz, int length) + { + this.WriteFixedLengthString(sz, length); + } + + public void WriteInt16(short value) + { + byte[] _buffer = BitConverter.GetBytes(value); + byte[] buffer = new byte[2]; + if (mvarEndianness == Endianness.BigEndian) + { + buffer[1] = _buffer[0]; + buffer[0] = _buffer[1]; + } + else + { + buffer[0] = _buffer[0]; + buffer[1] = _buffer[1]; + } + WriteBytes(buffer); + } + public void WriteUInt16(ushort value) + { + byte[] _buffer = BitConverter.GetBytes(value); + byte[] buffer = new byte[2]; + if (mvarEndianness == Endianness.BigEndian) + { + buffer[1] = _buffer[0]; + buffer[0] = _buffer[1]; + } + else + { + buffer[0] = _buffer[0]; + buffer[1] = _buffer[1]; + } + WriteBytes(buffer); + } public void WriteInt24 (int value) { byte[] buffer = new byte[3]; @@ -280,117 +280,117 @@ namespace UniversalEditor.IO } WriteBytes(buffer); } - public void WriteUInt24(uint value) - { - byte[] buffer = new byte[3]; - if (mvarEndianness == Endianness.BigEndian) - { - buffer[2] = (byte)value; - buffer[1] = (byte)(value >> 8); - buffer[0] = (byte)(value >> 16); - } - else - { - buffer[0] = (byte)value; - buffer[1] = (byte)(value >> 8); - buffer[2] = (byte)(value >> 16); - } - WriteBytes(buffer); - } - public void WriteInt32(int value) - { - byte[] _buffer = BitConverter.GetBytes(value); - byte[] buffer = new byte[4]; - if (mvarEndianness == Endianness.BigEndian) - { - buffer[3] = _buffer[0]; - buffer[2] = _buffer[1]; - buffer[1] = _buffer[2]; - buffer[0] = _buffer[3]; - } - else - { - buffer[0] = _buffer[0]; - buffer[1] = _buffer[1]; - buffer[2] = _buffer[2]; - buffer[3] = _buffer[3]; - } - WriteBytes(buffer); - } - public void WriteUInt32(uint value) - { - byte[] _buffer = BitConverter.GetBytes(value); - byte[] buffer = new byte[4]; - if (mvarEndianness == Endianness.BigEndian) - { - buffer[3] = _buffer[0]; - buffer[2] = _buffer[1]; - buffer[1] = _buffer[2]; - buffer[0] = _buffer[3]; - } - else - { - buffer[0] = _buffer[0]; - buffer[1] = _buffer[1]; - buffer[2] = _buffer[2]; - buffer[3] = _buffer[3]; - } - WriteBytes(buffer); - } - public void WriteInt64(long value) - { - byte[] _buffer = new byte[8]; - if (mvarEndianness == IO.Endianness.BigEndian) - { - _buffer[0] = (byte)(value >> 56); - _buffer[1] = (byte)(value >> 48); - _buffer[2] = (byte)(value >> 40); - _buffer[3] = (byte)(value >> 32); - _buffer[4] = (byte)(value >> 24); - _buffer[5] = (byte)(value >> 16); - _buffer[6] = (byte)(value >> 8); - _buffer[7] = (byte)value; - } - else - { - _buffer[0] = (byte)value; - _buffer[1] = (byte)(value >> 8); - _buffer[2] = (byte)(value >> 16); - _buffer[3] = (byte)(value >> 24); - _buffer[4] = (byte)(value >> 32); - _buffer[5] = (byte)(value >> 40); - _buffer[6] = (byte)(value >> 48); - _buffer[7] = (byte)(value >> 56); - } - WriteBytes(_buffer); - } - public void WriteUInt64(ulong value) - { - byte[] _buffer = new byte[8]; - if (mvarEndianness == IO.Endianness.BigEndian) - { - _buffer[0] = (byte)(value >> 56); - _buffer[1] = (byte)(value >> 48); - _buffer[2] = (byte)(value >> 40); - _buffer[3] = (byte)(value >> 32); - _buffer[4] = (byte)(value >> 24); - _buffer[5] = (byte)(value >> 16); - _buffer[6] = (byte)(value >> 8); - _buffer[7] = (byte)value; - } - else - { - _buffer[0] = (byte)value; - _buffer[1] = (byte)(value >> 8); - _buffer[2] = (byte)(value >> 16); - _buffer[3] = (byte)(value >> 24); - _buffer[4] = (byte)(value >> 32); - _buffer[5] = (byte)(value >> 40); - _buffer[6] = (byte)(value >> 48); - _buffer[7] = (byte)(value >> 56); - } - WriteBytes(_buffer); - } + public void WriteUInt24(uint value) + { + byte[] buffer = new byte[3]; + if (mvarEndianness == Endianness.BigEndian) + { + buffer[2] = (byte)value; + buffer[1] = (byte)(value >> 8); + buffer[0] = (byte)(value >> 16); + } + else + { + buffer[0] = (byte)value; + buffer[1] = (byte)(value >> 8); + buffer[2] = (byte)(value >> 16); + } + WriteBytes(buffer); + } + public void WriteInt32(int value) + { + byte[] _buffer = BitConverter.GetBytes(value); + byte[] buffer = new byte[4]; + if (mvarEndianness == Endianness.BigEndian) + { + buffer[3] = _buffer[0]; + buffer[2] = _buffer[1]; + buffer[1] = _buffer[2]; + buffer[0] = _buffer[3]; + } + else + { + buffer[0] = _buffer[0]; + buffer[1] = _buffer[1]; + buffer[2] = _buffer[2]; + buffer[3] = _buffer[3]; + } + WriteBytes(buffer); + } + public void WriteUInt32(uint value) + { + byte[] _buffer = BitConverter.GetBytes(value); + byte[] buffer = new byte[4]; + if (mvarEndianness == Endianness.BigEndian) + { + buffer[3] = _buffer[0]; + buffer[2] = _buffer[1]; + buffer[1] = _buffer[2]; + buffer[0] = _buffer[3]; + } + else + { + buffer[0] = _buffer[0]; + buffer[1] = _buffer[1]; + buffer[2] = _buffer[2]; + buffer[3] = _buffer[3]; + } + WriteBytes(buffer); + } + public void WriteInt64(long value) + { + byte[] _buffer = new byte[8]; + if (mvarEndianness == IO.Endianness.BigEndian) + { + _buffer[0] = (byte)(value >> 56); + _buffer[1] = (byte)(value >> 48); + _buffer[2] = (byte)(value >> 40); + _buffer[3] = (byte)(value >> 32); + _buffer[4] = (byte)(value >> 24); + _buffer[5] = (byte)(value >> 16); + _buffer[6] = (byte)(value >> 8); + _buffer[7] = (byte)value; + } + else + { + _buffer[0] = (byte)value; + _buffer[1] = (byte)(value >> 8); + _buffer[2] = (byte)(value >> 16); + _buffer[3] = (byte)(value >> 24); + _buffer[4] = (byte)(value >> 32); + _buffer[5] = (byte)(value >> 40); + _buffer[6] = (byte)(value >> 48); + _buffer[7] = (byte)(value >> 56); + } + WriteBytes(_buffer); + } + public void WriteUInt64(ulong value) + { + byte[] _buffer = new byte[8]; + if (mvarEndianness == IO.Endianness.BigEndian) + { + _buffer[0] = (byte)(value >> 56); + _buffer[1] = (byte)(value >> 48); + _buffer[2] = (byte)(value >> 40); + _buffer[3] = (byte)(value >> 32); + _buffer[4] = (byte)(value >> 24); + _buffer[5] = (byte)(value >> 16); + _buffer[6] = (byte)(value >> 8); + _buffer[7] = (byte)value; + } + else + { + _buffer[0] = (byte)value; + _buffer[1] = (byte)(value >> 8); + _buffer[2] = (byte)(value >> 16); + _buffer[3] = (byte)(value >> 24); + _buffer[4] = (byte)(value >> 32); + _buffer[5] = (byte)(value >> 40); + _buffer[6] = (byte)(value >> 48); + _buffer[7] = (byte)(value >> 56); + } + WriteBytes(_buffer); + } public void WriteObject (object value) { @@ -485,104 +485,104 @@ namespace UniversalEditor.IO WriteInt64(value.ToBinary()); } - public void WriteDecimal(decimal value) - { - int[] bits = decimal.GetBits(value); - int lo = bits[0], mid = bits[1], hi = bits[2], flags = bits[3]; + public void WriteDecimal(decimal value) + { + int[] bits = decimal.GetBits(value); + int lo = bits[0], mid = bits[1], hi = bits[2], flags = bits[3]; - byte[] buffer = new byte[16]; - if (mvarEndianness == IO.Endianness.LittleEndian) - { - buffer[0] = (byte)lo; - buffer[1] = (byte)(lo >> 8); - buffer[2] = (byte)(lo >> 16); - buffer[3] = (byte)(lo >> 24); - buffer[4] = (byte)mid; - buffer[5] = (byte)(mid >> 8); - buffer[6] = (byte)(mid >> 16); - buffer[7] = (byte)(mid >> 24); - buffer[8] = (byte)hi; - buffer[9] = (byte)(hi >> 8); - buffer[10] = (byte)(hi >> 16); - buffer[11] = (byte)(hi >> 24); - buffer[12] = (byte)flags; - buffer[13] = (byte)(flags >> 8); - buffer[14] = (byte)(flags >> 16); - buffer[15] = (byte)(flags >> 24); - } - else - { - buffer[15] = (byte)lo; - buffer[14] = (byte)(lo >> 8); - buffer[13] = (byte)(lo >> 16); - buffer[12] = (byte)(lo >> 24); - buffer[11] = (byte)mid; - buffer[10] = (byte)(mid >> 8); - buffer[9] = (byte)(mid >> 16); - buffer[9] = (byte)(mid >> 24); - buffer[7] = (byte)hi; - buffer[6] = (byte)(hi >> 8); - buffer[5] = (byte)(hi >> 16); - buffer[4] = (byte)(hi >> 24); - buffer[3] = (byte)flags; - buffer[2] = (byte)(flags >> 8); - buffer[1] = (byte)(flags >> 16); - buffer[0] = (byte)(flags >> 24); - } - WriteBytes(buffer); - } + byte[] buffer = new byte[16]; + if (mvarEndianness == IO.Endianness.LittleEndian) + { + buffer[0] = (byte)lo; + buffer[1] = (byte)(lo >> 8); + buffer[2] = (byte)(lo >> 16); + buffer[3] = (byte)(lo >> 24); + buffer[4] = (byte)mid; + buffer[5] = (byte)(mid >> 8); + buffer[6] = (byte)(mid >> 16); + buffer[7] = (byte)(mid >> 24); + buffer[8] = (byte)hi; + buffer[9] = (byte)(hi >> 8); + buffer[10] = (byte)(hi >> 16); + buffer[11] = (byte)(hi >> 24); + buffer[12] = (byte)flags; + buffer[13] = (byte)(flags >> 8); + buffer[14] = (byte)(flags >> 16); + buffer[15] = (byte)(flags >> 24); + } + else + { + buffer[15] = (byte)lo; + buffer[14] = (byte)(lo >> 8); + buffer[13] = (byte)(lo >> 16); + buffer[12] = (byte)(lo >> 24); + buffer[11] = (byte)mid; + buffer[10] = (byte)(mid >> 8); + buffer[9] = (byte)(mid >> 16); + buffer[9] = (byte)(mid >> 24); + buffer[7] = (byte)hi; + buffer[6] = (byte)(hi >> 8); + buffer[5] = (byte)(hi >> 16); + buffer[4] = (byte)(hi >> 24); + buffer[3] = (byte)flags; + buffer[2] = (byte)(flags >> 8); + buffer[1] = (byte)(flags >> 16); + buffer[0] = (byte)(flags >> 24); + } + WriteBytes(buffer); + } - public void WriteVersion(Version version) - { - WriteVersion(version, 4); - } - public void WriteVersion(Version version, int count) - { - switch (count) - { - case 1: - { - WriteByte(1); - WriteInt32(version.Major); - break; - } - case 2: - { - WriteByte(2); - WriteInt32(version.Major); - WriteInt32(version.Minor); - break; - } - case 3: - { - WriteByte(3); - WriteInt32(version.Major); - WriteInt32(version.Minor); - WriteInt32(version.Build); - break; - } - case 4: - { - WriteByte(4); - WriteInt32(version.Major); - WriteInt32(version.Minor); - WriteInt32(version.Build); - WriteInt32(version.Revision); - break; - } - } - } + public void WriteVersion(Version version) + { + WriteVersion(version, 4); + } + public void WriteVersion(Version version, int count) + { + switch (count) + { + case 1: + { + WriteByte(1); + WriteInt32(version.Major); + break; + } + case 2: + { + WriteByte(2); + WriteInt32(version.Major); + WriteInt32(version.Minor); + break; + } + case 3: + { + WriteByte(3); + WriteInt32(version.Major); + WriteInt32(version.Minor); + WriteInt32(version.Build); + break; + } + case 4: + { + WriteByte(4); + WriteInt32(version.Major); + WriteInt32(version.Minor); + WriteInt32(version.Build); + WriteInt32(version.Revision); + break; + } + } + } - public long CountAlignment(int paddingCount) - { - return CountAlignment(paddingCount, 0); - } - public long CountAlignment(int paddingCount, int dataCount) - { - long position = (mvarAccessor.Position + dataCount); - int num = (int)(position % paddingCount); - return num; - } + public long CountAlignment(int paddingCount) + { + return CountAlignment(paddingCount, 0); + } + public long CountAlignment(int paddingCount, int dataCount) + { + long position = (mvarAccessor.Position + dataCount); + int num = (int)(position % paddingCount); + return num; + } public void Align(int paddingCount) @@ -600,9 +600,9 @@ namespace UniversalEditor.IO } case 4: { - long num = mvarAccessor.Position; + long num = mvarAccessor.Position; num = (num + 3L & -4L); - long num2 = num - mvarAccessor.Position; + long num2 = num - mvarAccessor.Position; byte[] array = new byte[num2]; array.Initialize(); WriteBytes(array); @@ -610,106 +610,106 @@ namespace UniversalEditor.IO } default: { - long count = (mvarAccessor.Position % paddingCount); - byte[] array = new byte[count]; - WriteBytes(array); - break; + long count = (mvarAccessor.Position % paddingCount); + byte[] array = new byte[count]; + WriteBytes(array); + break; } } } - public void WriteSingle(float value) - { - byte[] buffer = BitConverter.GetBytes(value); - byte[] _buffer = new byte[4]; - if (mvarEndianness == IO.Endianness.BigEndian) - { - _buffer[0] = buffer[3]; - _buffer[1] = buffer[2]; - _buffer[2] = buffer[1]; - _buffer[3] = buffer[0]; - } - else - { - _buffer[0] = buffer[0]; - _buffer[1] = buffer[1]; - _buffer[2] = buffer[2]; - _buffer[3] = buffer[3]; - } - WriteBytes(_buffer); - } - public void WriteDouble(double value) - { - byte[] buffer = BitConverter.GetBytes(value); - byte[] _buffer = new byte[8]; - if (mvarEndianness == IO.Endianness.BigEndian) - { - _buffer[0] = buffer[7]; - _buffer[1] = buffer[6]; - _buffer[2] = buffer[5]; - _buffer[3] = buffer[4]; - _buffer[4] = buffer[3]; - _buffer[5] = buffer[2]; - _buffer[6] = buffer[1]; - _buffer[7] = buffer[0]; - } - else - { - _buffer[0] = buffer[0]; - _buffer[1] = buffer[1]; - _buffer[2] = buffer[2]; - _buffer[3] = buffer[3]; - _buffer[4] = buffer[4]; - _buffer[5] = buffer[5]; - _buffer[6] = buffer[6]; - _buffer[7] = buffer[7]; - } - WriteBytes(_buffer); - } + public void WriteSingle(float value) + { + byte[] buffer = BitConverter.GetBytes(value); + byte[] _buffer = new byte[4]; + if (mvarEndianness == IO.Endianness.BigEndian) + { + _buffer[0] = buffer[3]; + _buffer[1] = buffer[2]; + _buffer[2] = buffer[1]; + _buffer[3] = buffer[0]; + } + else + { + _buffer[0] = buffer[0]; + _buffer[1] = buffer[1]; + _buffer[2] = buffer[2]; + _buffer[3] = buffer[3]; + } + WriteBytes(_buffer); + } + public void WriteDouble(double value) + { + byte[] buffer = BitConverter.GetBytes(value); + byte[] _buffer = new byte[8]; + if (mvarEndianness == IO.Endianness.BigEndian) + { + _buffer[0] = buffer[7]; + _buffer[1] = buffer[6]; + _buffer[2] = buffer[5]; + _buffer[3] = buffer[4]; + _buffer[4] = buffer[3]; + _buffer[5] = buffer[2]; + _buffer[6] = buffer[1]; + _buffer[7] = buffer[0]; + } + else + { + _buffer[0] = buffer[0]; + _buffer[1] = buffer[1]; + _buffer[2] = buffer[2]; + _buffer[3] = buffer[3]; + _buffer[4] = buffer[4]; + _buffer[5] = buffer[5]; + _buffer[6] = buffer[6]; + _buffer[7] = buffer[7]; + } + WriteBytes(_buffer); + } - public void WriteDoubleEndianInt16(short value) - { - WriteInt16(value); - SwapEndianness(); - WriteInt16(value); - SwapEndianness(); - } - public void WriteDoubleEndianInt32(int value) - { - WriteInt32(value); - SwapEndianness(); - WriteInt32(value); - SwapEndianness(); - } - public void WriteDoubleEndianInt64(long value) - { - WriteInt64(value); - SwapEndianness(); - WriteInt64(value); - SwapEndianness(); - } - public void WriteDoubleEndianUInt16(ushort value) - { - WriteUInt16(value); - SwapEndianness(); - WriteUInt16(value); - SwapEndianness(); - } - public void WriteDoubleEndianUInt32(uint value) - { - WriteUInt32(value); - SwapEndianness(); - WriteUInt32(value); - SwapEndianness(); - } - public void WriteDoubleEndianUInt64(ulong value) - { - WriteUInt64(value); - SwapEndianness(); - WriteUInt64(value); - SwapEndianness(); - } + public void WriteDoubleEndianInt16(short value) + { + WriteInt16(value); + SwapEndianness(); + WriteInt16(value); + SwapEndianness(); + } + public void WriteDoubleEndianInt32(int value) + { + WriteInt32(value); + SwapEndianness(); + WriteInt32(value); + SwapEndianness(); + } + public void WriteDoubleEndianInt64(long value) + { + WriteInt64(value); + SwapEndianness(); + WriteInt64(value); + SwapEndianness(); + } + public void WriteDoubleEndianUInt16(ushort value) + { + WriteUInt16(value); + SwapEndianness(); + WriteUInt16(value); + SwapEndianness(); + } + public void WriteDoubleEndianUInt32(uint value) + { + WriteUInt32(value); + SwapEndianness(); + WriteUInt32(value); + SwapEndianness(); + } + public void WriteDoubleEndianUInt64(ulong value) + { + WriteUInt64(value); + SwapEndianness(); + WriteUInt64(value); + SwapEndianness(); + } public void WriteUInt16SizedString(string value) { @@ -724,20 +724,20 @@ namespace UniversalEditor.IO WriteBytes(output); } - public void WriteInt64String(string value) - { - WriteInt64(value.Length); - WriteFixedLengthString(value); - } + public void WriteInt64String(string value) + { + WriteInt64(value.Length); + WriteFixedLengthString(value); + } - public void Flush() - { - mvarAccessor.FlushInternal(); - } + public void Flush() + { + mvarAccessor.FlushInternal(); + } public void Close() { mvarAccessor.Close(); } - } + } } diff --git a/CSharp/Libraries/UniversalEditor.Core/Localization/StringTable.cs b/CSharp/Libraries/UniversalEditor.Core/Localization/StringTable.cs index 82865a56..4f7ade2c 100644 --- a/CSharp/Libraries/UniversalEditor.Core/Localization/StringTable.cs +++ b/CSharp/Libraries/UniversalEditor.Core/Localization/StringTable.cs @@ -4,24 +4,24 @@ using System.Text; namespace UniversalEditor.Localization { - public static class StringTable - { - private static string mvarApplicationName = "Universal Editor"; - public static string ApplicationName { get { return mvarApplicationName; } } + public static class StringTable + { + private static string mvarApplicationName = "Universal Editor"; + public static string ApplicationName { get { return mvarApplicationName; } } - private static string mvarErrorDataFormatNotOpen = "The data format is not open."; - public static string ErrorDataFormatNotOpen { get { return mvarErrorDataFormatNotOpen; } } + private static string mvarErrorDataFormatNotOpen = "The data format is not open."; + public static string ErrorDataFormatNotOpen { get { return mvarErrorDataFormatNotOpen; } } - private static string mvarErrorDataCorrupted = "The file is corrupted."; - public static string ErrorDataCorrupted { get { return mvarErrorDataCorrupted; } } + private static string mvarErrorDataCorrupted = "The file is corrupted."; + public static string ErrorDataCorrupted { get { return mvarErrorDataCorrupted; } } - private static string mvarErrorFileNotFound = "The file could not be found."; - public static string ErrorFileNotFound { get { return mvarErrorFileNotFound; } } - private static string mvarErrorNotAnObjectModel = "The specified type is not an object model."; - public static string ErrorNotAnObjectModel { get { return mvarErrorNotAnObjectModel; } } + private static string mvarErrorFileNotFound = "The file could not be found."; + public static string ErrorFileNotFound { get { return mvarErrorFileNotFound; } } + private static string mvarErrorNotAnObjectModel = "The specified type is not an object model."; + public static string ErrorNotAnObjectModel { get { return mvarErrorNotAnObjectModel; } } - private static string mvarErrorObjectModelNull = "The object model must not be null."; - public static string ErrorObjectModelNull { get { return mvarErrorObjectModelNull; } set { mvarErrorObjectModelNull = value; } } + private static string mvarErrorObjectModelNull = "The object model must not be null."; + public static string ErrorObjectModelNull { get { return mvarErrorObjectModelNull; } set { mvarErrorObjectModelNull = value; } } private static string mvarErrorDataFormatInvalid = "The data format is invalid."; public static string ErrorDataFormatInvalid { get { return mvarErrorDataFormatInvalid; } set { mvarErrorDataFormatInvalid = value; } } diff --git a/CSharp/Libraries/UniversalEditor.UserInterface/Common/Reflection.cs b/CSharp/Libraries/UniversalEditor.UserInterface/Common/Reflection.cs index ab88565d..5e64ae68 100644 --- a/CSharp/Libraries/UniversalEditor.UserInterface/Common/Reflection.cs +++ b/CSharp/Libraries/UniversalEditor.UserInterface/Common/Reflection.cs @@ -178,10 +178,10 @@ namespace UniversalEditor.UserInterface.Common list.Add(editor); } } - if (!editorsByObjectModelType.ContainsKey(objectModelReference.ObjectModelType)) - { - editorsByObjectModelType.Add(objectModelReference.ObjectModelType, list.ToArray()); - } + if (!editorsByObjectModelType.ContainsKey(objectModelReference.ObjectModelType)) + { + editorsByObjectModelType.Add(objectModelReference.ObjectModelType, list.ToArray()); + } } // editorsByObjectModelType.Clear(); return editorsByObjectModelType[objectModelReference.ObjectModelType]; diff --git a/CSharp/Libraries/UniversalEditor.UserInterface/Engine.cs b/CSharp/Libraries/UniversalEditor.UserInterface/Engine.cs index 91c78086..117a738d 100644 --- a/CSharp/Libraries/UniversalEditor.UserInterface/Engine.cs +++ b/CSharp/Libraries/UniversalEditor.UserInterface/Engine.cs @@ -169,16 +169,16 @@ namespace UniversalEditor.UserInterface editor.Redo(); }); #endregion - #region View - AttachCommandEventHandler("ViewFullScreen", delegate(object sender, EventArgs e) - { - Command cmd = (sender as Command); - LastWindow.FullScreen = !LastWindow.FullScreen; - cmd.Checked = LastWindow.FullScreen; - }); - #endregion - #region Tools - // ToolsOptions should actually be under the Edit menu as "Preferences" on Linux systems + #region View + AttachCommandEventHandler("ViewFullScreen", delegate(object sender, EventArgs e) + { + Command cmd = (sender as Command); + LastWindow.FullScreen = !LastWindow.FullScreen; + cmd.Checked = LastWindow.FullScreen; + }); + #endregion + #region Tools + // ToolsOptions should actually be under the Edit menu as "Preferences" on Linux systems AttachCommandEventHandler("ToolsOptions", delegate(object sender, EventArgs e) { LastWindow.ShowOptionsDialog(); diff --git a/CSharp/Libraries/UniversalEditor.UserInterface/IHostApplicationWindow.cs b/CSharp/Libraries/UniversalEditor.UserInterface/IHostApplicationWindow.cs index 941ca0d2..a4892ef4 100644 --- a/CSharp/Libraries/UniversalEditor.UserInterface/IHostApplicationWindow.cs +++ b/CSharp/Libraries/UniversalEditor.UserInterface/IHostApplicationWindow.cs @@ -32,7 +32,7 @@ namespace UniversalEditor.UserInterface IEditorImplementation GetCurrentEditor(); - bool FullScreen { get; set; } + bool FullScreen { get; set; } /// /// Displays the "Options" dialog (on Windows, under the "Tools" menu; on Linux, under the "Edit" diff --git a/CSharp/Libraries/UniversalEditor.UserInterface/MenuBar.cs b/CSharp/Libraries/UniversalEditor.UserInterface/MenuBar.cs index 6554180a..1817b521 100644 --- a/CSharp/Libraries/UniversalEditor.UserInterface/MenuBar.cs +++ b/CSharp/Libraries/UniversalEditor.UserInterface/MenuBar.cs @@ -6,178 +6,178 @@ namespace UniversalEditor.UserInterface { public class MenuBar { - private MenuItem.MenuItemCollection mvarItems = new MenuItem.MenuItemCollection(); - public MenuItem.MenuItemCollection Items { get { return mvarItems; } } - } + private MenuItem.MenuItemCollection mvarItems = new MenuItem.MenuItemCollection(); + public MenuItem.MenuItemCollection Items { get { return mvarItems; } } + } - public abstract class MenuItem - { - public class MenuItemCollection - : System.Collections.ObjectModel.Collection - { - private System.Collections.Generic.Dictionary itemsByName = new Dictionary(); + public abstract class MenuItem + { + public class MenuItemCollection + : System.Collections.ObjectModel.Collection + { + private System.Collections.Generic.Dictionary itemsByName = new Dictionary(); - public ActionMenuItem Add(string name, string title) - { - return Add(name, title, null); - } - public ActionMenuItem Add(string name, string title, EventHandler onClick) - { - return Add(name, title, onClick, Count); - } - public ActionMenuItem Add(string name, string title, int position) - { - return Add(name, title, null, position); - } - public ActionMenuItem Add(string name, string title, EventHandler onClick, int position) - { - ActionMenuItem item = new ActionMenuItem(name, title); - if (onClick != null) - { - item.Click += onClick; - } - item.Position = position; - Add(item); - return item; - } - public SeparatorMenuItem AddSeparator() - { - return AddSeparator(Count); - } - public SeparatorMenuItem AddSeparator(int position) - { - SeparatorMenuItem item = new SeparatorMenuItem(); - item.Position = position; - item.Name = "separator__" + (Count + 1).ToString(); - Add(item); - return item; - } + public ActionMenuItem Add(string name, string title) + { + return Add(name, title, null); + } + public ActionMenuItem Add(string name, string title, EventHandler onClick) + { + return Add(name, title, onClick, Count); + } + public ActionMenuItem Add(string name, string title, int position) + { + return Add(name, title, null, position); + } + public ActionMenuItem Add(string name, string title, EventHandler onClick, int position) + { + ActionMenuItem item = new ActionMenuItem(name, title); + if (onClick != null) + { + item.Click += onClick; + } + item.Position = position; + Add(item); + return item; + } + public SeparatorMenuItem AddSeparator() + { + return AddSeparator(Count); + } + public SeparatorMenuItem AddSeparator(int position) + { + SeparatorMenuItem item = new SeparatorMenuItem(); + item.Position = position; + item.Name = "separator__" + (Count + 1).ToString(); + Add(item); + return item; + } - public MenuItem this[string name] - { - get - { - return itemsByName[name]; - } - } + public MenuItem this[string name] + { + get + { + return itemsByName[name]; + } + } - public bool Contains(string name) - { - return itemsByName.ContainsKey(name); - } - public bool Remove(string name) - { - if (itemsByName.ContainsKey(name)) - { - base.Remove(itemsByName[name]); - return true; - } - return false; - } + public bool Contains(string name) + { + return itemsByName.ContainsKey(name); + } + public bool Remove(string name) + { + if (itemsByName.ContainsKey(name)) + { + base.Remove(itemsByName[name]); + return true; + } + return false; + } - protected override void InsertItem(int index, MenuItem item) - { - item.mvarParent = this; - base.InsertItem(index, item); - itemsByName.Add(item.Name, item); - } - protected override void RemoveItem(int index) - { - this[index].mvarParent = null; - itemsByName.Remove(this[index].Name); - base.RemoveItem(index); - } + protected override void InsertItem(int index, MenuItem item) + { + item.mvarParent = this; + base.InsertItem(index, item); + itemsByName.Add(item.Name, item); + } + protected override void RemoveItem(int index) + { + this[index].mvarParent = null; + itemsByName.Remove(this[index].Name); + base.RemoveItem(index); + } - internal void UpdateName(MenuItem item, string oldName) - { - itemsByName.Remove(oldName); - itemsByName.Add(item.Name, item); - } - } + internal void UpdateName(MenuItem item, string oldName) + { + itemsByName.Remove(oldName); + itemsByName.Add(item.Name, item); + } + } - private List mvarNativeControls = new List(); - public List NativeControls { get { return mvarNativeControls; } } + private List mvarNativeControls = new List(); + public List NativeControls { get { return mvarNativeControls; } } - private MenuItemCollection mvarParent = null; + private MenuItemCollection mvarParent = null; - private string mvarName = String.Empty; - public string Name - { - get { return mvarName; } - set - { - string oldName = mvarName; mvarName = value; - if (mvarParent != null) - { - mvarParent.UpdateName(this, oldName); - } - } - } + private string mvarName = String.Empty; + public string Name + { + get { return mvarName; } + set + { + string oldName = mvarName; mvarName = value; + if (mvarParent != null) + { + mvarParent.UpdateName(this, oldName); + } + } + } - private int mvarPosition = -1; - public int Position { get { return mvarPosition; } set { mvarPosition = value; } } + private int mvarPosition = -1; + public int Position { get { return mvarPosition; } set { mvarPosition = value; } } - private bool mvarEnabled = true; - public bool Enabled - { - get { return mvarEnabled; } - set - { - mvarEnabled = value; - foreach (object NativeControl in mvarNativeControls) - { - HostApplication.CurrentWindow.RefreshCommand(NativeControl); - } - } - } + private bool mvarEnabled = true; + public bool Enabled + { + get { return mvarEnabled; } + set + { + mvarEnabled = value; + foreach (object NativeControl in mvarNativeControls) + { + HostApplication.CurrentWindow.RefreshCommand(NativeControl); + } + } + } - private bool mvarVisible = true; - public bool Visible { get { return mvarVisible; } - set - { - mvarVisible = value; - foreach (object NativeControl in mvarNativeControls) - { - HostApplication.CurrentWindow.RefreshCommand(NativeControl); - } - } - } - } - public class ActionMenuItem : MenuItem - { - private string mvarTitle = String.Empty; - public string Title { get { return mvarTitle; } set { mvarTitle = value; } } + private bool mvarVisible = true; + public bool Visible { get { return mvarVisible; } + set + { + mvarVisible = value; + foreach (object NativeControl in mvarNativeControls) + { + HostApplication.CurrentWindow.RefreshCommand(NativeControl); + } + } + } + } + public class ActionMenuItem : MenuItem + { + private string mvarTitle = String.Empty; + public string Title { get { return mvarTitle; } set { mvarTitle = value; } } - private MenuItem.MenuItemCollection mvarItems = new MenuItem.MenuItemCollection(); - public MenuItem.MenuItemCollection Items { get { return mvarItems; } } + private MenuItem.MenuItemCollection mvarItems = new MenuItem.MenuItemCollection(); + public MenuItem.MenuItemCollection Items { get { return mvarItems; } } - private CommandDisplayStyle mvarDisplayStyle = CommandDisplayStyle.ImageOnly; - public CommandDisplayStyle DisplayStyle { get { return mvarDisplayStyle; } set { mvarDisplayStyle = value; } } + private CommandDisplayStyle mvarDisplayStyle = CommandDisplayStyle.ImageOnly; + public CommandDisplayStyle DisplayStyle { get { return mvarDisplayStyle; } set { mvarDisplayStyle = value; } } - public event EventHandler Click; + public event EventHandler Click; - public ActionMenuItem(string title) - { - base.Name = title; - mvarTitle = title; - } - public ActionMenuItem(string name, string title) - { - base.Name = name; - mvarTitle = title; - } + public ActionMenuItem(string title) + { + base.Name = title; + mvarTitle = title; + } + public ActionMenuItem(string name, string title) + { + base.Name = name; + mvarTitle = title; + } - public void OnClick(EventArgs e) - { - if (Click != null) - { - Click(this, e); - } - } - } - public class SeparatorMenuItem : MenuItem - { + public void OnClick(EventArgs e) + { + if (Click != null) + { + Click(this, e); + } + } + } + public class SeparatorMenuItem : MenuItem + { - } + } } diff --git a/CSharp/Libraries/UniversalEditor.UserInterface/Toolbar.cs b/CSharp/Libraries/UniversalEditor.UserInterface/Toolbar.cs index fd5ad322..076b470c 100644 --- a/CSharp/Libraries/UniversalEditor.UserInterface/Toolbar.cs +++ b/CSharp/Libraries/UniversalEditor.UserInterface/Toolbar.cs @@ -9,30 +9,30 @@ namespace UniversalEditor.UserInterface public class ToolbarCollection : System.Collections.ObjectModel.Collection { - public Toolbar Add(string name) - { - return Add(name, name); - } - public Toolbar Add(string name, string title) - { - Toolbar tb = new Toolbar(); - tb.Name = name; - tb.Title = title; - Add(tb); - return tb; - } - } + public Toolbar Add(string name) + { + return Add(name, name); + } + public Toolbar Add(string name, string title) + { + Toolbar tb = new Toolbar(); + tb.Name = name; + tb.Title = title; + Add(tb); + return tb; + } + } - private string mvarName = String.Empty; - public string Name { get { return mvarName; } set { mvarName = value; } } + private string mvarName = String.Empty; + public string Name { get { return mvarName; } set { mvarName = value; } } - private string mvarTitle = String.Empty; - public string Title { get { return mvarTitle; } set { mvarTitle = value; } } + private string mvarTitle = String.Empty; + public string Title { get { return mvarTitle; } set { mvarTitle = value; } } - private MenuItem.MenuItemCollection mvarItems = new MenuItem.MenuItemCollection(); - public MenuItem.MenuItemCollection Items { get { return mvarItems; } } + private MenuItem.MenuItemCollection mvarItems = new MenuItem.MenuItemCollection(); + public MenuItem.MenuItemCollection Items { get { return mvarItems; } } - private bool mvarVisible = true; - public bool Visible { get { return mvarVisible; } set { mvarVisible = value; } } - } + private bool mvarVisible = true; + public bool Visible { get { return mvarVisible; } set { mvarVisible = value; } } + } } diff --git a/CSharp/Libraries/UniversalEditor.UserInterface/Toolbox.cs b/CSharp/Libraries/UniversalEditor.UserInterface/Toolbox.cs index c0f3c271..49719a5c 100644 --- a/CSharp/Libraries/UniversalEditor.UserInterface/Toolbox.cs +++ b/CSharp/Libraries/UniversalEditor.UserInterface/Toolbox.cs @@ -24,32 +24,32 @@ namespace UniversalEditor.UserInterface public sealed class ToolboxItemCollection : System.Collections.ObjectModel.Collection { - public ToolboxCommandItem AddCommand(string name) - { - return AddCommand(name, name); - } - public ToolboxCommandItem AddCommand(string name, string title) - { - return AddCommand(name, title, null); - } - public ToolboxCommandItem AddCommand(string name, string title, string imageFileName) - { - ToolboxCommandItem item = new ToolboxCommandItem(name, title, imageFileName); - Add(item); - return item; - } + public ToolboxCommandItem AddCommand(string name) + { + return AddCommand(name, name); + } + public ToolboxCommandItem AddCommand(string name, string title) + { + return AddCommand(name, title, null); + } + public ToolboxCommandItem AddCommand(string name, string title, string imageFileName) + { + ToolboxCommandItem item = new ToolboxCommandItem(name, title, imageFileName); + Add(item); + return item; + } - public ToolboxGroupItem AddGroup(string name) - { - return AddGroup(name, name); - } - public ToolboxGroupItem AddGroup(string name, string title) - { - ToolboxGroupItem group = new ToolboxGroupItem(name, title); - Add(group); - return group; - } - } + public ToolboxGroupItem AddGroup(string name) + { + return AddGroup(name, name); + } + public ToolboxGroupItem AddGroup(string name, string title) + { + ToolboxGroupItem group = new ToolboxGroupItem(name, title); + Add(group); + return group; + } + } private string mvarName = String.Empty; public string Name { get { return mvarName; } set { mvarName = value; } } @@ -67,8 +67,8 @@ namespace UniversalEditor.UserInterface private string mvarTitle = String.Empty; public string Title { get { return mvarTitle; } set { mvarTitle = value; } } - private ToolboxItem.ToolboxItemCollection mvarItems = new ToolboxItem.ToolboxItemCollection(); - public ToolboxItem.ToolboxItemCollection Items { get { return mvarItems; } } + private ToolboxItem.ToolboxItemCollection mvarItems = new ToolboxItem.ToolboxItemCollection(); + public ToolboxItem.ToolboxItemCollection Items { get { return mvarItems; } } public ToolboxGroupItem(string name, string title) : base(name) {