Exemple #1
0
 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;
             }
         }
     }
 }
Exemple #2
0
        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();
        }
Exemple #3
0
        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;
                                    }

                                    _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();
        }