示例#1
0
        private void UpdateActuatorFunctionList()
        {
            int    selectedFunction = _instanceData.SelectedFunction;
            int    selection        = 0;
            string language         = ActivityCommon.GetCurrentLanguage();

            CreateActuatorJobList();

            _spinnerBmwActuatorFunctionAdapter.Items.Clear();

            int index = 0;

            foreach (XmlToolEcuActivity.JobInfo jobInfo in _jobActuatorList)
            {
                string displayText = jobInfo.EcuFixedFuncStruct.Title?.GetTitle(language);
                _spinnerBmwActuatorFunctionAdapter.Items.Add(new StringObjType(displayText, index));

                if (index == selectedFunction)
                {
                    selection = index;
                }

                index++;
            }

            _spinnerBmwActuatorFunctionAdapter.NotifyDataSetChanged();
            _spinnerBmwActuatorFunction.SetSelection(selection);

            UpdateActuator();
        }
示例#2
0
        private void UpdateCodingSubsystemList()
        {
            int selection = _instanceData.SelectedSubsystem;

            _spinnerVagCodingSubsystemAdapter.Items.Clear();
            if (_ecuInfo.VagCodingShort != null || _ecuInfo.VagCodingLong != null)
            {
                int           index = 0;
                StringBuilder sb    = new StringBuilder();
                sb.Append(string.Format("{0}: ", index));
                bool append = false;
                if (!string.IsNullOrEmpty(_ecuInfo.VagPartNumber))
                {
                    sb.Append(_ecuInfo.VagPartNumber);
                    append = true;
                }
                if (!string.IsNullOrEmpty(_ecuInfo.VagSysName))
                {
                    if (append)
                    {
                        sb.Append(" / ");
                    }
                    sb.Append(_ecuInfo.VagSysName);
                }
                _spinnerVagCodingSubsystemAdapter.Items.Add(new StringObjType(sb.ToString(), index));
            }

            if (_ecuInfo.SubSystems != null)
            {
                foreach (XmlToolActivity.EcuInfoSubSys subSystem in _ecuInfo.SubSystems)
                {
                    if (subSystem.VagCodingLong != null)
                    {
                        int           index = subSystem.SubSysIndex + 1;
                        StringBuilder sb    = new StringBuilder();
                        sb.Append(string.Format("{0}: ", index));
                        bool append = false;
                        if (!string.IsNullOrEmpty(subSystem.VagPartNumber))
                        {
                            sb.Append(subSystem.VagPartNumber);
                            append = true;
                        }
                        if (!string.IsNullOrEmpty(subSystem.Name))
                        {
                            if (append)
                            {
                                sb.Append(" / ");
                            }
                            sb.Append(subSystem.Name);
                        }
                        _spinnerVagCodingSubsystemAdapter.Items.Add(new StringObjType(sb.ToString(), index));
                    }
                }
            }
            _spinnerVagCodingSubsystemAdapter.NotifyDataSetChanged();

            _spinnerVagCodingSubsystem.SetSelection(selection);
            UpdateCoding();
        }
