Пример #1
0
        private void CurrentMisty_Connected(Misty misty)
        {
            ConnectionState.Fill  = new SolidColorBrush(Colors.Green);
            ConnectButton.Content = "Disconnect";

            Debug.WriteLine("Misty Serial Number - " + currentMisty.SerialNumber);
        }
Пример #2
0
        private async Task ConnectToMisty(string ip)
        {
            currentMisty               = new Misty();
            currentMisty.Connected    += CurrentMisty_Connected;
            currentMisty.Disconnected += CurrentMisty_Disconnected;

            Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
            localSettings.Values[kIPKey] = ip;

            await currentMisty.ConnectAsync(ip, kWebSocketPort);
        }
Пример #3
0
 private async void ConnectButton_Click(object sender, RoutedEventArgs e)
 {
     if (currentMisty != null && currentMisty.IsConnected)
     {
         currentMisty.disconnect();
         currentMisty = null;
     }
     else
     {
         if (!String.IsNullOrEmpty(ManualIPEntry.Text))
         {
             await ConnectToMisty(ManualIPEntry.Text);
         }
         else if (SelectedIndex > -1)
         {
             var instance = mistyFinder.MistyInstances[SelectedIndex];
             await ConnectToMisty(instance.IpAddress);
         }
         else
         {
             await new MessageDialog("Please Enter a connection string - either IP Address or Name", "Cannot connect").ShowAsync();
         }
     }
 }
Пример #4
0
 private void CurrentMisty_Disconnected(Misty misty)
 {
     ConnectionState.Fill  = new SolidColorBrush(Colors.Red);
     currentMisty          = null;
     ConnectButton.Content = "Connect";
 }