Beispiel #1
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);
             }
         }
     }
 }
Beispiel #2
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);
                }
            }
        }
        public static AvatarListItem Create(RdlActor avatar)
        {
            AvatarListItem item = new AvatarListItem();

            item.Actor = avatar;
            return(item);
        }