Пример #1
0
 public void clearAll()
 {
     view = null;
     Data = null;
     titleL.Text = String.Empty;
     fileL.Text = String.Empty;
     genreL.Text = String.Empty;
     ratingL.Text = String.Empty;
     yearL.Text = String.Empty;
     imageL.Text = String.Empty;
     description.Text = String.Empty;
 }
Пример #2
0
        public void editItem(simpleMovie editMovie)
        {
            this.index = dm.getIndexOf(editMovie);
            this.selected = dm.getMovie(index);
            titleT.Text = editMovie.getTitle();
            fileLocationT.Text = editMovie.File;
            genreCB.SelectedIndex = (int)editMovie.Genre;
            ratingCB.SelectedIndex = (int)editMovie.Rating;
            movieData = dm.getdata(editMovie.File);
            yearT.Text = movieData.Year.ToString();
            imageT.Text = movieData.Image;
            actors = movieData.getActors();
            actorListBox.DataSource = actors;
            descriptionT.Text = movieData.Description.Replace("\n", "\r\n");
            if (movieData.Image != "")
            {
                    try
                    {
                        Image image = Image.FromFile(@movieData.Image);
                        Rectangle newRect = ImageHandling.GetScaledRectangle(image, imageP.ClientRectangle);
                        imageP.MaximumSize = imageP.Size;

                        imageP.Image = ImageHandling.GetResizedImage(image, newRect);

                    }
                    catch (ArgumentException ae)
                    {
                        dm.ge.GlobalTryCatch(ae, movieData.Image);
                    }
                    catch (FileNotFoundException fnfe)
                    {
                        dm.ge.GlobalTryCatch(fnfe, movieData.Image);
                    }
                }
                else
                {

                }
        }
