예제 #1
0
        public override Size DrawCompare(ViewInfo view, int x, int y)
        {
            var viewType   = (MemoryCompareControl.ViewTypes)view.Tag;
            var otherViews = (List <MemoryBuffer>)view.Tag2;

            if (IsHidden && !view.ShowOptions.ShowHidden)
            {
                return(DrawHidden(view, x, y));
            }

            // DrawInvalidMemoryIndicator(view, y);

            var origX = x;
            var origY = y;

            AddSelection(view, x, y, view.Font.Height);

            x = AddOpenClose(view, x, y);
            // x = AddIcon(view, x, y, Icons.Pointer, -1, HotSpotType.None);

            var tx = x;

            x = AddAddressOffset(view, x, y, true, false);

            x = AddText(view, x, y, view.Settings.TypeColor, HotSpot.NoneId, "Ptr") + view.Font.Width;
            x = AddText(view, x, y, view.Settings.NameColor, HotSpot.NameId, Name) + view.Font.Width;
            // x = AddText(view, x, y, view.Settings.ValueColor, HotSpot.NoneId, $"<{InnerNode.Name}>") + view.Font.Width;
            // x = AddIcon(view, x, y, Icons.Change, 4, HotSpotType.ChangeType) + view.Font.Width;

            IntPtr ptr = view.Memory.ReadIntPtr(Offset);

            x = AddText(view, x, y, view.Settings.OffsetColor, HotSpot.NoneId, "->") + view.Font.Width;
            x = AddText(view, x, y, view.Settings.ValueColor, 0, "0x" + ptr.ToString(Constants.AddressHexFormat)) + view.Font.Width;

            // x = AddComment(view, x, y);

            // AddTypeDrop(view, y);
            // AddDelete(view, y);

            y += view.Font.Height;

            var size = new Size(x - origX, y - origY);

            if (levelsOpen[view.Level])
            {
                memory.Size    = InnerNode.MemorySize;
                memory.Process = view.Memory.Process;
                memory.Update(ptr);

                var v = view.Clone();
                v.Address = ptr;
                v.Memory  = memory;
                v.Tag     = viewType;
                v.Tag2    = otherViews.Select(M => // Update all other MemoryBuffer
                {
                    var newMem     = new MemoryBuffer(M);
                    IntPtr newPtr  = M.ReadIntPtr(Offset);
                    newMem.Size    = InnerNode.MemorySize;
                    newMem.Process = view.Memory.Process;
                    newMem.Update(newPtr);

                    return(newMem);
                }).ToList();

                var innerSize = InnerNode.DrawCompare(v, tx, y);

                size.Width   = Math.Max(size.Width, innerSize.Width + tx - origX);
                size.Height += innerSize.Height;
            }

            return(size);
        }