コード例 #1
0
ファイル: Actor.cs プロジェクト: Ubersteinn/470Baconator
 public Actor(string n = "none", List<Film> f = null, TextBox output = null, ListView listview = null, ImageList imagelist = null,  bool v = false)
 {
     Name = n;
     Films = f;
     outputBox = output;
     listView = listview;
     imageList = imagelist;
     Visited = v;
     Connect = null;
 }
コード例 #2
0
ファイル: Form1.cs プロジェクト: Ubersteinn/470Baconator
        private void ImportActorsFilms()
        {
            //using (StreamReader r = new StreamReader(FilmFile))
            //{
            //    string line;
            //    int linecount = 0;
            //    while ((line = r.ReadLine()) != null)
            //    {
            //        linecount++;
            //        if (linecount % 10000 == 0)
            //        {
            //            OutputBox.AppendText(".");
            //        }

            //        films.Add(new Film(line, new List<Actor>()));

            //    }
            //}

            //OutputBox.AppendText(Environment.NewLine + "Imported Films");

            //takes our sample file and indexes it into film and actor objects
            using (StreamReader r = new StreamReader(ActorsFile))
            {
                //using (StreamWriter u = new StreamWriter(UpdatedFile))
                //{

                string line;
                bool newactor = true;
                Actor currentActor = new Actor();
                Film currentFilm = new Film();
                int linecount = 0;
                //int idcount = 0;
                int indx = 0;
                bool checkID = false;

                while ((line = r.ReadLine()) != null)
                {
                    linecount++;
                    if (linecount % 10000 == 0)
                    {
                        OutputBox.AppendText(Environment.NewLine + linecount);
                    }

                    if (line == "")
                    {
                      //  u.WriteLine("");
                        newactor = true;
                        continue;
                    }

                    if (newactor == true)
                    {
                      //  u.WriteLine(line);
                        currentActor = new Actor(line, new List<Film>(), OutputBox, listView1, imageList1);
                        actors.Add(currentActor);
                        newactor = false;
                    }
                    else
                    {
                        //u.WriteLine(line);
                        //int filmid = films.FindIndex(delegate(Film film) { return film.name.Equals(line); });

                        //if (filmid == -1)
                        //{
                            //  u.WriteLine(idcount);
                            //OutputBox.AppendText(Environment.NewLine + line + "Null when searched!!");
                            //  currentFilm = new Film(line, new List<Actor>());
                            //  films.Add(currentFilm);
                        //    idcount++;
                        //}
                        // else
                        // {
                            //   u.WriteLine(filmid);
                            //  currentFilm = films[filmid];
                        // }

                        //currentFilm.cast.Add(currentActor);
                        // currentActor.films.Add(currentFilm);
                        if (checkID == false)
                        {
                            currentFilm = new Film(line, new List<Actor>());
                            checkID = true;
                            continue;
                        }
                        if (checkID == true)
                        {
                            indx = Convert.ToInt32(line);
                            if (indx >= films.Count)
                            {
                                films.Add(currentFilm);
                            }
                            films[indx].cast.Add(currentActor);
                            currentActor.films.Add(films[indx]);
                            checkID = false;
                        }

                    }
                }
            }
            OutputBox.AppendText(Environment.NewLine + "Imported Actors");
        }