protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); if (this._mouseDown) { this.UpdatePosition(e.Y); } else { if (this.ColorProvider != null) { int scrollPosition = Math.Max(0, (e.Y - this.Top) * this.Maximum / this.Height); if (_lastPreviewScrollPosition != scrollPosition) { Point p = this.PointToScreen(new Point(this.ClientRectangle.Right, e.Y)); if (_codeTooltip == null) { _codeTooltip = this.ColorProvider.GetPreview(scrollPosition); } else { _codeTooltip.ScrollToLineIndex(scrollPosition); } if (_codeTooltip != null) { _codeTooltip.Left = p.X + 5; _codeTooltip.Top = p.Y; _codeTooltip.Show(); } _lastPreviewScrollPosition = scrollPosition; } } } }
private void ResetTooltip() { if (_tooltip != null) { _tooltip.Close(); _tooltip = null; } }
protected override void OnMouseLeave(EventArgs e) { base.OnMouseLeave(e); if (_codeTooltip != null) { _codeTooltip.Close(); _codeTooltip = null; } _lastPreviewScrollPosition = -1; }
private void picPicture_MouseMove(object sender, MouseEventArgs e) { int cycle = e.X * 341 / (picPicture.Width - 2); int scanline = e.Y * 262 / (picPicture.Height - 2); if (scanline == 261) { scanline = -1; } int[] offsets = new int[3] { 0, -1, 1 }; for (int y = 0; y < 3; y++) { for (int x = 0; x < 3; x++) { int key = (scanline + offsets[y] + 1) * 341 + cycle + offsets[x]; PpuRegisterWriteInfo writeInfo; if (_ppuRegisterWrites.TryGetValue(key, out writeInfo)) { if (key != _lastKey) { ResetTooltip(); Dictionary <string, string> values = new Dictionary <string, string>() { { "Register", "$" + (0x2000 + writeInfo.Address).ToString("X4") }, { "Value", "$" + writeInfo.Value.ToString("X2") }, { "Scanline", writeInfo.Scanline.ToString() }, { "Cycle", writeInfo.Cycle.ToString() }, }; _tooltip = new frmCodeTooltip(values); Point location = PointToScreen(e.Location); location.Offset(10, 10); _tooltip.Location = location; _tooltip.Show(); _lastKey = key; } //Found a matching write to display, stop processing return; } } } //No match found, make sure any existing tooltip is closed ResetTooltip(); }
private void picViewer_MouseMove(object sender, MouseEventArgs e) { Point pos = GetCycleScanline(e.Location); if (_lastPos == pos) { return; } EventViewerDisplayOptions options = GetInteropOptions(); DebugEventInfo debugEvent = new DebugEventInfo(); InteropEmu.GetEventViewerEvent(ref debugEvent, (Int16)(pos.Y - 1), (UInt16)pos.X, options); if (debugEvent.ProgramCounter == 0xFFFFFFFF) { ResetTooltip(); UpdateOverlay(e.Location); return; } Dictionary <string, string> values = new Dictionary <string, string>() { { "Type", ResourceHelper.GetEnumText(debugEvent.Type) }, { "Scanline", debugEvent.Scanline.ToString() }, { "Cycle", debugEvent.Cycle.ToString() }, { "PC", "$" + debugEvent.ProgramCounter.ToString("X4") }, }; switch (debugEvent.Type) { case DebugEventType.MapperRegisterRead: case DebugEventType.MapperRegisterWrite: case DebugEventType.PpuRegisterRead: case DebugEventType.PpuRegisterWrite: values["Register"] = "$" + debugEvent.Address.ToString("X4"); values["Value"] = "$" + debugEvent.Value.ToString("X2"); if (debugEvent.PpuLatch >= 0) { values["2nd Write"] = debugEvent.PpuLatch == 0 ? "false" : "true"; } break; case DebugEventType.DmcDmaRead: values["Address"] = "$" + debugEvent.Address.ToString("X4"); values["Value"] = "$" + debugEvent.Value.ToString("X2"); break; case DebugEventType.Breakpoint: ReadOnlyCollection <Breakpoint> breakpoints = BreakpointManager.Breakpoints; if (debugEvent.BreakpointId >= 0 && debugEvent.BreakpointId < breakpoints.Count) { Breakpoint bp = breakpoints[debugEvent.BreakpointId]; values["BP Type"] = bp.ToReadableType(); values["BP Addresses"] = bp.GetAddressString(true); if (bp.Condition.Length > 0) { values["BP Condition"] = bp.Condition; } } break; } ResetTooltip(); UpdateOverlay(new Point((int)(debugEvent.Cycle * 2 * picViewer.ImageScale), (int)((debugEvent.Scanline + 1) * 2 * picViewer.ImageScale))); Form parentForm = this.FindForm(); _tooltip = new frmCodeTooltip(parentForm, values, null, null, null, 10); _tooltip.FormClosed += (s, evt) => { _tooltip = null; }; Point location = Control.MousePosition; location.Offset(10, 10); _tooltip.SetFormLocation(location, this); }
private void picPicture_MouseMove(object sender, MouseEventArgs e) { int cycle = e.X * 341 / (picPicture.Width - 2); int scanline = e.Y * (int)_state.PPU.ScanlineCount / (picPicture.Height - 2) - 1; int[] offsets = new int[3] { 0, -1, 1 }; for (int y = 0; y < 3; y++) { for (int x = 0; x < 3; x++) { int key = (scanline + offsets[y] + 1) * 341 + cycle + offsets[x]; List <DebugEventInfo> eventList; if (_debugEventsByCycle.TryGetValue(key, out eventList)) { foreach (DebugEventInfo debugEvent in eventList) { if (ShowEvent(debugEvent.Type)) { if (key != _lastKey) { ResetTooltip(); Dictionary <string, string> values = new Dictionary <string, string>() { { "Type", ResourceHelper.GetEnumText(debugEvent.Type) }, { "Scanline", debugEvent.Scanline.ToString() }, { "Cycle", debugEvent.Cycle.ToString() }, { "PC", "$" + debugEvent.ProgramCounter.ToString("X4") }, }; switch (debugEvent.Type) { case DebugEventType.MapperRegisterRead: case DebugEventType.MapperRegisterWrite: case DebugEventType.PpuRegisterRead: case DebugEventType.PpuRegisterWrite: values["Register"] = "$" + debugEvent.Address.ToString("X4"); values["Value"] = "$" + debugEvent.Value.ToString("X2"); if (debugEvent.PpuLatch >= 0) { values["2nd Write"] = debugEvent.PpuLatch == 0 ? "false" : "true"; } break; case DebugEventType.Breakpoint: ReadOnlyCollection <Breakpoint> breakpoints = BreakpointManager.Breakpoints; if (debugEvent.BreakpointId >= 0 && debugEvent.BreakpointId < breakpoints.Count) { Breakpoint bp = breakpoints[debugEvent.BreakpointId]; values["BP Type"] = bp.ToReadableType(); values["BP Addresses"] = bp.GetAddressString(true); if (bp.Condition.Length > 0) { values["BP Condition"] = bp.Condition; } } break; } Form parentForm = this.FindForm(); _tooltip = new frmCodeTooltip(parentForm, values); _tooltip.FormClosed += (s, evt) => { _tooltip = null; }; Point location = PointToScreen(e.Location); location.Offset(10, 10); _tooltip.SetFormLocation(location, this); _lastKey = key; } //Found a matching write to display, stop processing return; } } } } } //No match found, make sure any existing tooltip is closed ResetTooltip(); }