示例#1
0
 private void btn_new_item_Click(object sender, EventArgs e)
 {
     using (var newItemForm = new NewItemForm())
     {
         var result = newItemForm.ShowDialog();
         if (result == DialogResult.OK)
         {
             var newList = ITEM_NAMES.ToList();
             newList.Add(newItemForm.ReturnValue);
             ITEM_NAMES    = newList.ToArray();
             nItem.Maximum = ITEM_NAMES.Length - 1;
             ItemList.Add(new ItemLogic());
             nItem.Value = nItem.Maximum;
             ItemSelectorForm.AddItem(newItemForm.ReturnValue);
         }
     }
 }
示例#2
0
 private void mImport_Click(object sender, EventArgs e)
 {
     if (openLogic.ShowDialog() == DialogResult.OK)
     {
         StreamReader LogicFile = new StreamReader(File.Open(openLogic.FileName, FileMode.Open));
         ItemList = new List <ItemLogic>();
         var logicString = LogicFile.ReadToEnd();
         logicString = Migrator.ApplyMigrations(logicString);
         string[] lines = logicString.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
         ItemSelectorForm.ResetItems();
         ITEM_NAMES = DEFAULT_ITEM_NAMES.ToArray();
         int i = 0;
         while (true)
         {
             if (i == lines.Length)
             {
                 break;
             }
             ;
             if (lines[i].Contains("-"))
             {
                 var itemName = lines[i].Substring(2);
                 if (ItemList.Count >= ITEM_NAMES.Length)
                 {
                     var newList = ITEM_NAMES.ToList();
                     newList.Add(itemName);
                     ItemSelectorForm.AddItem(itemName);
                     ITEM_NAMES = newList.ToArray();
                 }
                 i++;
                 continue;
             }
             else
             {
                 ItemLogic l = new ItemLogic();
                 l.Dependence = new List <int>();
                 if (lines[i] != "")
                 {
                     foreach (string j in lines[i].Split(','))
                     {
                         l.Dependence.Add(Convert.ToInt32(j));
                     }
                     ;
                 }
                 ;
                 l.Conditional = new List <List <int> >();
                 if (lines[i + 1] != "")
                 {
                     foreach (string j in lines[i + 1].Split(';'))
                     {
                         List <int> c = new List <int>();
                         foreach (string k in j.Split(','))
                         {
                             c.Add(Convert.ToInt32(k));
                         }
                         ;
                         l.Conditional.Add(c);
                     }
                     ;
                 }
                 ;
                 l.Time_Needed    = Convert.ToInt32(lines[i + 2]);
                 l.Time_Available = Convert.ToInt32(lines[i + 3]);
                 ItemList.Add(l);
                 i += 4;
             };
         }
         ;
         LogicFile.Close();
         nItem.Value   = 1;
         nItem.Value   = 0;
         nItem.Maximum = ITEM_NAMES.Length - 1;
     }
     ;
 }
示例#3
0
        private void LoadLogic(string logicString)
        {
            ItemList = new List <ItemLogic>();
            string[] lines = logicString.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
            ItemSelectorForm.ResetItems();
            ITEM_NAMES = DEFAULT_ITEM_NAMES.ToArray();
            int i = 0;

            while (true)
            {
                if (i == lines.Length)
                {
                    break;
                }
                ;
                if (lines[i].Contains("-"))
                {
                    var itemName = lines[i].Substring(2);
                    if (ItemList.Count >= ITEM_NAMES.Length)
                    {
                        var newList = ITEM_NAMES.ToList();
                        newList.Add(itemName);
                        ItemSelectorForm.AddItem(itemName);
                        ITEM_NAMES = newList.ToArray();
                    }
                    i++;
                    continue;
                }
                else
                {
                    ItemLogic l = new ItemLogic();
                    l.Dependence = new List <int>();
                    if (lines[i] != "")
                    {
                        foreach (string j in lines[i].Split(','))
                        {
                            l.Dependence.Add(Convert.ToInt32(j));
                        }
                        ;
                    }
                    ;
                    l.Conditional = new List <List <int> >();
                    if (lines[i + 1] != "")
                    {
                        foreach (string j in lines[i + 1].Split(';'))
                        {
                            List <int> c = new List <int>();
                            foreach (string k in j.Split(','))
                            {
                                c.Add(Convert.ToInt32(k));
                            }
                            ;
                            l.Conditional.Add(c);
                        }
                        ;
                    }
                    ;
                    l.Time_Needed    = Convert.ToInt32(lines[i + 2]);
                    l.Time_Available = Convert.ToInt32(lines[i + 3]);
                    ItemList.Add(l);
                    i += 4;
                };
            }
            ;

            nItem.Maximum = ITEM_NAMES.Length - 1;
            SetIndex((int)nItem.Value);
        }