コード例 #1
0
        void ClientStatusChanged(LoRConnector sender, StateChangedEventArgs e)
        {
            Dispatcher.Invoke(() =>
            {
                lblGameConnectionStatus.Content = "Client: " + e.NextState.ToString();

                switch (e.NextState)
                {
                case ClientConnectionStatus.CONNECTED:
                    lblGameConnectionStatus.Foreground = new SolidColorBrush(Colors.Green);
                    break;

                case ClientConnectionStatus.CONNECTING:
                    lblGameConnectionStatus.Foreground = new SolidColorBrush(Colors.DarkOrange);
                    break;

                case ClientConnectionStatus.DISCONNECTED:
                    lblGameConnectionStatus.Foreground = new SolidColorBrush(Colors.Red);
                    break;

                case ClientConnectionStatus.UNKNOWN:
                    lblGameConnectionStatus.Foreground = new SolidColorBrush(Colors.Black);
                    break;
                }
            });
        }
コード例 #2
0
        public MainWindow()
        {
            InitializeComponent();

            ClientConnector = new LoRConnector(21337);
            ClientConnector.StateChanged += ClientStatusChanged;

            ClientConnector.Connect();
        }