There is a program that generates code by two selected parameters (color and capital). The parameters themselves are stored in a text file, in the form of color format lines : small capital: link .
Example:
102:classic:capitels/0206102.png 103:nonstandard1:capitels/0301103.png 104:seriya:capitels/0405104.png Some capitals are missing in certain colors. In this case, it is necessary for the program to print a specific string.
Program:
List<string> data = new List<string>(); string[] chosen_colors; string[] chosen_caps; public Form1() { InitializeComponent(); var splitChars = new[] { ':' }; try { data = File.ReadLines("config.txt").ToList(); } catch (Exception e) { MessageBox.Show("Файл конфигурации не найден:\n" + e.Message); } } private void generate_Click(object sender, EventArgs e) { chosen_colors = colorsList.CheckedItems.OfType<string>().ToArray(); chosen_caps = capList.CheckedItems.OfType<string>().ToArray(); foreach (string cap in chosen_caps) { code.Text += "'" + cap + "': {\n"; foreach (string s in data) { string[] array = s.Split(new char[] { ':' }, 3); if (array[1] == cap) { foreach (string chosenColor in chosen_colors) { if (array[0] == chosenColor) code.Text += "\t'" + array[0] + "':'" + array[2] + "',\n"; } } } code.Text += "},\n"; } } Those. Now, if the selected capitals are not in color 102, then the program will not output anything. I also need to display a string of the form '102': '/no-capitel.png' , how to write a check for the absence of a selected capital in a certain color?
I hope explained clearly
|- Cerbo