示例#3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SupportActionBar.SetHomeButtonEnabled(true);
            SupportActionBar.SetDisplayShowHomeEnabled(true);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetDisplayShowCustomEnabled(true);
            SetContentView(Resource.Layout.can_adapter_config);

            _imm         = (InputMethodManager)GetSystemService(InputMethodService);
            _contentView = FindViewById <View>(Android.Resource.Id.Content);

            _barView = LayoutInflater.Inflate(Resource.Layout.bar_can_adapter, null);
            ActionBar.LayoutParams barLayoutParams = new ActionBar.LayoutParams(
                ViewGroup.LayoutParams.MatchParent,
                ViewGroup.LayoutParams.WrapContent);
            barLayoutParams.Gravity = barLayoutParams.Gravity &
                                      (int)(~(GravityFlags.HorizontalGravityMask | GravityFlags.VerticalGravityMask)) |
                                      (int)(GravityFlags.Left | GravityFlags.CenterVertical);
            SupportActionBar.SetCustomView(_barView, barLayoutParams);

            SetResult(Android.App.Result.Canceled);

            _deviceAddress = Intent.GetStringExtra(ExtraDeviceAddress);
            ActivityCommon.InterfaceType interfaceType = (ActivityCommon.InterfaceType)Intent.GetIntExtra(ExtraInterfaceType,
                                                                                                          (int)ActivityCommon.InterfaceType.Bluetooth);
            ViewStates visibility = interfaceType == ActivityCommon.InterfaceType.Bluetooth ? ViewStates.Visible : ViewStates.Gone;

            _buttonRead = _barView.FindViewById <Button>(Resource.Id.buttonAdapterRead);
            _buttonRead.SetOnTouchListener(this);
            _buttonRead.Click += (sender, args) =>
            {
                PerformRead();
            };
            _buttonRead.Visibility = visibility;

            _buttonWrite = _barView.FindViewById <Button>(Resource.Id.buttonAdapterWrite);
            _buttonWrite.SetOnTouchListener(this);
            _buttonWrite.Click += (sender, args) =>
            {
                PerformWrite();
            };

            _layoutCanAdapter = FindViewById <LinearLayout>(Resource.Id.layoutCanAdapter);
            _layoutCanAdapter.SetOnTouchListener(this);

            _spinnerCanAdapterMode = FindViewById <Spinner>(Resource.Id.spinnerCanAdapterMode);
            _spinnerCanAdapterMode.SetOnTouchListener(this);
            _spinnerCanAdapterModeAdapter  = new StringObjAdapter(this);
            _spinnerCanAdapterMode.Adapter = _spinnerCanAdapterModeAdapter;
            _spinnerCanAdapterModeAdapter.Items.Add(new StringObjType(GetString(Resource.String.button_can_adapter_can_500), AdapterMode.Can500));
            _spinnerCanAdapterModeAdapter.Items.Add(new StringObjType(GetString(Resource.String.button_can_adapter_can_100), AdapterMode.Can100));
            _spinnerCanAdapterModeAdapter.Items.Add(new StringObjType(GetString(Resource.String.button_can_adapter_can_off), AdapterMode.CanOff));
            _spinnerCanAdapterModeAdapter.NotifyDataSetChanged();

            _textViewCanAdapterSepTimeTitle            = FindViewById <TextView>(Resource.Id.textViewCanAdapterSepTimeTitle);
            _textViewCanAdapterSepTimeTitle.Visibility = visibility;

            _spinnerCanAdapterSepTime = FindViewById <Spinner>(Resource.Id.spinnerCanAdapterSepTime);
            _spinnerCanAdapterSepTime.SetOnTouchListener(this);
            _spinnerCanAdapterSepTimeAdapter  = new StringAdapter(this);
            _spinnerCanAdapterSepTime.Adapter = _spinnerCanAdapterSepTimeAdapter;
            _spinnerCanAdapterSepTimeAdapter.Items.Add(GetString(Resource.String.can_adapter_text_off));
            for (int i = 1; i <= 2; i++)
            {
                _spinnerCanAdapterSepTimeAdapter.Items.Add(i.ToString());
            }
            _spinnerCanAdapterSepTimeAdapter.NotifyDataSetChanged();
            _spinnerCanAdapterSepTime.Visibility = visibility;

            _textViewCanAdapterBlockSizeTitle            = FindViewById <TextView>(Resource.Id.textViewCanAdapterBlockSizeTitle);
            _textViewCanAdapterBlockSizeTitle.Visibility = visibility;

            _spinnerCanAdapterBlockSize = FindViewById <Spinner>(Resource.Id.spinnerCanAdapterBlockSize);
            _spinnerCanAdapterBlockSize.SetOnTouchListener(this);
            _spinnerCanAdapterBlockSizeAdapter  = new StringAdapter(this);
            _spinnerCanAdapterBlockSize.Adapter = _spinnerCanAdapterBlockSizeAdapter;
            _spinnerCanAdapterBlockSizeAdapter.Items.Add(GetString(Resource.String.can_adapter_text_off));
            for (int i = 0; i <= 15; i++)
            {
                _spinnerCanAdapterBlockSizeAdapter.Items.Add(i.ToString());
            }
            _spinnerCanAdapterBlockSizeAdapter.NotifyDataSetChanged();
            _spinnerCanAdapterBlockSize.Visibility = visibility;

            _textViewBtPinTitle            = FindViewById <TextView>(Resource.Id.textViewCanAdapterBtPinTitle);
            _textViewBtPinTitle.Visibility = visibility;

            _editTextBtPin            = FindViewById <EditText>(Resource.Id.editTextBtPin);
            _editTextBtPin.Visibility = visibility;

            _textViewBtNameTitle            = FindViewById <TextView>(Resource.Id.textViewCanAdapterBtNameTitle);
            _textViewBtNameTitle.Visibility = visibility;

            _editTextBtName            = FindViewById <EditText>(Resource.Id.editTextBtName);
            _editTextBtName.Visibility = visibility;

            _textViewCanAdapterIgnitionStateTitle            = FindViewById <TextView>(Resource.Id.textViewCanAdapterIgnitionStateTitle);
            _textViewCanAdapterIgnitionStateTitle.Visibility = visibility;

            _textViewIgnitionState            = FindViewById <TextView>(Resource.Id.textViewCanAdapterIgnitionState);
            _textViewIgnitionState.Visibility = visibility;

            _textViewBatteryVoltageTitle            = FindViewById <TextView>(Resource.Id.textViewCanAdapterBatVoltageTitle);
            _textViewBatteryVoltageTitle.Visibility = visibility;

            _textViewBatteryVoltage            = FindViewById <TextView>(Resource.Id.textViewCanAdapterBatVoltage);
            _textViewBatteryVoltage.Visibility = visibility;

            _textViewFwVersionTitle            = FindViewById <TextView>(Resource.Id.textViewCanAdapterFwVersionTitle);
            _textViewFwVersionTitle.Visibility = visibility;

            _textViewFwVersion            = FindViewById <TextView>(Resource.Id.textViewCanAdapterFwVersion);
            _textViewFwVersion.Visibility = visibility;

            _textViewSerNumTitle = FindViewById <TextView>(Resource.Id.textViewCanAdapterSerNumTitle);
            _textViewSerNum      = FindViewById <TextView>(Resource.Id.textViewCanAdapterSerNum);
