public bool HasMatching(CastList aCast) { foreach (string name in aCast.InnerList) { foreach (string secondName in this.List) { if (name == secondName && name != "NULL") return true; } } return false; }
private void loadSession_Click(object sender, EventArgs e) { beingLoaded = true; LoadFileName form_popup = new LoadFileName(this); form_popup.ShowDialog(); if (form_popup.loadFileName == "" || form_popup.loadFileName == null) { return; } loadedFileName = form_popup.loadFileName; string sessionPath = loadedFileName + "/" + loadedFileName; SwitchVisibility("loaded"); //read in the cast lists StreamReader file = new StreamReader(sessionPath + ".xml"); XmlReaderSettings settings = new XmlReaderSettings(); settings.ConformanceLevel = ConformanceLevel.Fragment; XmlReader reader = XmlReader.Create(file, settings); int howManyToInsert = 0; bool readHowMany = false; int index = -1; bool firstOne = true; castListTxt.Clear(); while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: // The node is an element. if (reader.Name == "int") { readHowMany = true; index++; if (!firstOne) { CastList aCastList = new CastList(this); castListArray.Add(aCastList); List<int> list = new List<int>(); showOrderPosition.Add(list); AddNewPiece(); numberOfPieces++; } else { CastList aCastList = new CastList(this); castListArray.Add(aCastList); List<int> list = new List<int>(); showOrderPosition.Add(list); numberOfPieces++; firstOne = false; } } break; case XmlNodeType.Text: //Display the text in each element. if (readHowMany) { howManyToInsert = Convert.ToInt32(reader.Value); readHowMany = false; } else { listBoxArray[index].Items.Add(reader.Value); } break; } } file = new StreamReader(sessionPath + "Titles.xml"); reader = XmlReader.Create(file, settings); index = 0; while (reader.Read()) { if (reader.NodeType == XmlNodeType.Text) { textBoxArray[index].Text = reader.Value; index++; } } file.Close(); using (StreamReader sr = new StreamReader(sessionPath + "DanceTypes.txt")) foreach (ComboBox danceType in danceTypeBoxArray) danceType.SelectedItem = sr.ReadLine(); if (File.Exists(sessionPath + "DanceTypesExtra.txt")) { using (StreamReader sr = new StreamReader(sessionPath + "DanceTypesExtra.txt")) { int i = 16; while (sr.Peek() > 0) { string extra = sr.ReadLine(); foreach (ComboBox danceType in danceTypeBoxArray) { danceType.Items[i] = extra; } i++; } } } using (StreamReader sr = new StreamReader(sessionPath + "CastList.txt")) castListTxt.Text += sr.ReadToEnd(); PopulateComboBoxes(); beingLoaded = false; firstHalfTxt.Text = (numberOfPieces / 2).ToString(); limitTxt.Text = (numberOfPieces / 4).ToString(); if (castListTxt.Lines[castListTxt.Lines.Length - 1] == "") { List<string> aList = castListTxt.Lines.ToList(); aList.RemoveAt(castListTxt.Lines.Length - 1); castListTxt.Lines = aList.ToArray(); } }
private void createBtn_Click(object sender, EventArgs e) { for (int i = 0; i < Convert.ToInt32(numPiecesTxt.Text) - 1; i++) { AddNewPiece(); CastList aCastList = new CastList(this); castListArray.Add(aCastList); List<int> list = new List<int>(); showOrderPosition.Add(list); } PopulateComboBoxes(); numberOfPieces = castListArray.Count; firstHalfTxt.Text = (numberOfPieces / 2).ToString(); limitTxt.Text = (numberOfPieces / 4).ToString(); SwitchVisibility("created"); }