Пример #1
0
        private void ShowUrl()
        {
            this.ip = "http://" + GetIPUtil.IPV4() + ":" + port;

            this.urlLable.Text = "请扫描二维码或者用浏览器打开:" + ip;
            this.urlLable.Links.Add(15, ip.Length, ip);
            var qrcode = new QrCode(ip, new Vector2Slim(256, 256), SkiaSharp.SKEncodedImageFormat.Png);

            using (MemoryStream stream = new MemoryStream())
            {
                qrcode.GenerateImage(stream);
                stream.Position    = 0;
                imgQRCode.SizeMode = PictureBoxSizeMode.Zoom;
                imgQRCode.Image    = Image.FromStream(stream);
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            if (args.Length < 2)
            {
                Console.WriteLine($"Usage: dotnet {nameof(NanoServerGenerate)}.dll your_message output_path");
                return;
            }
            var content = args[0];
            var path    = args[1];

            // generate qr code
            var qrCode = new QrCode(content, new Vector2Slim(256, 256), SKEncodedImageFormat.Png);

            using (var output = new FileStream(path, FileMode.OpenOrCreate))
            {
                qrCode.GenerateImage(output);
            }

            Console.WriteLine($"Successfully output QRCode in {path}");
        }