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);
                }
            }
        }