예제 #1
0
        private void Refresh()
        {
            // Remove any actors not in the current location.
            var removes = _actors.Where(a => new Point3(a.Value.Properties.GetValue <int>("X"),
                                                        a.Value.Properties.GetValue <int>("Y"),
                                                        a.Value.Properties.GetValue <int>("Z")) != this.Location).Select(a => a.Value.ID).ToList();

            foreach (var id in removes)
            {
                _actors.Remove(id);
            }

            ctlItems.Children.Clear();
            foreach (var actor in _actors.Values)
            {
                ObjectType type = (ObjectType)Enum.Parse(typeof(ObjectType), actor.Properties.GetValue <string>("ObjectType"), true);
                if (type == ObjectType.Mobile || type == ObjectType.Player)
                {
                    AvatarListItem avatarItem = AvatarListItem.Create(actor);
                    avatarItem.Action += new ActionEventHandler(OnActorItemAction);
                    ctlItems.Children.Add(avatarItem);
                }
                else if (type == ObjectType.Actor)
                {
                    ItemListItem listItem = ItemListItem.Create(actor);
                    listItem.Action += new ActionEventHandler(OnActorItemAction);
                    ctlItems.Children.Add(listItem);
                }
            }
        }
예제 #2
0
 private void BindActors()
 {
     if (this.ItemsSource != null)
     {
         lstActors.Children.Clear();
         foreach (var actor in this.ItemsSource)
         {
             ObjectType type = (ObjectType)Enum.Parse(typeof(ObjectType), actor.Properties.GetValue <string>("ObjectType"), true);
             if (type == ObjectType.Mobile || type == ObjectType.Player)
             {
                 AvatarListItem avatarItem = AvatarListItem.Create(actor);
                 //avatarItem.Action += new ActionEventHandler(OnActorItemAction);
                 if (this.EnableDrag)
                 {
                     avatarItem.BeginDrag += new BeginDragEventHandler(OnDroppableBeginDrag);
                     avatarItem.ActorDrop += new ActorEventHandler(OnAvatarListItemActorDrop);
                     avatarItem.Click     += new ActorEventHandler(OnAvatarListItemClick);
                 }
                 lstActors.Children.Add(avatarItem);
             }
             else if (type == ObjectType.Actor)
             {
                 ItemListItem listItem = ItemListItem.Create(actor);
                 //listItem.Action += new ActionEventHandler(OnActorItemAction);
                 if (this.EnableDrag)
                 {
                     listItem.BeginDrag += new BeginDragEventHandler(OnDroppableBeginDrag);
                 }
                 lstActors.Children.Add(listItem);
             }
         }
     }
 }
예제 #3
0
        public static ItemListItem Create(RdlActor item)
        {
            ItemListItem listItem = new ItemListItem();

            listItem.Actor = item;
            return(listItem);
        }
예제 #4
0
        public void Refresh()
        {
            if (this.Target != null)
            {
                lblName.Text = String.Concat("Corpse of ", this.Target.Name.A(this.Target.Properties.GetValue <bool>("HasProperName")));

                lstInventory.Children.Clear();
                foreach (var item in this.Target.Inventory.GetContents().Where(i => !ActorHelper.HasFlag(i, "NoSell") &&
                                                                               i.Properties.GetValue <bool>("IsInventoryItem")))
                {
                    ItemListItem listItem = ItemListItem.Create(item);
                    listItem.CommerceType = CommerceType.Get;
                    listItem.Action      += new ActionEventHandler(OnListItemAction);
                    listItem.Refresh();
                    lstInventory.Children.Add(listItem);
                }
            }
        }
        public void Refresh()
        {
            if (this.Target != null)
            {
                lstGoods.Children.Clear();
                foreach (var item in this.Target.Inventory.GetContents().Where(i => !ActorHelper.HasFlag(i, "NoSell")))
                {
                    // Ensure that the buy prices have been set.
                    ItemHelper.EnsureBuyCost(item, this.Target.Properties.GetValue <double>("MarkupPercentage"));

                    ItemListItem listItem = ItemListItem.Create(item);
                    listItem.CommerceType = CommerceType.Buy;
                    listItem.Action      += new ActionEventHandler(OnListItemAction);
                    listItem.Refresh();
                    lstGoods.Children.Add(listItem);
                }
                this.HideLoading();
            }

            if (this.Player != null)
            {
                lstInventory.Children.Clear();
                foreach (var item in this.Player.Inventory.GetContents().Where(i => !ActorHelper.HasFlag(i, "NoSell")))
                {
                    // Ensure that the sell prices have been set.
                    if (this.Target != null)
                    {
                        ItemHelper.EnsureSellCost(item, this.Target.Properties.GetValue <double>("MarkdownPercentage"));
                    }

                    ItemListItem listItem = ItemListItem.Create(item);
                    listItem.CommerceType = CommerceType.Sell;
                    listItem.Action      += new ActionEventHandler(OnListItemAction);
                    listItem.Refresh();
                    lstInventory.Children.Add(listItem);
                }
            }
        }