private void AutoComplete_ItemClick(object sender, EventArgs eventArgs) { var itemView = sender as TextView; if (itemView.Text == limitRows.limValueText) { autocomplete.SetText("", TextView.BufferType.Normal); return; } if (хdoc == null) { хdoc = XDocument.Load(Resources.GetXml(Resource.Xml.codes)); } var search = itemView.Text.Split('|').Select(p => p.Trim()).ToList(); var item = хdoc.Root.Elements("item").Where(x => (string)x.Attribute("order") == search[0] && (string)x.Attribute("type") == search[1]).FirstOrDefault(); var brend = item.FirstAttribute.Value; textView2.SetText(Html.FromHtml("<b>Бренд:</b> " + brend), TextView.BufferType.Editable); tableLayout.RemoveAllViewsInLayout(); tableLayout.RemoveAllViews(); TableLayout.LayoutParams par = new TableLayout.LayoutParams(TableLayout.LayoutParams.WrapContent, TableLayout.LayoutParams.MatchParent); par.SetMargins(20, 0, 20, 0); tableLayout.LayoutParameters = par; if (item != null) { var codeData = new List <string>() { item.Attribute("series").Value, item.Attribute("custom").Value, item.Attribute("model").Value }; var isVacon = (brend == "Vacon" ? true : false); txtView = new TextView(this); txtView.SetText(Html.FromHtml("<b>Аналог марки VLT</b>"), TextView.BufferType.Editable); txtView.Gravity = GravityFlags.Left; txtView.SetPadding(25, 25, 25, 25); txtView.SetTextColor(Color.Black); txtView.SetTextSize(Android.Util.ComplexUnitType.Dip, 20); var tableRow = new TableRow(this); tableRow.AddView(txtView); tableLayout.AddView(tableRow); for (int i = 0; i < codeData.Count; i++) { var txt = "<b>"; if (i == 0) { txt += "Серия:"; } else if (i == 1) { txt += "Заказной код:"; } else if (i == 2) { txt += "Типовой код:"; } txt += "</b> "; txtView = new TextView(this); txtView.SetText(Html.FromHtml(txt + (i == 0 && isVacon ? "Micro Drive" : codeData[i])), TextView.BufferType.Editable); txtView.SetBackgroundResource(Resource.Layout.finded); txtView.Gravity = GravityFlags.Left; txtView.SetPadding(25, 25, 25, 25); txtView.SetTextColor(Color.Black); tableRow = new TableRow(this); tableRow.LayoutParameters = new TableRow.LayoutParams(TableRow.LayoutParams.WrapContent, TableRow.LayoutParams.MatchParent); tableRow.AddView(txtView); tableLayout.AddView(tableRow); } if (!isVacon) { var items = хdoc.Root.Elements("item") .Where(x => (string)x.Attribute("brend") == "Vacon" && (string)x.Attribute("custom") == item.Attribute("custom").Value && (string)x.Attribute("series") != "VACON 10" && (string)x.Attribute("series") != "VACON NXL") .ToList(); if (items != null && items.Count > 0) { txtView = new TextView(this); txtView.SetText(Html.FromHtml("<b>Аналог марки Vacon</b>"), TextView.BufferType.Editable); txtView.Gravity = GravityFlags.Left; txtView.SetPadding(25, 50, 25, 25); txtView.SetTextColor(Color.Black); txtView.SetTextSize(Android.Util.ComplexUnitType.Dip, 20); tableRow = new TableRow(this); tableRow.AddView(txtView); tableLayout.AddView(tableRow); drawItems(items, tableLayout, tableRow); } } Toast.MakeText(this, "Поиск завершен", ToastLength.Short).Show(); hideKeyBoard(); bntSendFromMain.Visibility = ViewStates.Visible; } }
protected void InitAddForm() { Button loanLower = FindViewById <Button>(Resource.Id.loanLowerButton), loanHigher = FindViewById <Button>(Resource.Id.loanHigherButton), loanSwitch = FindViewById <Button>(Resource.Id.loanSwitchButton); loanLower.Click += delegate { CheckFocus(); addBalance -= 100; UploadLoanAddInput(); }; loanHigher.Click += delegate { CheckFocus(); addBalance += 100; UploadLoanAddInput(); }; loanSwitch.Click += delegate { CheckFocus(); addBalance *= -1; UploadLoanAddInput(); }; EditText loanInput = FindViewById <EditText>(Resource.Id.loanAddInput); loanInput.FocusChange += delegate(object sender, View.FocusChangeEventArgs e) { if (e.HasFocus) { loanInput.SetText("", TextView.BufferType.Editable); } else { LoadInputValue(loanInput); } }; Button addLoanButton = FindViewById <Button>(Resource.Id.addLoanButton); AutoCompleteTextView nameInput = FindViewById <AutoCompleteTextView>(Resource.Id.personNameInput); TextView notesInput = FindViewById <TextView>(Resource.Id.loanNotesInput); addLoanButton.Click += delegate { Color errorCollor = new Color(255, 0, 0, 100); bool allOk = true; if (addBalance == 0) { loanInput.SetBackgroundColor(errorCollor); allOk = false; } else { loanInput.SetBackgroundColor(Color.Transparent); } if (nameInput.Text.Length == 0) { nameInput.SetBackgroundColor(errorCollor); allOk = false; } else { nameInput.SetBackgroundColor(Color.Transparent); } if (allOk) { Repository repository = Repository.GetInstance(); Person person = repository.FindPersonByName(nameInput.Text); if (person == null) { person = new Person(nameInput.Text); repository.InsertObject(person); } Loan loan = new Loan( (int)System.Math.Abs(addBalance), addBalance > 0, person, notesInput.Text ); repository.InsertObject(loan); UpdateLoanCount(); UpdateAutocompleteNames(); UpdateRecentLoans(); addBalance = 0; UploadLoanAddInput(); nameInput.SetText("", TextView.BufferType.Editable); notesInput.SetText("", TextView.BufferType.Editable); } }; UpdateAutocompleteNames(); UploadLoanAddInput(); }