Example #1
0
        private void readData()
        {

            XmlDocument xml = new XmlDocument();

           

            xml.Load(file);
            XmlNodeList xnList = xml.SelectNodes("movielist/movie");

            foreach (XmlNode xn in xnList)
            {
                if (xn.Name == "movie")
                {
                    xn.SelectNodes("movie");
                    Movie nMovie = new Movie();
                    count++;
                    List<String> actors = new List<String>();
                    List<String> genres = new List<String>();

                    foreach (XmlNode xnchild in xn)
                    {
                        if (xnchild.NodeType == XmlNodeType.Element)
                        {
                            switch (xnchild.Name)
                            {
                                case "title":
                                    nMovie.Title = xnchild.InnerText;
                                    suggestions.Add(xnchild.InnerText);
                                    break;
                                case "year":
                                    nMovie.Year = xnchild.InnerText.Trim();
                                    break;
                                case "actor":
                                     actors.Add(xnchild.InnerText);
                                    suggestions.Add(xnchild.InnerText);
                                    break;
                                case "certification":
                                    nMovie.Certification = xnchild.InnerText.Trim();
                                    break;
                                case "rating":
                                    nMovie.Rating = xnchild.InnerText.Trim();
                                    break;
                                case "length":
                                    nMovie.Time = xnchild.InnerText;
                                    break;
                                case "genre":
                                    genres.Add(xnchild.InnerText.Trim());
                                    break;
                                case "director":
                                    nMovie.Director = xnchild.InnerText;
                                    suggestions.Add(xnchild.InnerText);
                                    break;
                                case "data":
                                    if (xnchild.InnerText.Substring(0, 1) == "1")
                                        nMovie.watchList = true;
                                    break;
                            }
                        }
                    }
                    nMovie.Actor = actors.ToArray();
                    nMovie.Genre = genres.ToArray();

                    ListViewItem item = new ListViewItem(nMovie.Title);
                    item.SubItems.Add(nMovie.Year);
                    item.SubItems.Add(nMovie.Time);
                    item.SubItems.Add(nMovie.Certification);
                    item.SubItems.Add(nMovie.Director);
                    item.SubItems.Add(nMovie.Rating);
                    movieList.Items.Add(item);
                    if (nMovie.watchList)
                    {
                        ListViewItem item2 = new ListViewItem(nMovie.Title);
                        item2.SubItems.Add(nMovie.Year);
                        item2.SubItems.Add(nMovie.Time);
                        item2.SubItems.Add(nMovie.Certification);
                        item2.SubItems.Add(nMovie.Director);
                        item2.SubItems.Add(nMovie.Rating);
                        
                        WatchlistView.Items.Add(item2);
                    }
                    Movies.Add(nMovie);
                   
                }
            }

            var source = new AutoCompleteStringCollection();

            
            source.AddRange(suggestions.ToArray());
            searchBox.AutoCompleteCustomSource = source;
            searchBox.AutoCompleteMode = AutoCompleteMode.Suggest;
            searchBox.AutoCompleteSource = AutoCompleteSource.CustomSource;
            
            DTitle.Text = count + " items";
        }
Example #2
0
        private void AESave_Click(object sender, EventArgs e)
        {
            AddEditPanel_Validating(sender, e);

            if (textBox1.Text.Length != 0 && comboBox1.Text.Length != 0
                && textBox3.Text.Length != 0 && textBox4.Text.Length != 0
                && comboBox3.Text.Length != 0)
            {
                Movie movie = new Movie();
                movie.Title = textBox1.Text;
                movie.Year = comboBox1.Text;
                movie.Rating = numericUpDown1.Value + "";
                movie.Director = textBox3.Text;
                movie.Time = textBox2.Text;
                movie.Certification = comboBox2.Text;

                String[] actor = new String[5];
                String[] genre = new String[5];

                actor[0] = textBox4.Text;

                if (textBox5 != null)
                    actor[1] = textBox5.Text;
                if (textBox6 != null)
                    actor[2] = textBox6.Text;
                if (textBox7 != null)
                    actor[3] = textBox7.Text;
                if (textBox8 != null)
                    actor[4] = textBox8.Text;

                genre[0] = comboBox3.Text;

                if (comboBox4 != null)
                    genre[1] = comboBox4.Text;
                if (comboBox5 != null)
                    genre[2] = comboBox5.Text;
                if (comboBox6 != null)
                    genre[3] = comboBox6.Text;
                if (comboBox7 != null)
                    genre[4] = comboBox7.Text;

                movie.Actor = actor;
                movie.Genre = genre;

              

                if (editing)
                {
                    Movies[selectedindex] = movie;
                    movieList.Items.RemoveAt(listselectedindex);
                }
                else
                {
                    Movies.Add(movie);
                    suggestions.Add(movie.Title);
                    suggestions.Add(movie.Director);
                    suggestions.Add(movie.Actor[0]);
                    update(movie.Title + " was added");
                }

                ListViewItem item = new ListViewItem(movie.Title);
                item.SubItems.Add(movie.Year);
                item.SubItems.Add(movie.Time);
                item.SubItems.Add(movie.Certification);
                item.SubItems.Add(movie.Director);
                item.SubItems.Add(movie.Rating);

                if ((listselectedindex % 2) != 0)
                {
                    item.BackColor = Color.LightGray;
                }

                movieList.Items.Add(item);

                clear();
                var source = new AutoCompleteStringCollection();
                source.AddRange(suggestions.ToArray());
                searchBox.AutoCompleteCustomSource = source;
                searchBox.AutoCompleteMode = AutoCompleteMode.Suggest;
                searchBox.AutoCompleteSource = AutoCompleteSource.CustomSource;
            }
            AddEditPanel.SendToBack();
        }
