Mesen-X/GUI.NET/Debugger/frmCodeTooltip.cs

84 lines
2.1 KiB
C#
Raw Normal View History

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;
namespace Mesen.GUI.Debugger
{
public partial class frmCodeTooltip : Form
{
private Dictionary<string, string> _values;
2018-01-02 11:11:50 -05:00
private int _previewAddress;
private string _code;
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)
{
_values = values;
2018-01-02 11:11:50 -05:00
_previewAddress = previewAddress;
_code = code;
InitializeComponent();
}
protected override void OnShown(EventArgs e)
{
base.OnShown(e);
2018-01-03 19:12:02 -05:00
tlpMain.SuspendLayout();
int i = 0;
foreach(KeyValuePair<string, string> kvp in _values) {
tlpMain.RowStyles.Insert(1, new RowStyle());
Label lbl = new Label();
lbl.Margin = new Padding(2, 3, 2, 2);
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);
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++;
}
2018-01-02 11:11:50 -05:00
if(_previewAddress >= 0) {
tlpMain.RowStyles.Insert(1, new RowStyle());
ctrlDebuggerCode codeWindow = new ctrlDebuggerCode();
codeWindow.SetConfig(ConfigManager.Config.DebugInfo.LeftView);
codeWindow.Code = _code;
codeWindow.Dock = DockStyle.Fill;
codeWindow.ShowScrollbars = false;
codeWindow.ScrollToLineNumber(_previewAddress, true);
tlpMain.SetRow(codeWindow, i);
tlpMain.SetColumn(codeWindow, 0);
tlpMain.SetColumnSpan(codeWindow, 2);
tlpMain.Controls.Add(codeWindow);
}
2018-01-03 19:12:02 -05:00
tlpMain.ResumeLayout();
this.Width = this.tlpMain.Width;
this.Height = this.tlpMain.Height;
}
}
}