예제 #1
0
 public CSharpArrayFormatter(HexBox hexBox, ulong start, ulong end, bool lowerHex)
     : base(hexBox, start, end)
 {
     allocStringStart = "new byte[] {";
     allocStringEnd = "};";
     unknownHex = "0x??";
     hexFormat = lowerHex ? "0x{0:x2}" : "0x{0:X2}";
 }
예제 #2
0
		bool TryUpdateOldTextInputCommand(HexWriteType type, HexBox hexBox, HexBoxPosition posBeforeWrite, ulong startOffset, byte[] originalData) {
			if (type != HexWriteType.ByteInput && type != HexWriteType.AsciiInput)
				return false;

			var cmd = (HexBoxUndoCommand)prevTextInputCmd.Target;
			if (cmd == null)
				return false;

			return cmd.TryAppend(hexBox, posBeforeWrite, startOffset, originalData);
		}
예제 #3
0
		public HexBoxUndoCommand(HexBox hexBox, HexBoxPosition origCaretPos, ulong offset, byte[] origData, string descr) {
			this.doc = hexBox.Document;
			this.hexBoxWeakRef = new WeakReference(hexBox);
			this.origCaretPos = origCaretPos;
			this.newCaretPos = hexBox.CaretPosition;
			this.offset = offset;
			this.origData = origData;
			this.newData = doc.ReadBytes(offset, origData.Length);
			this.descr = descr;
			this.canExecute = false;
		}
예제 #4
0
        protected DataFormatter(HexBox hexBox, ulong start, ulong end)
        {
            if (start < hexBox.StartOffset)
                start = hexBox.StartOffset;
            else if (start > hexBox.EndOffset)
                start = hexBox.EndOffset;
            if (end < hexBox.StartOffset)
                end = hexBox.StartOffset;
            else if (end > hexBox.EndOffset)
                end = hexBox.EndOffset;
            if (end < start)
                end = start;

            if (end - start >= MAX_BYTES - 1)
                end = start + MAX_BYTES - 1;

            this.hexBox = hexBox;
            this.start = start;
            this.end = end;
        }
예제 #5
0
 public SelectionLayer(HexBox hexBox)
 {
     this.hexBox = hexBox;
 }
예제 #6
0
		public bool TryAppend(HexBox hexBox, HexBoxPosition posBeforeWrite, ulong startOffset, byte[] originalData) {
			if (canNotAppend)
				return false;
			if (hexBoxWeakRef.Target != hexBox)
				return false;
			if (hexBox.Document == null)
				return false;
			if (originalData.Length == 0)
				return false;
			if (newCaretPos != posBeforeWrite)
				return false;
			if (newCaretPos.Offset > hexBox.CaretPosition.Offset)
				return false;
			if (newCaretPos.Kind != hexBox.CaretPosition.Kind)
				return false;

			if (newCaretPos.Offset == posBeforeWrite.Offset && newCaretPos.Kind == HexBoxPositionKind.HexByte && newCaretPos.KindPosition == HexBoxPosition.INDEX_HEXBYTE_LAST) {
				if (posBeforeWrite.Kind != HexBoxPositionKind.HexByte || posBeforeWrite.KindPosition != HexBoxPosition.INDEX_HEXBYTE_LAST)
					return false;
				if (originalData.Length != 1)
					return false;
				newData[newData.Length - 1] = (byte)hexBox.Document.ReadByte(posBeforeWrite.Offset);
			}
			else {
				if (newCaretPos.Offset != posBeforeWrite.Offset)
					return false;
				ulong c = hexBox.CaretPosition.Kind == HexBoxPositionKind.HexByte && hexBox.CaretPosition.KindPosition == HexBoxPosition.INDEX_HEXBYTE_LAST ? 1UL : 0;
				if (hexBox.CaretPosition.Offset - newCaretPos.Offset + c != (ulong)originalData.Length)
					return false;
				int origLen = newData.Length;
				Array.Resize(ref newData, origLen + originalData.Length);
				Array.Resize(ref origData, origLen + originalData.Length);

				for (int i = 0; i < originalData.Length; i++) {
					newData[origLen + i] = (byte)hexBox.Document.ReadByte(posBeforeWrite.Offset + (ulong)i);
					origData[origLen + i] = originalData[i];
				}
			}

			newCaretPos = hexBox.CaretPosition;
			return true;
		}
예제 #7
0
 public VBArrayFormatter(HexBox hexBox, ulong start, ulong end, bool lowerHex)
     : base(hexBox, start, end)
 {
     allocStringStart = "New Byte() {";
     allocStringEnd = "}";
     unknownHex = "&H??";
     hexFormat = lowerHex ? "&H{0:x2}" : "&H{0:X2}";
     eol = " _" + Environment.NewLine;
 }
예제 #8
0
 public UTF8StringFormatter(HexBox hexBox, ulong start, ulong end)
     : base(hexBox, start, end)
 {
 }
예제 #9
0
 public UILayoutFormatter(HexBox hexBox, ulong start, ulong end)
     : base(hexBox, start, end)
 {
 }
예제 #10
0
 protected LanguageArrayFormatter(HexBox hexBox, ulong start, ulong end)
     : base(hexBox, start, end)
 {
 }
예제 #11
0
 public HexStringFormatter(HexBox hexBox, ulong start, ulong end, bool lowerHex)
     : base(hexBox, start, end)
 {
     this.hexByteFormatString = lowerHex ? "{0:x2}" : "{0:X2}";
 }
예제 #12
0
		public void Uninitialize(HexBox hexBox) {
			hexBox.OnWrite -= HexBox_OnWrite;
		}
예제 #13
0
		public void Initialize(HexBox hexBox) {
			hexBox.OnWrite += HexBox_OnWrite;
		}
예제 #14
0
			public StateRestorer(HexBox hexBox, HexBoxState state) {
				this.hexBox = hexBox;
				this.state = state;
				this.hexBox.Loaded += HexBox_Loaded;
			}