diff --git a/GUI.NET/Controls/MesenNumericUpDown.cs b/GUI.NET/Controls/MesenNumericUpDown.cs
index 87b8e7bc..fd745249 100644
--- a/GUI.NET/Controls/MesenNumericUpDown.cs
+++ b/GUI.NET/Controls/MesenNumericUpDown.cs
@@ -1,4 +1,5 @@
-using System;
+using Mesen.GUI.Utilities;
+using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
@@ -61,7 +62,7 @@ namespace Mesen.GUI.Controls
_repeatCount++;
_preventClick = true;
}
-
+
private void btn_MouseDown(object sender, MouseEventArgs e)
{
_repeatCount = 0;
@@ -93,20 +94,26 @@ namespace Mesen.GUI.Controls
private void txtValue_TextChanged(object sender, EventArgs e)
{
decimal val;
+ int hexVal;
if(string.IsNullOrWhiteSpace(txtValue.Text)) {
SetValue(0, false);
- } else if(decimal.TryParse(txtValue.Text, out val)) {
+ } else if(!IsHex && decimal.TryParse(txtValue.Text, out val)) {
SetValue(val, false);
+ } else if(IsHex && int.TryParse(txtValue.Text, System.Globalization.NumberStyles.HexNumber, null, out hexVal)) {
+ SetValue(hexVal, false);
}
}
private void txtValue_Validated(object sender, EventArgs e)
{
decimal val;
+ int hexVal;
if(string.IsNullOrWhiteSpace(txtValue.Text)) {
SetValue(0, true);
- } else if(decimal.TryParse(txtValue.Text, out val)) {
+ } else if(!IsHex && decimal.TryParse(txtValue.Text, out val)) {
SetValue(val, true);
+ } else if(IsHex && int.TryParse(txtValue.Text, System.Globalization.NumberStyles.HexNumber, null, out hexVal)) {
+ SetValue(hexVal, true);
} else {
SetValue(this.Value, true);
}
@@ -128,7 +135,13 @@ namespace Mesen.GUI.Controls
ValueChanged?.Invoke(this, EventArgs.Empty);
}
if(updateText) {
- txtValue.Text = value.ToString("0" + (this.DecimalPlaces > 0 ? "." : "") + new string('0', this.DecimalPlaces));
+ txtValue.TextChanged -= txtValue_TextChanged;
+ if(IsHex) {
+ txtValue.Text = ((int)_value).ToString("X");
+ } else {
+ txtValue.Text = _value.ToString("0" + (this.DecimalPlaces > 0 ? "." : "") + new string('0', this.DecimalPlaces));
+ }
+ txtValue.TextChanged += txtValue_TextChanged;
}
}
@@ -142,6 +155,8 @@ namespace Mesen.GUI.Controls
}
}
+ public bool IsHex { get; set; } = false;
+
public new string Text
{
get { return txtValue.Text; }
@@ -177,6 +192,12 @@ namespace Mesen.GUI.Controls
if(this.Height < 21) {
this.Height = 21;
}
+
+ double scale = (double)this.Height / 21;
+ if(scale > 1) {
+ btnDown.Image = Properties.Resources.NudDownArrow.GetScaledImage(scale);
+ btnUp.Image = Properties.Resources.NudUpArrow.GetScaledImage(scale);
+ }
}
private void txtValue_KeyDown(object sender, KeyEventArgs e)
@@ -190,11 +211,16 @@ namespace Mesen.GUI.Controls
} else if(
!((e.KeyCode >= Keys.D0 && e.KeyCode <= Keys.D9) ||
(e.KeyCode >= Keys.NumPad0 && e.KeyCode <= Keys.NumPad9) ||
- e.KeyCode == Keys.OemPeriod || e.KeyCode == Keys.Oemcomma ||
+ e.KeyCode == Keys.OemPeriod || e.KeyCode == Keys.Oemcomma ||
e.KeyCode == Keys.Delete || e.KeyCode == Keys.Left ||
- e.KeyCode == Keys.Right || e.KeyCode == Keys.Home ||
+ e.KeyCode == Keys.Right || e.KeyCode == Keys.Home ||
e.KeyCode == Keys.End || e.KeyCode == Keys.Back)
) {
+ if(IsHex && e.KeyCode >= Keys.A && e.KeyCode <= Keys.F) {
+ //Allow A-F when in hex mode
+ return;
+ }
+
e.SuppressKeyPress = true;
}
}
diff --git a/GUI.NET/Debugger/Controls/ctrlCodeScrollbar.cs b/GUI.NET/Debugger/Controls/ctrlCodeScrollbar.cs
index 6607728c..a72a597a 100644
--- a/GUI.NET/Debugger/Controls/ctrlCodeScrollbar.cs
+++ b/GUI.NET/Debugger/Controls/ctrlCodeScrollbar.cs
@@ -15,8 +15,7 @@ namespace Mesen.GUI.Debugger.Controls
private Timer _tmrScroll;
private bool _scrollUp = false;
-
- private const int _buttonSize = 15;
+ private int _buttonSize = 15;
private IScrollbarColorProvider _colorProvider = null;
public IScrollbarColorProvider ColorProvider
@@ -57,6 +56,9 @@ namespace Mesen.GUI.Debugger.Controls
int width = rect.Width;
e.Graphics.FillRectangle(Brushes.DimGray, rect);
+ double scale = (double)width / 18;
+ _buttonSize = (int)(15 * scale);
+
int barTop = rect.Top + _buttonSize;
int barHeight = this.Height - _buttonSize * 2;
@@ -89,9 +91,9 @@ namespace Mesen.GUI.Debugger.Controls
float highlightTop = barTop + barHeight * startPos - HighlightOffset;
using(SolidBrush brush = new SolidBrush(Color.FromArgb(120, 220, 220, 255))) {
- e.Graphics.FillRectangle(brush, left + 1, highlightTop, width, HighlightHeight - 2);
- e.Graphics.DrawRectangle(Pens.DarkSlateGray, left + 1, highlightTop, width - 2, HighlightHeight - 2);
- e.Graphics.DrawRectangle(Pens.Gray, left + 2, highlightTop + 1, width - 4, HighlightHeight - 4);
+ e.Graphics.FillRectangle(brush, left + 1, highlightTop, width, (int)(HighlightHeight * scale) - 2);
+ e.Graphics.DrawRectangle(Pens.DarkSlateGray, left + 1, highlightTop, width - 2, (int)(HighlightHeight * scale) - 2);
+ e.Graphics.DrawRectangle(Pens.Gray, left + 2, highlightTop + 1, width - 4, (int)(HighlightHeight * scale) - 4);
}
if(this.ColorProvider != null) {
@@ -122,8 +124,8 @@ namespace Mesen.GUI.Debugger.Controls
}
}
- int arrowWidth = 10;
- int arrowHeight = 5;
+ int arrowWidth = (int)(10 * scale);
+ int arrowHeight = (int)(5 * scale);
int bottom = barTop + barHeight + _buttonSize;
e.Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
e.Graphics.FillRectangle(Brushes.Gainsboro, rect.Left + 1, rect.Top, this.Width - 1, _buttonSize);
@@ -131,8 +133,10 @@ namespace Mesen.GUI.Debugger.Controls
e.Graphics.DrawLine(Pens.DimGray, rect.Left + 1, rect.Top + _buttonSize, rect.Left + width, rect.Top + _buttonSize);
e.Graphics.DrawLine(Pens.DimGray, rect.Left + 1, bottom - _buttonSize, rect.Left + width, bottom - _buttonSize);
e.Graphics.DrawLine(Pens.DimGray, rect.Left + 1, bottom, rect.Left + width, bottom);
- e.Graphics.TranslateTransform(5, (_buttonSize - arrowHeight) / 2);
+
+ e.Graphics.TranslateTransform((int)(5 * scale), (_buttonSize - arrowHeight) / 2);
e.Graphics.FillPolygon(Brushes.DimGray, new Point[] { new Point(left, rect.Top + arrowHeight), new Point(left + arrowWidth, rect.Top + arrowHeight), new Point(left + arrowWidth / 2, rect.Top) }, FillMode.Winding);
+
e.Graphics.TranslateTransform(0, -(_buttonSize - arrowHeight));
e.Graphics.FillPolygon(Brushes.DimGray, new Point[] { new Point(left, bottom - arrowHeight), new Point(left + arrowWidth, bottom - arrowHeight), new Point(left + arrowWidth / 2, bottom) }, FillMode.Winding);
}
diff --git a/GUI.NET/GUI.NET.csproj b/GUI.NET/GUI.NET.csproj
index 323f76e7..1829a61a 100644
--- a/GUI.NET/GUI.NET.csproj
+++ b/GUI.NET/GUI.NET.csproj
@@ -1297,6 +1297,7 @@
+
diff --git a/GUI.NET/ImageExtensions.cs b/GUI.NET/ImageExtensions.cs
new file mode 100644
index 00000000..afe2581a
--- /dev/null
+++ b/GUI.NET/ImageExtensions.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Mesen.GUI.Utilities
+{
+ static class ImageExtensions
+ {
+ public static Image GetScaledImage(this Image img, double scale)
+ {
+ int newWidth = (int)(img.Width * scale);
+ int newHeight = (int)(img.Height * scale);
+
+ Bitmap scaledImg = new Bitmap(newWidth, newHeight);
+ using(Graphics g = Graphics.FromImage(scaledImg)) {
+ g.InterpolationMode = scale >= 2 ? InterpolationMode.NearestNeighbor : InterpolationMode.HighQualityBicubic;
+ g.DrawImage(img, 0, 0, newWidth, newHeight);
+ }
+
+ return scaledImg;
+ }
+ }
+}