2016-11-24 19:47:59 -05:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
2016-12-11 14:25:29 -05:00
|
|
|
|
using Mesen.GUI.Controls;
|
2018-01-02 11:11:50 -05:00
|
|
|
|
using Mesen.GUI.Config;
|
2016-11-24 19:47:59 -05:00
|
|
|
|
|
|
|
|
|
namespace Mesen.GUI.Debugger
|
|
|
|
|
{
|
|
|
|
|
public partial class frmCodeTooltip : Form
|
|
|
|
|
{
|
2018-02-11 15:58:23 -05:00
|
|
|
|
private ctrlDebuggerCode _codeWindow;
|
2016-11-24 19:47:59 -05:00
|
|
|
|
private Dictionary<string, string> _values;
|
2018-01-02 11:11:50 -05:00
|
|
|
|
private int _previewAddress;
|
|
|
|
|
private string _code;
|
2016-11-24 19:47:59 -05:00
|
|
|
|
|
|
|
|
|
protected override bool ShowWithoutActivation
|
|
|
|
|
{
|
|
|
|
|
get { return true; }
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-02 11:11:50 -05:00
|
|
|
|
public frmCodeTooltip(Dictionary<string, string> values, int previewAddress = -1, string code = null)
|
2016-11-24 19:47:59 -05:00
|
|
|
|
{
|
|
|
|
|
_values = values;
|
2018-01-02 11:11:50 -05:00
|
|
|
|
_previewAddress = previewAddress;
|
|
|
|
|
_code = code;
|
2016-11-24 19:47:59 -05:00
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnShown(EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnShown(e);
|
|
|
|
|
|
2018-01-03 19:12:02 -05:00
|
|
|
|
tlpMain.SuspendLayout();
|
2016-11-24 19:47:59 -05:00
|
|
|
|
int i = 0;
|
|
|
|
|
foreach(KeyValuePair<string, string> kvp in _values) {
|
|
|
|
|
tlpMain.RowStyles.Insert(1, new RowStyle());
|
|
|
|
|
Label lbl = new Label();
|
2016-11-27 20:59:33 -05:00
|
|
|
|
lbl.Margin = new Padding(2, 3, 2, 2);
|
2016-11-24 19:47:59 -05:00
|
|
|
|
lbl.Text = kvp.Key + ":";
|
|
|
|
|
lbl.Font = new Font(lbl.Font, FontStyle.Bold);
|
|
|
|
|
lbl.AutoSize = true;
|
|
|
|
|
tlpMain.SetRow(lbl, i);
|
|
|
|
|
tlpMain.SetColumn(lbl, 0);
|
|
|
|
|
tlpMain.Controls.Add(lbl);
|
|
|
|
|
|
|
|
|
|
lbl = new Label();
|
2016-12-11 14:25:29 -05:00
|
|
|
|
lbl.Font = new Font(BaseControl.MonospaceFontFamily, 10);
|
2016-11-24 19:47:59 -05:00
|
|
|
|
lbl.Margin = new Padding(2);
|
|
|
|
|
lbl.AutoSize = true;
|
|
|
|
|
lbl.Text = kvp.Value;
|
|
|
|
|
tlpMain.SetRow(lbl, i);
|
|
|
|
|
tlpMain.SetColumn(lbl, 1);
|
|
|
|
|
tlpMain.Controls.Add(lbl);
|
|
|
|
|
|
|
|
|
|
i++;
|
|
|
|
|
}
|
2016-12-19 18:25:52 -05:00
|
|
|
|
|
2018-01-02 11:11:50 -05:00
|
|
|
|
if(_previewAddress >= 0) {
|
|
|
|
|
tlpMain.RowStyles.Insert(1, new RowStyle());
|
|
|
|
|
|
2018-02-11 15:58:23 -05:00
|
|
|
|
_codeWindow = new ctrlDebuggerCode();
|
|
|
|
|
_codeWindow.HideSelection = true;
|
|
|
|
|
_codeWindow.SetConfig(ConfigManager.Config.DebugInfo.LeftView);
|
|
|
|
|
_codeWindow.Code = _code;
|
|
|
|
|
_codeWindow.Dock = DockStyle.Fill;
|
|
|
|
|
_codeWindow.ShowScrollbars = false;
|
|
|
|
|
_codeWindow.ScrollToLineNumber(_previewAddress, true);
|
2018-01-02 11:11:50 -05:00
|
|
|
|
|
2018-02-11 15:58:23 -05:00
|
|
|
|
tlpMain.SetRow(_codeWindow, i);
|
|
|
|
|
tlpMain.SetColumn(_codeWindow, 0);
|
|
|
|
|
tlpMain.SetColumnSpan(_codeWindow, 2);
|
|
|
|
|
tlpMain.Controls.Add(_codeWindow);
|
2018-01-02 11:11:50 -05:00
|
|
|
|
}
|
2018-01-03 19:12:02 -05:00
|
|
|
|
tlpMain.ResumeLayout();
|
2016-12-19 18:25:52 -05:00
|
|
|
|
this.Width = this.tlpMain.Width;
|
|
|
|
|
this.Height = this.tlpMain.Height;
|
2016-11-24 19:47:59 -05:00
|
|
|
|
}
|
2018-02-11 15:58:23 -05:00
|
|
|
|
|
|
|
|
|
public void ScrollToLineIndex(int lineIndex)
|
|
|
|
|
{
|
|
|
|
|
_codeWindow?.ScrollToLineIndex(0);
|
|
|
|
|
_codeWindow?.ScrollToLineIndex(lineIndex);
|
|
|
|
|
}
|
2016-11-24 19:47:59 -05:00
|
|
|
|
}
|
|
|
|
|
}
|