Пример #1
0
        public static void ShowWin_ParseProfileFromDirectory(string dirName)
        {
            string[] listFile            = Directory.GetFiles(dirName, "*.*");
            int      FileInFolder        = 0;
            int      FileMovieWithHash   = 0;
            int      FileMovieHadProfile = 0;
            int      FileMovieNewProfile = 0;

            for (int i = 0; i < listFile.Length; i++)
            {
                if (!File.Exists(listFile[i]))
                {
                    continue;
                }
                FileInFolder++;
                MovieProfile profile = new MovieProfile(listFile[i]);
                if (profile.Hash.Length.Equals(32))
                {
                    FileMovieWithHash++;
                    if (MovieDB.hMovie.ContainsKey(profile.Hash))
                    {
                        FileMovieHadProfile++;

                        // Add and Replase existing profile 's filePath with new import
                        MovieProfile existingProfile = (MovieProfile)MovieDB.hMovie[profile.Hash];
                        existingProfile.FilePath = profile.FilePath;
                        if (MovieDB.SaveMovieProfile(existingProfile))
                        {
                            that.DebugAndLog("Update existing Profile [" + existingProfile.Hash + "] to MovieDB success");
                        }
                    }
                    else
                    {
                        FileMovieNewProfile++;
                        if (MovieDB.SaveMovieProfile(profile))
                        {
                            that.DebugAndLog("Save new Profile [" + profile.Hash + "] to MovieDB success");
                        }
                    }
                }
            }
            MessageBox.Show(
                "Finish Import MovieProfile from Folder:" + "\r\n" +
                "Total File in Folder = " + FileInFolder.ToString() + "\r\n" +
                "File Movie with Hash = " + FileMovieWithHash.ToString() + "\r\n" +
                "File Movie update Profile = " + FileMovieHadProfile.ToString() + "\r\n" +
                "File Movie new Profile = " + FileMovieNewProfile.ToString()
                );
        }
Пример #2
0
        private void _Do_SelectAdd_ScreenShot2()
        {
            OpenFileDialog openFile = new OpenFileDialog();

            openFile.CheckFileExists = true;
            openFile.Filter          = "Image File (*.jpg, *.jpeg)|*.jpg;*.jpeg";
            if (openFile.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (MovieDB.SaveMovieImage_ScreenShot2(openFile.FileName, this.param_MovieProfile))
                {
                    RefreshTabMovieImage(4);
                    __TryDeletePictureFileIfConfig(openFile.FileName);
                }
            }
        }
Пример #3
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 + "]");
        }
Пример #4
0
        private void _Do_UseThisFile()
        {
            if (MovieDB.hMovie.Contains(param_MovieProfile.Hash))
            {
                that.DebugAndLog("Update MovieProfile{" + param_MovieProfile.Hash + "} with Path=" + param_MovieProfile.FilePath);
                MovieProfile mProfile = (MovieProfile)MovieDB.hMovie[param_MovieProfile.Hash];
                mProfile.FilePath = param_MovieProfile.FilePath;
                if (!mProfile.RenameFileToAttribute())
                {
                    that.DebugAndLog("Error in Remame file to Attribute: " + param_MovieProfile.FilePath + ")");
                    MessageBox.Show("Error in Remame file to Attribute\r\nMaybe file is in-use?", "Error!", MessageBoxButtons.OK);
                    return;
                }
                MovieDB.SaveMovieProfile(mProfile);

                that.ShowWin_MovieProfile(mProfile);
                _Do_CloseForm();
            }
        }
