From 2adb8859edb95921e8f6d3cbb41fdc349825d6f8 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 4 Jul 2017 17:57:29 -0400 Subject: abandon system.drawing for anything other than text --- ShiftOS.Frontend/GUI/Control.cs | 53 ++++++++++++++--------------------------- 1 file changed, 18 insertions(+), 35 deletions(-) (limited to 'ShiftOS.Frontend/GUI/Control.cs') diff --git a/ShiftOS.Frontend/GUI/Control.cs b/ShiftOS.Frontend/GUI/Control.cs index 32afecc..31a3dd0 100644 --- a/ShiftOS.Frontend/GUI/Control.cs +++ b/ShiftOS.Frontend/GUI/Control.cs @@ -362,9 +362,9 @@ namespace ShiftOS.Frontend.GUI public virtual void MouseStateChanged() { } - protected virtual void OnPaint(Graphics gfx) + protected virtual void OnPaint(GraphicsContext gfx) { - gfx.Clear(Engine.SkinEngine.LoadedSkin.ControlColor); + gfx.Clear(Engine.SkinEngine.LoadedSkin.ControlColor.ToMonoColor()); } public void InvalidateTopLevel() @@ -375,46 +375,29 @@ namespace ShiftOS.Frontend.GUI parent.Invalidate(); } - public void Paint(System.Drawing.Graphics gfx) + public void Paint(GraphicsContext gfx) { if (_visible == true) { - if (_invalidated) + OnPaint(gfx); + int draw_x = gfx.X; + int draw_y = gfx.Y; + int draw_width = gfx.Width; + int draw_height = gfx.Height; + foreach (var ctrl in _children) { - _texCache = new Bitmap(Width, Height); - using (var cGfx = Graphics.FromImage(_texCache)) + if (ctrl.Visible == true) { - OnPaint(cGfx); + gfx.X = draw_x + ctrl.X; + gfx.Y = draw_y + ctrl.Y; + gfx.Width = ctrl.Width; + gfx.Height = ctrl.Height; + ctrl.Paint(gfx); } - _invalidated = false; + gfx.Width = draw_width; + gfx.Height = draw_height; } - foreach (var child in _children) - { - if (child.Visible) - { - if (child._invalidated) - { - var cBmp = new Bitmap(child.Width, child.Height); - child.Paint(System.Drawing.Graphics.FromImage(cBmp)); - cBmp.SetOpacity((float)child.Opacity); - using(var cGfx = Graphics.FromImage(_texCache)) - { - cGfx.DrawImage(child.TextureCache, child.X, child.Y); - } - child._invalidated = false; - child._texCache = cBmp; - gfx.DrawImage(cBmp, new System.Drawing.Point(child.X, child.Y)); - - - - } - else - { - gfx.DrawImage(child._texCache, child.X, child.Y); - } - } - } - gfx.DrawImage(_texCache, 0, 0); + _invalidated = false; } } -- cgit v1.2.3