private void RunOverlay() { Thread thread = new Thread(() => { Rectangle canvas = new Rectangle(); foreach (var screen in Screen.AllScreens) { canvas.Right += screen.Bounds.Width; canvas.Bottom += screen.Bounds.Height; canvas.Left = Math.Min(screen.Bounds.Left, canvas.Left); canvas.Top = Math.Min(screen.Bounds.Top, canvas.Top); } form = new WatermaskForm(canvas); form.Setup(loadedConfig); form.Run(); }); thread.IsBackground = true; thread.Start(); }
static private void ReceiveConfig() { Thread thread = new Thread(() => { UdpClient udp = new UdpClient(new IPEndPoint(IPAddress.Any, 12345)); IPEndPoint anyEndpoint = new IPEndPoint(IPAddress.Any, 0); while (true) { byte[] anyBuf = udp.Receive(ref anyEndpoint); string recvMsg = Encoding.Default.GetString(anyBuf); if (!string.IsNullOrEmpty(recvMsg)) { if (recvMsg.StartsWith("password:"******"secure", "password", recvMsg.Replace("password:"******""), Path.Combine(Application.StartupPath, "config.ini")); } else { Config recvConfig = JsonConvert.DeserializeObject <Config>(recvMsg); if (recvConfig != null && recvConfig != new Config()) { File.WriteAllText(jsonFile, recvMsg); form.Dispose(); form = null; Application.Exit(); Process.Start(Application.ExecutablePath); } } } } }); thread.IsBackground = true; thread.Start(); }