示例#1
0
        /// <summary>
        /// Helper for thread form update.
        /// </summary>
        private void UpdateForm(ThreadMessageStruct p_tms)
        {
            string fullPath = p_tms.Data1.ToString();
            string folder = Path.GetDirectoryName(fullPath).Substring(Utility.StringFormat.GoUpDirectory(m_rootPath).Length);
            string name = Path.GetFileNameWithoutExtension(fullPath);
            string status = p_tms.Data2.ToString();

            ListViewItem item = new ListViewItem(folder);
            item.SubItems.Add(name);
            item.SubItems.Add(status);

            if (status.Contains("Attach"))
                item.ForeColor = Color.Red;

            f_filesResults.Items.Insert(0, item);

            m_filesChecked++;
            f_filesChecked.Text = "Files Checked: " + m_filesChecked;

            f_threadStatus.Text = "Thread: " + myThread.GetThread.IsAlive.ToString();
        }
示例#2
0
 // subroutine for thread launching
 private void ThreadCatch()
 {
     try
     {
         m_processFunc();
     }
     catch (Exception ex)
     {
         ThreadMessageStruct tms = new ThreadMessageStruct();
         tms.Type = TMSType.Error;
         tms.Data1 = ex;
         ThreadUpdate(tms);
     }
 }
示例#3
0
        /// <summary>
        /// Write a JPG's group name to its Keyword file property.
        /// This allows the images to be grouped by Keyword in windows explorer.
        /// </summary>
        public static void SetImageKeyword(FileSystem.ProcessParams p_params)
        {
            // only do this to JPG images

            string filePath = p_params.FilePath;

            if (Utility.FileSystem.IsJPG(filePath) == false)
                return;

            string status = "UNKNOWN";

            try
            {
                // check that the file doesn't already have this Keyword

                string groupName = FileSystem.GetGroupName(filePath);

                string keyword = ImageProcessor.GetImageKeyword(filePath);

                if (keyword != null && keyword == groupName)
                {
                    status = "Skipped (" + groupName + ")";
                }

                else
                {
                    ImageProcessor.AttachImageKeyword(filePath, groupName);
                    status = "Attached (" + groupName + ")";
                }
            }
            catch (Exception ex)
            {
                status = ex.Message;
            }
            finally
            {
                // notify any subscribers

                ThreadMessageStruct tms = new ThreadMessageStruct();
                tms.Type = TMSType.Progress1;
                tms.Data1 = filePath;
                tms.Data2 = status;

                if (Progress != null)
                    Progress(tms);
            }
        }
示例#4
0
        /// <summary>
        /// Manager function that calls all other standardization functions.
        /// </summary>
        public void Standardize(ProcessParams p_params)
        {
            string modedPath = p_params.FilePath;

            ThreadMessageStruct thdMsg = new ThreadMessageStruct();
            thdMsg.Type = TMSType.Progress1;
            thdMsg.Data1 = modedPath;
            if (Progress != null)
                Progress(thdMsg);

            modedPath = StandardizeGeneral(modedPath);

            modedPath = StandardizeImage(modedPath);

            modedPath = StandardizeMusic(modedPath);

            //        modedPath = OpenZip(modedPath);
        }
示例#5
0
        /// <summary>
        /// Deletes image from system.
        /// </summary>
        public void KillImage(ProcessParams p_params)
        {
            string filePath = p_params.FilePath;

            ThreadMessageStruct thdMsg = new ThreadMessageStruct();
            thdMsg.Type = TMSType.Progress1;
            thdMsg.Data1 = filePath;
            if (Progress != null)
                Progress(thdMsg);

            string status = "begin";

            try
            {
                if (FileSystem.IsImage(filePath) == true)
                {
                    File.Delete(filePath);
                    status = "Image Deleted";
                }
                else
                {
                    status = "Not An Image";
                }
            }
            catch (Exception ex)
            {
                status = "Error: " + ex.Message;
            }
            finally
            {
                thdMsg.Type = TMSType.Progress2;
                thdMsg.Data1 = filePath;
                thdMsg.Data2 = status;
                if (Progress != null)
                    Progress(thdMsg);
            }
        }
