Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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();
        }
Ejemplo n.º 4
0
 private void GotResponse(SpecialObject obj)
 {
     txtbxTitle.Text = obj.Title;
     ConvertFromStringToSpecialObject(obj.Points);
 }
Ejemplo n.º 5
0
 public SpecialObject(SpecialObject specialObj) : this(specialObj.Image, specialObj.Points, specialObj.Count)
 {
     Title = specialObj.Title;
 }
Ejemplo n.º 6
0
 public Examples(SpecialObject savedArt, Delegate callback) : this(callback) => objReceived = new SpecialObject(savedArt);