예제 #1
0
        public static void StartConnection()
        {
            loginForm.ProgressLine.Visibility      = System.Windows.Visibility.Visible;
            loginForm.ProgressLine.IsIndeterminate = true;
            var MessageQueue = loginForm.SnackbarThree.MessageQueue;

            Task.Factory.StartNew(() =>
            {
                if (Middle.ConnectWithServer())
                {
                    Middle.client.SubScribe(new string [] { "Arduino/#", "Console/#" });
                    loginForm.Dispatcher.Invoke(() =>
                    {
                        home = new GUI.HomeWindow();
                        MQTTEventTrigger.Transfer(home, Middle.client);
                        home.Show();
                        home.Activate();
                        loginForm.Close();
                    });
                }
                else
                {
                    Task.Factory.StartNew(() =>
                    {
                        MessageQueue.Enqueue("未能连接到服务器,请检查服务器地址和端口以及用户名密码是否正确");
                        loginForm.Dispatcher.Invoke(() =>
                        {
                            loginForm.ProgressLine.IsIndeterminate = false;
                            loginForm.ProgressLine.Visibility      = System.Windows.Visibility.Hidden;
                        });
                    });
                }
            });
        }
예제 #2
0
 public static void Transfer(WashingStatusRouter.GUI.HomeWindow home, PubSubClient client)
 {
     MQTTEventTrigger.home = home;
     Client            = client;
     Client.GetReceive = CallBack;
 }