예제 #1
0
        private void btnUndo_Click(object sender, EventArgs e)
        {
            if (Globals.lastFileTags.Count <= 0)
            {
                return;
            }

            FileTags undoFile = Globals.lastFileTags.Pop();

            foreach (ListViewItem fItem in listFiles.Items)
            {
                if (fItem.SubItems[0].Text == undoFile.filename &&  //filename
                    fItem.SubItems[3].Text == undoFile.folder.path) //folder
                {
                    List <string> tagArr = new List <string>();
                    foreach (Tag tagItem in undoFile.tags)
                    {
                        tagArr.Add(tagItem.text);
                    }
                    string tagsComb = String.Join(Globals.tagSeparator, tagArr.ToArray());
                    fItem.SubItems[2].Text = tagsComb;
                    break;
                }
            }
            //Globals.fileTags = Globals.lastFileTags;
            //reloadList();
            listFiles.SelectedItems.Clear();
            Globals.currFile = null;
        }
예제 #2
0
 public void CopyFrom(FileTags copyFT)
 {
     folder      = new Folder();
     folder.path = copyFT.folder.path;
     filename    = copyFT.filename;
     resolution  = copyFT.resolution;
     tags        = new List <Tag>();
     foreach (Tag cTag in copyFT.tags)
     {
         tags.Add(cTag);
     }
 }
예제 #3
0
        public static void shuffleFiles() // Fisher-Yates shuffle algorithm
        {
            Random rng = new Random();
            int    n   = Globals.files.Count;

            while (n > 1)
            {
                n--;
                int      k        = rng.Next(n + 1);
                FileTags tempFile = Globals.files[k];
                Globals.files[k] = Globals.files[n];
                Globals.files[n] = tempFile;
            }
        }
예제 #4
0
        private void btnRemoveTags_Click(object sender, EventArgs e)
        {
            if (Globals.lastFileTags.Count > 30)
            {
                Globals.lastFileTags.Clear();
            }

            //Globals.fileTags.CopyTo(Globals.lastFileTags, 0);
            if (!Globals.isMultiActive)
            {
                if (Globals.currFile == null)
                {
                    return;
                }

                FileTags remFile = new FileTags("", 0, "");
                remFile.CopyFrom(Globals.currFile);
                Globals.lastFileTags.Push(remFile);
                Globals.currFile.tags = new List <Tag>();
            }
            else
            {
                Globals.multiFiles = new List <FileTags>();
                foreach (ListViewItem item in listFiles.SelectedItems)
                {
                    string fName  = item.SubItems[0].Text;
                    int    res    = item.SubItems[1].Text != "" ? Convert.ToInt16(item.SubItems[1].Text) : 0;
                    string folder = item.SubItems[3].Text;
                    Globals.currFile = new FileTags(folder, res, fName);
                    FileTags remFile = new FileTags("", 0, "");
                    remFile.CopyFrom(Globals.currFile);
                    Globals.lastFileTags.Push(remFile);
                    Globals.currFile.tags = new List <Tag>();
                    Globals.multiFiles.Add(Globals.currFile);
                }
            }
            updateTagsList();
        }
예제 #5
0
        public static void populateFiles(BackgroundWorker bgWork = null)
        {
            if (bgWork == null)
            {
                bgWork = new BackgroundWorker();
            }


            //---- To find videos resolution; Used to placed in separate method, but to replace get all files method here
            Shell32.Shell  shell = new Shell32.Shell();
            Shell32.Folder shellFolder;

            List <string>            allFolders   = new List <string>();
            List <string>            allFiles     = new List <string>();
            Dictionary <int, string> shellHeaders = new Dictionary <int, string>();

            int errorFolders = 0;

            foreach (Folder item in folders)
            {
                if (Directory.Exists(item.path))
                {
                    allFolders.Add(item.path); //Add root Directories

                    string[] subdir = Directory.GetDirectories(item.path, "*", SearchOption.AllDirectories);
                    allFolders.AddRange(subdir); //Add root All Sub-Directories
                }
                else
                {
                    warnings.Add("\"" + item.path + "\" not found!");
                    errorFolders++;
                }
            }

            if (folders.Count <= errorFolders)
            {
                return;
            }

            totalFiles = 0;
            foreach (string x in allFolders)
            {
                totalFiles = totalFiles + Directory.GetFiles(x).Count();
                DebugCount dc = new DebugCount(x, totalFiles);
                debugCount.Add(dc);
            }

            if (totalFiles <= 0)
            {
                warnings.Add("No file(s) found in directory(s)!");
                return;
            }

            double progBGStep = (double)100 / (double)totalFiles;
            double currProg   = 0;
            double lastStep   = 0;
            bool   tooLong    = false;

            foreach (string fitem in allFolders)
            {
                shellFolder = shell.NameSpace(fitem);

                //To find out the header in shell 32
                if (shellHeaders.Count <= 0)
                {
                    for (int i = 0; i < short.MaxValue; i++)
                    {
                        string header = shellFolder.GetDetailsOf(null, i);
                        if (String.IsNullOrEmpty(header))
                        {
                            break;
                        }
                        if (header.Contains("Name") || header.Contains("Frame") || header.Contains("Path"))
                        {
                            shellHeaders.Add(i, header);
                        }
                    }
                }

                string[] folderFiles = Directory.GetFiles(fitem);
                foreach (string filename in folderFiles)
                {
                    //debugCount[debugCount.FindIndex(0, x => x.folder.Equals(fitem))].increaseAcc(); //#DEBUGONLY
                    string sFilename       = Path.GetFileName(filename);
                    Shell32.FolderItem2 aa = null;

                    string fullPath = fitem + "\\" + sFilename;

                    if (fullPath.Length > 260)
                    {
                        continue;
                        tooLong = true;
                    }
                    FileAttributes attr = File.GetAttributes(fitem + "\\" + sFilename);


                    if (attr.HasFlag(FileAttributes.Directory))
                    {
                        continue; //is Directory
                    }

                    var    item         = shellFolder.ParseName(sFilename);
                    string sFrameheight = shellFolder.GetDetailsOf(item, shellHeaders.FirstOrDefault(k => k.Value.Equals("Frame height")).Key);

                    int videoHeight = 0;
                    videoHeight = cIntNull(sFrameheight);
                    FileTags newFile = new FileTags(fitem, videoHeight, sFilename);
                    files.Add(newFile);

                    currProg = currProg + progBGStep;
                    if (currProg - lastStep < 1 || currProg > 100)  //To make progress +1% only and not overlimit
                    {
                        continue;
                    }
                    lastStep = currProg;
                    System.Threading.Thread.Sleep(1); // if using sleep thread sometimes get stucked
                    bgWork.ReportProgress(Convert.ToInt32(currProg));
                }

                if (tooLong)
                {
                    //warnings.Add("
                }
            }
        }
예제 #6
0
 public bool isSameFile(FileTags pFile)
 {
     return(filename.Equals(pFile.filename) && folder.path.Equals(pFile.folder.path));
 }