Exemple #1
0
        public static string Get(string name, string colour)
        {
            string meaning = "";
            Dictionary <string, string> contentsDicationary = ContentsFileIO.Read();

            if (contentsDicationary == null)
            {
                return(null);
            }

            if (contentsDicationary.Count <= 0)
            {
                return(null);
            }

            string key = "";

            if (colour == "")
            {
                key = name;
            }
            else
            {
                key = name + "(" + colour + ")";
            }

            string value;

            if (contentsDicationary.TryGetValue(key, out value))
            {
                meaning = contentsDicationary[key];
            }
            else
            {
                MessageBox.Show("エラーが発生しました。", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }


            return(meaning);
        }
Exemple #2
0
        private void Form2_Load(object sender, EventArgs e)
        {
            Dictionary <string, string> contentsDicationary = ContentsFileIO.Read();

            foreach (KeyValuePair <string, string> s in contentsDicationary)
            {
                if (s.Key.IndexOf('(') != -1)
                {
                    char[]   spliter = { '(', ')' };
                    string[] c1      = s.Key.Split(spliter);
                    string   c2      = s.Value;
                    dataGridViewContents.Rows.Add("削除", c1[0], c1[1], c2);
                }
                else if (s.Key != null && s.Value != null)
                {
                    string c1 = s.Key;
                    string c2 = s.Value;
                    dataGridViewContents.Rows.Add("削除", c1, null, c2);
                }
            }
        }
Exemple #3
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            int           count        = dataGridViewContents.Rows.Count;
            List <string> contentsList = new List <string>();

            for (int i = 0; i < count - 1; i++)
            {
                string c1 = (string)dataGridViewContents[1, i].Value;
                string c3 = (string)dataGridViewContents[3, i].Value;
                if (dataGridViewContents[2, i].Value != null)
                {
                    string c2 = (string)dataGridViewContents[2, i].Value;
                    contentsList.Add(c1 + '(' + c2 + ')' + ',' + c3 + Environment.NewLine);
                }
                else
                {
                    contentsList.Add(c1 + ',' + c3 + Environment.NewLine);
                }
            }

            ContentsFileIO.Write(contentsList);
        }