Example #1
0
 private void frmManageFilter_Shown(object sender, EventArgs e)
 {
     lstFilter.Items.Clear();
     foreach (string k in that.Filter.Keys)
     {
         if (k == KW.CreatedTime)
         {
             continue;
         }
         MovieFilter itemFilter = null;
         try
         {
             itemFilter = JsonConvert.DeserializeObject <MovieFilter>(that.Filter[k]);
         }
         catch {
             itemFilter = null;
         }
         if (itemFilter != null)
         {
             lstFilter.Items.Add(k);
         }
     }
     if (param_IsModeSelect)
     {
         btnAdd.Text = "Select";
         that.DebugAndLog("frmManageFilter open in mode SELECT");
         txtNewFilter.Focus();
     }
     else
     {
         btnAdd.Text = "Rename";
         that.DebugAndLog("frmManageFilter open in mode MANAGE");
         lstFilter.Focus();
     }
 }
Example #2
0
 public void RefreshFilterList()
 {
     toolFilter.DropDownItems.Clear();
     foreach (string k in that.Filter.Keys)
     {
         try
         {
             MovieFilter testFilter = JsonConvert.DeserializeObject <MovieFilter>(that.Filter[k]);
             toolFilter.DropDownItems.Add(k, null, new EventHandler(toolToolFilter_Click));
         }
         catch { }
     }
     toolFilter.Enabled = (toolFilter.DropDownItems.Count > 0);
 }
Example #3
0
        private bool DoSaveSearchFilter()
        {
            that.DebugAndLog("frmSearch -> DoSaveSearchFilter()");
            MovieFilter filter     = _BuildMovieFilter();
            string      nameFilter = that.GetNewOrReplaceFilterName();

            if (nameFilter.Length < 1)
            {
                return(false);
            }

            that.Filter[nameFilter] = JsonConvert.SerializeObject(filter);
            return(that.Filter.Save());
        }
Example #4
0
        public static void ShowTab_FilterMovie(string filterKey)
        {
            if (FRM.Main == null)
            {
                return;
            }
            if (!that.Filter.Contains(filterKey))
            {
                return;
            }
            MovieFilter filter = null;

            try
            {
                filter = JsonConvert.DeserializeObject <MovieFilter>(that.Filter[filterKey]);
                that.DebugAndLog("ShowFilterMovie()->Decode filter name [" + filterKey + "] Success");
            }
            catch (Exception ex) {
                that.DebugAndLog("ShowFilterMovie()->Decode filter name [" + filterKey + "] Fail");
                that.DebugAndLog("Exception: " + ex.Message);
                return;
            }
            if (filter == null)
            {
                return;                     // Second Trap for SAFE :P
            }
            ucMovieList movieList = new ucMovieList();

            movieList.Dock     = DockStyle.Fill;
            movieList.Location = new Point(0, 0);
            movieList.OnDoubleClickMovieList += new WhenDoubleClickMovieList(movieList_OnDoubleClickMovieList);
            movieList.OnKeyUpMovieList       += new WhenKeyUpMovieList(movieList_OnKeyUpMovieList);


            TabPage newTabPage = new TabPage();

            newTabPage.Tag = new string[] {
                "filter_movie",
                "Filter Movie"
            };
            newTabPage.Controls.Add(movieList);

            FRM.Main.tabMain.TabPages.Add(newTabPage);
            FRM.Main.tabMain.SelectedTab = newTabPage;
            FRM.Main.generateTabFunctionKey();

            movieList.RefreshMovieList(MovieDB.GetMovieList(filter), "Filter Movie by [" + filterKey + "]");
        }
Example #5
0
        private void _DoApplySearchResult(MovieFilter filter)
        {
            that.DebugAndLog("frmMovieStat -> DoApplySearchResult()");
            List <MovieProfile> movieList = MovieDB.GetMovieList(filter);

            that.DebugAndLog("Total movie got from MovieDB = " + movieList.Count.ToString());

            string descMovie = "Filter: "
                               + ((filter.NeedCheckCode()) ? ("Code, ") : (""))
                               + ((filter.NeedCheckTitle()) ? ("Title, ") : (""))
                               + ((filter.NeedCheckStory()) ? ("Story, ") : (""))
                               + ((filter.NeedCheckType()) ? ("Type, ") : (""))
                               + ((filter.NeedCheckRating()) ? ("Rating, ") : (""))
                               + ((filter.NeedCheckCountry()) ? ("Country, ") : (""))
                               + ((filter.NeedCheckFileConnect()) ? ("FileConnect, ") : (""))
                               + ((filter.NeedCheckActress()) ? ("Actress, ") : (""))
                               + ((filter.NeedCheckTag()) ? ("Tag, ") : (""))
                               + ((filter.NeedCheckCountPlay()) ? ("CountPlay, ") : (""))
                               + ((filter.NeedCheckFilePath()) ? ("FilePath, ") : (""))
            ;

            __RefreshSearchResult(movieList, descMovie);
        }
