private void FetchObjects() { listObjects = new List <SpecialObject>(); string[] fileNames = Directory.GetFiles(basePath); for (int i = 0; i < fileNames.Length; i++) { fileNames[i] = fileNames[i].Substring(fileNames[i].LastIndexOf(@"\")); } foreach (string name in fileNames) { TextReader tr = new StreamReader(basePath + name); SpecialObject obj = new SpecialObject(); obj.Title = tr.ReadLine(); obj.IsRandom = int.Parse(tr.ReadLine()) > 0 ? true : false; obj.Count = int.Parse(tr.ReadLine()); StringBuilder bobTheBuilder = new StringBuilder(); for (int i = 0; i < obj.Count; i++) { bobTheBuilder.AppendLine(tr.ReadLine()); } obj.Points = bobTheBuilder.ToString().Replace("\r", ""); obj.Points = obj.Points.Substring(0, obj.Points.Length - 1); obj.Image = StringToImage(tr.ReadToEnd()); tr.Dispose(); listBox.Items.Add(obj.Title); listObjects.Add(obj); } }
private void listExamples_SelectedIndexChanged(object sender, EventArgs e) { int index = Math.Max(0, listBox.SelectedIndex); SpecialObject obj = new SpecialObject(listObjects[index]); InfoBoxChanged(obj.IsRandom, obj.Points, obj.Image); }
private void SaveObject(SpecialObject objReceived) { string finalPath = basePath + objReceived.Title + FILE_TYPE; File.Create(finalPath).Close(); TextWriter tw = new StreamWriter(finalPath); tw.WriteLine(objReceived.Title); tw.WriteLine(Convert.ToInt32(objReceived.IsRandom).ToString()); tw.WriteLine(objReceived.Count.ToString()); tw.WriteLine(objReceived.Points); tw.WriteLine(ImageToString(new Bitmap(objReceived.Image))); selected = objReceived.Title; tw.Dispose(); }
private void GotResponse(SpecialObject obj) { txtbxTitle.Text = obj.Title; ConvertFromStringToSpecialObject(obj.Points); }
public SpecialObject(SpecialObject specialObj) : this(specialObj.Image, specialObj.Points, specialObj.Count) { Title = specialObj.Title; }
public Examples(SpecialObject savedArt, Delegate callback) : this(callback) => objReceived = new SpecialObject(savedArt);