Esempio n. 1
0
        public void SelectMemoriesByGuid(Collections.NgbhItems items)
        {
            if (items.Length > 0)
            {
                this.lv.Enabled = false;

                ArrayList guidList = new ArrayList();
                foreach (NgbhItem item in items)
                {
                    if (!guidList.Contains(item.Guid))
                    {
                        guidList.Add(item.Guid);
                    }
                }

                foreach (ListViewItem li in this.lv.Items)
                {
                    NgbhItem item = li.Tag as NgbhItem;
                    if (guidList.Contains(item.Guid))
                    {
                        li.Selected = true;
                    }
                }

                this.lv.Enabled = true;
            }
        }
Esempio n. 2
0
        public void DeleteMemoryEchoes(Collections.NgbhItems items, uint ownerID)
        {
            int deletedCount       = 0;
            ExceptionBuilder trace = new ExceptionBuilder();

            trace.Append("Memories found:" + Helper.lbr);

            Collections.NgbhSlots slots = this.GetSlots(Data.NeighborhoodSlots.Sims);
            foreach (NgbhSlot slot in slots)
            {
                // skip my own memories?
                if (ownerID == slot.SlotID)
                {
                    continue;
                }

                SDesc simDesc = FileTable.ProviderRegistry.SimDescriptionProvider.SimInstance[(ushort)slot.SlotID] as SDesc;
                Collections.NgbhItems simMemories = slot.ItemsB;

                Collections.NgbhItems memoryToRemove = new SimPe.Plugin.Collections.NgbhItems(null);
                for (int j = 0; j < simMemories.Length; j++)
                {
                    for (int i = 0; i < items.Length; i++)
                    {
                        NgbhItem item      = items[i];
                        NgbhItem simMemory = simMemories[j];

                        if (
                            simMemory.IsMemory && item.IsMemory &&
                            simMemory.Guid == item.Guid &&
                            ArrayEquals(simMemory.Data, item.Data) &&
                            !simMemory.Flags.IsVisible
                            )
                        {
                            memoryToRemove.Add(simMemory);                             // simMemory.RemoveFromParentB();
                        }
                    }
                }

                if (memoryToRemove.Count > 0)
                {
                    deletedCount += memoryToRemove.Count;
                    trace.AppendFormat("{0} {1}: {2} \r\n", simDesc.SimName, simDesc.SimFamilyName, memoryToRemove.Count);
                    foreach (NgbhItem item in memoryToRemove)
                    {
                        trace.AppendFormat("\t- {0}\r\n", item.ToString());
                    }
                    trace.Append("\t\r\n\r\n");
                    slot.ItemsB.Remove(memoryToRemove);
                }
            }

            if (deletedCount > 0)
            {
                Message.Show(String.Format("Deleted {0} memories from the sim pool", deletedCount) + Helper.lbr + Helper.lbr + trace.ToString());
            }
        }
Esempio n. 3
0
        public NgbhItems Clone(NgbhSlotList newparent)
        {
            NgbhItems ret = new NgbhItems(newparent);

            foreach (NgbhItem i in list)
            {
                ret.Add(i);
            }

            return(ret);
        }
Esempio n. 4
0
        public void Remove(NgbhItems items)
        {
            foreach (NgbhItem item in items)
            {
                Remove(item);
            }

            if (ngbh != null)
            {
                ngbh.Changed = true;
            }
        }
Esempio n. 5
0
        private void lldel_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            if (lv.SelectedItems.Count == 0 || items == null)
            {
                return;
            }
            //NgbhItemsListViewItem item = this.SelectedItem;
            Collections.NgbhItems nitems = this.SelectedNgbhItems;
            items.Remove(nitems);

            for (int i = lv.SelectedItems.Count; i > 0; i--)
            {
                lv.Items.Remove(lv.SelectedItems[0]);
            }
        }
Esempio n. 6
0
 void CopyItems()
 {
     Collections.NgbhItems selitems = SelectedNgbhItems;
     if (selitems.Count > 0)
     {
         this.Cursor = Cursors.WaitCursor;
         try
         {
             clipboard.Clear();
             foreach (NgbhItem item in selitems)
             {
                 clipboard.Enqueue(item);
             }
         }
         catch (Exception exception1)
         {
             this.Cursor = Cursors.Default;
             Helper.ExceptionMessage(Localization.Manager.GetString("errconvert"), exception1);
         }
         this.Cursor = Cursors.Default;
     }
 }
