Ejemplo n.º 1
0
 // Methods
 public void Add(string languageName)
 {
     Assert.ArgumentNotNullOrEmpty(languageName, "languageName");
     for (var i = _list.Count - 1; i >= 0; i--)
     {
         if (string.Compare(_list[i], languageName, StringComparison.InvariantCultureIgnoreCase) == 0)
         {
             _list.Remove(i);
         }
     }
     _list.AddAt(0, languageName);
     while (_list.Count > Historylength)
     {
         _list.Remove(_list.Count - 1);
     }
     Save();
 }
Ejemplo n.º 2
0
        public void ListString_ManageItems()
        {
            ListString list = new ListString();

            Assert.AreEqual(0, list.Count);

            list.Add("Item1");
            Assert.AreEqual(1, list.Count);

            Assert.AreEqual("Item1", list.Get(0));

            list.Remove(0);
            Assert.AreEqual(0, list.Count);
        }
Ejemplo n.º 3
0
 // Method to remove an element.
 public void Remove(Monarchy monarchy)
 {
     try
     {
         ListState.Remove(monarchy.BaseState);
         ListString.Remove(monarchy.BaseState.ToString());
         DictionaryState.Remove(monarchy.BaseState);
         DictionaryString.Remove(monarchy.BaseState.ToString());
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
 }
 protected void ToggleRibbonStrip(string id)
 {
     Assert.ArgumentNotNull(id, "id");
     ListString str = new ListString(UserOptions.ContentEditor.VisibleStrips);
     if (str.Count == 0)
     {
         Database database = Factory.GetDatabase("core", false);
         Assert.IsNotNull(database, typeof(Database));
         Item item = database.GetItem(ItemIDs.DefaultRibbon);
         Assert.IsNotNull(item, typeof(Ribbon));
         foreach (Item item2 in item.Children)
         {
             Item item3 = item2;
             if (item3.TemplateID == TemplateIDs.Reference)
             {
                 item3 = item3.Database.Items[item3["Reference"]];
             }
             if (item3["Hidden by default"] != "1")
             {
                 str.Add(item3.ID.ToString());
             }
         }
     }
     if (str.Contains(id))
     {
         if (str.Count > 1)
         {
             str.Remove(id);
         }
         else
         {
             SheerResponse.Alert("You cannot remove the last strip from the ribbon.", new string[0]);
         }
     }
     else
     {
         str.Add(id);
     }
     UserOptions.ContentEditor.VisibleStrips = str.ToString();
     this.Reload();
 }
Ejemplo n.º 5
0
        public Message(string msg)
        {
            if (string.IsNullOrEmpty(msg))
            {
                throw new IRCException("Empty Message");
            }
            this.msg = msg;
            string[] parts = msg.Split(new char[] { ' ' });

            if (parts.Length >= 2)
            {
                bool AddtoList = false;
                ListString = "";
                for (int i = 1; i < parts.Length; i++)
                {
                    string p = parts[i];
                    if (p.StartsWith(":"))
                    {
                        AddtoList = true;
                    }

                    if (AddtoList)
                    {
                        ListString += p + " ";
                    }
                }
                ListString = ListString.Trim();


                Prefix = parts[0];
                if (Prefix.StartsWith(":"))
                {
                    Prefix = Prefix.Remove(0, 1);
                }
                Command = parts[1];

                string la = "";
                for (int i = 2; i < parts.Length; i++)
                {
                    la += " " + parts[i];
                }
                la = la.Trim();
                if (la.StartsWith(":"))
                {
                    la = la.Remove(0, 1);
                }
                AfterCommandString = la;

                Target = parts[2];
                if (Target.StartsWith(":"))
                {
                    Target = Target.Remove(0, 1);
                }
                if (parts.Length > 3)
                {
                    Arg2 = parts[3];
                    if (Arg2.StartsWith(":"))
                    {
                        Arg2 = Arg2.Remove(0, 1);
                    }
                }
                if (parts.Length > 4)
                {
                    Arg3 = parts[4];
                    if (Arg3.StartsWith(":"))
                    {
                        Arg3 = Arg3.Remove(0, 1);
                    }
                }
                if (parts.Length > 5)
                {
                    Arg4 = parts[5];
                    if (Arg4.StartsWith(":"))
                    {
                        Arg4 = Arg4.Remove(0, 1);
                    }
                }
                if (ListString.StartsWith(":"))
                {
                    ListString = ListString.Remove(0, 1);
                }
            }
            else
            {
                throw new IRCException("Invalid Message: " + msg);
            }
        }