#if DEBUG
            _textViewSerNumTitle.Visibility = visibility;
            _textViewSerNum.Visibility      = visibility;
#else
            _textViewSerNumTitle.Visibility = ViewStates.Gone;
            _textViewSerNum.Visibility      = ViewStates.Gone;
#endif
            _buttonFwUpdate            = FindViewById <Button>(Resource.Id.buttonCanAdapterFwUpdate);
            _buttonFwUpdate.Visibility = visibility;
            _buttonFwUpdate.Click     += (sender, args) =>
            {
                PerformUpdateMessage();
            };
            _checkBoxExpert            = FindViewById <CheckBox>(Resource.Id.checkBoxCanAdapterExpert);
            _checkBoxExpert.Visibility = visibility;
            _checkBoxExpert.Click     += (sender, args) =>
            {
                UpdateDisplay();
            };

            _activityCommon = new ActivityCommon(this)
            {
                SelectedInterface = interfaceType
            };

            UpdateDisplay();
            PerformRead();
        }
示例#4
0
        private void UpdateDisplay()
        {
            bool requestFwUpdate = false;
            bool bEnabled        = !IsJobRunning();
            bool fwUpdateEnabled = bEnabled;
            bool expertMode      = _checkBoxExpert.Checked;

            _buttonRead.Enabled    = bEnabled;
            _buttonWrite.Enabled   = bEnabled;
            _editTextBtPin.Enabled = bEnabled && _btPin != null && _btPin.Length >= 4;
            int maxPinLength = (_btPin != null && _btPin.Length > 0) ? _btPin.Length : 4;

            _editTextBtPin.SetFilters(new Android.Text.IInputFilter[] { new Android.Text.InputFilterLengthFilter(maxPinLength) });
            if (!_editTextBtPin.Enabled)
            {
                _editTextBtPin.Text = string.Empty;
            }
            _editTextBtName.Enabled = bEnabled && _btName != null && _btName.Length > 0;
            int maxTextLength = (_btName != null && _btName.Length > 0) ? _btName.Length : 16;

            _editTextBtName.SetFilters(new Android.Text.IInputFilter[] { new Android.Text.InputFilterLengthFilter(maxTextLength) });
            if (!_editTextBtName.Enabled)
            {
                _editTextBtName.Text = string.Empty;
            }

            _textViewSerNum.Enabled = bEnabled;

            if (bEnabled)
            {
                if ((_separationTime < 0) || (_separationTime >= _spinnerCanAdapterSepTimeAdapter.Items.Count))
                {
                    _spinnerCanAdapterSepTime.SetSelection(0);
                }
                else
                {
                    _spinnerCanAdapterSepTime.SetSelection(_separationTime);
                    if (_separationTime != 0)
                    {
                        expertMode = true;
                    }
                }

                if ((_blockSize < 0) || (_blockSize >= _spinnerCanAdapterBlockSizeAdapter.Items.Count))
                {
                    _spinnerCanAdapterBlockSize.SetSelection(0);
                }
                else
                {
                    _spinnerCanAdapterBlockSize.SetSelection(_blockSize);
                    if (_blockSize != 0)
                    {
                        expertMode = true;
                    }
                }

                // moved down because of expert mode setting
                if (_activityCommon.SelectedInterface == ActivityCommon.InterfaceType.Bluetooth)
                {
                    if (_canMode == (int)AdapterMode.Can100)
                    {
                        expertMode = true;
                    }
                    _spinnerCanAdapterModeAdapter.Items.Clear();
                    if (_adapterType >= 0x0002 && _fwVersion >= 0x0008)
                    {
                        _spinnerCanAdapterModeAdapter.Items.Add(new StringObjType(GetString(Resource.String.button_can_adapter_can_auto), AdapterMode.CanAuto));
                    }
                    _spinnerCanAdapterModeAdapter.Items.Add(new StringObjType(GetString(Resource.String.button_can_adapter_can_500), AdapterMode.Can500));
                    if (expertMode)
                    {
                        _spinnerCanAdapterModeAdapter.Items.Add(new StringObjType(GetString(Resource.String.button_can_adapter_can_100), AdapterMode.Can100));
                    }
                    _spinnerCanAdapterModeAdapter.Items.Add(new StringObjType(GetString(Resource.String.button_can_adapter_can_off), AdapterMode.CanOff));
                    _spinnerCanAdapterModeAdapter.NotifyDataSetChanged();

                    int indexMode = 0;
                    for (int i = 0; i < _spinnerCanAdapterModeAdapter.Count; i++)
                    {
                        if ((int)_spinnerCanAdapterModeAdapter.Items[i].Data == _canMode)
                        {
                            indexMode = i;
                        }
                    }
                    _spinnerCanAdapterMode.SetSelection(indexMode);
                }

                if (_editTextBtPin.Enabled && _btPin != null)
                {
                    string btPin = PinDataToString(_btPin);
                    _editTextBtPin.Text = btPin.Length >= 4 ? btPin : "1234";
                }

                if (_editTextBtName.Enabled && _btName != null)
                {
                    try
                    {
                        int length = _btName.TakeWhile(value => value != 0x00).Count();
                        _editTextBtName.Text = Encoding.UTF8.GetString(_btName, 0, length);
                    }
                    catch (Exception)
                    {
                        _editTextBtName.Text = string.Empty;
                    }
                }

                string ignitionText = string.Empty;
                if (_ignitionState >= 0)
                {
                    ignitionText = (_ignitionState & 0x01) != 0x00 ? GetString(Resource.String.can_adapter_ignition_on) : GetString(Resource.String.can_adapter_ignition_off);
                    if ((_ignitionState & 0x80) != 0)
                    {
                        ignitionText = "(" + ignitionText + ")";
                    }
                }
                _textViewIgnitionState.Text = ignitionText;

                string voltageText = string.Empty;
                if (_adapterType > 1 && _batteryVoltage >= 0)
                {
                    voltageText = string.Format(ActivityMain.Culture, "{0,4:0.0}V", (double)_batteryVoltage / 10);
                }
                _textViewBatteryVoltage.Text = voltageText;

                string versionText = string.Empty;
                if (_adapterType >= 0 && _fwVersion >= 0)
                {
                    versionText = string.Format(ActivityMain.Culture, "{0}.{1} / ", (_fwVersion >> 8) & 0xFF, _fwVersion & 0xFF);
                    int fwUpdateVersion = PicBootloader.GetFirmwareVersion((uint)_adapterType);
                    if (fwUpdateVersion >= 0)
                    {
                        if (!_fwUpdateShown && _fwVersion < fwUpdateVersion)
                        {
                            requestFwUpdate = true;
                        }
                        versionText += string.Format(ActivityMain.Culture, "{0}.{1}", (fwUpdateVersion >> 8) & 0xFF, fwUpdateVersion & 0xFF);
                    }
                    else
                    {
                        versionText += "--";
                    }
                    fwUpdateEnabled = fwUpdateVersion >= 0 && ((_fwVersion != fwUpdateVersion) || ActivityCommon.CollectDebugInfo);
                }
                _textViewFwVersion.Text = versionText;

                if (_textViewSerNum.Enabled)
                {
                    _textViewSerNum.Text = (_serNum == null) ? string.Empty : BitConverter.ToString(_serNum).Replace("-", "");
                }
            }
            _buttonFwUpdate.Enabled             = fwUpdateEnabled;
            _spinnerCanAdapterMode.Enabled      = bEnabled;
            _spinnerCanAdapterSepTime.Enabled   = bEnabled && expertMode;
            _spinnerCanAdapterBlockSize.Enabled = bEnabled && expertMode;
            _checkBoxExpert.Enabled             = bEnabled;
            _checkBoxExpert.Checked             = expertMode;
            if (requestFwUpdate)
            {
                _fwUpdateShown = true;
                new AlertDialog.Builder(this)
                .SetPositiveButton(Resource.String.button_yes, (sender, args) =>
                {
                    PerformUpdateMessage();
                })
                .SetNegativeButton(Resource.String.button_no, (sender, args) =>
                {
                })
                .SetCancelable(true)
                .SetMessage(Resource.String.can_adapter_fw_update_present)
                .SetTitle(Resource.String.alert_title_question)
                .Show();
            }

            HideKeyboard();
        }
