Esempio n. 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;
        }
Esempio n. 2
0
 private void RunLocalButton_Click(object sender, RoutedEventArgs e)
 {
     SelectedDeviceItem = new MainWindow.DeviceItem
     {
         DeviceAddress = "__LOCAL__",
         DeviceType    = MainWindow.DeviceTypes.Local,
         DeviceName    = "Local"
     };
     DialogResult = true;
     Close();
 }
Esempio n. 3
0
        public ConnectWindow()
        {
            InitializeComponent();

            _udpDiscoveryClient = new UdpDiscoveryClient(
                ready => { },
                (name, address) => Dispatcher.Invoke((Action)(() =>
            {
                if (address.Contains(":?/"))     // Android emulator, so use forwarded ports
                {
                    // todo: use telnet to discover already set up port forwards, instead of hardcoding
                    address = address.Replace(":?/", String.Format(":{0}/", HttpForwardedHostPort));
                }
                var deviceItem = new MainWindow.DeviceItem
                {
                    DeviceAddress = address,
                    DeviceName = name,
                    DeviceType =
                        name.StartsWith("ProtoPad Service on ANDROID Device ")
                                ? MainWindow.DeviceTypes.Android
                                : MainWindow.DeviceTypes.iOS
                };
                if (!DevicesList.Items.Cast <object>().Any(i => (i as MainWindow.DeviceItem).DeviceAddress == deviceItem.DeviceAddress))
                {
                    DevicesList.Items.Add(deviceItem);
                }
                DevicesList.IsEnabled = true;
                //LogToResultsWindow("Found '{0}' on {1}", name, address);
            })));

            _dispatcherTimer       = new System.Windows.Threading.DispatcherTimer();
            _dispatcherTimer.Tick += (s, a) =>
            {
                if (_ticksPassed > 2)
                {
                    _dispatcherTimer.Stop();
                    if (DevicesList.Items.Count == 1)
                    {
                        DevicesList.SelectedIndex = 0;
                    }
                }
                _udpDiscoveryClient.SendServerPing();
                _ticksPassed++;
            };
            _dispatcherTimer.Interval = TimeSpan.FromMilliseconds(200);

            FindApps();
        }
Esempio n. 4
0
        public ConnectWindow()
        {
            InitializeComponent();

            _udpDiscoveryClient = new UdpDiscoveryClient(
                ready => { },
                (name, address) => Dispatcher.Invoke((Action)(() =>
                {
                    if (address.Contains(":?/")) // Android emulator, so use forwarded ports
                    {
                        // todo: use telnet to discover already set up port forwards, instead of hardcoding
                        address = address.Replace(":?/", String.Format(":{0}/", HttpForwardedHostPort));
                    }
                    var deviceItem = new MainWindow.DeviceItem
                    {
                        DeviceAddress = address,
                        DeviceName = name,
                        DeviceType =
                            name.StartsWith("ProtoPad Service on ANDROID Device ")
                                ? MainWindow.DeviceTypes.Android
                                : MainWindow.DeviceTypes.iOS
                    };
                    if (!DevicesList.Items.Cast<object>().Any(i => (i as MainWindow.DeviceItem).DeviceAddress == deviceItem.DeviceAddress))
                    {
                        DevicesList.Items.Add(deviceItem);
                    }
                    DevicesList.IsEnabled = true;
                    //LogToResultsWindow("Found '{0}' on {1}", name, address);
                })));

            _dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
            _dispatcherTimer.Tick += (s, a) =>
            {
                if (_ticksPassed > 2)
                {
                    _dispatcherTimer.Stop();
                    if (DevicesList.Items.Count == 1) DevicesList.SelectedIndex = 0;
                }
                _udpDiscoveryClient.SendServerPing();
                _ticksPassed++;
            };
            _dispatcherTimer.Interval = TimeSpan.FromMilliseconds(200);

            FindApps();
        }
Esempio n. 5
0
 private void ConnectButton_Click(object sender, RoutedEventArgs e)
 {
     SelectedDeviceItem = DevicesList.SelectedItem as MainWindow.DeviceItem;
     DialogResult       = true;
     Close();
 }
Esempio n. 6
0
 private void RunLocalButton_Click(object sender, RoutedEventArgs e)
 {
     SelectedDeviceItem = new MainWindow.DeviceItem
     {
         DeviceAddress = "__LOCAL__",
         DeviceType = MainWindow.DeviceTypes.Local,
         DeviceName = "Local"
     };
     DialogResult = true;
     Close();
 }
Esempio n. 7
0
 private void ConnectButton_Click(object sender, RoutedEventArgs e)
 {
     SelectedDeviceItem = DevicesList.SelectedItem as MainWindow.DeviceItem;
     DialogResult = true;
     Close();
 }
Esempio n. 8
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;
 }