Пример #5
0
        private bool _Do_SaveMovieProfile()
        {
            //-- Flush data in edit control to Object
            __FlushProfileAttributeToObjectMovieProfile();

            //-- Check Hash Key
            if (!param_MovieProfile.Hash.Length.Equals(32))
            {
                MessageBox.Show(
                    "Please build HASH of first first\nMovieProfile use HASH as key-index",
                    "Need Hash!", MessageBoxButtons.OK);
                btnSave.Enabled  = true;
                btnClose.Enabled = true;
                that.DebugAndLog("User try to save MovieProfile while HASH is empty!");
                return(false);
            }

            //-- Try RenameFileToAttribute
            if (!__TryRenameFileToAttribute())
            {
                return(false);
            }

            //--- Try SaveMovieProfile
            if (MovieDB.SaveMovieProfile(param_MovieProfile))
            {
                zLog.Write("frmMovieProfile->btnSave_Click(): Save Success");
                if (param_MovieList != null)
                {
                    // update data in MovieList
                    param_MovieList._UpdateMovieProfileInList(param_MovieProfile);
                }
                return(true);  // No need to process any more
            }
            else
            {
                that.DebugAndLog("Error in SaveMovieProfile()");
                MessageBox.Show("Error in MovieDB.SaveMovieProfile()!");
                return(false);
            }
        }
Пример #6
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);
        }
Пример #7
0
        private void _Do_DeleteLastFilePath()
        {
            if (this.param_isNewImport)
            {
                MessageBox.Show("Cannot use this function with New Import File");
                return;
            }
            if (this.param_MovieProfile.Hash.Length != 32)
            {
                MessageBox.Show("Please Build HASH first...");
                return;
            }
            string hKey      = this.param_MovieProfile.Hash;
            bool   isContain = false;

            lock (MovieDB.hMovie.SyncRoot) { isContain = MovieDB.hMovie.Contains(hKey); }
            if (!isContain)
            {
                MessageBox.Show("This Profile is not existing in MovieDB...");
                return;
            }

            if (this.param_MovieProfile.FilePath.Trim().Length.Equals(0))
            {
                txtFilePath.Text = this.param_MovieProfile.FilePath;
                MessageBox.Show("This FilePath was Empty...");
                return;
            }

            //---- Last Confirm
            if (
                MessageBox.Show(
                    "Do You want to Delete Last FilePath?",
                    "Confirm?",
                    MessageBoxButtons.YesNo) !=
                System.Windows.Forms.DialogResult.Yes
                )
            {
                return;
            }

            //--------------------------------------------------
            string filePath2Delete = this.param_MovieProfile.FilePath;

            if (File.Exists(filePath2Delete))
            {
                try
                {
                    File.Delete(filePath2Delete);
                    that.DebugAndLog("Delete RealFileInDisk [" + filePath2Delete + "] Success");
                }
                catch (Exception ex)
                {
                    that.DebugAndLog("Error in delete RealFileInDisk [" + filePath2Delete + "] " + ex.Message);
                }
            }
            this.param_MovieProfile.FilePath = "";
            txtFilePath.Text = this.param_MovieProfile.FilePath;
            this.param_MovieProfile.CheckFileConnect();
            //--------------------------------------------------

            if (!MovieDB.SaveMovieProfile(this.param_MovieProfile))
            {
                that.DebugAndLog("Error in MovieDB.SaveMovieProfile() ... Cannot Remove Last FilePath");
                MessageBox.Show(
                    "Error in MovieDB::SaveMovieProfile()\r\nMaybe Disk write proteced",
                    "Error Save",
                    MessageBoxButtons.OK
                    );
                return;
            }
            else
            {
                that.DebugAndLog("Delete last File path from Movie{" + this.param_MovieProfile.Hash + "} Success");
                return;
            }
        }
