DigitalFormLookupComboBox.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using System;
  2. using InABox.Core;
  3. using InABox.Mobile;
  4. using Xamarin.Forms;
  5. namespace PRS.Mobile
  6. {
  7. public class DigitalFormLookupComboBox : DigitalFormLookupView
  8. {
  9. private readonly Grid _grid;
  10. private readonly MobileCard _labelframe;
  11. private readonly Label _label;
  12. private readonly MobileButton _button;
  13. protected override void UpdateUI()
  14. {
  15. _label.Text = String.IsNullOrWhiteSpace(_value.Text) ? "Select Value" : _value.Text;
  16. }
  17. public DigitalFormLookupComboBox()
  18. {
  19. HeightRequest = 40;
  20. _grid = new Grid();
  21. _grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Star });
  22. _grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
  23. _grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Star });
  24. _labelframe = new MobileCard()
  25. {
  26. Padding = 5
  27. };
  28. _grid.Children.Add(_labelframe);
  29. _label = new Label
  30. {
  31. Text = "Select Value",
  32. VerticalTextAlignment = TextAlignment.Center,
  33. FontSize = Device.GetNamedSize(NamedSize.Small,new Label()),
  34. LineBreakMode = LineBreakMode.TailTruncation,
  35. Margin = 5
  36. };
  37. _labelframe.Content = _label;
  38. _button = new MobileButton()
  39. {
  40. WidthRequest = 35,
  41. Image = ImageSource.FromFile("lines")
  42. };
  43. _button.Clicked += DoLookup;
  44. _button.SetValue(Grid.ColumnProperty,1);
  45. _grid.Children.Add(_button);
  46. Content = _grid;
  47. }
  48. protected override void UpdateStatus()
  49. {
  50. IsEnabled = !ReadOnly || Definition.Properties.Secure;
  51. var labelcolors = DigitalFormUtils.GetColors(!IsEnabled, Definition.Properties.Required, false);
  52. _labelframe.BackgroundColor = labelcolors.Background;
  53. _labelframe.BorderColor = labelcolors.Border;
  54. _label.TextColor = labelcolors.Foreground;
  55. var menucolors = DigitalFormUtils.GetColors(!IsEnabled, Definition.Properties.Required, true);
  56. _button.BackgroundColor = menucolors.Background;
  57. _button.BorderColor = menucolors.Border;
  58. }
  59. }
  60. }