Esempio n. 1
0
        /// <summary>
        /// Add file and its checksum for verification.
        /// </summary>
        /// <param name="file">Path to file to add.</param>
        /// <param name="checksum">Checksum of the file.</param>
        public void AddFile(string file, string checksum)
        {
            CheckSumItem newItem = new CheckSumItem(file);

            FileInfo fileInfo = new FileInfo(file);

            newItem.Size = fileInfo.Length;

            if (checksum != null && checksum != String.Empty)
            {
                newItem.SetSum(checksum);
            }

            _listChanged = true;
            _fileList.Add(newItem);
        }
Esempio n. 2
0
        /// <summary>
        /// Add files in folder to items to process.
        /// </summary>
        /// <param name="folder">Path to folder to add.</param>
        /// <param name="progressInfo">Returns information about progress.</param>
        void AddFolder(string folder, ref ProgressInfo progressInfo)
        {
            DirectoryInfo info = new DirectoryInfo(folder);

            FileInfo[] files = info.GetFiles();

            _listChanged = true;
            foreach (FileInfo fi in files)
            {
                CheckSumItem newItem = new CheckSumItem(fi.FullName);

                FileInfo fileInfo = new FileInfo(fi.FullName);
                newItem.Size = fileInfo.Length;

                _fileList.Add(newItem);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Add files in folder to items to process.
        /// </summary>
        /// <param name="folder">Path to folder to add.</param>
        /// <param name="progressInfo">Returns information about progress.</param>
        void AddFolder(string folder, ref ProgressInfo progressInfo)
        {
            DirectoryInfo info = new DirectoryInfo(folder);
            FileInfo[] files = info.GetFiles();

            _listChanged = true;
            foreach (FileInfo fi in files)
            {
                CheckSumItem newItem = new CheckSumItem(fi.FullName);

                FileInfo fileInfo = new FileInfo(fi.FullName);
                newItem.Size = fileInfo.Length;

                _fileList.Add(newItem);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Add file and its checksum for verification.
        /// </summary>
        /// <param name="file">Path to file to add.</param>
        /// <param name="checksum">Checksum of the file.</param>
        public void AddFile(string file, string checksum)
        {
            CheckSumItem newItem = new CheckSumItem(file);

            FileInfo fileInfo = new FileInfo(file);
            newItem.Size = fileInfo.Length;

            if (checksum != null && checksum != String.Empty)
                newItem.SetSum(checksum);

            _listChanged = true;
            _fileList.Add(newItem);
        }
Esempio n. 5
0
 /// <summary>
 /// Determines if given item should be visible in the GUI.
 /// </summary>
 /// <param name="item">Item to check.</param>
 /// <returns>true if item is added to GUI, false otherwise.</returns>
 private bool IsItemVisible(CheckSumItem item)
 {
     if (item.CheckSum == null && _visibleItems.NonCalculated == false)
         return false;
     if ((item.CheckSum != null && _visibleItems.Calculated == false) &&
         (item.Verified != VerificationState.VerifyOK && _visibleItems.Verified == true))
     {
         return false;
     }
     if (item.Verified == VerificationState.VerifyOK && _visibleItems.Verified == false)
         return false;
     return true;
 }
Esempio n. 6
0
        /// <summary>
        /// Add item to the GUI item list.
        /// </summary>
        /// <param name="item">Checksum item to add.</param>
        private void AddItemToList(CheckSumItem item)
        {
            ListViewItem listItem = itemList.Items.Add(item.FullPath,
                    item.FileName, String.Empty);

            string[] listItems = new string[(int)ListIndices.Count - 1];

            if (item.CheckSum != null)
            {
                listItems[(int)ListIndices.CheckSum - 1] =
                        item.CheckSum.ToString();
            }
            else
                listItems[(int)ListIndices.CheckSum - 1] = String.Empty;

            switch (item.Verified)
            {
                case VerificationState.NotVerified:
                    listItems[(int)ListIndices.Verified - 1] = String.Empty;
                    break;
                case VerificationState.VerifyOK:
                    listItems[(int)ListIndices.Verified - 1] = "OK";
                    break;
                case VerificationState.VerifyFailed:
                    listItems[(int)ListIndices.Verified - 1] = "FAIL";
                    break;
                default:
                    throw new ApplicationException("Unknown verification state!");
                    break;
            }

            if (item.Size != 0)
            {
                string size = Locality.GetShortFileSize(item.Size);
                listItems[(int)ListIndices.Size - 1] = size;
            }
            else
                listItems[(int)ListIndices.Size - 1] = String.Empty;

            listItems[(int)ListIndices.FullPath - 1] = item.FullPath;
            itemList.Items[listItem.Index].SubItems.AddRange(listItems);

            //Add original size as Tag for sorting
            itemList.Items[listItem.Index].SubItems[(int)ListIndices.Size].Tag = item.Size;
        }