Example #6
0
        private void DoSearchMovieByDetail()
        {
            that.DebugAndLog("Do SearchMovieByTopic: [" + CurrentTopic + "] Detail: [" + lvwDetail.SelectedItems[0].Text + "]");

            MovieFilter mFilter  = new MovieFilter();
            string      KeyWord1 = lvwDetail.SelectedItems[0].Text;
            string      KeyWord2 = lvwDetail.SelectedItems[0].SubItems[0].Text;

            switch (CurrentTopic)
            {
            case "General":
                switch (KeyWord1.ToLower())
                {
                case kwTotalMovieProfile:                       // No Filter
                    break;

                case kwLocalProfile:                            // Have FilePath!
                    mFilter.FileConnect.Add("Y");
                    mFilter.FileConnect.Add("N");
                    break;

                case kwFileOnLine:                              // File Can Acess
                    mFilter.FileConnect.Add("Y");
                    break;

                case kwFileOffLine:                             // File Cannot Access
                    mFilter.FileConnect.Add("N");
                    break;

                case kwFileUnknow:                              // New Add File Unknow Status
                    mFilter.FileConnect.Add("?");
                    break;

                case kwGlobalProfile:                           // No FilePath! So GlobalProfile
                    mFilter.FileConnect.Add("G");
                    break;

                default:
                    that.DebugAndLog("Nothing Math for KeyWord1=[" + KeyWord1 + "]");
                    break;
                }
                break;

            case "Type": mFilter.Type.Add(KeyWord1);    break;

            case "Country": mFilter.Country.Add(KeyWord1); break;

            case "Rating": mFilter.Rating.Add(int.Parse(KeyWord1)); break;

            case "Actress": mFilter.Actress.Add(KeyWord1); break;

            case "Tag": mFilter.Tag.Add(KeyWord1); break;

            case "FilePath": mFilter.FilePath = KeyWord1; break;

            case "CountPlay": mFilter.MinCountPlay = mFilter.MaxCountPlay = KeyWord1; break;

            // --------- Unknow What TOPIC???
            default:
                return;
            }
            _DoApplySearchResult(mFilter);
        }