Пример #3
0
        private void doSearch(object sender, MouseEventArgs e)
        {
            searchParam = searchT.Text.Trim();
            treeList = new List<TreeNode>();
            resultList.Clear();
            resultKey.Clear();
            resultTree.Nodes.Clear();
            bool exact = false;
            string extraParams = "No additional parameters";
            if (searchParam != "")
            {
                DateTime start = DateTime.Now;
                if (searchCB.CheckedItems.Count > 0 && searchCB.CheckedIndices.Contains(0)) //Actor only search ignores all other search parameters
                {

                    extraParams = "Returing only results matching from Actor's Field";
                    DateTime startActor = DateTime.Now;
                    dm.performActorOnlySearch(searchParam, searchCB.CheckedIndices.Contains(1), ref resultList); //Determinds if each word is searched, or if exact matches are
                    DateTime endActor = DateTime.Now;
                    if ((endActor - startActor).TotalMilliseconds > 1000)
                    {
                        resultString = String.Format("{0}\r\n{1}{2}{3}", resultString, "Search Completed: ", decimal.Round((decimal)(endActor - startActor).TotalSeconds, 2, MidpointRounding.AwayFromZero), " seconds");
                    }
                    else
                    {
                        resultString = String.Format("{0}\r\n{1}0.{2}{3}", resultString, "Search Completed: ", decimal.Round((decimal)(endActor - startActor).TotalMilliseconds, 0, MidpointRounding.AwayFromZero), " seconds");
                    }
                    if (resultList.Count == 0)
                    {
                        searchCB.SetItemChecked(0, false);
                        searchCB.SetItemChecked(1, false);
                        searchCB.SetItemChecked(2, false);
                        searchCB.SetItemChecked(3, false);
                        searchButton_Click(sender, e);
                        extraParams = "No results found, performing default search";
                        resultString = String.Format("{0}{1}{2}\r\n{3}\r\n{4}\r\n", ">>> ", searchParam, " <<<", extraParams, resultString);
                        resultInfoT.SelectionStart = 0;
                        resultInfoT.SelectionLength = 0;
                        resultInfoT.SelectedText = resultString;
                        return;
                    }
                }
                else
                {
                    DateTime startSearch = DateTime.Now;
                    exactMovie = dm.performSearch(searchParam);
                    DateTime endSearch = DateTime.Now;
                    if ((endSearch - startSearch).TotalMilliseconds > 1000)
                    {
                        resultString = String.Format("{0}\r\n{1}{2}{3}", resultString, "Search Completed: ", decimal.Round((decimal)(endSearch - startSearch).TotalSeconds, 2, MidpointRounding.AwayFromZero), " seconds");
                    }
                    else
                    {
                        resultString = String.Format("{0}\r\n{1}0.{2}{3}", resultString, "Search Completed: ", decimal.Round((decimal)(endSearch - startSearch).TotalMilliseconds, 0, MidpointRounding.AwayFromZero), " seconds");
                    }

                    DateTime startRegex = DateTime.Now;
                    if (exactMovie != null)
                    {
                        exactMatch = new TreeNode(exactMovie.getTitle());
                        TreeNode[] array = new TreeNode[] { exactMatch };
                        TreeNode treeNode = new TreeNode("Exact Match", array);
                        treeNode.Expand();
                        resultTree.Nodes.Add(treeNode);
                        exact = true;
                        exactMatch.Tag = exactMovie;
                    }

                    dm.performRegexSearch(searchParam, ref resultList);
                    DateTime endRegex = DateTime.Now;
                    if ((endRegex - startRegex).TotalMilliseconds > 1000)
                    {
                        resultString = String.Format("{0}\r\n{1}{2}{3}", resultString, "Regex Search Completed: ", decimal.Round((decimal)(endRegex - startRegex).TotalSeconds, 2, MidpointRounding.AwayFromZero), " seconds");
                    }
                    else
                    {
                        resultString = String.Format("{0}\r\n{1}0.{2}{3}", resultString, "Regex Search Completed: ", decimal.Round((decimal)(endRegex - startRegex).TotalMilliseconds, 0, MidpointRounding.AwayFromZero), " seconds");
                    }

                    if (searchCB.CheckedItems.Count > 0 && searchCB.CheckedIndices.Contains(2) && !searchCB.CheckedIndices.Contains(3)) //Detailed but not advanced
                    {
                        DateTime startDetailed = DateTime.Now;
                        dm.performDetailedSearch(searchParam, ref resultList);
                        DateTime endDetailed = DateTime.Now;
                        if ((endDetailed - startDetailed).TotalMilliseconds > 1000)
                        {
                            resultString = String.Format("{0}\r\n{1}{2}{3}", resultString, "Detailed Search Completed: ", decimal.Round((decimal)(endDetailed - startDetailed).TotalSeconds, 2, MidpointRounding.AwayFromZero), " seconds");
                        }
                        else
                        {
                            resultString = String.Format("{0}\r\n{1}0.{2}{3}", resultString, "Detailed Search Completed: ", decimal.Round((decimal)(endDetailed - startDetailed).TotalMilliseconds, 0, MidpointRounding.AwayFromZero), " seconds");
                        }
                        extraParams = "Detailed but not Advanced";
                    }
                    else if (searchCB.CheckedItems.Count > 0 && searchCB.CheckedIndices.Contains(3) && !searchCB.CheckedIndices.Contains(2)) //Advanced but not detailed
                    {
                        DateTime startAdvanced = DateTime.Now;
                        dm.performAdvancedSearch(searchParam, ref resultList);
                        DateTime endAdvanced = DateTime.Now;
                        if ((endAdvanced - startAdvanced).TotalMilliseconds > 1000)
                        {
                            resultString = String.Format("{0}\r\n{1}{2}{3}", resultString, "Advanced Search Completed: ", decimal.Round((decimal)(endAdvanced - startAdvanced).TotalSeconds, 2, MidpointRounding.AwayFromZero), " seconds");
                        }
                        else
                        {
                            resultString = String.Format("{0}\r\n{1}0.{2}{3}", resultString, "Advanced Search Completed: ", decimal.Round((decimal)(endAdvanced - startAdvanced).TotalMilliseconds, 0, MidpointRounding.AwayFromZero), " seconds");
                        }
                        extraParams = "Advanced but not detailed";
                    }
                    else if (searchCB.CheckedItems.Count > 0 && searchCB.CheckedIndices.Contains(2) && searchCB.CheckedIndices.Contains(3)) //Detailed and Advanced
                    {
                        DateTime startAdvancedDetailed = DateTime.Now;
                        dm.performDetailedAdvancedSearch(searchParam, ref resultList);
                        DateTime endAdvancedDetailed = DateTime.Now;
                        if ((endAdvancedDetailed - startAdvancedDetailed).TotalMilliseconds > 1000)
                        {
                            resultString = String.Format("{0}\r\n{1}{2}{3}", resultString, "Advanced Detailed Search Completed: ", decimal.Round((decimal)(endAdvancedDetailed - startAdvancedDetailed).TotalSeconds, 2, MidpointRounding.AwayFromZero), " seconds");
                        }
                        else
                        {
                            resultString = String.Format("{0}\r\n{1}0.{2}{3}", resultString, "Advanced Detailed Search Completed: ", decimal.Round((decimal)(endAdvancedDetailed - startAdvancedDetailed).TotalMilliseconds, 0, MidpointRounding.AwayFromZero), " seconds");
                        }
                        extraParams = "Detailed and Advanced";
                    }
                }
                dm.quickSort(ref resultList);
                dm.cullSorted(ref resultList);
                DateTime buildList = DateTime.Now;
                resultList.Remove(exactMovie);
                if (resultList.Count > 0)
                {
                    TreeNode[] anotherArray;
                    int i = 0;
                    int k = 0;
                    anotherArray = new TreeNode[resultList.Count];

                    for (; i < resultList.Count; i++)
                    {
                        anotherArray[k] = new TreeNode(resultList[i].getTitle());
                        anotherArray[k].Tag = resultList[i];
                        k++;
                        resultKey.Add(i);
                    }

                    TreeNode node = new TreeNode("Partial Match", anotherArray);
                    if (!exact)
                    {
                        node.Expand();
                    }
                    resultTree.Nodes.Add(node);
                }
                DateTime builtList = DateTime.Now;
                if ((builtList - buildList).TotalMilliseconds > 1000)
                {
                    resultString = String.Format("{0}\r\n{1}{2}{3}", resultString, "List Built: ", decimal.Round((decimal)(builtList - buildList).TotalSeconds, 2, MidpointRounding.AwayFromZero), " seconds");
                }
                else
                {
                    resultString = String.Format("{0}\r\n{1}0.{2}{3}", resultString, "List Built: ", decimal.Round((decimal)(builtList - buildList).TotalMilliseconds, 0, MidpointRounding.AwayFromZero), " seconds");
                }

                if (resultList.Count == 0 && !exact)
                {
                    resultTree.Nodes.Add(new TreeNode("No Results"));
                }
                DateTime end = DateTime.Now;
                int f = 0;
                if (exactMatch != null)
                {
                    f = 1;
                    exactMatch = null;
                }
                if ((end - start).TotalMilliseconds < 1000)
                {
                    resultString = String.Format("{0}\r\n{1}{2}{3}\r\n\r\n{4}{5}\r\n", resultString, "Entire Operation: ", decimal.Round((decimal)(end - start).TotalSeconds, 2, MidpointRounding.AwayFromZero), " seconds", resultList.Count + f, " results returned");
                }
                else
                {
                    resultString = String.Format("{0}\r\n{1}{2}{3}\r\n\r\n{4}{5}\r\n", resultString, "Entire Operation: ", decimal.Round((decimal)(end - start).TotalSeconds, 0, MidpointRounding.AwayFromZero), " seconds", resultList.Count + f, " results returned");
                }

                resultString = String.Format("{0}{1}{2}\r\n{3}\r\n{4}\r\n", ">>> ", searchParam, " <<<", extraParams, resultString);
                resultInfoT.SelectionStart = 0;
                resultInfoT.SelectionLength = 0;
                resultInfoT.SelectedText = resultString;
                resultString = "";
            }
            else
            {
                resultInfoT.SelectionStart = 0;
                resultInfoT.SelectionLength = 0;
                resultInfoT.SelectedText = "Not a valid search\r\n";
            }

            exactMovie = null;
            performSearch = false;
        }
Пример #4
0
        public void viewItem(simpleMovie view)
        {
            this.view = view;
            titleL.Text = view.getTitle();
            fileL.Text = view.File;
            genreL.Text = view.Genre.ToString();
            ratingL.Text = view.Rating.ToString();

            if ((this.Data = dm.getdata(view.File)) != null)
            {
                yearL.Text = Data.Year.ToString();
                imageL.Text = Data.Image;
                description.Text = Data.Description;
                actor = null;
                actor = Data.getActors();
                actors.DataSource = null;
                actors.DataSource = actor;
                secondsIn.Text = String.Format("{0}{1}", "Time: ", Data.SecondsIn * 1000);
                string imageFile = Data.Image;
                if (imageFile == "")
                {
                    imageFile = @"noImage.png";

                }

                DoImage(imageFile, false);

            }
            else
            {
                yearL.Text = "No Year";
                imageL.Text = "No Image";
                description.Text = "No Description";
                actor.Clear();
                actor.Add("No Actors");
                actors.DataSource = null;
                actors.DataSource = actor;
            }
        }