Пример #1
0
        /// <summary>
        /// Met à jour la liste de fichiers dans le répertoire courant
        /// </summary>
        /// <param name="selectedNode">Noeud sélectionné</param>
        /// <param name="keepSelection">true to keep previous item selected in file list</param>
        private void _RefreshFileList(TreeNode selectedNode, bool keepSelection)
        {
            // ANO 15 : sauvegarde de la sélection de fichier courante
            if (keepSelection)
            {
                ListView2.StoreSelectedIndex(bnkListView);
            }

            // Effacement des listes et contexte
            bnkListView.Items.Clear();
            _ClearContentLists();
            _CurrentBnkFile = null;

            // Mise à jour statuts
            bnkStatusLabel.Text = bnkStatusLabelCountSize.Text = "";

            StatusBarLogManager.ShowEvent(this, _STATUS_NO_BNK_SELECTED);

            if (selectedNode == null)
            {
                return;
            }

            try
            {
                Cursor = Cursors.WaitCursor;

                string        currentFolder = (string)selectedNode.Tag;
                DirectoryInfo di            = new DirectoryInfo(currentFolder);
                FileInfo[]    fileList      = di.GetFiles();
                long          totalSize     = 0;

                foreach (FileInfo anotherBnk in fileList)
                {
                    // File name check
                    bool isNameValid = false;

                    foreach (string anotherPattern in _ALLOWED_FILENAME_PATTERNS)
                    {
                        if (Regex.IsMatch(anotherBnk.Name, anotherPattern, RegexOptions.IgnoreCase))
                        {
                            isNameValid = true;
                            break;
                        }
                    }

                    if (isNameValid)
                    {
                        // On ajoute l'élément
                        ListViewItem newItem = new ListViewItem(anotherBnk.Name)
                        {
                            ImageIndex = _GetImageIndexFromFilename(anotherBnk.Name)
                        };

                        // L'image dépend de l'extension
                        // EVO_42 : nouvelles icônes

                        string typeDesc = TduFile.GetTypeDescription(anotherBnk.Name);

                        // EVO_57 : Infos supplémentaires pour la vue détaillée
                        // Taille
                        long currentSize = anotherBnk.Length;

                        newItem.SubItems.Add(currentSize.ToString());
                        totalSize += currentSize;
                        // Type
                        newItem.SubItems.Add(typeDesc);

                        // Tooltip !
                        newItem.ToolTipText = string.Format(_TOOLTIP_STD_FILE,
                                                            typeDesc,
                                                            anotherBnk.Length);

                        bnkListView.Items.Add(newItem);
                    }
                }

                // Mise à jour statut
                bnkStatusLabel.Text = currentFolder;

                if (bnkListView.Items.Count == 0)
                {
                    bnkStatusLabelCountSize.Text = _STATUS_COUNT_SIZE_NO;
                }
                else
                {
                    bnkStatusLabelCountSize.Text = string.Format(_STATUS_COUNT_SIZE_CONTENTS, bnkListView.Items.Count, totalSize);
                }

                // Rétablit le fichier sélectionné
                if (keepSelection)
                {
                    ListView2.RestoreSelectedIndex(bnkListView);

                    // ANO_21 : le contenu du BNK est à actualiser
                    bnkListView_SelectedIndexChanged(this, new EventArgs());
                }

                Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                MessageBoxes.ShowError(this, ex);
            }
        }
Пример #2
0
        /// <summary>
        /// Met à jour la liste d'éditions
        /// </summary>
        private void _RefreshEditList()
        {
            // Threading support
            // @see http://msdn.microsoft.com/fr-fr/library/ms171728.aspx
            if (editTasksListView.InvokeRequired)
            {
                RefreshEditListCallBack refreshCallBack = _RefreshEditList;

                Invoke(refreshCallBack);
                return;
            }

            Collection <EditHelper.Task> taskList = EditHelper.Instance.Tasks;

            // Effacement de la liste
            editTasksListView.Items.Clear();

            Cursor = Cursors.AppStarting;

            try
            {
                // Parcours de la liste de tâches
                foreach (EditHelper.Task anotherTask in taskList)
                {
                    // New in 1.10: task must not be furtive to be displayed
                    if (!anotherTask.isFurtive)
                    {
                        // EVO_74: column order and title are changed
                        string       fileName = anotherTask.parentBNK.GetPackedFileName(anotherTask.editedPackedFilePath);
                        ListViewItem li       = new ListViewItem(fileName);
                        // Type description
                        li.SubItems.Add(
                            TduFile.GetTypeDescription(fileName));
                        // Date
                        li.SubItems.Add(anotherTask.startDate.ToString());
                        // Last modified
                        li.SubItems.Add(anotherTask.trackedLastFileWriteTime.ToString());
                        // BNK
                        li.SubItems.Add(anotherTask.parentBNK.FileName);
                        // Fichier de travail
                        li.SubItems.Add(anotherTask.extractedFile);
                        // Clé (pour conserver la référence)
                        li.Tag = anotherTask;
                        // Tooltip
                        li.ToolTipText = anotherTask.editedPackedFilePath;

                        // EVO_74: color for modified files
                        if (anotherTask.trackedFileHasChanged)
                        {
                            li.ForeColor = GuiConstants.COLOR_MODIFIED_ITEM;
                        }

                        editTasksListView.Items.Add(li);
                    }
                }

                Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                MessageBoxes.ShowError(this, ex);
            }
        }