Example #7
0
        public static List <MovieProfile> GetMovieList(MovieFilter filter)
        {
            List <MovieProfile> curList = new List <MovieProfile>();

            lock (MovieDB.hMovie.SyncRoot)
            {
                foreach (DictionaryEntry kv in hMovie)
                {
                    curList.Add((MovieProfile)kv.Value);
                }
            }

            if (filter.NeedCheckCode())
            {
                that.DebugAndLog("MovieDB.GetMovieList():: filter->CheckCode");
                if (filter.IsEmptyCode)
                {
                    for (int i = curList.Count - 1; i >= 0; i--)
                    {
                        if (!curList[i].Code.Length.Equals(0))
                        {
                            curList.RemoveAt(i);
                        }
                    }
                }
                else
                {
                    string keyword = filter.Code.Trim().ToUpper();
                    for (int i = curList.Count - 1; i >= 0; i--)
                    {
                        if (!curList[i].Code.Contains(keyword))
                        {
                            curList.RemoveAt(i);
                        }
                    }
                }
            }
            if (filter.NeedCheckTitle())
            {
                that.DebugAndLog("MovieDB.GetMovieList():: filter->CheckTitle");
                if (filter.IsEmptyTitle)
                {
                    for (int i = curList.Count - 1; i >= 0; i--)
                    {
                        if (!curList[i].Title.Length.Equals(0))
                        {
                            curList.RemoveAt(i);
                        }
                    }
                }
                else
                {
                    string keyword = filter.Title.Trim();
                    for (int i = curList.Count - 1; i >= 0; i--)
                    {
                        if (!curList[i].Title.Contains(keyword))
                        {
                            curList.RemoveAt(i);
                        }
                    }
                }
            }
            if (filter.NeedCheckStory())
            {
                that.DebugAndLog("MovieDB.GetMovieList():: filter->CheckStory");
                if (filter.IsEmptyStory)
                {
                    for (int i = curList.Count - 1; i >= 0; i--)
                    {
                        if (!curList[i].Story.Length.Equals(0))
                        {
                            curList.RemoveAt(i);
                        }
                    }
                }
                else
                {
                    string keyword = filter.Story.Trim();
                    for (int i = curList.Count - 1; i >= 0; i--)
                    {
                        if (!curList[i].Story.Contains(keyword))
                        {
                            curList.RemoveAt(i);
                        }
                    }
                }
            }
            if (filter.NeedCheckType())
            {   // Include one of filter.Type
                that.DebugAndLog("MovieDB.GetMovieList():: filter->CheckType");
                for (int i = curList.Count - 1; i >= 0; i--)
                {
                    if (!filter.Type.Contains(curList[i].Type))
                    {
                        curList.RemoveAt(i);
                    }
                }
            }
            if (filter.NeedCheckRating())
            {   // Include one of filter.Rating
                that.DebugAndLog("MovieDB.GetMovieList():: filter->CheckRating");
                for (int i = curList.Count - 1; i >= 0; i--)
                {
                    if (!filter.Rating.Contains(curList[i].Rating))
                    {
                        curList.RemoveAt(i);
                    }
                }
            }
            if (filter.NeedCheckCountry())
            {
                that.DebugAndLog("MovieDB.GetMovieList():: filter->CheckCountry");
                for (int i = curList.Count - 1; i >= 0; i--)
                {
                    if (!filter.Country.Contains(curList[i].Country))
                    {
                        curList.RemoveAt(i);
                    }
                }
            }
            if (filter.NeedCheckActress())
            {   // Find any actress match filter
                that.DebugAndLog("MovieDB.GetMovieList():: filter->CheckActress");
                if (filter.IsNoActress)
                {
                    for (int i = curList.Count - 1; i >= 0; i--)
                    {
                        if (curList[i].Actress.Length > 0)
                        {
                            curList.RemoveAt(i);
                        }
                    }
                }
                else
                {
                    string[] keywords = filter.Actress.ToArray();
                    for (int i = 0; i < keywords.Length; i++)
                    {
                        keywords[i] = keywords[i].ToUpper();
                    }
                    bool isFound;
                    for (int i = curList.Count - 1; i >= 0; i--)
                    {
                        isFound = false;
                        for (int k = 0; k < keywords.Length; k++)
                        {
                            if (curList[i].FoundActress(keywords[k]))
                            {
                                isFound = true;
                                break;
                            }
                        }
                        if (isFound)
                        {
                            continue;
                        }
                        curList.RemoveAt(i);    // Not Found of any keyword
                    }
                }
            }
            if (filter.NeedCheckTag())
            {
                that.DebugAndLog("MovieDB.GetMovieList():: filter->CheckTag");
                if (filter.IsNoTag)
                {
                    for (int i = curList.Count - 1; i >= 0; i--)
                    {
                        if (curList[i].Tag.Length > 0)
                        {
                            curList.RemoveAt(i);
                        }
                    }
                }
                else
                {
                    string[] keywords = filter.Tag.ToArray();
                    for (int i = 0; i < keywords.Length; i++)
                    {
                        keywords[i] = keywords[i].ToLower();
                    }
                    bool isFound;
                    for (int i = curList.Count - 1; i >= 0; i--)
                    {
                        isFound = false;
                        for (int k = 0; k < keywords.Length; k++)
                        {
                            if (curList[i].Tag.Contains(keywords[k]))
                            {
                                isFound = true;
                                break;
                            }
                        }
                        if (isFound)
                        {
                            continue;
                        }
                        curList.RemoveAt(i);    // Not Found of any keyword
                    }
                }
            }
            if (filter.NeedCheckFileConnect())
            {
                that.DebugAndLog("MovieDB.GetMovieList():: filter->CheckFileConnect");
                string[] keywords = filter.FileConnect.ToArray();
                for (int i = 0; i < keywords.Length; i++)
                {
                    keywords[i] = keywords[i].ToUpper();
                }
                bool isFound;
                for (int i = curList.Count - 1; i >= 0; i--)
                {
                    isFound = false;
                    for (int k = 0; k < keywords.Length; k++)
                    {
                        if (curList[i].FileConnect.Equals(keywords[k]))
                        {
                            isFound = true;
                            break;
                        }
                    }
                    if (isFound)
                    {
                        continue;
                    }
                    curList.RemoveAt(i);    // Not found of any keyword
                }
            }
            if (filter.NeedCheckNoFilePath())
            {   // Have no FilePath
                that.DebugAndLog("MovieDB.GetMovieList():: filter->CheckNoFilePath");
                for (int i = curList.Count - 1; i >= 0; i--)
                {
                    if (curList[i].FilePath.Length > 0)
                    {
                        curList.RemoveAt(i);
                    }
                }
            }
            if (filter.NeedCheckCountPlay())
            {   // Count play in range of Min & Max
                that.DebugAndLog("MovieDB.GetMovieList:: filter->CheckCountPlay");
                if (filter.MinCountPlay.Length > 0)
                {
                    long minPlay = long.Parse(filter.MinCountPlay);
                    for (int i = curList.Count - 1; i >= 0; i--)
                    {
                        if (curList[i].CountPlay < minPlay)
                        {
                            curList.RemoveAt(i);
                        }
                    }
                }
                if (filter.MaxCountPlay.Length > 0)
                {
                    long maxPlay = long.Parse(filter.MaxCountPlay);
                    for (int i = curList.Count - 1; i >= 0; i--)
                    {
                        if (curList[i].CountPlay > maxPlay)
                        {
                            curList.RemoveAt(i);
                        }
                    }
                }
            }
            if (filter.NeedCheckFilePath())
            {   // Check Have FilePath in Last Path
                that.DebugAndLog("MovieDB.GetMovieList:: filter->CheckFilePath");
                string keyword = filter.FilePath.ToLower();
                for (int i = curList.Count - 1; i >= 0; i--)
                {
                    if (!curList[i].FilePath.ToLower().Contains(keyword))
                    {
                        curList.RemoveAt(i);
                    }
                }
            }


            return(curList);
        }