Esempio n. 7
0
        void DeleteItems(bool cascade)
        {
            if (lv.SelectedItems.Count != 0)
            {
                this.Cursor = Cursors.WaitCursor;
                try
                {
                    ArrayList items = new ArrayList();
                    foreach (ListViewItem li in lv.SelectedItems)
                    {
                        items.Add(li);
                    }

                    Collections.NgbhItems memoryItems = this.SelectedNgbhItems;

                    if (cascade)
                    {
                        ((EnhancedNgbh)Slot.Parent).DeleteMemoryEchoes(memoryItems, Slot.SlotID);
                    }

                    memoryItems[0].ParentSlot.ItemsB.Remove(memoryItems);

                    foreach (ListViewItem li in items)
                    {
                        lv.Items.Remove(li);
                    }

                    lv.SelectedItems.Clear();
                }
                catch (Exception exception1)
                {
                    this.Cursor = Cursors.Default;
                    Helper.ExceptionMessage(Localization.Manager.GetString("errconvert"), exception1);
                }
                this.Cursor = Cursors.Default;
            }
        }
Esempio n. 8
0
        public void FixNeighborhoodMemories()
        {
            int deletedCount = 0;
            int fixedCount   = 0;

            ExceptionBuilder trace = new ExceptionBuilder();

            trace.Append("Invalid memories found:" + Helper.lbr);

            Collections.NgbhSlots slots = this.GetSlots(Data.NeighborhoodSlots.Sims);

            foreach (NgbhSlot slot in slots)
            {
                SDesc simDesc = FileTable.ProviderRegistry.SimDescriptionProvider.SimInstance[slot.SlotID] as SDesc;
                Collections.NgbhItems simMemories = slot.ItemsB;

                ArrayList memoryToRemove = new ArrayList();
                ArrayList memoryToFix    = new ArrayList();


                NgbhItem lastSpamMemory = null;

                for (int j = 0; j < simMemories.Length; j++)
                {
                    NgbhItem simMemory = simMemories[j];

                    // skip tokens...
                    if (simMemory.IsMemory)
                    {
                        // ...and the lame "Met Unknown" memories
                        if (simMemory.SimInstance != 0)
                        {
                            // fix invalid sim instances
                            ushort inst = FileTable.ProviderRegistry.SimDescriptionProvider.GetInstance(simMemory.SimID);
                            if (simMemory.SimInstance != inst)
                            {
                                simMemory.SimInstance = inst;
                                memoryToFix.Add(simMemory);
                            }


                            if (simDesc == null)
                            {
                                memoryToRemove.Add(simMemory);
                            }
                        }

                        // it could be spam...
                        // collapse duplicate items
                        if (simMemory.IsSpam)
                        {
                            if (
                                lastSpamMemory != null &&
                                lastSpamMemory.Guid == simMemory.Guid &&
                                lastSpamMemory.SimInstance == simMemory.SimInstance
                                )
                            {
                                memoryToRemove.Add(simMemory);
                            }

                            lastSpamMemory = simMemory;
                        }
                        else
                        {
                            lastSpamMemory = null;
                        }
                    }
                }                 // for simMemories


                if (memoryToRemove.Count > 0 || memoryToFix.Count > 0)
                {
                    deletedCount += memoryToRemove.Count;
                    fixedCount   += memoryToFix.Count;

                    trace.AppendFormat("{0} {1}: {2} \r\n", simDesc.SimName, simDesc.SimFamilyName, memoryToRemove.Count + memoryToFix.Count);

                    foreach (NgbhItem item in memoryToFix)
                    {
                        trace.AppendFormat("[FIX]- {0}\r\n", item.ToString());
                    }

                    NgbhItem[] itemsToRemove = (NgbhItem[])memoryToRemove.ToArray(typeof(NgbhItem));
                    foreach (NgbhItem item in itemsToRemove)
                    {
                        trace.AppendFormat("[DEL]- {0}\r\n", item.ToString());
                    }

                    trace.Append("\t\r\n\r\n");
                    slot.ItemsB.Remove(itemsToRemove);
                }
            }

            if (deletedCount > 0 || fixedCount > 0)
            {
                Helper.ExceptionMessage(String.Format("Fixed/Deleted {0} invalid memories.", deletedCount + fixedCount), trace);
            }
        }