예제 #1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            if (DesignMode)
            {
                e.Graphics.FillRectangle(Brushes.White, ClientRectangle);

                return;
            }

            hotSpots.Clear();

            using (var brush = new SolidBrush(Program.Settings.BackgroundColor))
            {
                e.Graphics.FillRectangle(brush, ClientRectangle);
            }

            if (ClassNode == null)
            {
                return;
            }

            ClassNode.UpdateAddress(Memory);

            Memory.Size = ClassNode.MemorySize;
            Memory.Update(ClassNode.Offset);

            var view = new ViewInfo
            {
                Settings      = Program.Settings,
                Context       = e.Graphics,
                Font          = font,
                Address       = ClassNode.Offset,
                ClientArea    = ClientRectangle,
                Level         = 0,
                Memory        = Memory,
                MultiSelected = selectedNodes.Count > 1,
                HotSpots      = hotSpots
            };

            var scrollY = VerticalScroll.Value * font.Height;
            int maxY;

            try
            {
                BaseHexNode.CurrentHighlightTime = DateTime.Now;

                maxY = ClassNode.Draw(view, 0, -scrollY) + scrollY;
            }
            catch
            {
                return;
            }

            /*foreach (var spot in hotSpots.Where(h => h.Type == HotSpotType.Select))
             * {
             *      e.Graphics.DrawRectangle(new Pen(new SolidBrush(Color.FromArgb(150, 255, 0, 0)), 1), spot.Rect);
             * }*/

            if (maxY > ClientSize.Height)
            {
                VerticalScroll.Enabled = true;

                VerticalScroll.LargeChange = ClientSize.Height / font.Height;
                VerticalScroll.Maximum     = (maxY - ClientSize.Height) / font.Height + VerticalScroll.LargeChange;
            }
            else
            {
                VerticalScroll.Enabled = false;

                VerticalScroll.Value = 0;
            }
        }
예제 #2
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            if (DesignMode)
            {
                e.Graphics.FillRectangle(Brushes.White, ClientRectangle);

                return;
            }

            var args = new DrawContextRequestEventArgs();

            var requestHandler = DrawContextRequested;

            requestHandler?.Invoke(this, args);

            hotSpots.Clear();

            using (var brush = new SolidBrush(Program.Settings.BackgroundColor))
            {
                e.Graphics.FillRectangle(brush, ClientRectangle);
            }

            if (args.Process == null || args.Memory == null || args.Node == null)
            {
                return;
            }

            if (memoryPreviewPopUp.Visible)
            {
                memoryPreviewPopUp.UpdateMemory();
            }

            var view = new ViewInfo
            {
                Settings              = args.Settings,
                Context               = e.Graphics,
                Font                  = font,
                Process               = args.Process,
                Memory                = args.Memory,
                CurrentTime           = args.CurrentTime,
                ClientArea            = ClientRectangle,
                HotSpots              = hotSpots,
                Address               = args.BaseAddress,
                Level                 = 0,
                MultipleNodesSelected = selectedNodes.Count > 1
            };

            var scrollPosition = AutoScrollPosition;

            var drawnSize = args.Node.Draw(
                view,
                scrollPosition.X,
                scrollPosition.Y
                );

            drawnSize.Width += 10;

            /*foreach (var spot in hotSpots.Where(h => h.Type == HotSpotType.Select))
             * {
             *      e.Graphics.DrawRectangle(new Pen(new SolidBrush(Color.FromArgb(150, 255, 0, 0)), 1), spot.Rect);
             * }*/

            AutoScrollMinSize = new Size(Math.Max(drawnSize.Width, ClientSize.Width), Math.Max(drawnSize.Height, ClientSize.Height));

            // Sometimes setting AutoScrollMinSize resets AutoScrollPosition. This restores the original position.
            AutoScrollPosition = new Point(-scrollPosition.X, -scrollPosition.Y);
        }