Example #8
0
        private MovieFilter _BuildMovieFilter()
        {
            MovieFilter filter = new MovieFilter();

            // CODE
            filter.IsEmptyCode = chkCodeEmpty.Checked;
            if (!filter.IsEmptyCode)
            {
                filter.Code = txtCode.Text.Trim().ToUpper();
            }

            // TITLE
            filter.IsEmptyTitle = chkTitleEmpty.Checked;
            if (!filter.IsEmptyTitle)
            {
                filter.Title = txtTitle.Text.Trim();
            }

            // STORY
            filter.IsEmptyStory = chkStoryEmpty.Checked;
            if (!filter.IsEmptyStory)
            {
                filter.Story = txtStory.Text.Trim();
            }

            // TYPE
            filter.Type = new List <string>();
            foreach (object obj in checkListType.CheckedItems)
            {
                filter.Type.Add((string)obj);
            }

            // RATING
            filter.Rating = new List <int>();
            foreach (object obj in checkListRating.CheckedItems)
            {
                filter.Rating.Add(int.Parse((string)obj));
            }

            // COUNTRY
            filter.Country = new List <string>();
            foreach (object obj in checkListCountry.CheckedItems)
            {
                filter.Country.Add((string)obj);
            }

            // ACTRESS
            filter.Actress     = new List <string>();
            filter.IsNoActress = (chkNoActress.Checked);
            if (!filter.IsNoActress)
            {
                foreach (object obj in checkListActress.CheckedItems)
                {
                    filter.Actress.Add((string)obj);
                }
            }

            // TAG
            filter.Tag     = new List <string>();
            filter.IsNoTag = (chkNoTag.Checked);
            if (!filter.IsNoTag)
            {
                foreach (object obj in checkListTag.CheckedItems)
                {
                    filter.Tag.Add((string)obj);
                }
            }

            // FileConnect
            filter.FileConnect = new List <string>();
            foreach (object obj in checkListFileConnect.CheckedItems)
            {
                filter.FileConnect.Add((string)obj);
            }

            // NoFilePath
            filter.IsNoFilePath = chkNoFilePath.Checked;

            // CountPlay
            if (txtMinCountPlay.Text.Trim().Length > 0)
            {
                try
                {
                    long minPlay = long.Parse(txtMinCountPlay.Text);
                    if (minPlay >= 0)
                    {
                        filter.MinCountPlay = minPlay.ToString();
                    }
                }
                catch { filter.MinCountPlay = ""; }
            }
            if (txtMaxCountPlay.Text.Trim().Length > 0)
            {
                try
                {
                    long maxPlay = long.Parse(txtMaxCountPlay.Text);
                    if (maxPlay >= 0)
                    {
                        filter.MaxCountPlay = maxPlay.ToString();
                    }
                }
                catch { filter.MaxCountPlay = ""; }
            }

            // FilePath
            if (txtFilePath.Text.Trim().Length > 0)
            {
                filter.FilePath = txtFilePath.Text.Trim();
            }


            /////// Everything OK /////////////
            return(filter);
        }