Example #1
0
 public ControlKit(ControlKit controlKit)
 {
     ID          = controlKit.ID;
     Name        = controlKit.Name;
     Elements    = controlKit.Elements;
     Description = controlKit.Description;
 }
Example #2
0
        public ControlKitViewModel(ControlKit controlKit)
        {
            ControlKit = controlKit;

            name        = ControlKit.Name;
            elements    = ControlKit.Elements;
            description = ControlKit.Description;
        }
Example #3
0
        public ControlKitXAML(ControlKit controlKit)
        {
            _controlKitViewModel = new ControlKitViewModel(controlKit);

            BindingContext = _controlKitViewModel;

            InitializeComponent();
        }
Example #4
0
        public ControlKitPage()
        {
            Title = "Kit";

            ListView listView = new ListView {
                RowHeight    = 40,
                ItemTemplate = new DataTemplate(typeof(ControlKitCell))
            };

            _myItems = new ObservableCollection <ControlKit>();

            _refreshList();

            listView.ItemsSource = _myItems;

            Content = new StackLayout {
                Children =
                {
                    new Label {
                        HorizontalOptions = LayoutOptions.Center
                    },
                    listView
                }
            };

            listView.ItemSelected += (sender, e) => {
                ControlKit controlKit = (ControlKit)e.SelectedItem;

                Navigation.PushAsync(new ControlKitXAML(controlKit));
            };

            MessagingCenter.Subscribe <ListView, ControlKit> (listView, "deleteControlKit", (sender, arg) => {
                _myItems.Remove(arg);

                App.Database.Delete((ControlKit)arg);
            });

            MessagingCenter.Subscribe <ListView, string> (listView, "useKit", (sender, arg) => {
                var kits = App.Database.GetControlKits();

                ControlKit kit = kits.First(x => x.Name == arg);

                dynamic json = Newtonsoft.Json.JsonConvert.DeserializeObject(kit.Elements);

                foreach (var property in json)
                {
                    GeStockItem item = App.Database.GetItem(Convert.ToUInt16((string)property.Name));

                    item.Quantity -= Convert.ToUInt16((string)property.Value);

                    App.Database.Save(item);
                }

                _refreshList();
            });
        }
        public EditControlKitXAML(ControlKitViewModel controlKitViewModel)
        {
            _controlKitOriginal = new ControlKit(controlKitViewModel.ControlKit);

            _controlKitViewModel = controlKitViewModel;

            InitializeComponent();

            products = App.Database.GetItems();
            foreach (GeStockItem product in products)
            {
                ProductPicker.Items.Add(product.Name);
            }

            ProductPicker.SelectedIndex = 0;

            StepperQuantity.Value = quantity;
            LabelQuantity.Text    = quantity.ToString();

            GeStockItemCell.showDelete = true;
            GeStockItemCell.IdMessage  = "deleteProductFromControlKit";

            _myItems = new ObservableCollection <GeStockItem>();
            ObjectsList.ItemsSource  = _myItems;
            ObjectsList.ItemTemplate = new DataTemplate(typeof(GeStockItemCell));

            dynamic json = Newtonsoft.Json.JsonConvert.DeserializeObject(_controlKitViewModel.Elements);

            foreach (var property in json)
            {
                GeStockItem item = App.Database.GetItem(Convert.ToUInt16((string)property.Name));

                item.Quantity = Convert.ToUInt16((string)property.Value);

                _myItems.Add(item);
            }

            MessagingCenter.Subscribe <ListView, GeStockItem> (ObjectsList, "deleteProductFromControlKit", (sender, arg) => {
                _myItems.Remove(arg);
            });

            BindingContext = _controlKitViewModel;
        }
Example #6
0
 public void Restore(ControlKit originalControlKit)
 {
     Name        = ControlKit.Name = originalControlKit.Name;
     Elements    = ControlKit.Elements = originalControlKit.Elements;
     Description = ControlKit.Description = originalControlKit.Description;
 }