Exemplo n.º 1
0
 void Buffer_Changed(object sender, HexContentChangedEventArgs e)
 {
     // Descendants() shouldn't be used since some of the nodes could have thousands of
     // children and it's better if the parent can quickly check whether any of its children
     // need to get notified.
     foreach (HexNode node in TreeNode.DataChildren)
     {
         node.OnBufferChanged(e.Changes);
     }
 }
Exemplo n.º 2
0
 void Buffer_Changed(object?sender, HexContentChangedEventArgs e)
 {
     if (nodeWeakRef.Target is PENode node)
     {
         node.Buffer_Changed(sender, e);
     }
     else
     {
         var buffer = (HexBuffer)sender !;
         buffer.Changed -= Buffer_Changed;
     }
 }
Exemplo n.º 3
0
        void Buffer_Changed(object sender, HexContentChangedEventArgs e)
        {
            if (e.EditTag == HexBufferUndoRedo.UndoRedoObject)
            {
                return;
            }
            var buffer = (HexBuffer)sender;
            var desc   = dnSpy_AsmEditor_Resources.Hex_Undo_Message_InsertBytes;
            var cmd    = new HexBufferUndoCommand(buffer, e.Changes, e.BeforeVersion.ReiteratedVersionNumber, e.AfterVersion.ReiteratedVersionNumber, desc);

            undoCommandService.Add(cmd);
        }
Exemplo n.º 4
0
            void Buffer_Changed(object sender, HexContentChangedEventArgs e)
            {
                var node = (PENode)nodeWeakRef.Target;

                if (node != null)
                {
                    node.Buffer_Changed(sender, e);
                }
                else
                {
                    var buffer = (HexBuffer)sender;
                    buffer.Changed -= Buffer_Changed;
                }
            }
Exemplo n.º 5
0
 void Buffer_ChangedLowPriority(object sender, HexContentChangedEventArgs e)
 {
     if (savedValue != null)
     {
         foreach (var change in e.Changes)
         {
             if (savedValue.BufferSpan.Span.OverlapsWith(change.OldSpan))
             {
                 if (!savedValue.UpdateValue())
                 {
                     RefreshAll();
                 }
                 break;
             }
         }
     }
 }
Exemplo n.º 6
0
        internal void ApplyChanges(HexEditImpl hexEdit, List <HexChange> changes, int?reiteratedVersionNumber, object editTag)
        {
            VerifyAccess();
            if (hexEdit != hexEditInProgress)
            {
                throw new InvalidOperationException();
            }
            hexEditInProgress = null;

            if (RaiseChangingGetIsCanceled(editTag))
            {
                PostChanged?.Invoke(this, EventArgs.Empty);
                return;
            }

            if (changes.Count != 0)
            {
                // We don't support overlapping changes. All offsets are relative to the original buffer
                changes.Sort(ReverseOldPositionSorter.Instance);
                for (int i = 1; i < changes.Count; i++)
                {
                    if (changes[i - 1].OldSpan.OverlapsWith(changes[i].OldSpan))
                    {
                        throw new InvalidOperationException("Two edit operations overlap");
                    }
                }

                var beforeVersion = Version;
                // changes is sorted in reverse order by OldPosition
                foreach (var change in changes)
                {
                    stream.Write(change.OldPosition, change.NewData);
                }
                CreateNewVersion(changes, reiteratedVersionNumber);
                var afterVersion = Version;

                HexContentChangedEventArgs args = null;
                //TODO: The event handlers are allowed to modify the buffer, but the new events must only be
                //		raised after all of these three events have been raised.
                ChangedHighPriority?.Invoke(this, args ?? (args = new HexContentChangedEventArgs(beforeVersion, afterVersion, editTag)));
                Changed?.Invoke(this, args ?? (args = new HexContentChangedEventArgs(beforeVersion, afterVersion, editTag)));
                ChangedLowPriority?.Invoke(this, args ?? (args = new HexContentChangedEventArgs(beforeVersion, afterVersion, editTag)));
            }
            PostChanged?.Invoke(this, EventArgs.Empty);
        }
Exemplo n.º 7
0
        // UI thread
        void Buffer_ChangedLowPriority(object sender, HexContentChangedEventArgs e)
        {
            uiDispatcher.VerifyAccess();
            var callerState = TryGetBufferState_UI((HexBuffer)sender);

            foreach (var bufferState in bufferStates)
            {
                if (bufferState == callerState)
                {
                    continue;
                }
                if (bufferState.Process == null)
                {
                    continue;
                }
                if (bufferState.Process != callerState.Process)
                {
                    continue;
                }
                bufferState.InvalidateSpan(e.Changes);
            }
        }