コード例 #1
0
 // update all the new file name previews in FileNamesOldNewListView
 private void UpdateFileRenameListView()
 {
     ResetOldNewFileNameValues();
     if (FileNamesOldNewListView.Items.Count > 0)
     {
         FileNamesOldNewListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
     }
     if (Globals.RenameRules.Count > 0)
     {
         ToggleLoadingPanels(true);
         FileNamesOldNewListView.BeginUpdate();
         foreach (IRenameRule renameRule in Globals.RenameRules)
         {
             if (renameRule.Enabled)
             {
                 foreach (ListViewItem torrentFileItem in FileNamesOldNewListView.Items)
                 {
                     FriendlyTorrentFileInfo torrentFileInfo = (FriendlyTorrentFileInfo)torrentFileItem.Tag;
                     torrentFileInfo.NewestName       = renameRule.DoRename(torrentFileInfo, torrentFileItem.Index);
                     torrentFileItem.SubItems[1].Text = torrentFileInfo.NewestName;
                     if (torrentFileItem.Text != torrentFileInfo.NewestName)
                     {
                         torrentFileItem.BackColor = Color.FromArgb(235, 235, 255);
                     }
                     else
                     {
                         torrentFileItem.BackColor = Color.FromArgb(255, 255, 255);
                     }
                 }
             }
         }
         FileNamesOldNewListView.EndUpdate();
         ToggleLoadingPanels(false);
     }
 }
コード例 #2
0
        // load selected files to rules tab
        private async Task LoadSelectedFilesToRulesTab()
        {
            ToggleLoadingPanels(true);
            FileNamesOldNewListView.BeginUpdate();
            FileNamesOldNewListView.Items.Clear();
            await Task.Run(() =>
            {
                List <ListViewItem> torrentFilesLVItems = new List <ListViewItem>();
                foreach (FriendlyTorrentFileInfo torrentFile in Globals.SelectedTorrentFiles)
                {
                    ListViewItem torrentFileLVItem = new ListViewItem()
                    {
                        Text        = torrentFile.InitialPath.Split('/').Last(), // don't show entire path, just the file name
                        ToolTipText = torrentFile.InitialPath,
                        ImageIndex  = -1,
                        Tag         = torrentFile
                    };
                    torrentFileLVItem.SubItems.Add(torrentFileLVItem.Text);
                    torrentFilesLVItems.Add(torrentFileLVItem);
                }
                BeginInvoke((Action)(() =>
                {
                    FileNamesOldNewListView.Items.AddRange(torrentFilesLVItems.ToArray());
                    FileNamesOldNewListView.Sort();
                    if (FileNamesOldNewListView.Items.Count > 0)
                    {
                        FileNamesOldNewListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                    }
                }));
            });

            UpdateFileRenameListView();
            FileNamesOldNewListView.EndUpdate();
            ToggleLoadingPanels(false);
        }
コード例 #3
0
 private void ResetOldNewFileNameValues()
 {
     FileNamesOldNewListView.BeginUpdate();
     foreach (ListViewItem torrentFileItem in FileNamesOldNewListView.Items)
     {
         FriendlyTorrentFileInfo torrentFileInfo = (FriendlyTorrentFileInfo)torrentFileItem.Tag;
         torrentFileInfo.NewestName       = torrentFileInfo.InitialPath;
         torrentFileItem.SubItems[1].Text = torrentFileItem.Text;
         torrentFileItem.Tag       = torrentFileInfo;
         torrentFileItem.BackColor = Color.FromArgb(255, 255, 255);
     }
     FileNamesOldNewListView.EndUpdate();
 }