public void SetOrderItemStarted(int id) { if (currentOrder.OrderItems.Where(i => i.Id == id).Count() != 0) { OrderItemModel model = currentOrder.OrderItems.Where(i => i.Id == id).Single(); model.State = State.Started; Resources res = container.Context.Resources; ImageViewWithId editButton = editButtons.Where(b => b.Id == id).Single(); #pragma warning disable CS0618 // Type or member is obsolete editButton.SetImageDrawable(res.GetDrawable(Resource.Drawable.Locked)); #pragma warning restore CS0618 // Type or member is obsolete editButton.Click -= EditImage_Click; ImageViewWithPosition deleteButton = deleteButtons.Where(b => b.Id == id).Single(); #pragma warning disable CS0618 // Type or member is obsolete deleteButton.SetImageDrawable(res.GetDrawable(Resource.Drawable.Locked)); #pragma warning restore CS0618 // Type or member is obsolete deleteButton.Click -= DeleteImage_Click; } SaveOrderItemState(id, State.Started); }
private void DeleteImage_Click(object sender, EventArgs e) { if (tillPopup != null) { return; } ImageViewWithPosition image = (ImageViewWithPosition)sender; layout.RemoveViewAt(image.Position); nameViews.RemoveAt(image.Position); priceViews.RemoveAt(image.Position); deleteButtons.RemoveAt(image.Position); editButtons.RemoveAt(image.Position); for (int i = image.Position; i < deleteButtons.Count; ++i) { ImageViewWithPosition deleteImage = deleteButtons[i]; --deleteImage.Position; ImageViewWithId editImage = editButtons[i]; --editImage.Position; } currentOrder.RemoveOrderItem(image.Position); SetTotalView(CurrentOrder); }
private void EditImage_Click(object sender, EventArgs e) { if (tillPopup != null) { return; } ImageViewWithId image = (ImageViewWithId)sender; if (container.Parent.Parent is CurrentOrderLayout) { CurrentOrderLayout layout = (CurrentOrderLayout)container.Parent.Parent; VariationsFragment variations = (VariationsFragment)layout.LeftFragment; editingPosition = image.Position; nameViews[editingPosition].SetTextColor(Color.DarkGreen); OrderItemModel thisModel = currentOrder.OrderItems[editingPosition]; svc.LockOrderItem(thisModel.Id); lockedOrderItemId = thisModel.Id; variations.RehydrateOrderItem(thisModel); } }
private void ThisItem_CheckedChange(object sender, CompoundButton.CheckedChangeEventArgs e) { CheckBoxWithId thisBox = (CheckBoxWithId)sender; if (!checking || subChecking) { if (thisBox.Group > 0 && !thisBox.Checked && !subChecking) { checking = true; thisBox.Checked = true; checking = false; return; } else if (thisBox.Group > 0 && !subChecking) { foreach (CheckBoxWithId box in checkBoxes) { if (box.Group == thisBox.Group && box.Position != thisBox.Position) { subChecking = true; box.Checked = false; subChecking = false; } } } TextViewWithId portions = this.portions[thisBox.Position]; ImageViewWithId arrow = arrows[thisBox.Position]; ComponentModel varModel = model.ComponentModels[thisBox.Position]; if (thisBox.Checked) { if (varModel.HasComponents) { arrow.Visibility = ViewStates.Visible; } if (varModel.Portions > 0) { portions.Visibility = ViewStates.Visible; } else { portions.Visibility = ViewStates.Invisible; } } else { arrow.Visibility = ViewStates.Invisible; portions.Visibility = ViewStates.Invisible; } ComponentChecked(this, new ComponentCheckedEventArgs(model.ComponentModels[thisBox.Position])); } }
public ComponentListViewAdapter(int id, Context context, ComponentListMode mode, bool ignoreDefaults = true) { model = new ComponentsModel(id, mode); int position = 0; foreach (ComponentModel cModel in model.ComponentModels) { CheckBoxWithId thisItem = new CheckBoxWithId(context); thisItem.Group = cModel.Group; thisItem.Position = position++; thisItem.ComponentId = cModel.Id; TextViewWithId portions = new TextViewWithId(context); portions.ComponentId = cModel.Id; portions.Text = " " + cModel.Portions.ToString(); portions.SetTextColor(Color.White); portions.SetBackgroundColor(Color.Black); portions.SetTextSize(Android.Util.ComplexUnitType.Sp, 25); portions.Click += Portions_Click; ImageViewWithId arrow = new ImageViewWithId(context); arrow.SetImageResource(Resource.Drawable.ViewComponents); arrow.SetPadding(5, 8, 0, 0); arrow.ComponentId = cModel.Id; arrow.Visibility = ViewStates.Invisible; arrow.Click += Arrow_Click; if (!ignoreDefaults && cModel.IsDefault) { thisItem.Checked = true; } checkBoxes.Add(thisItem); this.portions.Add(portions); arrows.Add(arrow); } }
private void Arrow_Click(object sender, EventArgs e) { ImageViewWithId arrow = (ImageViewWithId)sender; ArrowClicked(this, new ArrowClickedEventArgs(arrow)); }
public override View GetView(int position, View convertView, ViewGroup parent) { Activity context = (Activity)parent.Context; ComponentModel varModel = model.ComponentModels[position]; View view = new LinearLayout(context); view.LayoutDirection = LayoutDirection.Ltr; CheckBoxWithId thisItem = checkBoxes[position]; if (thisItem.Parent != null) { thisItem.CheckedChange -= ThisItem_CheckedChange; ((LinearLayout)thisItem.Parent).RemoveAllViews(); } thisItem.Position = position; thisItem.Text = varModel.Name; thisItem.SetTextColor(Color.Black); thisItem.SetTextSize(Android.Util.ComplexUnitType.Sp, 25); thisItem.CheckedChange += ThisItem_CheckedChange; ((LinearLayout)view).AddView(thisItem); thisItem.LayoutParameters.Width = 615; TextViewWithId portions = this.portions[position]; ImageViewWithId arrow = arrows[position]; if (thisItem.Checked) { if (varModel.HasComponents) { arrow.Visibility = ViewStates.Visible; } if (varModel.Portions > 0) { portions.Visibility = ViewStates.Visible; } else { portions.Visibility = ViewStates.Invisible; } } else { arrow.Visibility = ViewStates.Invisible; portions.Visibility = ViewStates.Invisible; } ((LinearLayout)view).AddView(portions); ((LinearLayout)view).AddView(arrow); portions.LayoutParameters.Width = 50; if (varModel.Group > 0) { view.SetBackgroundColor(Color.Beige); } view.SetPadding(10, 0, 0, 0); return(view); }
public void AddOrderItem(OrderItemModel model) { TableRow newRow = new TableRow(container.Context); TextView nameView = new TextView(container.Context); TextView priceView = new TextView(container.Context); nameView.Text = model.DisplayName; nameView.SetPadding(10, 0, 0, 0); nameView.SetTextSize(ComplexUnitType.Sp, 20); nameView.SetTextColor(Color.Black); priceView.Text = model.Price.ToString("#0.00"); priceView.SetPadding(90, 0, 0, 0); priceView.SetTextSize(ComplexUnitType.Sp, 20); priceView.SetBackgroundColor(Color.White); priceView.SetTextColor(Color.Black); newRow.AddView(nameView); newRow.AddView(priceView); nameViews.Add(nameView); priceViews.Add(priceView); if (container.Parent.Parent is CurrentOrderLayout) { ImageViewWithPosition deleteImage = new ImageViewWithPosition(container.Context); Resources res = container.Context.Resources; if (model.State == State.None) #pragma warning disable CS0618 // Type or member is obsolete { deleteImage.SetImageDrawable(res.GetDrawable(Resource.Drawable.Delete)); } #pragma warning restore CS0618 // Type or member is obsolete else if (model.State == State.Started) #pragma warning disable CS0618 // Type or member is obsolete { deleteImage.SetImageDrawable(res.GetDrawable(Resource.Drawable.Locked)); } #pragma warning restore CS0618 // Type or member is obsolete else #pragma warning disable CS0618 // Type or member is obsolete { deleteImage.SetImageDrawable(res.GetDrawable(Resource.Drawable.Completed)); } #pragma warning restore CS0618 // Type or member is obsolete deleteImage.SetPadding(15, 0, 0, 0); if (model.State == State.None) { deleteImage.Click += DeleteImage_Click; } deleteImage.Id = model.Id; deleteImage.Position = deleteButtons.Count; deleteButtons.Add(deleteImage); newRow.AddView(deleteImage); ImageViewWithId editImage = new ImageViewWithId(container.Context); if (model.State == State.None) #pragma warning disable CS0618 // Type or member is obsolete { editImage.SetImageDrawable(res.GetDrawable(Resource.Drawable.Pen)); } #pragma warning restore CS0618 // Type or member is obsolete else if (model.State == State.Started) #pragma warning disable CS0618 // Type or member is obsolete { editImage.SetImageDrawable(res.GetDrawable(Resource.Drawable.Locked)); } #pragma warning restore CS0618 // Type or member is obsolete else if (model.State == State.Completed) #pragma warning disable CS0618 // Type or member is obsolete { editImage.SetImageDrawable(res.GetDrawable(Resource.Drawable.Completed)); } #pragma warning restore CS0618 // Type or member is obsolete editImage.SetPadding(15, 0, 0, 0); if (model.State == State.None) { editImage.Click += EditImage_Click; } editImage.Id = model.Id; editImage.Position = deleteButtons.Count - 1; editButtons.Add(editImage); newRow.AddView(editImage); } layout.AddView(newRow); nameView.LayoutParameters.Width = 600; }
public ArrowClickedEventArgs(ImageViewWithId view) { arrow = view; }