aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.Frontend/GUI/TextControl.cs
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-07-02 13:31:39 -0400
committerMichael <[email protected]>2017-07-02 13:31:39 -0400
commitdad09c9e7c1ff68a157836b636f13f25d27e050a (patch)
treec19c3648072a2ee8b04fa26ef2d875e9ba9857ca /ShiftOS.Frontend/GUI/TextControl.cs
parent345c1446863c3944bb08bfb3dfa25596b94e98db (diff)
downloadshiftos_thereturn-dad09c9e7c1ff68a157836b636f13f25d27e050a.tar.gz
shiftos_thereturn-dad09c9e7c1ff68a157836b636f13f25d27e050a.tar.bz2
shiftos_thereturn-dad09c9e7c1ff68a157836b636f13f25d27e050a.zip
Render text onscreen
Diffstat (limited to 'ShiftOS.Frontend/GUI/TextControl.cs')
-rw-r--r--ShiftOS.Frontend/GUI/TextControl.cs72
1 files changed, 72 insertions, 0 deletions
diff --git a/ShiftOS.Frontend/GUI/TextControl.cs b/ShiftOS.Frontend/GUI/TextControl.cs
new file mode 100644
index 0000000..06d8233
--- /dev/null
+++ b/ShiftOS.Frontend/GUI/TextControl.cs
@@ -0,0 +1,72 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ShiftOS.Frontend.GUI
+{
+ public class TextControl : Control
+ {
+ private string _text = "Text Control";
+ private TextAlign _textAlign = TextAlign.TopLeft;
+ private Font _font = new Font("Tahoma", 9f);
+
+ public override void Paint(Graphics gfx)
+ {
+ var sMeasure = gfx.MeasureString(_text, _font);
+ PointF loc = new PointF(2, 2);
+ float centerH = (Width - sMeasure.Width) / 2;
+ float centerV = (Height - sMeasure.Height) / 2;
+ switch (_textAlign)
+ {
+ case TextAlign.TopCenter:
+ loc.X = centerH;
+ break;
+ case TextAlign.TopRight:
+ loc.X = Width - sMeasure.Width;
+ break;
+ case TextAlign.MiddleLeft:
+ loc.Y = centerV;
+ break;
+ case TextAlign.MiddleCenter:
+ loc.Y = centerV;
+ loc.X = centerH;
+ break;
+ case TextAlign.MiddleRight:
+ loc.Y = centerV;
+ loc.X = (Width - sMeasure.Width);
+ break;
+ case TextAlign.BottomLeft:
+ loc.Y = (Height - sMeasure.Height);
+ break;
+ case TextAlign.BottomCenter:
+ loc.Y = (Height - sMeasure.Height);
+ loc.X = centerH;
+ break;
+ case TextAlign.BottomRight:
+ loc.Y = (Height - sMeasure.Height);
+ loc.X = (Width - sMeasure.Width);
+ break;
+
+
+ }
+
+ gfx.DrawString(_text, _font, new SolidBrush(Color.White), new RectangleF(loc.X, loc.Y, sMeasure.Width, sMeasure.Height));
+ }
+ }
+
+ public enum TextAlign
+ {
+ TopLeft,
+ TopCenter,
+ TopRight,
+ MiddleLeft,
+ MiddleCenter,
+ MiddleRight,
+ BottomLeft,
+ BottomCenter,
+ BottomRight
+ }
+}