Ejemplo n.º 1
0
 private void model_ItemRemoved(IAvatarGridModel <T> model, T item)
 {
     if (!model.ModelUpdating)
     {
         QApplication.Invoke(delegate {
             RemoveItem(item);
         });
     }
 }
Ejemplo n.º 2
0
 private void model_ItemAdded(IAvatarGridModel <T> model, T item)
 {
     if (!model.ModelUpdating)
     {
         QApplication.Invoke(delegate {
             AddItem(item);
             ResizeAndRepositionGroups();
         });
     }
 }
Ejemplo n.º 3
0
        private void model_ItemChanged(IAvatarGridModel <T> model, T item)
        {
            if (model.ModelUpdating)
            {
                return;
            }

            QApplication.Invoke(delegate {
                bool visibilityChanged = false;
                bool groupsChanged     = false;

                lock (m_Items) {
                    if (!m_Items.ContainsKey(item))
                    {
                        Console.Error.WriteLine("Item changed before being added: " + item);
                        //	model_ItemAdded(model, item);
                        return;
                    }

                    List <string> toRemove = new List <string>();

                    // Check if item was added to any groups
                    foreach (string groupName in model.GetItemGroups(item))
                    {
                        if (!m_Items[item].ContainsKey(groupName))
                        {
                            AddItemToGroup(item, groupName);
                            groupsChanged = true;
                        }
                    }

                    // Check if item needs to be removed from any groups, redraw others.
                    // FIXME: Don't need to redraw items we just added.
                    foreach (RosterItem <T> gitem in m_Items[item].Values.ToArray())
                    {
                        RosterItemGroup group = (RosterItemGroup)gitem.ParentItem();
                        var groups            = model.GetItemGroups(item);
                        if (groups.Contains(group.Name) || (groups.Count() == 0 && group.Name == "No Group"))
                        {
                            if (model.IsVisible(item) != gitem.IsVisible())
                            {
                                visibilityChanged = true;
                            }
                            else
                            {
                                gitem.Update();
                            }
                        }
                        else
                        {
                            toRemove.Add(group.Name);
                            groupsChanged = true;
                        }
                    }

                    foreach (string groupName in toRemove)
                    {
                        RemoveItemFromGroup(item, groupName, false);
                    }
                }

                if (visibilityChanged || groupsChanged)
                {
                    ResizeAndRepositionGroups();
                }
            });
        }