/// <summary> /// Добавление нового пистолета /// </summary> /// <param name="hose"></param> public void AddHose(Nozzle hose) { if (!_hoses.Any(x => x.Id == hose.Id)) { _hoses.Add(hose); } }
/// <summary> /// Сгенерировать кнопку для пистолета /// </summary> /// <param name="nozzle">Пистолет</param> /// <returns>Фрэйм пистолета</returns> private Frame CreateNozzleButton(Nozzle nozzle) { var frame = new Frame() { Style = (Style)App.Current.Resources["UsualFrameStyle"], ClassId = nozzle.Id.ToString(), Padding = 5, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, CornerRadius = 10, BackgroundColor = (Color)App.Current.Resources["SelectionColor"] }; var miniFrame = new Frame() { Style = (Style)App.Current.Resources["UsualFrameStyle"], Margin = 0, Padding = 1, HasShadow = false }; var gesture = new TapGestureRecognizer(); frame.GestureRecognizers.Add(gesture); var stack = new StackLayout { Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.CenterAndExpand, Padding = 5 }; var prefix = GetFuelPrefix(nozzle.Id); var topLbl = new Label { Text = prefix, Style = (Style)App.Current.Resources["BoldUsualLabelStyle"], HorizontalTextAlignment = TextAlignment.Center, FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)) }; var bottomLbl = new Label { Text = nozzle.FuelName, Style = (Style)App.Current.Resources["BoldUsualLabelStyle"], HorizontalTextAlignment = TextAlignment.Center, }; stack.Children.Add(topLbl); stack.Children.Add(bottomLbl); miniFrame.Content = stack; frame.Content = miniFrame; return(frame); }
/// <summary> /// Обновление пистолета /// </summary> /// <param name="hose"></param> public bool UpdateHose(Nozzle hose) { var oldHose = _hoses.FirstOrDefault(x => x.Id == hose.Id); if (oldHose == null) { _hoses.Add(hose); return(true); } else { if (oldHose.State != hose.State) { oldHose.State = hose.State; return(true); } oldHose.Price = hose.Price; return(false); } }