Beispiel #1
0
        /// <summary>
        /// Start the application
        /// </summary>
        /// <param name="udpSender">The remote program</param>
        /// <param name="pointListener">Receiver</param>
        public WhiteBoard(UdpSender udpSender, PointListener pointListener)
        {
            InitializeComponent();
            _graphics = canvas.CreateGraphics();
            _pen      = new Pen(Color.Black);
            _previousMousePosition = new Point();
            _udpSender             = udpSender;

            pointListener.SetCallback(DrawLine);
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (args.Length != 3)
            {
                return;
            }

            if (!int.TryParse(args[0], out var remotePort) || remotePort > 65535)
            {
                Console.WriteLine("Invalid port!");
                return;
            }

            if (!IPAddress.TryParse(args[1], out var ipAddress))
            {
                Console.WriteLine("Invalid IP!");
                return;
            }

            if (!int.TryParse(args[2], out var port) || port > 65535)
            {
                Console.WriteLine("Invalid port!");
                return;
            }

            using (var pointSender = new UdpSender())
                using (var pointListener = new PointListener())
                {
                    pointSender.Connect(ipAddress, remotePort);
                    pointListener.StartListen(port: port);
                    Application.Run(new WhiteBoard(pointSender, pointListener));
                }
        }