Esempio n. 1
0
        protected void UpdateValue()
        {
            if (disable_UpdateValue)
            {
                return;
            }
            if (DataFieldVM.HasError)
            {
                return;
            }
            var newData = GetDataAsByteArray();

            Debug.Assert(newData != null && (ulong)newData.Length == endOffset - startOffset + 1);

            var origData = doc.ReadBytes(startOffset, newData.Length);

            if (Equals(newData, origData))
            {
                return;
            }

            var undoDoc = doc as IUndoHexDocument;

            Debug.Assert(undoDoc != null);
            if (undoDoc != null)
            {
                undoDoc.WriteUndo(startOffset, newData, string.Format(dnSpy_AsmEditor_Resources.HexField_UndoMessage_Write_Parent_Field, parentName, Name));
            }
            else
            {
                doc.Write(startOffset, newData);
            }
            OnUpdateValue();
        }
Esempio n. 2
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;
 }
Esempio n. 3
0
        protected void UpdateValue()
        {
            if (disable_UpdateValue)
            {
                return;
            }
            if (DataFieldVM.HasError)
            {
                return;
            }
            var newData = GetDataAsByteArray();

            Debug.Assert(newData != null && (ulong)newData.Length == endOffset - startOffset + 1);

            var origData = doc.ReadBytes(startOffset, newData.Length);

            if (Equals(newData, origData))
            {
                return;
            }

            WriteHexUndoCommand.AddAndExecute(doc, startOffset, newData, string.Format("Write {0}.{1}", parentName, Name));
            OnUpdateValue();
        }