Пример #8
0
        private void frmMain_Shown(object sender, EventArgs e)
        {
            this.Text = that.ProgramNameAndVersion();

            that.DebugAndLog("Begin lstDebug...");
            lstDebug.Dock    = DockStyle.Fill;
            lstDebug.Visible = true;
            this.Refresh();

            /* Check Version Update */
            if (that.CheckProgramUpdate())
            {
                that.DebugAndLog("Program has been UPDATE new version, Need to Restart");
                //P2P.UDP.Terminate();
                Application.Exit();
                Environment.Exit(0);
                return;
            }
            else
            {
                that.DebugAndLog("CheckProgramUpdate() return FALSE, No need to restart");
            }

            that.DebugAndLog("Prepare MovieDB...");
            if (!MovieDB.CheckAndPrepareDbFolder())
            {
                that.DebugAndLog("Error in Parepare MovieDB!");
                MessageBox.Show("Error Cannot Prepare MovieDB");
                Application.Exit();
                return;
            }
            else
            {
                that.DebugAndLog("Prepare MovieDB Success");
            }

            that.DebugAndLog("Prepare MovieIMG...");
            if (!MovieDB.CheckAndPrepareImgFolder())
            {
                that.DebugAndLog("Error in Prepare MovieIMG!");
                MessageBox.Show("Error Cannot Prepare MovieDB");
                Application.Exit();
                return;
            }
            else
            {
                that.DebugAndLog("Prepare MovieIMG Success");
            }

            that.DebugAndLog("Load MovieDB from Disk");
            if (!MovieDB.LoadMovieProfileFromDisk())
            {
                that.DebugAndLog("Error in Load MovieDB from Disk!!");
                MessageBox.Show("Error Cannot Load MovieDB from Disk!!");
                Application.Exit();
                return;
            }

            that.DebugAndLog("Begin menuMain...");
            menuMain.Visible = true;
            menuOptionAutoBuildHash.Checked         = that.Config[KW.AutoBuildHashIfEmpty].ToUpper().Equals(KW.YES);
            menuOptionDeleteSourcePicture.Checked   = that.Config[KW.DeleteSourcePicture].ToUpper().Equals(KW.YES);
            menuOptionAllSaveOfflineProfile.Checked = that.Config[KW.AllowEditOfflineProfile].ToUpper().Equals(KW.YES);
            this.Refresh();

            that.DebugAndLog("Begin mainToolBar...");
            for (int i = 0; i < mainToolBar.Items.Count; i++)
            {
                mainToolBar.Items[i].Enabled = true;
            }
            this.Refresh();

            that.DebugAndLog("Begin refresh list filter...");
            RefreshFilterList();

            that.DebugAndLog("Begin tabMain...");
            lstDebug.Visible = false;
            tabMain.Dock     = DockStyle.Fill;
            TabPage movieListTemplate = tabMain.TabPages["tabMovieList"];

            tabMain.TabPages.Clear();
            tabMain.Visible = true;
            this.Refresh();

            generateTabFunctionKey();
        }
Пример #9
0
        public static void BatchDeleteLastFilePathInCurrentTab(TabPage tabToDelete)
        {
            ucMovieList movieList = null;

            foreach (Control ctl in tabToDelete.Controls)
            {
                if (ctl is ucMovieList)
                {
                    movieList = (ucMovieList)ctl;
                    break;
                }
            }
            if (movieList == null)
            {
                return;
            }

            // Begin Delete Last File Path
            List <MovieProfile> listMovie = movieList.GetListMovie();

            if (listMovie.Count > 0)
            {
                if (MessageBox.Show(
                        "Are you sure to delete " + listMovie.Count.ToString() + " movie File Path!!",
                        " Confirm?", MessageBoxButtons.OKCancel
                        ) != DialogResult.OK)
                {
                    return;
                }
            }

            // After Confirm Begin Real Delete
            int countSuccess = 0;

            for (int i = 0; i < listMovie.Count; i++)
            {
                MovieProfile profile = (MovieProfile)listMovie[i];

                //--------------------------------------------------
                string filePath2Delete = profile.FilePath;
                if (File.Exists(filePath2Delete))
                {
                    try
                    {
                        File.Delete(filePath2Delete);
                        that.DebugAndLog("Delete RealFileInDisk [" + filePath2Delete + "] Success");
                    }
                    catch (Exception ex)
                    {
                        that.DebugAndLog("Error in delete RealFileInDisk [" + filePath2Delete + "] " + ex.Message);
                    }
                }
                profile.FilePath = "";      // Delete from Object
                profile.CheckFileConnect();
                //--------------------------------------------------

                if (!MovieDB.SaveMovieProfile(profile))
                {
                    that.DebugAndLog("Error in MovieDB.SaveMovieProfile() ... Cannot Remove Last FilePath");
                }
                else
                {
                    that.DebugAndLog("Delete last File path from Movie{" + profile.Hash + "} Success");
                    countSuccess++;
                }
            }
            MessageBox.Show("Success delete " + countSuccess.ToString() + " LastFile Path from " + listMovie.Count.ToString() + " profile");
        }