示例#6
0
        public static void ReplaceFileName(ProcessParams p_params)
        {
            // get formatted parameters

            string filePath = p_params.FilePath;

            string regLit = p_params.Parameter1.ToString();

             //   regLit = regLit.Replace(@"\", @"\\");
             //   regLit = regLit.Replace(@".", @"\.");
            regLit = regLit.Replace(@"$", @"\$");
            regLit = regLit.Replace(@"^", @"\^");
            regLit = regLit.Replace(@"{", @"\{");
            regLit = regLit.Replace(@"(", @"\(");
            regLit = regLit.Replace(@"|", @"\|");
            regLit = regLit.Replace(@")", @"\)");
            regLit = regLit.Replace(@"*", @"\*");
            regLit = regLit.Replace(@"+", @"\+");
            regLit = regLit.Replace(@"?", @"\?");

            Regex m_matchText = new Regex(regLit);

            string fileName = Path.GetFileName(filePath);
            string changeTo = p_params.Parameter2.ToString();

            // create file with substituted name

            string newFileName = null;
            string newFilePath = null;

            if (m_matchText.IsMatch(fileName))
            {
                newFileName = m_matchText.Replace(fileName, changeTo);

                newFilePath = Path.GetDirectoryName(filePath);
                newFilePath = Path.Combine(newFilePath, newFileName);

                File.Move(filePath, newFilePath);
            }

            // notify any calling control

            ThreadMessageStruct tms = new ThreadMessageStruct();
            tms.Type = TMSType.Progress1;
            tms.Data1 = filePath;
            tms.Data2 = newFilePath;

            if (Progress != null)
                Progress(tms);
        }
示例#7
0
        /// <summary>
        /// Helper for thread form update.
        /// </summary>
        private void UpdateForm(ThreadMessageStruct p_tms)
        {
            string origPath = p_tms.Data1.ToString();
            string newPath = null;

            if (p_tms.Data2 != null)
                newPath = p_tms.Data2.ToString();

            string origName = Path.GetFileName(origPath);
            string newName = @"-";

            if (newPath != null)
                newName = Path.GetFileName(newPath);

            string dir = Path.GetDirectoryName(origPath);
            string lastDir = Utility.StringFormat.GetLastDirectoryOnly(f_rootPath.Text);

            string abrev = dir.Substring(f_rootPath.Text.Length - lastDir.Length -2);

            ListViewItem item = new ListViewItem(abrev);
            item.SubItems.Add(origName);
            item.SubItems.Add(newName);

            f_fileSystemList.Items.Insert(0, item);
        }
示例#8
0
        public static void SetAlbumCover(FileSystem.ProcessParams p_params)
        {
            string musicPath = p_params.FilePath;

            // only do this to MP3's

            if (FileSystem.IsMP3(musicPath) == false)
                return;

            string status = "UNKNOWN";

            try
            {
                // can factor out the mp3 instation, but then have to close it here

                string coverPath;

                bool hasCover = MusicProcessor.GetCoverFile(musicPath, out coverPath);

                Image existingCover = MusicProcessor.GetExistingCover(musicPath);

                if (coverPath == null)
                    status = "Music Name Error";

                else if (coverPath == "" || hasCover == false)
                    status = "No Cover Exists";

                else if (hasCover == true)
                    status = "Cover Found";

                Bitmap bit;
                Image newCover = null;

                if (coverPath != null && coverPath != "")
                {
                    bit = new Bitmap(coverPath);
                    newCover = bit.GetThumbnailImage(bit.Width, bit.Height, null, IntPtr.Zero);
                }

                if (existingCover != null &&
                        ((newCover != null && ImageProcessor.ImageEquals(existingCover, newCover) == false) ||
                         (newCover == null) ) )
                {
                    RemoveAllImages(musicPath);
                }

                if (newCover != null &&
                    ((existingCover != null && ImageProcessor.ImageEquals(existingCover, newCover) == false) ||
                     (existingCover == null) ) )
                {
                    AttachCover(musicPath, coverPath);
                }

                // correct a previous mistake

                AttachIDv2(musicPath);

            }
            catch (Exception ex)
            {
                status = "Error: " + ex.Message;
            }
            finally
            {
                // notify any subscribers

                ThreadMessageStruct tms = new ThreadMessageStruct();
                tms.Type = TMSType.Progress1;
                tms.Data1 = musicPath;
                tms.Data2 = status;

                if (Progress != null)
                    Progress(tms);
            }
        }