Example #3
0
        private void editMovie(Movie movie)
        {
            textBox1.Text = movie.Title;
            comboBox1.Text = movie.Year;
            numericUpDown1.Value = movie.Irate;
            textBox2.Text = movie.Time ;
            textBox3.Text = movie.Director ;
            comboBox2.Text = movie.Certification;

            textBox4.Text = movie.Actor[0];

            if(movie.Actor.Length > 1)
                textBox5.Text = movie.Actor[1];
            if (movie.Actor.Length > 2)
                textBox6.Text = movie.Actor[2];
            if (movie.Actor.Length > 3)
                textBox6.Text = movie.Actor[3];
            if (movie.Actor.Length > 4)
                textBox7.Text = movie.Actor[4];

            
            comboBox3.Text = movie.Genre[0];

            if (movie.Genre.Length > 1)
                comboBox4.Text = movie.Genre[1];
            if (movie.Genre.Length > 2)
                comboBox5.Text = movie.Genre[2];
            if (movie.Genre.Length > 3)
                comboBox6.Text = movie.Genre[3];
            if (movie.Genre.Length > 4)
                comboBox7.Text = movie.Genre[4];

            AddEditPanel.BringToFront();
            AddEditlabel.Text = "Edit Movie";
        }
Example #4
0
        //Preview movies
        public void preview(Movie movie)
        {
            previewPanel.BringToFront();
            PreviewTitle.Text = movie.Title;
            PreviewYear.Text = movie.Year;
            previewDirector.Text = movie.Director;
            previewCert.Text = movie.Certification;
            previewRating.Text = movie.Irate + "/" + "10";
            PreviewTime.Text = movie.Time;

            String genres = "";
            String actors = "";
            for (int i = 0; i < movie.Genre.Length && movie.Genre[i] != "" ; i++)
            {
                genres += (i + 1 < movie.Genre.Length) ? movie.Genre[i] + " | "
                    : movie.Genre[i] + ".";
            }
            for (int i = 0; i < movie.Actor.Length && movie.Actor[i] != ""; i++)
            {
                actors += (1 + i < movie.Actor.Length) ? movie.Actor[i] + ", "
                    : movie.Actor[i] + ".";
            }

            previewActors.Text = actors;
            PreviewGenre.Text = genres;

            if (movie.Like)
            {
                previewLike.Image = imageList1.Images[1];
            }
            else
            {
                previewLike.Image = imageList1.Images[0];
            }

            if (movie.watchList)
            {
                prevAddWatchlist.Text = "Remove Watchlist";
            }
            else
            {
                prevAddWatchlist.Text = "Add To WatchList";
            }
        }
Example #5
0
        private void showMovie(Movie movie)
        {
            
            Graphics g = MapPreview.CreateGraphics();
            g.Clear(Color.WhiteSmoke);

            using (Font myFont = new Font("Arial", 11, FontStyle.Bold))
            { g.DrawString(TruncateAtWord(movie.Title, MapPreview.Width - 30), myFont, Brushes.Black, new PointF(10, 10)); }

            using (Font myFont = new Font("Arial", 8))
            {
                g.DrawString("Director: " + movie.Director, myFont, Brushes.Black, new PointF(10, 30));
                g.DrawString("Year: " + movie.Year, myFont, Brushes.Black, new PointF(10, 45));

                if (movie.Certification != null)
                {
                    int size = (movie.Certification.Length == 1) ? 14 : (movie.Certification.Length == 2) ?
                        22 : (movie.Certification.Length * 8);
                    g.DrawRectangle(Pens.Red, 110, 45, size, 15);
                    g.DrawString(movie.Certification, myFont, Brushes.Black, new PointF(110, 45));
                }

                g.DrawString("Rating: " + movie.Rating, myFont, Brushes.Black, new PointF(10, 60));
                g.DrawString("Length: " + movie.Time, myFont, Brushes.Black, new PointF(10, 75));

                int i = 90;
                g.DrawString("Genre: ", myFont, Brushes.Black, new PointF(10, i));
                foreach (String str in movie.Genre)
                {
                    g.DrawString(str, myFont, Brushes.Black, new PointF(10, i += 15));
                }

                i = 90;
                g.DrawString("Actor: ", myFont, Brushes.Black, new PointF(110, i));

                foreach (String str in movie.Actor)
                {
                    g.DrawString(str, myFont, Brushes.Black, new PointF(110, i += 15));
                }
            }
        }
