Пример #1
0
 public bool EntryRemove(int UniqueID)
 {
     if (IsBusy)
     {
         if (AllowExceptions)
         {
             throw new InvalidOperationException("Wheel is currently busy");
         }
         else
         {
             return(false);
         }
     }
     try { EntryList.RemoveAt(EntryList.FindIndex(x => x.UniqueID == UniqueID)); return(true); }
     catch { return(false); }
 }
Пример #2
0
        public int EntryAdd(Entry entry)
        {
            if (IsDisposed)
            {
                if (AllowExceptions)
                {
                    throw new InvalidOperationException("This Wheel has been Disposed.");
                }
                else
                {
                    return(-1);
                }
            }
            if (IsBusy)
            {
                if (AllowExceptions)
                {
                    throw new InvalidOperationException("Wheel is currently busy");
                }
                else
                {
                    return(-1);
                }
            }
            if (entry.UniqueID == -1)
            {
                if (EntryList.Count() == 0)
                {
                    entry.UniqueID = 0;
                }
                else
                {
                    entry.UniqueID = EntryList.Last().UniqueID + 1;
                }
            }

            int check1 = EntryList.FindIndex(x => x.UniqueID == entry.UniqueID);

            if (check1 != -1)
            {
                return(-1);
            }

            if (ToolProperties.ForceUniqueEntryColors)
            {
                int check2 = EntryList.FindIndex(x => x.Name == entry.Name);
                if (check2 != -1)
                {
                    entry.Aura = EntryList[check2].Aura;
                }                                       //use same color as others with same name
                else
                {
                    int check3 = EntryList.FindIndex(x => x.Aura == entry.Aura);
                    if (check3 != -1)
                    {
                        entry.Aura = ColorIncrementRnd(EntryList[check3].Aura, 25);
                        int check4 = EntryList.FindIndex(x => x.Aura == entry.Aura);
                        if (check4 != -1)
                        {
                            entry.Aura = ColorIncrementRnd(EntryList[check3].Aura, 50);
                        } //use new color since another name is using this color
                    }     //use new color since another name is using this color
                }
            }

            EntryList.Add(entry);

            return(entry.UniqueID);
        }