using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading; using System.Threading.Tasks; namespace WMS.EnumDefine { public class basicData { [DllImport("user32.dll", EntryPoint = "GetDesktopWindow", CharSet = CharSet.Auto, SetLastError = true)] static extern IntPtr GetDesktopWindow(); /// 文字提示 /// /// /// 文字内容 public static void no( string text) { Thread pen = new Thread(new ParameterizedThreadStart(GraphicsText)); pen.Start(text); Thread.Sleep(2000); pen.Abort(); } public static void GraphicsText(object text) { IntPtr hct = GetDesktopWindow(); Graphics g = Graphics.FromHwnd(hct); // Random ra = new Random(); for (int i = 0; i < 5; i++) { Thread.Sleep(500); int A = 20; int B = 20; Font drawFont = new Font("Arial", 30); SolidBrush drawBrush = new SolidBrush(Color.FromArgb(254, 240, 240)); SolidBrush drawtext = new SolidBrush(Color.FromArgb(245, 108, 108)); Rectangle rect = new Rectangle(A, B, 220, 50); g.FillRectangle(drawBrush, rect); g.DrawString((string)text, drawFont, drawtext, A + 10, B + 5); } g.Dispose(); } } }