From 0b7cfb98b13d210626c4a266fe2fe42310462a3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20Andr=C3=A9?= Date: Fri, 20 Jul 2018 23:04:01 -0300 Subject: [PATCH] Better Overlay and AppVeyor Happifier --- Help/How To.txt | Bin 9666 -> 10128 bytes Overlay/Functions.cs | 106 ++++++++---- Overlay/IOverlay.cs | 35 ++++ Overlay/Overlay.Designer.cs | 3 +- Overlay/Overlay.cs | 68 +++++--- Overlay/Overlay.csproj | 14 +- Overlay/TextOverlay.Designer.cs | 42 +++++ Overlay/TextOverlay.cs | 287 ++++++++++++++++++++++++++++++++ Overlay/TextOverlay.resx | 120 +++++++++++++ SRLTracer/Form1.cs | 4 +- 10 files changed, 623 insertions(+), 56 deletions(-) create mode 100644 Overlay/IOverlay.cs create mode 100644 Overlay/TextOverlay.Designer.cs create mode 100644 Overlay/TextOverlay.cs create mode 100644 Overlay/TextOverlay.resx diff --git a/Help/How To.txt b/Help/How To.txt index f79d208aa73a254632e963fd98b4f245242f5bae..5ffee112a2f271590663ff3020aba11290a5b89b 100644 GIT binary patch delta 395 zcmYk2!D_-#6hvn!g6;%Gs99KIpy0k6DYa0M;zGf78eggylA=kgtNudeZT$%S1;5O> z_eGEpNY0%%GxuG_|C7_@aa}_dGZ^fU!@~qA672EJ?;INxob(YRB;E4cLl5s*VWE7A zB{KY~cBxYzpVUTJUusmKu9bGPLOki=JYOvqp8yQeDB%mD_PF|$FlV~-D2 zTd!2!Mi`R1S*VU4a}0ZBOp#VDJ!Z3%@0R~hq!H&S_YhjxL%a1Sdm8dWsZ3p;Is2^0 xWN*p2^|f5>~oAyohlfCGd8 diff --git a/Overlay/Functions.cs b/Overlay/Functions.cs index 976e582..bfd77bb 100644 --- a/Overlay/Functions.cs +++ b/Overlay/Functions.cs @@ -1,4 +1,5 @@ -using System; +//#define DEBUG +using System; using System.Collections.Generic; using System.Drawing; using System.Runtime.InteropServices; @@ -12,6 +13,13 @@ #pragma warning disable 1591 namespace Overlay { public static class Exports { + + public static bool TextOnly = false; + internal static IOverlay DefaultInstance { + get { + return (TextOnly ? (IOverlay)TextOverlay.DefaultInstance : Overlay.DefaultInstance); + } + } public static string SetDialogue(string text) { try { if (text.StartsWith("::EVENT")) { @@ -32,7 +40,7 @@ public static string SetDialogue(string text) { } if (EventList.Length == 0 || HookText) - Overlay.DefaultInstance.ShowText(text); + DefaultInstance.Text = text; } catch (Exception ex) { #if DEBUG MessageBox.Show(ex.ToString()); @@ -56,16 +64,16 @@ public static void SendMouseClick(IntPtr WindowHandler, int X, int Y) { static bool Minimized = false; internal static void UpdateWindow(IntPtr WindowHandler) { - if (!Overlay.DefaultInstance.CanInvoke()) + if (!DefaultInstance.CanInvoke()) return; var Rst = new WINDOWPLACEMENT(); GetWindowPlacement(WindowHandler, ref Rst); if (Rst.showCmd == WMinimized) { - if (Overlay.DefaultInstance.WindowState == FormWindowState.Normal) { + if (DefaultInstance.WindowState == FormWindowState.Normal) { Minimized = true; - Overlay.DefaultInstance.Invoke(new MethodInvoker(() => { - Overlay.DefaultInstance.WindowState = FormWindowState.Minimized; + DefaultInstance.Invoke(new MethodInvoker(() => { + DefaultInstance.WindowState = FormWindowState.Minimized; })); } @@ -75,18 +83,22 @@ internal static void UpdateWindow(IntPtr WindowHandler) { if (Minimized) { Minimized = false; - Overlay.DefaultInstance.Invoke(new MethodInvoker(() => { - Overlay.DefaultInstance.WindowState = FormWindowState.Normal; + DefaultInstance.Invoke(new MethodInvoker(() => { + DefaultInstance.WindowState = FormWindowState.Normal; })); } - Overlay.DefaultInstance.Invoke(new MethodInvoker(() => { + DefaultInstance.Invoke(new MethodInvoker(() => { try { GetPoint(WindowHandler, out Size Size, out Point Point); - Overlay.DefaultInstance.Size = Size; - Overlay.DefaultInstance.Location = Point; + DefaultInstance.Size = Size; + DefaultInstance.Location = Point; + + DefaultInstance.Focus(); + + SetWindowPos(DefaultInstance.Handle, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW); + SetWindowPos(DefaultInstance.Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW); - Overlay.DefaultInstance.Focus(); SetForegroundWindow(WindowHandler); } catch { } })); @@ -125,7 +137,7 @@ public static bool HookWindow(IntPtr WindowHandler) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - Overlay.DefaultInstance.Show(); + DefaultInstance.Show(); new Thread(() => { SetDialogue("::EVENT0::"); }).Start(); @@ -139,7 +151,7 @@ public static bool HookWindow(IntPtr WindowHandler) { } try { - for (int i = 0; i < 50; i++) { + for (int i = 0; i < 25; i++) { Application.DoEvents(); Thread.Sleep(10); } @@ -147,7 +159,7 @@ public static bool HookWindow(IntPtr WindowHandler) { } //Maybe Envoriment.Exit will bee needed. - Overlay.DefaultInstance.Close(); + DefaultInstance.Close(); }); OverlayThread.SetApartmentState(ApartmentState.STA); @@ -176,6 +188,15 @@ internal static class Imports { internal const int WMinimized = 2; internal const int WMaximized = 3; + [DllImport("user32.dll")] + internal static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags); + + internal static readonly IntPtr HWND_TOPMOST = new IntPtr(-1); + internal static readonly IntPtr HWND_TOP = new IntPtr(0); + internal const uint SWP_NOSIZE = 0x0001; + internal const uint SWP_NOMOVE = 0x0002; + internal const uint SWP_SHOWWINDOW = 0x0040; + [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool GetWindowPlacement(IntPtr hWnd, ref WINDOWPLACEMENT lpwndpl); @@ -276,30 +297,30 @@ internal static void TriggerEvent(uint ID) { case "subtitle": case "set text": case "text": - Overlay.DefaultInstance.ShowText(CMDV.Replace("\\n", "\n")); + DefaultInstance.Text = CMDV.Replace("\\n", "\n"); break; case "clear": case "clear text": case "remove text": case "cls": - Overlay.DefaultInstance.ShowText(string.Empty); + DefaultInstance.Text = string.Empty; break; case "hide": case "close": case "hide overlay": case "close overlay": - Overlay.DefaultInstance.Invoke(new MethodInvoker(() => { - Overlay.DefaultInstance.Opacity = 1.0d; - Overlay.DefaultInstance.Hide(); + DefaultInstance.Invoke(new MethodInvoker(() => { + DefaultInstance.Opacity = 1.0d; + DefaultInstance.Hide(); })); break; case "show": case "open": case "show overlay": case "open overlay": - Overlay.DefaultInstance.Invoke(new MethodInvoker(() => { - Overlay.DefaultInstance.Opacity = 1.0d; - Overlay.DefaultInstance.Show(); + DefaultInstance.Invoke(new MethodInvoker(() => { + DefaultInstance.Opacity = 1.0d; + DefaultInstance.Show(); })); break; case "window opacity": @@ -307,23 +328,21 @@ internal static void TriggerEvent(uint ID) { case "global opacity": case "opacity": double Opacity = double.Parse(CMDV); - Overlay.DefaultInstance.Invoke(new MethodInvoker(() => { - Overlay.DefaultInstance.Opacity = Opacity; + DefaultInstance.Invoke(new MethodInvoker(() => { + DefaultInstance.Opacity = Opacity; })); break; case "set background color": case "background color": case "back color": case "backcolor": - Overlay.DefaultInstance.TranslatePanel.BackColor = LoadColor(CMDV, Color.FromArgb(40, 40, 40)); - Overlay.DefaultInstance.ButtonPanel.BackColor = LoadColor(CMDV, Color.FromArgb(40, 40, 40)); - Overlay.DefaultInstance.DialogueBox.BackColor = LoadColor(CMDV, Color.FromArgb(40, 40, 40)); + DefaultInstance.TextBackColor = LoadColor(CMDV, Color.Black); break; case "text color": case "set text color": case "fore color": case "forecolor": - Overlay.DefaultInstance.DialogueBox.ForeColor = LoadColor(CMDV, Color.FromArgb(40, 40, 40)); + DefaultInstance.TextForeColor = LoadColor(CMDV, Color.FromArgb(40, 40, 40)); break; case "set padding": case "force padding": @@ -371,13 +390,13 @@ internal static void TriggerEvent(uint ID) { case "set font size": case "font resize": case "resize font": - Overlay.DefaultInstance.FixedFontSize = float.Parse(CMDV); + DefaultInstance.Font = new Font(DefaultInstance.Font.FontFamily, float.Parse(CMDV), DefaultInstance.Font.Style); break; case "auto font size": case "auto resize text": case "auto font resize": case "resize text": - Overlay.DefaultInstance.AutoFontSize = CMDV.ToLower() == "true"; + DefaultInstance.AutoSize = CMDV.ToLower() == "true"; break; case "set dock": case "change dock": @@ -395,6 +414,18 @@ internal static void TriggerEvent(uint ID) { break; } break; + case "text only": + case "no background": + case "subtitle mode": + case "hide background": + string Text = DefaultInstance?.Text; + DefaultInstance?.Close(); + DefaultInstance?.Dispose(); + TextOnly = CMDV.ToLower() == "true"; + DefaultInstance.Show(); + DefaultInstance.Text = Text; + UpdateWindow(HookHandler); + break; case "hook text": case "enable hook": case "auto show": @@ -407,6 +438,18 @@ internal static void TriggerEvent(uint ID) { case "run": TriggerEvent(uint.Parse(CMDV)); break; + case "call async": + case "async": + case "async invoke": + case "invoke async": + new Thread(() => { TriggerEvent(uint.Parse(CMDV)); }).Start(); + break; + case "wait": + case "sleep": + case "delay": + case "suspend": + Thread.Sleep(int.Parse(CMDV)); + break; case "continue to event": case "jump to event": case "go to": @@ -427,7 +470,6 @@ internal static void TriggerEvent(uint ID) { } } - internal static Color LoadColor(string ColorName, Color Default) { try { if (ColorName.StartsWith("#")) { diff --git a/Overlay/IOverlay.cs b/Overlay/IOverlay.cs new file mode 100644 index 0000000..ea0a311 --- /dev/null +++ b/Overlay/IOverlay.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; + +namespace Overlay { + internal interface IOverlay { + + bool AutoSize { get; set; } + string Text { get; set; } + Font Font { get; set; } + + Size Size { get; set; } + Point Location { get; set; } + + Color TextBackColor { get; set; } + Color TextForeColor { get; set; } + + IntPtr Handle { get; } + + FormWindowState WindowState { get; set; } + double Opacity { get; set; } + + bool CanInvoke(); + + void Invoke(Delegate Method); + void Close(); + void Show(); + void Dispose(); + void Hide(); + void Focus(); + } +} diff --git a/Overlay/Overlay.Designer.cs b/Overlay/Overlay.Designer.cs index 4ba7b6b..2e70c3c 100644 --- a/Overlay/Overlay.Designer.cs +++ b/Overlay/Overlay.Designer.cs @@ -139,7 +139,8 @@ private void InitializeComponent() this.Name = "Overlay"; this.Opacity = 0.8D; this.Padding = new System.Windows.Forms.Padding(15); - this.Text = "Overlay"; + this.ShowIcon = false; + this.ShowInTaskbar = false; this.TopMost = true; this.TransparencyKey = System.Drawing.Color.Fuchsia; this.LabelBackground.ResumeLayout(false); diff --git a/Overlay/Overlay.cs b/Overlay/Overlay.cs index 64335af..7eaaef4 100644 --- a/Overlay/Overlay.cs +++ b/Overlay/Overlay.cs @@ -7,18 +7,39 @@ #pragma warning disable 1591 namespace Overlay { - public partial class Overlay + public partial class Overlay : IOverlay { + + public Color TextBackColor { get { + return DialogueBox.BackColor; + } + set { + DialogueBox.BackColor = value; + } + } + + public Color TextForeColor { + get { + return DialogueBox.ForeColor; + } + set { + DialogueBox.ForeColor = value; + } + } + private string ListFN = null; private bool TranslationMode = false; public bool AutoFontSize = false; - public float FixedFontSize = 8f; static bool Initializing = false; internal Overlay() { InitializeComponent(); + + TopMost = true; + TopLevel = true; + TranslatePanel.Visible = TranslationMode; ButtonPanel.Visible = File.Exists(AppDomain.CurrentDomain.BaseDirectory + "Strings.lst"); } @@ -27,23 +48,27 @@ private void LB_Legenda_TextChanged(object sender, EventArgs e) { if (string.IsNullOrEmpty(DialogueBox.Text)) return; - DialogueBox.Font = new Font(DialogueBox.Font.Name, FixedFontSize, DialogueBox.Font.Style); DialogueBox.BorderStyle = BorderStyle.Fixed3D; - while (AutoFontSize) { - Font New = new Font(DialogueBox.Font.Name, DialogueBox.Font.Size + 1, DialogueBox.Font.Style); - using (var g = Graphics.FromHwnd(IntPtr.Zero)) { - SizeF Rst = g.MeasureString(DialogueBox.Text, New); - if (Rst.Width >= DialogueBox.Size.Width - 5 || Rst.Height >= DialogueBox.Size.Height - 5) - break; + Font New = Font; + using (var g = Graphics.FromHwnd(IntPtr.Zero)) { + bool First = true; + if (AutoFontSize) { + SizeF ExpectedSize; + do { + if (!First) + New = new Font(New.Name, New.Size - 1, New.Style); + First = false; + ExpectedSize = g.MeasureString(Text, New); + + } while (ExpectedSize.Width > DialogueBox.Width || ExpectedSize.Height > DialogueBox.Height); } - - DialogueBox.Font = New; } + DialogueBox.Font = New; DialogueBox.BorderStyle = BorderStyle.None; } - public string DialogueText { + public new string Text { get { return DialogueBox.Text; } set { @@ -62,9 +87,6 @@ public string DialogueText { })); } } - public void ShowText(string Text) { - DialogueText = Text; - } private static Overlay _DefaultInstance; @@ -76,6 +98,8 @@ public static Overlay DefaultInstance { } if (_DefaultInstance == null || _DefaultInstance.IsDisposed || !_DefaultInstance.CanInvoke()) { + if (Exports.TextOnly) + return null; Initializing = true; _DefaultInstance = new Overlay(); _DefaultInstance.Show(); @@ -86,7 +110,6 @@ public static Overlay DefaultInstance { return _DefaultInstance; } } - public bool CanInvoke() { try { Invoke(new MethodInvoker(() => { })); @@ -103,7 +126,7 @@ private void bntSettings_Click(object sender, EventArgs e) { TranslationMode = Window.TranslationMode; ListFN = Window.ListFile; AutoFontSize = Window.AutoResizeFont; - FixedFontSize = Window.FixedFontSize; + Font = new Font(Font.FontFamily, Window.FixedFontSize, Font.Style); TranslatePanel.Visible = TranslationMode; } @@ -123,7 +146,7 @@ private void AddTranslation(string Text) { //Initial Algoritm, Needs implement overwrite feature if the string is already present. using (StreamWriter List = File.AppendText(AppDomain.CurrentDomain.BaseDirectory + ListFN)) { - List.WriteLine(DialogueText.Replace("\n", BreakLineFlag).Replace("\r", ReturnLineFlag)); + List.WriteLine(this.Text.Replace("\n", BreakLineFlag).Replace("\r", ReturnLineFlag)); List.WriteLine(Text.Replace("\n", BreakLineFlag).Replace("\r", ReturnLineFlag)); } } @@ -178,9 +201,14 @@ private static void Encode(ref string String, bool Enable) { } } - new void Invoke(Delegate Method) { - base.Invoke(Method); + void IOverlay.Invoke(Delegate Method) { + Invoke(Method); } + + void IOverlay.Focus() { + Focus(); + } + private void MouseClicked(object sender, MouseEventArgs e) { Point Pos = PointToScreen(e.Location); Exports.SendMouseClick(Exports.HookHandler, Pos.X, Pos.Y); diff --git a/Overlay/Overlay.csproj b/Overlay/Overlay.csproj index 83711b4..0d54db1 100644 --- a/Overlay/Overlay.csproj +++ b/Overlay/Overlay.csproj @@ -31,7 +31,8 @@ TRACE true bin\Release\ - Overlay.xml + + @@ -43,6 +44,7 @@ On + @@ -69,6 +71,7 @@ + Form @@ -83,6 +86,12 @@ Settings.cs + + Form + + + TextOverlay.cs + @@ -91,6 +100,9 @@ Settings.cs + + TextOverlay.cs + \ No newline at end of file diff --git a/Overlay/TextOverlay.Designer.cs b/Overlay/TextOverlay.Designer.cs new file mode 100644 index 0000000..ac760e6 --- /dev/null +++ b/Overlay/TextOverlay.Designer.cs @@ -0,0 +1,42 @@ +namespace Overlay { + partial class TextOverlay { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) { + if (disposing && (components != null)) { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() { + this.SuspendLayout(); + // + // TextOverlay + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(606, 196); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; + this.Name = "TextOverlay"; + this.Text = "TextOverlay"; + this.ResumeLayout(false); + + } + + #endregion + } +} \ No newline at end of file diff --git a/Overlay/TextOverlay.cs b/Overlay/TextOverlay.cs new file mode 100644 index 0000000..c40fc7f --- /dev/null +++ b/Overlay/TextOverlay.cs @@ -0,0 +1,287 @@ +using System; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Drawing.Imaging; +using System.Drawing.Text; +using System.Linq; +using System.Runtime.InteropServices; +using System.Threading; +using System.Windows.Forms; + +namespace Overlay { + public partial class TextOverlay : Form, IOverlay { + + Bitmap Content = new Bitmap(500, 500, PixelFormat.Format32bppArgb); + public TextOverlay() { + TopMost = true; + ShowInTaskbar = false; + FormBorderStyle = FormBorderStyle.None; + + TopLevel = true; + + MouseClick += MouseClicked; + } + + private static bool Initializing = false; + private static TextOverlay _DefaultInstance; + + public static TextOverlay DefaultInstance { + get { + while (Initializing) { + Thread.Sleep(10); + Application.DoEvents(); + } + + if (_DefaultInstance == null || _DefaultInstance.IsDisposed || !_DefaultInstance.CanInvoke()) { + if (!Exports.TextOnly) + return null; + Initializing = true; + _DefaultInstance = new TextOverlay(); + _DefaultInstance.Show(); + _DefaultInstance.Hide(); + Initializing = false; + } + + return _DefaultInstance; + } + } + + public bool CanInvoke() { + try { + Invoke(new MethodInvoker(() => { })); + return true; + } catch { + return false; + } + + } + + public new bool AutoSize = true; + + string _text = string.Empty; + public new string Text { + get { + return _text; + } + set { + if (Application.OpenForms.OfType().Count() == 0) + Show(); + + _text = value; + DrawBitmap(); + } + } + + Color _oc = Color.Black; + public Color TextBackColor { + get { + return _oc; + } + set { + _oc = value; + DrawBitmap(); + } + } + Color _tc = Color.White; + public Color TextForeColor { + get { + return _tc; + } + set { + _tc = value; + DrawBitmap(); + } + } + private void DrawBitmap() { + lock (Content) { + Content = new Bitmap(Content.Width, Content.Height, PixelFormat.Format32bppArgb); + Content.MakeTransparent(Color.Turquoise); + + Graphics g = Graphics.FromImage(Content); + g.SmoothingMode = SmoothingMode.AntiAlias; + g.TextRenderingHint = TextRenderingHint.AntiAlias; + g.PixelOffsetMode = PixelOffsetMode.HighQuality; + + Font Font = this.Font; + if (AutoSize) + Font = GetBestSize(g); + + SizeF MeasuredSize = g.MeasureString(_text, Font); + PointF TPos = new PointF((Size.Width / 2) - (MeasuredSize.Width / 2), (Size.Height / 2) - (MeasuredSize.Height / 2)); + + using (var path = GetStringPath(Text, g.DpiY, new RectangleF(TPos, MeasuredSize), Font)) { + g.FillPath(new SolidBrush(_tc), path); + g.DrawPath(new Pen(_oc, 1f), path); + g.Flush(); + g.Dispose(); + } + + SelectBitmap(Content); + } + } + + Font GetBestSize(Graphics g) { + bool First = true; + Font Font = this.Font; + SizeF TextSize; + + do { + if (!First) + Font = new Font(Font.FontFamily, Font.Size - 1, Font.Style); + First = false; + TextSize = g.MeasureString(Text, Font); + } while ((TextSize.Width > Size.Width || TextSize.Height > Size.Height) & Font.Size > 5); + + return Font; + } + GraphicsPath GetStringPath(string s, float dpi, RectangleF rect, Font font) { + GraphicsPath path = new GraphicsPath(); + float emSize = dpi * font.SizeInPoints / 72; + path.AddString(s, font.FontFamily, (int)font.Style, emSize, rect, new StringFormat()); + + return path; + } + + public new Size Size { + get { + return Content.Size; + } + set { + Content = new Bitmap(value.Width, value.Height); + base.Size = value; + } + } + + + public void SelectBitmap(Bitmap bitmap) { + if (bitmap.PixelFormat != PixelFormat.Format32bppArgb) { + throw new ApplicationException("The bitmap must be 32bpp with alpha-channel."); + } + + IntPtr screenDc = APIHelp.GetDC(IntPtr.Zero); + IntPtr memDc = APIHelp.CreateCompatibleDC(screenDc); + IntPtr hBitmap = IntPtr.Zero; + IntPtr hOldBitmap = IntPtr.Zero; + + try { + hBitmap = bitmap.GetHbitmap(Color.FromArgb(0)); + hOldBitmap = APIHelp.SelectObject(memDc, hBitmap); + + APIHelp.Size newSize = new APIHelp.Size(bitmap.Width, bitmap.Height); + APIHelp.Point sourceLocation = new APIHelp.Point(0, 0); + APIHelp.Point newLocation = new APIHelp.Point(this.Left, this.Top); + + APIHelp.BLENDFUNCTION blend = new APIHelp.BLENDFUNCTION { + BlendOp = APIHelp.AC_SRC_OVER, + BlendFlags = 0, + SourceConstantAlpha = 255, + AlphaFormat = APIHelp.AC_SRC_ALPHA + }; + + APIHelp.UpdateLayeredWindow(Handle, screenDc, ref newLocation, ref newSize, memDc, ref sourceLocation, 0, ref blend, APIHelp.ULW_ALPHA); + } finally { + APIHelp.ReleaseDC(IntPtr.Zero, screenDc); + if (hBitmap != IntPtr.Zero) { + APIHelp.SelectObject(memDc, hOldBitmap); + APIHelp.DeleteObject(hBitmap); + } + APIHelp.DeleteDC(memDc); + } + } + + protected override CreateParams CreateParams { + get { + CreateParams createParams = base.CreateParams; + createParams.ExStyle |= APIHelp.WS_EX_LAYERED; + return createParams; + } + } + /* + protected override void WndProc(ref Message message) { + if (message.Msg == APIHelp.WM_NCHITTEST) { + message.Result = (IntPtr)APIHelp.HTCAPTION; + } else { + base.WndProc(ref message); + } + } + */ + + void IOverlay.Invoke(Delegate Method) { + Invoke(Method); + } + + void IOverlay.Focus() { + Focus(); + } + private void MouseClicked(object sender, MouseEventArgs e) { + Point Pos = PointToScreen(e.Location); + Exports.SendMouseClick(Exports.HookHandler, Pos.X, Pos.Y); + } + } + class APIHelp { + public const Int32 WS_EX_LAYERED = 0x80000; + public const Int32 HTCAPTION = 0x02; + public const Int32 WM_NCHITTEST = 0x84; + public const Int32 ULW_ALPHA = 0x02; + public const byte AC_SRC_OVER = 0x00; + public const byte AC_SRC_ALPHA = 0x01; + + public enum Bool { + False = 0, + True = 1 + } + + [StructLayout(LayoutKind.Sequential)] + public struct Point { + public Int32 x; + public Int32 y; + + public Point(Int32 x, Int32 y) { this.x = x; this.y = y; } + } + + [StructLayout(LayoutKind.Sequential)] + public struct Size { + public Int32 cx; + public Int32 cy; + + public Size(Int32 cx, Int32 cy) { this.cx = cx; this.cy = cy; } + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + struct ARGB { + public byte Blue; + public byte Green; + public byte Red; + public byte Alpha; + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + public struct BLENDFUNCTION { + public byte BlendOp; + public byte BlendFlags; + public byte SourceConstantAlpha; + public byte AlphaFormat; + } + + [DllImport("user32.dll", ExactSpelling = true, SetLastError = true)] + public static extern Bool UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDst, ref Point pptDst, ref Size psize, IntPtr hdcSrc, ref Point pprSrc, Int32 crKey, ref BLENDFUNCTION pblend, Int32 dwFlags); + + [DllImport("gdi32.dll", ExactSpelling = true, SetLastError = true)] + public static extern IntPtr CreateCompatibleDC(IntPtr hDC); + + [DllImport("user32.dll", ExactSpelling = true, SetLastError = true)] + public static extern IntPtr GetDC(IntPtr hWnd); + + [DllImport("user32.dll", ExactSpelling = true)] + public static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC); + + [DllImport("gdi32.dll", ExactSpelling = true, SetLastError = true)] + public static extern Bool DeleteDC(IntPtr hdc); + + [DllImport("gdi32.dll", ExactSpelling = true)] + public static extern IntPtr SelectObject(IntPtr hDC, IntPtr hObject); + + [DllImport("gdi32.dll", ExactSpelling = true, SetLastError = true)] + public static extern Bool DeleteObject(IntPtr hObject); + } +} diff --git a/Overlay/TextOverlay.resx b/Overlay/TextOverlay.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Overlay/TextOverlay.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SRLTracer/Form1.cs b/SRLTracer/Form1.cs index 40735d7..96ccccf 100644 --- a/SRLTracer/Form1.cs +++ b/SRLTracer/Form1.cs @@ -9,7 +9,7 @@ public Main() { } private void button1_Click(object sender, EventArgs e) { -#if AppVeyor +#if !AppVeyor TBInput.Text = SRLUnity.Wrapper.Process(TBInput.Text); #endif } @@ -23,7 +23,7 @@ private void button2_Click(object sender, EventArgs e) { if (ofd.ShowDialog() != DialogResult.OK) return; -#if AppVeyor +#if !AppVeyor Wrapper Wrapper = new Wrapper(); for (int i = 0; i < ofd.FileNames.Length; i++) { string Script = ofd.FileNames[i];