Пример #1
0
        private void folderTreeView_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
        {
            folderTreeView.LabelEdit = false;

            OpenDat dat = ControlDat.GetDat(currentDat);

            if (createFolder)
            {
                dat.AddEmptyFolder(createFolderPath);
                e.Node.Name      = createFolderPath.ToLowerInvariant();
                createFolderPath = null;
                createFolder     = false;
            }

            if (e.Label == null)
            {
                return;
            }
            if (e.Label.Equals(e.Node.Text))
            {
                e.CancelEdit = true;
                return;
            }

            string folderPath = e.Node.Name; // in lower case;

            int    i = folderPath.LastIndexOf(e.Node.Text.ToLowerInvariant() + '\\');
            string renameFolderPath = folderPath.Remove(i) + e.Label + '\\';

            if (dat.FolderExist(renameFolderPath, false))
            {
                MessageBox.Show((LocaleRU)
                                ? "Директория с таким именем уже существует."
                                : "This directory already exists.",
                                "Dat Explorer II", MessageBoxButtons.OK, MessageBoxIcon.Error);
                e.CancelEdit = true;
                return;
            }
            e.Node.Name = renameFolderPath.ToLowerInvariant();

            dat.RenameFolder(folderPath, e.Label);

            SaveToolStripButton.Enabled  = dat.ShouldSave();
            dirToolStripStatusLabel.Text = "Directory: " + e.Node.Name;
        }
Пример #2
0
        internal void DeleteFiles(string path)
        {
            List <String> listFiles = new List <String>();

            GetFolderFiles(listFiles, path);

            OpenDat dat = ControlDat.GetDat(currentDat);

            if (listFiles.Count > 0)
            {
                toolStripProgressBar.Maximum = listFiles.Count;
                dat.DeleteFile(listFiles, true);
            }
            else
            {
                dat.RemoveEmptyFolder(path);
            }
        }
Пример #3
0
        private void SaveToolStripButton_Click(object sender, EventArgs e)
        {
            OpenDat dat = ControlDat.GetDat(currentDat);

            string message = (LocaleRU) ? "Сохранить изменения в DAT файл?" : "Save changes to a DAT file?";

            if (!dat.IsFO2Type())
            {
                message += (LocaleRU)
                          ? "\n\nПримечание: Данная версия программы не поддерживает сжатие добавленных файлов для DAT формата Fallout 1."
                          : "\n\nNote: This version does not support the compression of the added files for DAT Fallout 1 format.";
            }
            if (MessageBox.Show(message, "Dat Explorer II", MessageBoxButtons.YesNo) == DialogResult.No)
            {
                return;
            }

            statusToolStripStatusLabel.Text = "Saving:";
            textToolStripStatusLabel.Text   = "Prepare...";

            int count = dat.TotalFiles - dat.AddedFiles;

            if (count > 1000)
            {
                count /= 5;
            }
            count += (dat.AddedFiles > 1000) ? dat.AddedFiles / 5 : dat.AddedFiles;
            toolStripProgressBar.Maximum = count;

            if (dat.SaveDat())
            {
                FindFiles(currentDat, folderTreeView.SelectedNode);
            }

            SaveToolStripButton.Enabled   = false;
            toolStripProgressBar.Value    = 0;
            textToolStripStatusLabel.Text = "Done.";
        }
Пример #4
0
        private void Delete(bool isList)
        {
            if (MessageBox.Show((LocaleRU)
                                ? "Вы действительно хотите это удалить?"
                                : "Do you want to delete it?",
                                "Dat Explorer II", MessageBoxButtons.YesNo) == DialogResult.No)
            {
                return;
            }

            statusToolStripStatusLabel.Text = "Deleting:";
            textToolStripStatusLabel.Text   = "Prepare...";

            if (isList)
            {
                new WaitForm(this).RemoveFile(filesListView.SelectedItems);
                FindFiles(currentDat, currentNode);
            }
            else
            {
                new WaitForm(this).RemoveFile(currentNode.Name);
                folderTreeView.Nodes.Remove(currentNode);
            }

            textToolStripStatusLabel.Text = toolStripProgressBar.Value + " file(s)";
            toolStripProgressBar.Value    = 0;

            var dat = ControlDat.GetDat(currentDat);

            totalToolStripStatusLabel.Text = dat.TotalFiles.ToString();

            if (dat.ShouldSave())
            {
                SaveToolStripButton.Enabled = true;
            }
        }
Пример #5
0
        private void GetFolderFiles(List <String> listFiles, string folderPath)
        {
            OpenDat dat = ControlDat.GetDat(currentDat);

            dat.GetFilesFromFolder(listFiles, folderPath);
        }
Пример #6
0
        private void filesListView_AfterLabelEdit(object sender, LabelEditEventArgs e)
        {
            deleteFilesToolStripMenuItem.Enabled = true;
            filesListView.LabelEdit = false;
            skipKeyEvent            = true;

            if (!createFolder && (e.Label == null || e.Label.Equals(filesListView.Items[e.Item].Text)))
            {
                e.CancelEdit = true;
                return;
            }

            string newName = e.Label ?? filesListView.Items[e.Item].Text;

            if (e.Label != null)
            {
                bool isSelfRename = e.Label.Equals(filesListView.Items[e.Item].Text, StringComparison.OrdinalIgnoreCase);
                if (!isSelfRename)
                {
                    foreach (ListViewItem item in filesListView.Items)
                    {
                        if (e.Label.Equals(item.Text, StringComparison.OrdinalIgnoreCase))
                        {
                            if (item.Tag == null)
                            {
                                MessageBox.Show((LocaleRU)
                                                 ? "Директория с таким именем уже существует."
                                                 : "This directory already exists.",
                                                "Dat Explorer II", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                if (createFolder)
                                {
                                    newName      = filesListView.Items[e.Item].Text;
                                    e.CancelEdit = true;
                                    break;
                                }
                            }
                            else     // file
                            {
                                MessageBox.Show((LocaleRU)
                                                ? "Файл с таким именем уже существует."
                                                : "The file with the same name already exists.",
                                                "Dat Explorer II", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                            e.CancelEdit = true;
                            return;
                        }
                    }
                }
            }

            OpenDat dat      = ControlDat.GetDat(currentDat);
            string  fullPath = Misc.GetNodeFullPath(currentNode);

            if (createFolder)
            {
                string folderPath = fullPath + '\\' + newName + '\\';
                folderPath = folderPath.Substring(currentDat.Length + 1);

                TreeNode addNode = new TreeNode(newName);
                addNode.Name = folderPath.ToLowerInvariant();
                currentNode.Nodes.Add(addNode);

                filesListView.Items[e.Item].Name = addNode.Name;

                dat.AddEmptyFolder(folderPath);
                createFolder = false;
            }
            else
            {
                string pathTo = (fullPath + '\\' + filesListView.Items[e.Item].Text).ToLowerInvariant();
                pathTo = pathTo.Substring(currentDat.Length + 1);

                if (filesListView.Items[e.Item].Tag == null)   // folder
                {
                    pathTo += '\\';
                    string renamePath = dat.RenameFolder(pathTo, e.Label);
                    if (renamePath == null)
                    {
                        return;
                    }

                    filesListView.Items[e.Item].Name = renamePath;

                    // rename path and name for tree node
                    TreeNode node = Misc.FindPathNode(pathTo, currentNode);
                    node.Name = renamePath;
                    node.Text = e.Label;
                }
                else
                {
                    filesListView.Items[e.Item].Tag = dat.RenameFile(pathTo, e.Label);
                }
            }
            SaveToolStripButton.Enabled = dat.ShouldSave();
        }