Пример #1
0
        private void AddManualIPButton_Click(object sender, RoutedEventArgs e)
        {
            var promptWindow = new PromptIPAddressWindow();

            if (!promptWindow.ShowDialog().Value)
            {
                return;
            }
            var address    = String.Format("http://{0}:{1}", promptWindow.IPAddressTextBox.Text, promptWindow.PortTextBox.Text);
            var deviceType = QuickConnect(address);

            if (!deviceType.HasValue)
            {
                MessageBox.Show(String.Format("Could not connect to {0}", address));
                return;
            }
            var deviceItem = new MainWindow.DeviceItem
            {
                DeviceAddress = address,
                DeviceName    = String.Format("{0} app on {1}", deviceType, address),
                DeviceType    = deviceType.Value
            };

            if (!DevicesList.Items.Cast <object>().Any(i => (i as MainWindow.DeviceItem).DeviceAddress == deviceItem.DeviceAddress))
            {
                DevicesList.Items.Add(deviceItem);
            }
            DevicesList.IsEnabled = true;
        }
Пример #2
0
 private void AddManualIPButton_Click(object sender, RoutedEventArgs e)
 {
     var promptWindow = new PromptIPAddressWindow();
     if (!promptWindow.ShowDialog().Value) return;
     var address = String.Format("http://{0}:{1}", promptWindow.IPAddressTextBox.Text, promptWindow.PortTextBox.Text);
     var deviceType = QuickConnect(address);
     if (!deviceType.HasValue)
     {
         MessageBox.Show(String.Format("Could not connect to {0}", address));
         return;
     }
     var deviceItem = new MainWindow.DeviceItem
     {
         DeviceAddress = address,
         DeviceName = String.Format("{0} app on {1}", deviceType, address),
         DeviceType = deviceType.Value
     };
     if (!DevicesList.Items.Cast<object>().Any(i => (i as MainWindow.DeviceItem).DeviceAddress == deviceItem.DeviceAddress))
     {
         DevicesList.Items.Add(deviceItem);
     }
     DevicesList.IsEnabled = true;
 }