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 { 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 = 0; 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; } }
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); BaseHexNode.CurrentHighlightTime = DateTime.Now; var view = new ViewInfo { Settings = Program.Settings, Context = e.Graphics, Font = font, Address = ClassNode.Offset, ClientArea = ClientRectangle, Level = 0, Memory = Memory, MultipleNodesSelected = selectedNodes.Count > 1, HotSpots = hotSpots }; try { var drawnSize = ClassNode.Draw( view, -HorizontalScroll.Value, -VerticalScroll.Value * font.Height ); drawnSize.Width += 50; /*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 (drawnSize.Height > ClientSize.Height) { VerticalScroll.Enabled = true; VerticalScroll.LargeChange = ClientSize.Height / font.Height; VerticalScroll.Maximum = (drawnSize.Height - ClientSize.Height) / font.Height + VerticalScroll.LargeChange; } else { VerticalScroll.Enabled = false; VerticalScroll.Value = 0; } if (drawnSize.Width > ClientSize.Width) { HorizontalScroll.Enabled = true; HorizontalScroll.LargeChange = ClientSize.Width; HorizontalScroll.Maximum = (drawnSize.Width - ClientSize.Width) + HorizontalScroll.LargeChange; } else { HorizontalScroll.Enabled = false; HorizontalScroll.Value = 0; } } catch (Exception ex) { Debug.Assert(false); } }