コード例 #1
0
        public static ImageListViewItem FindItem(ImageListViewItemCollection imageListViewItemCollection, string fullFilename)
        {
            ImageListViewItem foundItem = null;

            foreach (ImageListViewItem item in imageListViewItemCollection)
            {
                if (FilesCutCopyPasteDrag.IsFilenameEqual(item.FileFullPath, fullFilename))
                {
                    foundItem = item;
                    break;
                }
            }
            return(foundItem);
        }
コード例 #2
0
        public static void Write(DataGridView dataGridView, out Dictionary <string, string> renameSuccess, out Dictionary <string, RenameToNameAndResult> renameFailed, out HashSet <string> directoryCreated, bool showFullPathIsUsed)
        {
            using (new WaitCursor())
            {
                renameSuccess    = new Dictionary <string, string>();
                renameFailed     = new Dictionary <string, RenameToNameAndResult>();
                directoryCreated = new HashSet <string>();

                int columnIndex = DataGridViewHandler.GetColumnIndexFirstFullFilePath(dataGridView, headerNewFilename, false);
                if (columnIndex == -1)
                {
                    return;
                }

                for (int rowIndex = 0; rowIndex < DataGridViewHandler.GetRowCountWithoutEditRow(dataGridView); rowIndex++)
                {
                    DataGridViewGenericCell cellGridViewGenericCell = DataGridViewHandler.GetCellDataGridViewGenericCellCopy(dataGridView, columnIndex, rowIndex);

                    if (!cellGridViewGenericCell.CellStatus.CellReadOnly)
                    {
                        DataGridViewGenericRow dataGridViewGenericRow = DataGridViewHandler.GetRowDataGridViewGenericRow(dataGridView, rowIndex);

                        #region Get Old filename from grid
                        string oldFilename     = dataGridViewGenericRow.RowName;
                        string oldDirectory    = dataGridViewGenericRow.HeaderName;
                        string oldFullFilename = FileHandler.CombinePathAndName(oldDirectory, oldFilename);
                        #endregion

                        #region Get New filename from grid and rename
                        if (dataGridViewGenericRow.Metadata != null)
                        {
                            string newFullFilename = FileHandler.CombinePathAndName(oldDirectory, DataGridViewHandler.GetCellValueNullOrStringTrim(dataGridView, columnIndex, rowIndex));

                            string newDirectory = Path.GetDirectoryName(newFullFilename);
                            if (!Directory.Exists(newDirectory) && !directoryCreated.Contains(newDirectory))
                            {
                                directoryCreated.Add(newDirectory);
                            }
                            FilesCutCopyPasteDrag.RenameFile(oldFullFilename, newFullFilename, ref renameSuccess, ref renameFailed);
                        }
                        #endregion
                    }
                }
            }
        }