aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.Frontend/GUI/TextInput.cs
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-07-04 17:57:29 -0400
committerMichael <[email protected]>2017-07-04 17:57:29 -0400
commit2adb8859edb95921e8f6d3cbb41fdc349825d6f8 (patch)
treeaa1780fe7f8e2c7ab759429aa53717d7a14ca7ef /ShiftOS.Frontend/GUI/TextInput.cs
parent5515881e922de087f4e0f5db51ae681bcd7f70d6 (diff)
downloadshiftos_thereturn-2adb8859edb95921e8f6d3cbb41fdc349825d6f8.tar.gz
shiftos_thereturn-2adb8859edb95921e8f6d3cbb41fdc349825d6f8.tar.bz2
shiftos_thereturn-2adb8859edb95921e8f6d3cbb41fdc349825d6f8.zip
abandon system.drawing for anything other than text
Diffstat (limited to 'ShiftOS.Frontend/GUI/TextInput.cs')
-rw-r--r--ShiftOS.Frontend/GUI/TextInput.cs21
1 files changed, 10 insertions, 11 deletions
diff --git a/ShiftOS.Frontend/GUI/TextInput.cs b/ShiftOS.Frontend/GUI/TextInput.cs
index 13ee596..73954ef 100644
--- a/ShiftOS.Frontend/GUI/TextInput.cs
+++ b/ShiftOS.Frontend/GUI/TextInput.cs
@@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
-using System.Drawing;
+
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -15,7 +15,7 @@ namespace ShiftOS.Frontend.GUI
private string _label = "Type here!";
private string _text = "";
private int _index = 0;
- private Font _font = new Font("Tahoma", 9f);
+ private System.Drawing.Font _font = new System.Drawing.Font("Tahoma", 9f);
public int Index
{
@@ -96,7 +96,7 @@ namespace ShiftOS.Frontend.GUI
protected void CalculateVisibleText()
{
- using(var gfx = Graphics.FromImage(new Bitmap(1, 1)))
+ using(var gfx = System.Drawing.Graphics.FromImage(new System.Drawing.Bitmap(1, 1)))
{
string toCaret = _text.Substring(0, _index);
var measure = gfx.MeasureString(toCaret, _font);
@@ -115,25 +115,24 @@ namespace ShiftOS.Frontend.GUI
private float _textDrawOffset = 0;
- protected override void OnPaint(Graphics gfx)
+ protected override void OnPaint(GraphicsContext gfx)
{
- gfx.Clear(LoadedSkin.ControlColor);
- gfx.DrawString(_text, _font, new SolidBrush(LoadedSkin.ControlTextColor), 2 - _textDrawOffset, 2);
+ gfx.Clear(LoadedSkin.ControlColor.ToMonoColor());
+ gfx.DrawString(_text, 2 - (int)Math.Floor(_textDrawOffset), 2, LoadedSkin.ControlTextColor.ToMonoColor(), _font);
if (IsFocusedControl)
{
//Draw caret.
- gfx.FillRectangle(new SolidBrush(LoadedSkin.ControlTextColor), new RectangleF(caretPos - _textDrawOffset, 2, 2, Height - 4));
+
+
+ gfx.DrawRectangle((int)(Math.Floor(caretPos) - Math.Floor(_textDrawOffset)), 2, 2, Height - 4, LoadedSkin.ControlTextColor.ToMonoColor());
}
else
{
if (string.IsNullOrEmpty(_text))
{
- gfx.DrawString(_label, _font, Brushes.Gray, 2, 2);
+ gfx.DrawString(_label, 2, 2, Color.Gray, _font);
}
}
- gfx.DrawRectangle(new Pen(new SolidBrush(LoadedSkin.ControlTextColor), 1), new System.Drawing.Rectangle(0, 0, Width - 1, Height - 1));
-
-
}
}
}