예제 #1
0
        private void AddClicked(Label label, string hint, WordLookup.Definition definition)
        {
            label.BackgroundColor = Color.GreenYellow;

            var item = new Item();

            item.Category = definition.Category;
            item.Text     = hint;
            store.AddItem(item);
        }
예제 #2
0
        public ItemsViewModel()
        {
            Title = "Browse";

            MessagingCenter.Subscribe <NewItemPage, Item>(this, "AddItem", async(obj, item) =>
            {
                var newItem = item as Item;
                itemStore.AddItem(item);
                await DataStore.AddItemAsync(newItem);
            });
        }
예제 #3
0
 //these are accessed through the context menu use
 public void Add(Mobile from)
 {
     _Store.AddItem(from);
 }
예제 #4
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            try
            {
                //read in the text field and set the withdraw amount based on the contents
                //bounded by max storage, and 1
                if (!_Store.LockWithdrawalAmount)
                {
                    _Store.WithdrawAmount = Math.Max(_Store.MinWithdrawAmount, Math.Min(ItemStore.MaxAmount, Int32.Parse(GetTextField(info, 0))));
                }
            }
            catch
            {
                _Owner.SendMessage("Invalid entry in withdrawl amount: " + GetTextField(info, 0));
            }

            if (!_Store.CanUse(_Owner))
            {
                return;
            }

            //store flags
            int  buttonid = info.ButtonID;
            bool deed     = false;

            //right click
            if (buttonid == 0)
            {
                return;
            }

            //toggle lock button
            if (buttonid == _Store.StoreEntries.Count * 2 + 1)
            {
                _Store.LockWithdrawalAmount = !_Store.LockWithdrawalAmount;
                _Owner.SendGump(new ItemStoreGump(this));
                return;
            }

            //add button
            if (buttonid == _Store.StoreEntries.Count * 2 + 2)
            {
                _Store.AddItem(_Owner);

                _Owner.SendGump(new ItemStoreGump(this));
                return;
            }

            //fill from backpack button
            if (buttonid == _Store.StoreEntries.Count * 2 + 3)
            {
                _Store.FillFromBackpack(_Owner);

                _Owner.SendGump(new ItemStoreGump(this));
                return;
            }

            //previous page button
            if (buttonid == _Store.StoreEntries.Count * 2 + 4)
            {
                if (_Page > 0)
                {
                    _Owner.SendGump(new ItemStoreGump(_Owner, _Store, _Page - 1));
                }
                return;
            }

            //next page button
            if (buttonid == _Store.StoreEntries.Count * 2 + 5)
            {
                if (_Page < _MaxPages - 1)
                {
                    _Owner.SendGump(new ItemStoreGump(_Owner, _Store, _Page + 1));
                }
                return;
            }

            //flag if a deed is requested
            if (buttonid > _Store.StoreEntries.Count)
            {
                deed      = true;
                buttonid -= _Store.StoreEntries.Count;
            }

            //any button that is left is a withdraw request
            //offset of 1 between the passed value and the list index
            _Store.WithdrawItem(_Owner, buttonid - 1, deed);
            _Owner.SendGump(new ItemStoreGump(this));
        }
 protected override void OnTarget(Mobile from, object targeted)
 {
     _Store.AddItem(from, targeted);
 }