public static void PaintLabel(Graphics g, RECT rect, RenderedLayout Layout, bool clear = true, bool title = true, List <RenderedZone> ActiveZones = null) { if (clear) { g.FillRectangle(Black, rect.Left, rect.Top, rect.Width, rect.Height); } if (Layout.Base.Name != null && title) { var size = g.MeasureString(Layout.Base.Name, LabelFont).ToSize(); var point = new Point((rect.Width - size.Width) / 2, size.Height / 2); g.DrawString(Layout.Base.Name, LabelFont, RedBrush, point); g.DrawRectangle(ThickRedPen, new Rectangle(point, size)); } int i = 0; ActiveZones = ActiveZones ?? new List <RenderedZone>(); foreach (var Zone in Layout.Zones.Except(ActiveZones).Union(ActiveZones)) { i += 1; var text = Zone.Name ?? i.ToString(); var size = g.MeasureString(text, LabelFont).ToSize(); var point = new Point(Zone.Trigger.Left + ((Zone.TriggerWidth - size.Width) / 2), Zone.Trigger.Top + ((Zone.TriggerHeight - size.Height) / 2)); var borderColor = (ActiveZones?.Contains(Zone) ?? false) ? ThinRedPenInverted : ThinRedPen; var labelColor = (ActiveZones?.Contains(Zone) ?? false) ? RedBrushInverted : RedBrush; g.DrawString(text, LabelFont, labelColor, point); g.DrawRectangle(borderColor, new Rectangle(Zone.Trigger.Left, Zone.Trigger.Top, Zone.TriggerWidth, Zone.TriggerHeight)); } }
public GDIZone(RenderedLayout Layout) { var instanceHandle = System.Diagnostics.Process.GetCurrentProcess().Handle; TransWind = new Window("ZoneMove", TransparencyPaintFunc, instanceHandle, hidden: true, delayShow: true) { Left = -5, Top = 0 - GDIWindow.WinApi.WinAPI.GetSystemMetrics(GDIWindow.Win32Enums.SystemMetric.SM_CYCAPTION) - 7, Width = ScreenInfo.GetDisplays().MaxWidth + 10, Height = ScreenInfo.GetDisplays().MaxHeight + GDIWindow.WinApi.WinAPI.GetSystemMetrics(GDIWindow.Win32Enums.SystemMetric.SM_CYCAPTION) + 15, ZPos = GDIWindow.Win32Enums.HWNDPosStates.TopMost, Style = GDIWindow.Win32Enums.WindowStylesEx.WS_EX_VisualStudioEmulation | GDIWindow.Win32Enums.WindowStylesEx.WS_EX_TOPMOST, Transparency = BackgroundColor.A, }; LabelWind = new Window("ZoneMove1", LabelPaintFunc, TransWind.Handle, hidden: true, delayShow: true) { Left = -5, Top = 0 - GDIWindow.WinApi.WinAPI.GetSystemMetrics(GDIWindow.Win32Enums.SystemMetric.SM_CYCAPTION) - 7, Width = ScreenInfo.GetDisplays().MaxWidth + 10, Height = ScreenInfo.GetDisplays().MaxHeight + GDIWindow.WinApi.WinAPI.GetSystemMetrics(GDIWindow.Win32Enums.SystemMetric.SM_CYCAPTION) + 15, ZPos = GDIWindow.Win32Enums.HWNDPosStates.TopMost, Style = GDIWindow.Win32Enums.WindowStylesEx.WS_EX_VisualStudioEmulation | GDIWindow.Win32Enums.WindowStylesEx.WS_EX_TOPMOST, Transparency = 255, }; TransWind.DelayedShow(); LabelWind.DelayedShow(); UpdateZones(Layout); }
public override void UpdateZones(RenderedLayout Layout) { LabelsDirty = true; this.Layout = Layout; TransWind.UpdateWindow(); LabelWind.UpdateWindow(); }