Example #1
0
        private void ConnectToApp(DeviceItem deviceItem)
        {
            _currentDevice = deviceItem;

            var isLocal = _currentDevice.DeviceType == DeviceTypes.Local;

            ClearSimulatorWindowButton.IsEnabled = !isLocal;

            if (isLocal)
            {
                LogToResultsWindow("Running locally (regular .Net)");
            }
            else
            {
                _currentDevice.MainXamarinAssemblyName = SimpleHttpServer.SendCustomCommand(_currentDevice.DeviceAddress, "GetMainXamarinAssembly");
                if (_currentDevice.DeviceType == DeviceTypes.iOS)
                {
                    var cssFilesJson = SimpleHttpServer.SendCustomCommand(_currentDevice.DeviceAddress, "GetPixateCssFiles");
                    _currentDevice.PixateCssPaths = UtilityMethods.JsonDecode <string[]>(cssFilesJson);
                }
                LogToResultsWindow("Connected to device '{0}' on [{1}]", _currentDevice.DeviceName, _currentDevice.DeviceAddress);
            }

            UpdateCodeTypesComboBox();

            Title = String.Format("ProtoPad - {0}", _currentDevice.DeviceName);

            SetText(true);

            SendCodeButton.IsEnabled     = true;
            LoadAssemblyButton.IsEnabled = true;

            StatusLabel.Content = "";

            if (_currentDevice.DeviceType != DeviceTypes.iOS)
            {
                return; // todo: locate and provide Android Emulator file path if applicable
            }

            var wrapText      = EditorHelpers.GetWrapText(CodeTypes.Expression, _currentDevice.DeviceType, null);
            var getFolderCode = wrapText.Replace("__STATEMENTSHERE__", "Environment.GetFolderPath(Environment.SpecialFolder.Personal)");
            var result        = SendCode(_currentDevice.DeviceAddress, false, getFolderCode);

            if (result == null || result.Results == null)
            {
                return;
            }
            var folder = result.Results.FirstOrDefault();

            if (folder == null)
            {
                return;
            }
            StatusLabel.Content = folder.ResultValue.PrimitiveValue.ToString();
        }
        private static MainWindow.DeviceTypes?QuickConnect(string endpoint)
        {
            var appIdentifier = SimpleHttpServer.SendCustomCommand(endpoint, "WhoAreYou");

            if (String.IsNullOrWhiteSpace(appIdentifier))
            {
                return(null);
            }
            if (appIdentifier.Contains("Android"))
            {
                return(MainWindow.DeviceTypes.Android);
            }
            if (appIdentifier.Contains("iOS"))
            {
                return(MainWindow.DeviceTypes.iOS);
            }
            return(null);
        }