private void UpdateArgList(string selectArg = null) { try { bool argTypeId = _radioButtonArgTypeId.Checked; int selection = 0; int index = 0; _spinnerArgumentAdapter.Items.Clear(); if (_serviceId >= 0) { foreach (EdiabasToolActivity.SgFuncInfo funcInfo in _sgFuncInfoList.OrderBy(x => argTypeId ? x.Id : x.Arg)) { if (funcInfo.ServiceList.Contains(_serviceId)) { string name = argTypeId ? funcInfo.Id : funcInfo.Arg; string info = funcInfo.InfoTrans ?? funcInfo.Info; EdiabasToolActivity.ExtraInfo extraInfo = new EdiabasToolActivity.ExtraInfo(name, string.Empty, new List <string> { info }) { CheckVisible = false, Tag = funcInfo }; _spinnerArgumentAdapter.Items.Add(extraInfo); if (selectArg != null) { if (string.Compare(name, selectArg, StringComparison.OrdinalIgnoreCase) == 0) { selection = index; } } index++; } } } _spinnerArgumentAdapter.NotifyDataSetChanged(); _argumentSelectLastItem = selection; _spinnerArgument.SetSelection(selection); } catch (Exception) { // ignored } }
private void UpdateArgList(List <string> selectList = null) { try { bool argTypeId = _radioButtonArgTypeId.Checked; _argsListAdapter.Items.Clear(); if (_serviceId >= 0) { foreach (EdiabasToolActivity.SgFuncInfo funcInfo in _sgFuncInfoList.OrderBy(x => argTypeId ? x.Id : x.Arg)) { if (funcInfo.ServiceList.Contains(_serviceId)) { string name = argTypeId ? funcInfo.Id : funcInfo.Arg; string info = funcInfo.InfoTrans ?? funcInfo.Info; EdiabasToolActivity.ExtraInfo extraInfo = new EdiabasToolActivity.ExtraInfo(name, string.Empty, new List <string> { info }); if (selectList != null) { if (selectList.Contains(name)) { extraInfo.Selected = true; } } _argsListAdapter.Items.Add(extraInfo); } } } _argsListAdapter.NotifyDataSetChanged(); } catch (Exception) { // ignored } }
private string GetArgString() { try { string argType = ArgTypeArg; if (_radioButtonArgTypeId.Checked) { argType = ArgTypeID; } StringBuilder sb = new StringBuilder(); sb.Append(argType); int position = _spinnerArgument.SelectedItemPosition; if (position >= 0 && position < _spinnerArgumentAdapter.ItemsVisible.Count) { EdiabasToolActivity.ExtraInfo item = _spinnerArgumentAdapter.ItemsVisible[position]; if (!string.IsNullOrEmpty(item.Name)) { sb.Append(";"); sb.Append(item.Name); } } string controlParameter = string.Empty; if (_controlRoutine) { if (_radioButtonStpr.Checked) { controlParameter = "STPR"; } else if (_radioButtonRrr.Checked) { controlParameter = "RRR"; } else { controlParameter = "STR"; } } else if (_controlIo) { if (_radioButtonRtd.Checked) { controlParameter = "RTD"; } else if (_radioButtonFcs.Checked) { controlParameter = "FCS"; } else if (_radioButtonSta.Checked) { controlParameter = "STA"; } else { controlParameter = "RCTECU"; } } if (!string.IsNullOrEmpty(controlParameter)) { sb.Append(";"); sb.Append(controlParameter); } if (_layoutArgParams.Visibility == ViewStates.Visible) { foreach (ParameterData parameterData in _parameterList) { string parameter = string.Empty; foreach (object itemObject in parameterData.ItemList) { parameter = string.Empty; if (itemObject is EditText editText) { parameter = editText.Text; } else if (itemObject is Spinner spinner) { if (spinner.Adapter is StringObjAdapter spinnerAdapter) { int spinnerPos = spinner.SelectedItemPosition; if (spinnerPos >= 0 && spinnerPos < spinnerAdapter.Items.Count) { StringObjType itemSpinner = spinnerAdapter.Items[spinnerPos]; if (itemSpinner.Data is EdiabasToolActivity.SgFuncValNameInfo valNameInfo) { parameter = valNameInfo.Text; } } } } if (!string.IsNullOrWhiteSpace(parameter)) { break; } } sb.Append(";"); sb.Append(parameter); } } return(sb.ToString()); } catch (Exception) { return(string.Empty); } }
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 UpdateArgList(List <string> selectList = null) { try { bool argTypeId = _radioButtonArgTypeId.Checked; _argsListAdapter.Items.Clear(); if (_serviceId >= 0) { foreach (SgFunctions.SgFuncInfo funcInfo in _sgFuncInfoList.OrderBy(x => argTypeId ? x.Id : x.Arg)) { bool addArg = false; if (_mwBlock) { if (funcInfo.ServiceList == null) { addArg = true; } } else { if (funcInfo.ServiceList != null && funcInfo.ServiceList.Contains(_serviceId)) { addArg = true; } } if (addArg) { string argType = argTypeId ? funcInfo.Id : funcInfo.Arg; string argName = argTypeId ? funcInfo.Arg : funcInfo.Id; string name = argType + " (" + argName + ")"; string info = funcInfo.InfoTrans ?? funcInfo.Info; if (!string.IsNullOrEmpty(_argFilterText)) { if (name.IndexOf(_argFilterText, StringComparison.OrdinalIgnoreCase) < 0) { continue; // filter is not matching } } EdiabasToolActivity.ExtraInfo extraInfo = new EdiabasToolActivity.ExtraInfo(name, argType, new List <string> { info }); if (selectList != null) { if (selectList.Contains(argType)) { extraInfo.Selected = true; } } _argsListAdapter.Items.Add(extraInfo); } } } UpdateArgFilter(); } catch (Exception) { // ignored } }
private string GetArgString() { try { string argType = ArgTypeArg; if (_radioButtonArgTypeId.Checked) { argType = ArgTypeID; } StringBuilder sb = new StringBuilder(); sb.Append(argType); int position = _spinnerArgument.SelectedItemPosition; if (position >= 0 && position < _spinnerArgumentAdapter.Items.Count) { EdiabasToolActivity.ExtraInfo item = _spinnerArgumentAdapter.Items[position]; if (!string.IsNullOrEmpty(item.Name)) { sb.Append(";"); sb.Append(item.Name); } } string controlParameter = string.Empty; if (_controlRoutine) { if (_radioButtonStpr.Checked) { controlParameter = "STPR"; } else if (_radioButtonRrr.Checked) { controlParameter = "RRR"; } else { controlParameter = "STR"; } } else if (_controlIo) { if (_radioButtonRtd.Checked) { controlParameter = "RTD"; } else if (_radioButtonFcs.Checked) { controlParameter = "FCS"; } else if (_radioButtonSta.Checked) { controlParameter = "STA"; } else { controlParameter = "RCTECU"; } } if (!string.IsNullOrEmpty(controlParameter)) { sb.Append(";"); sb.Append(controlParameter); } return(sb.ToString()); } catch (Exception) { return(string.Empty); } }