Example #6
0
        private Boolean filter(Movie movie)
        {
            Boolean result = false;

            //check Iyear
            if (Int32.Parse(YearFrom.Text) <= movie.Iyear && movie.Iyear <= Int32.Parse(YearTo.Text))
            {
                result = true;
            }
            //check rating
            if (RatingGuage.Text == "<=" && result)
            {
                if (movie.Irate <= RatingMeter.Value)
                    result = true && result;
                else
                    result = false;
            }else
                if (RatingGuage.Text == ">=" && result)
                {
                    if (movie.Irate >= RatingMeter.Value)
                        result = true && result;
                    else
                        result = false;
                }
                else
                {
                    if (movie.Irate == RatingMeter.Value)
                        result = true;
                    else
                        result = false;
                }
            //check certification
            if (selectAll.Checked)
            {
                result = true && result;
            }
            else
            {
            if (G.Checked && movie.Certification == "G")
            {
               result = true && result;
            }
            else
            if (PG.Checked && movie.Certification == "PG")
            {
               result = true && result;
            }
            else
            if (PG13.Checked && movie.Certification == "PG-13")
            {
                result = true && result;
            }
            else
            if (R.Checked && movie.Certification == "R")
            {
                 result = true && result;
            }
            else
            if (Approved.Checked && movie.Certification == "Approved")
            {
                result = true && result;
            }
            else
            if (NC17.Checked && movie.Certification == "NC-17")
            {
                result = true && result;
            }
            else
            if (GP.Checked && movie.Certification == "GP")
            {
               result = true && result;
            }
            else
            if (Unrated.Checked && movie.Certification == "Unrated")
            {
                result = true && result;
            }
            else
            if (Passed.Checked && movie.Certification == "Passed")
            {
                result = true && result;
            }
            else
            if (Not.Checked && movie.Certification == "Not")
            {
                result = true && result;
            }
            else
            if (X.Checked && movie.Certification == "X")
            {
               result = true && result;
            }
            else
            if (TVG.Checked && movie.Certification == "TV-G")
            {
               result = true && result;
            }
            else
            if (TVMA.Checked && movie.Certification == "TV-MA")
            {
               result = true && result;
            }
            else
            if (TV14.Checked && movie.Certification == "TV-14")
            {
                 result = true && result;
            }
            else
                if (NLA.Checked && movie.Certification == null)
                {
                        result = true && result;
                }
                else
                {
                    result = false;
                }
                
            }
            //check Time
            if (TimeGuage.Text == "<=" && movie.Itime <= range)
            {
                result = true && result;
            }
            else
                if (TimeGuage.Text == ">=" && movie.Itime >= range)
                {
                        result = true && result;
                }
                else
                    if (movie.Itime == range)
                    {
                        result = true && result;
                    }
                    else
                    {
                        result = false;
                    }
            //check Title
            if (!allTitle)
            {
                if (titleIndex == 0 && Convert.ToChar(movie.Title.Substring(0, 1)) < 'A')
                {
                    result = true && result;
                }
                else
                    if (Convert.ToChar(movie.Title.Substring(0, 1)) == AtoZ[titleIndex])
                    {
                        result = true && result;
                    }
                    else
                    {
                        result = false;
                    }
            }

            //check Director
            if (!allDirector)
            {
                if (Convert.ToChar(movie.Director.Substring(0, 1)) == AtoZ[directorIndex])
                {
                    result = true && result;
                }
                else
                {
                    result = false;
                }
            }
            //Actors
            if (!allActor)
            {
                int x = 0;
                Boolean yes = false;
                while (x < movie.Actor.Length && !yes)
                {
                    if (Convert.ToChar(movie.Actor[x].Substring(0, 1)) == AtoZ[actorIndex])
                    {                  
                        yes = true;
                    }
                    x++;
                }
                result = yes && result;
            }
            if (comboBox8.Text == "All")
            {
                result = true && result;
            }
            else
            {
                int y = 0;
                Boolean yes = false;
                while (y < movie.Genre.Length && !yes)
                {
                    String value = comboBox8.Text;
                    if (value == movie.Genre[y])
                    {
                        yes = true;
                    }
                    y++;
                }
                if (yes)
                    result = yes && result;
                else
                    result = false;
            }
            return result;
        }