/// <summary> /// This method uses factory shape method where the specified shape is passed and it executes them /// It not only reads numbers but also reads datatype values /// </summary> /// <param name="line"></param> /// <param name="i"></param> /// <param name="e"></param> private void validate_data(String [] line, int i, PaintEventArgs e) { if (line[i].Contains("RECTANGLE") == true) { Shape s = fact.getShape("RECTANGLE"); string errMsg = s.getData(e, line[i], i, hashtable); textBox2.Text = errMsg; } if (line[i].Contains("SQUARE") == true) { Shape s = fact.getShape("SQUARE"); string errMsg = s.getData(e, line[i], i, hashtable); textBox2.Text = errMsg; } if (line[i].Contains("TRIANGLE") == true) { Shape s = fact.getShape("TRIANGLE"); string errMsg = s.getData(e, line[i], i, hashtable); textBox2.Text = errMsg; } if (line[i].Contains("CIRCLE") == true) { Shape s = fact.getShape("CIRCLE"); string errMsg = s.getData(e, line[i], i, hashtable); textBox2.Text = errMsg; } if (line[i].Contains("++") == true) { int pFrom = line[i].IndexOf("++") + "++".Length; int pTo = line[i].LastIndexOf(";"); int res = Int32.Parse(line[i].Substring(pFrom, pTo - pFrom)); string[] hash = line[i].Split(new string[] { "++" }, StringSplitOptions.None); hash[0] = hash[0].Replace(" ", ""); try { hashtable[hash[0]] = Int32.Parse(hashtable[hash[0]] + "") + res; } catch (Exception x) { } } if (line[i].Contains("TEXTURE") == true) { Shape s = fact.getShape("TEXTURE"); string errMsg = s.getData(e, line[i], i, hashtable); textBox2.Text = errMsg; } if (line[i].Contains("INT") == true) { if (line[i].Contains("=") && line[i].Contains(";")) { int valFrom2 = line[i].IndexOf("INT") + "INT".Length; int valTo2 = line[i].LastIndexOf("="); string val1 = ""; val1 = line[i].Substring(valFrom2, valTo2 - valFrom2).Replace(" ", "");; int valFrom1 = line[i].IndexOf("=") + "=".Length; int valTo1 = line[i].LastIndexOf(";"); int val2 = 0; val2 = Int32.Parse(line[i].Substring(valFrom1, valTo1 - valFrom1)); try { hashtable.Add(val1, val2); } catch (Exception ex) { hashtable[val1] = val2; } } } }