示例#5
0
        private void UpdateArgParams(List <string> selectParams = null)
        {
            try
            {
                _layoutArgParams.RemoveAllViews();
                _parameterList.Clear();
                Android.Content.Res.ColorStateList captionTextColors = _textViewArgTypeTitle.TextColors;
                Drawable captionTextBackground = _textViewArgTypeTitle.Background;
                int      position = _spinnerArgument.SelectedItemPosition;
                if (position >= 0 && position < _spinnerArgumentAdapter.ItemsVisible.Count)
                {
                    EdiabasToolActivity.ExtraInfo item = _spinnerArgumentAdapter.ItemsVisible[position];
                    if (item.Tag is EdiabasToolActivity.SgFuncInfo funcInfo)
                    {
                        if (funcInfo.ArgInfoList != null)
                        {
                            foreach (EdiabasToolActivity.SgFuncArgInfo funcArgInfo in funcInfo.ArgInfoList)
                            {
                                string selectParam = string.Empty;
                                if (selectParams != null && selectParams.Count > _parameterList.Count)
                                {
                                    selectParam = selectParams[_parameterList.Count];
                                }

                                LinearLayout argLayout = new LinearLayout(this);
                                argLayout.Orientation = Orientation.Vertical;

                                LinearLayout.LayoutParams wrapLayoutParams = new LinearLayout.LayoutParams(
                                    ViewGroup.LayoutParams.MatchParent,
                                    ViewGroup.LayoutParams.WrapContent);

                                TextView textViewCaption = new TextView(this);
                                textViewCaption.SetOnTouchListener(this);
                                textViewCaption.SetTextColor(captionTextColors);
                                textViewCaption.Background = captionTextBackground;

                                StringBuilder sbCaption = new StringBuilder();
                                sbCaption.Append(GetString(Resource.String.arg_assist_control_parameter));
                                sbCaption.Append(": ");
                                sbCaption.Append(funcArgInfo.Arg);
                                textViewCaption.Text = sbCaption.ToString();
                                argLayout.AddView(textViewCaption, wrapLayoutParams);

                                TextView      textViewDesc = null;
                                StringBuilder sbDesc       = new StringBuilder();
                                string        info         = funcArgInfo.InfoTrans ?? funcArgInfo.Info;
                                if (!string.IsNullOrEmpty(info))
                                {
                                    sbDesc.Append(info);
                                }

                                if (!string.IsNullOrEmpty(funcArgInfo.DataType))
                                {
                                    if (sbDesc.Length > 0)
                                    {
                                        sbDesc.Append("\r\n");
                                    }
                                    sbDesc.Append("Data type: ");
                                    sbDesc.Append(funcArgInfo.DataType);
                                }

                                if (!string.IsNullOrEmpty(funcArgInfo.Unit))
                                {
                                    if (sbDesc.Length > 0)
                                    {
                                        sbDesc.Append("\r\n");
                                    }
                                    sbDesc.Append("Unit: ");
                                    sbDesc.Append(funcArgInfo.Unit);
                                }


                                if (funcArgInfo.TableDataType == EdiabasToolActivity.TableDataType.Float)
                                {
                                    string minText = funcArgInfo.MinText;
                                    if (string.IsNullOrEmpty(minText))
                                    {
                                        if (funcArgInfo.Min.HasValue)
                                        {
                                            minText = string.Format(CultureInfo.InvariantCulture, "{0:0.0}", funcArgInfo.Min.Value);
                                        }
                                    }
                                    if (!string.IsNullOrEmpty(minText))
                                    {
                                        if (sbDesc.Length > 0)
                                        {
                                            sbDesc.Append("\r\n");
                                        }
                                        sbDesc.Append("Min: ");
                                        sbDesc.Append(minText);
                                    }

                                    string maxText = funcArgInfo.MaxText;
                                    if (string.IsNullOrEmpty(maxText))
                                    {
                                        if (funcArgInfo.Max.HasValue)
                                        {
                                            maxText = string.Format(CultureInfo.InvariantCulture, "{0:0.0}", funcArgInfo.Max.Value);
                                        }
                                    }
                                    if (!string.IsNullOrEmpty(maxText))
                                    {
                                        if (sbDesc.Length > 0)
                                        {
                                            sbDesc.Append("\r\n");
                                        }
                                        sbDesc.Append("Max: ");
                                        sbDesc.Append(maxText);
                                    }
                                }

                                if (sbDesc.Length > 0)
                                {
                                    textViewDesc = new TextView(this);
                                    textViewDesc.SetOnTouchListener(this);
                                    textViewDesc.Text = sbDesc.ToString();
                                    argLayout.AddView(textViewDesc, wrapLayoutParams);
                                }

                                Drawable      defaultBackground = null;
                                List <object> itemList          = new List <object>();
                                if (funcArgInfo.NameInfoList != null && funcArgInfo.NameInfoList.Count > 0)
                                {
                                    if (funcArgInfo.NameInfoList[0] is EdiabasToolActivity.SgFuncValNameInfo)
                                    {
                                        Spinner spinner = new Spinner(this);
                                        spinner.SetOnTouchListener(this);
                                        defaultBackground = spinner.Background;
                                        StringObjAdapter spinnerAdapter = new StringObjAdapter(this);
                                        spinnerAdapter.Items.Add(new StringObjType("--", null, Android.Graphics.Color.Red));
                                        int selection = 0;
                                        int index     = 1;
                                        foreach (EdiabasToolActivity.SgFuncNameInfo funcNameInfo in funcArgInfo.NameInfoList)
                                        {
                                            if (funcNameInfo is EdiabasToolActivity.SgFuncValNameInfo valNameInfo)
                                            {
                                                spinner.Adapter = spinnerAdapter;
                                                StringBuilder sbName = new StringBuilder();
                                                sbName.Append(valNameInfo.Value);
                                                sbName.Append(": ");
                                                sbName.Append(valNameInfo.Text);
                                                spinnerAdapter.Items.Add(new StringObjType(sbName.ToString(), valNameInfo));
                                                if (string.Compare(valNameInfo.Text, selectParam, StringComparison.OrdinalIgnoreCase) == 0)
                                                {
                                                    selection = index;
                                                }
                                            }

                                            index++;
                                        }

                                        spinnerAdapter.NotifyDataSetChanged();
                                        spinner.SetSelection(selection);
                                        spinner.ItemSelected += (sender, args) =>
                                        {
                                            ValidateParams();
                                        };
                                        argLayout.AddView(spinner, wrapLayoutParams);
                                        itemList.Add(spinner);
                                    }
                                }
                                else
                                {
                                    EditText editText = new EditText(this);
                                    defaultBackground = editText.Background;
                                    editText.SetSingleLine();
                                    editText.ImeOptions = ImeAction.Done;
                                    editText.Text       = selectParam;

                                    editText.TextChanged += (sender, args) =>
                                    {
                                        ValidateParams();
                                    };

                                    editText.EditorAction += (sender, args) =>
                                    {
                                        switch (args.ActionId)
                                        {
                                        case ImeAction.Go:
                                        case ImeAction.Send:
                                        case ImeAction.Next:
                                        case ImeAction.Done:
                                        case ImeAction.Previous:
                                            ValidateParams();
                                            HideKeyboard();
                                            break;
                                        }
                                    };

                                    argLayout.AddView(editText, wrapLayoutParams);
                                    itemList.Add(editText);
                                }

                                _layoutArgParams.AddView(argLayout, wrapLayoutParams);

                                _parameterList.Add(new ParameterData(funcArgInfo, textViewCaption, textViewDesc, defaultBackground, itemList));
                            }
                        }
                    }
                }

                ValidateParams();
            }
            catch (Exception)
            {
                // ignored
            }
        }
        private void UpdateDisplay()
        {
            if (_activityCommon == null)
            {
                return;
            }

            try
            {
                _ignoreCheckChange = true;

                List <string> selectList     = null;
                string        blockNumber    = string.Empty;
                string        defineBlockNew = string.Empty;
                string        argType        = string.Empty;
                if (!string.IsNullOrEmpty(_instanceData.Arguments))
                {
                    string[] argArray = _instanceData.Arguments.Split(";");
                    if (_mwBlock)
                    {
                        if (argArray.Length > 0)
                        {
                            defineBlockNew = argArray[0].Trim();
                            selectList     = argArray.ToList();
                            selectList.RemoveAt(0);
                        }
                    }
                    else if (_dynamicId)
                    {
                        if (argArray.Length > 2)
                        {
                            blockNumber    = argArray[0].Trim();
                            defineBlockNew = argArray[1].Trim();
                            argType        = argArray[2].Trim();
                            selectList     = argArray.ToList();
                            selectList.RemoveRange(0, 3);
                        }
                    }
                    else
                    {
                        if (argArray.Length > 0)
                        {
                            argType    = argArray[0].Trim();
                            selectList = argArray.ToList();
                            selectList.RemoveAt(0);
                        }
                    }
                }

                switch (argType.ToUpperInvariant())
                {
                case ArgTypeID:
                    _radioButtonArgTypeId.Checked = true;
                    break;

                default:
                    _radioButtonArgTypeArg.Checked = true;
                    break;
                }

                if (_dynamicId)
                {
                    Int64 numberValue = EdiabasNet.StringToValue(blockNumber, out bool valid);
                    if (!valid)
                    {
                        numberValue = 0;
                    }

                    int selection = 0;
                    int index     = 0;
                    for (int i = 0; i < 10; i++)
                    {
                        _spinnerBlockNumberAdapter.Items.Add(new StringObjType(string.Format(CultureInfo.InvariantCulture, "{0}", i), i));
                        if (i == numberValue)
                        {
                            selection = index;
                        }

                        index++;
                    }

                    _spinnerBlockNumberAdapter.NotifyDataSetChanged();
                    _spinnerBlockNumber.SetSelection(selection);
                }

                if (_mwBlock || _dynamicId)
                {
                    bool newBlock = string.IsNullOrEmpty(defineBlockNew) ||
                                    string.Compare(defineBlockNew, "JA", StringComparison.OrdinalIgnoreCase) == 0 ||
                                    string.Compare(defineBlockNew, "YES", StringComparison.OrdinalIgnoreCase) == 0;
                    _checkBoxDefineBlockNew.Checked = newBlock;
                }

                UpdateArgList(selectList);
                UpdateButtonState();
            }
            catch (Exception)
            {
                // ignored
            }
            finally
            {
                _ignoreCheckChange = false;
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SupportActionBar.SetHomeButtonEnabled(true);
            SupportActionBar.SetDisplayShowHomeEnabled(true);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            //SupportActionBar.SetDisplayShowCustomEnabled(true);
            SupportActionBar.Title = string.Format(GetString(Resource.String.xml_tool_ecu_title), Intent.GetStringExtra(ExtraEcuName) ?? string.Empty);
            SetContentView(Resource.Layout.xml_tool_ecu);

            _imm         = (InputMethodManager)GetSystemService(InputMethodService);
            _contentView = FindViewById <View>(Android.Resource.Id.Content);

            SetResult(Android.App.Result.Canceled);

            _activityCommon = new ActivityCommon(this);
            _ecuInfo        = IntentEcuInfo;
            _ediabas        = IntentEdiabas;

            _editTextPageName      = FindViewById <EditText>(Resource.Id.editTextPageName);
            _editTextPageName.Text = _ecuInfo.PageName;

            _editTextEcuName      = FindViewById <EditText>(Resource.Id.editTextEcuName);
            _editTextEcuName.Text = _ecuInfo.EcuName;

            _spinnerJobs         = FindViewById <Spinner>(Resource.Id.spinnerJobs);
            _spinnerJobsAdapter  = new JobListAdapter(this);
            _spinnerJobs.Adapter = _spinnerJobsAdapter;
            _spinnerJobs.SetOnTouchListener(this);
            _spinnerJobs.ItemSelected += (sender, args) =>
            {
                int pos = args.Position;
                JobSelected(pos >= 0 ? _spinnerJobsAdapter.Items[pos] : null);
            };

            _layoutJobConfig = FindViewById <LinearLayout>(Resource.Id.layoutJobConfig);
            _layoutJobConfig.SetOnTouchListener(this);

            _textViewJobCommentsTitle = FindViewById <TextView>(Resource.Id.textViewJobCommentsTitle);
            _textViewJobComments      = FindViewById <TextView>(Resource.Id.textViewJobComments);

            _spinnerJobResults               = FindViewById <Spinner>(Resource.Id.spinnerJobResults);
            _spinnerJobResultsAdapter        = new ResultListAdapter(this);
            _spinnerJobResults.Adapter       = _spinnerJobResultsAdapter;
            _spinnerJobResults.ItemSelected += (sender, args) =>
            {
                ResultSelected(args.Position);
            };

            _textViewResultCommentsTitle = FindViewById <TextView>(Resource.Id.textViewResultCommentsTitle);
            _textViewResultComments      = FindViewById <TextView>(Resource.Id.textViewResultComments);
            _editTextDisplayText         = FindViewById <EditText>(Resource.Id.editTextDisplayText);
            _editTextLogTag = FindViewById <EditText>(Resource.Id.editTextLogTag);

            _textViewFormatDot = FindViewById <TextView>(Resource.Id.textViewFormatDot);
            _editTextFormat    = FindViewById <EditText>(Resource.Id.editTextFormat);

            _spinnerFormatPos         = FindViewById <Spinner>(Resource.Id.spinnerFormatPos);
            _spinnerFormatPosAdapter  = new StringAdapter(this);
            _spinnerFormatPos.Adapter = _spinnerFormatPosAdapter;
            _spinnerFormatPosAdapter.Items.Add(GetString(Resource.String.xml_tool_ecu_format_right));
            _spinnerFormatPosAdapter.Items.Add(GetString(Resource.String.xml_tool_ecu_format_left));
            _spinnerFormatPosAdapter.NotifyDataSetChanged();
            _spinnerFormatPos.ItemSelected += FormatItemSelected;

            _spinnerFormatLength1         = FindViewById <Spinner>(Resource.Id.spinnerFormatLength1);
            _spinnerFormatLength1Adapter  = new StringObjAdapter(this);
            _spinnerFormatLength1.Adapter = _spinnerFormatLength1Adapter;
            _spinnerFormatLength1Adapter.Items.Add(new StringObjType("--", -1));
            foreach (int value in LengthValues)
            {
                _spinnerFormatLength1Adapter.Items.Add(new StringObjType(value.ToString(), value));
            }
            _spinnerFormatLength1Adapter.NotifyDataSetChanged();
            _spinnerFormatLength1.ItemSelected += FormatItemSelected;

            _spinnerFormatLength2         = FindViewById <Spinner>(Resource.Id.spinnerFormatLength2);
            _spinnerFormatLength2Adapter  = new StringObjAdapter(this);
            _spinnerFormatLength2.Adapter = _spinnerFormatLength2Adapter;
            _spinnerFormatLength2Adapter.Items.Add(new StringObjType("--", -1));
            foreach (int value in LengthValues)
            {
                _spinnerFormatLength2Adapter.Items.Add(new StringObjType(value.ToString(), value));
            }
            _spinnerFormatLength2Adapter.NotifyDataSetChanged();
            _spinnerFormatLength2.ItemSelected += FormatItemSelected;

            _spinnerFormatType         = FindViewById <Spinner>(Resource.Id.spinnerFormatType);
            _spinnerFormatTypeAdapter  = new StringObjAdapter(this);
            _spinnerFormatType.Adapter = _spinnerFormatTypeAdapter;
            _spinnerFormatTypeAdapter.Items.Add(new StringObjType("--", FormatType.None));
            _spinnerFormatTypeAdapter.NotifyDataSetChanged();
            _spinnerFormatType.ItemSelected += FormatItemSelected;

            _buttonTestFormat         = FindViewById <Button>(Resource.Id.buttonTestFormat);
            _buttonTestFormat.Enabled = _ediabas != null;
            _buttonTestFormat.Click  += (sender, args) =>
            {
                ExecuteTestFormat();
            };
            _textViewTestFormatOutput = FindViewById <TextView>(Resource.Id.textViewTestFormatOutput);

            _layoutJobConfig.Visibility = ViewStates.Gone;
            UpdateDisplay();
            ResetTestResult();
        }