Esempio n. 1
0
        private void AddMoreFiles_Click(object sender, EventArgs e)
        {
            if (!Program.HasPandaPath())
            {
                MessageBox.Show("You haven't set the Panda3D SDK path yet!", "PCAT", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.InitialDirectory = Directory.GetCurrentDirectory();
            openFileDialog.Filter           = "Multifiles (*.mf)|*.mf|All files (*.*)|*.*";
            openFileDialog.FilterIndex      = 1;
            openFileDialog.RestoreDirectory = true;
            openFileDialog.Multiselect      = true;

            if (openFileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }


            FolderSelectDialog outputDialog = new FolderSelectDialog();
            DirectoryInfo      parent       = Directory.GetParent(openFileDialog.FileNames[0]);

            if (parent == null)
            {
                outputDialog.InitialDirectory = openFileDialog.FileNames[0];
            }
            else
            {
                outputDialog.InitialDirectory = parent.ToString();
            }

            outputDialog.Title       = "Select the destination folder";
            outputDialog.Multiselect = false;

            if (!outputDialog.ShowDialog())
            {
                return;
            }

            string destination = outputDialog.FileName;

            TreeNode[] nodes    = folderView.Nodes.Find(destination, false);
            TreeNode   destNode = null;

            if (nodes.Length == 0)
            {
                destNode                  = new TreeNode(String.Format("Destination: {0}", destination));
                destNode.Name             = destination;
                destNode.ContextMenuStrip = menu;
            }
            else
            {
                destNode = nodes[0];
            }

            // Should we do this with the multifiles list or dynamically add like this?
            foreach (string mfFile in openFileDialog.FileNames)
            {
                /*
                 * // Check for duplicates
                 * TreeNode[] directories = folderView.Nodes.Find(directory, true);
                 *
                 * if (directories.Length > 0) {
                 *  // Only non-green nodes are duplicates
                 *  bool green = true;
                 *
                 *  foreach (TreeNode dirNode in directories) {
                 *      if (dirNode.BackColor != COMPLETE_COLOR) {
                 *          green = false;
                 *          break;
                 *      }
                 *  }
                 *
                 *  if (!green && MessageBox.Show(String.Format("The folder {0} is already specified as a build target. Are you sure?", directory), "PCAT", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.No) {
                 *      continue;
                 *  }
                 * }
                 */


                TreeNode mfNode = new TreeNode(mfFile);
                mfNode.Name             = mfFile;
                mfNode.ContextMenuStrip = menu;
                destNode.Nodes.Add(mfNode);
            }

            if (nodes.Length == 0 && destNode.Nodes.Count > 0)
            {
                folderView.Nodes.Add(destNode);
            }

            currentIndex = 0;
            initialCount = GetRemainingCount();

            if (initialCount > 0)
            {
                StartExtractButton.Enabled = true;
                OpenFileLocButton.Enabled  = true;
            }

            MFProgressBar.Maximum = initialCount;
        }
Esempio n. 2
0
        private void AddMoreFiles_Click(object sender, EventArgs e)
        {
            if (!Program.HasPandaPath())
            {
                MessageBox.Show("You haven't set the Panda3D SDK path yet!", "PCAT", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            FolderSelectDialog multifileDialog = new FolderSelectDialog();

            multifileDialog.Title       = "Select the multifile folders";
            multifileDialog.Multiselect = true;

            if (!multifileDialog.ShowDialog())
            {
                return;
            }

            FolderSelectDialog outputDialog = new FolderSelectDialog();
            DirectoryInfo      parent       = Directory.GetParent(multifileDialog.FileNames[0]);

            if (parent == null)
            {
                outputDialog.InitialDirectory = multifileDialog.FileNames[0];
            }
            else
            {
                outputDialog.InitialDirectory = parent.ToString();
            }

            outputDialog.Title       = "Select the destination folder";
            outputDialog.Multiselect = false;

            if (!outputDialog.ShowDialog())
            {
                return;
            }

            string destination = outputDialog.FileName;

            TreeNode[] nodes    = folderView.Nodes.Find(destination, false);
            TreeNode   destNode = null;

            if (nodes.Length == 0)
            {
                destNode                  = new TreeNode(String.Format("Destination: {0}", destination));
                destNode.Name             = destination;
                destNode.ContextMenuStrip = menu;
            }
            else
            {
                destNode = nodes[0];
            }

            // Should we do this with the multifiles list or dynamically add like this?
            foreach (string directory in multifileDialog.FileNames)
            {
                // Check for drive
                if (Directory.GetParent(directory) == null)
                {
                    MessageBox.Show("You have selected an entire drive. You will not continue.", "PCAT", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    continue; // continues anyway
                }

                // Check for duplicates
                TreeNode[] directories = folderView.Nodes.Find(directory, true);

                if (directories.Length > 0)
                {
                    // Only non-green nodes are duplicates
                    bool green = true;

                    foreach (TreeNode dirNode in directories)
                    {
                        if (dirNode.BackColor != COMPLETE_COLOR)
                        {
                            green = false;
                            break;
                        }
                    }

                    if (!green && MessageBox.Show(String.Format("The folder {0} is already specified as a build target. Are you sure?", directory), "PCAT", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.No)
                    {
                        continue;
                    }
                }

                // Check for directory size
                DirectoryInfo info = new DirectoryInfo(directory);

                if (GetDirectorySize(info, 0) >= WARNING_SIZE)
                {
                    if (MessageBox.Show(String.Format("Your selected folder {0} is over two gigabytes in size. This might take some time to build. Are you sure you want to continue?", directory), "PCAT", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
                    {
                        continue;
                    }
                }

                TreeNode mfNode = new TreeNode(directory);
                mfNode.Name             = directory;
                mfNode.ContextMenuStrip = menu;
                destNode.Nodes.Add(mfNode);
            }

            if (nodes.Length == 0 && destNode.Nodes.Count > 0)
            {
                folderView.Nodes.Add(destNode);
            }

            currentIndex = 0;
            initialCount = GetRemainingCount();

            if (initialCount > 0)
            {
                StartBuildButton.Enabled  = true;
                OpenFileLocButton.Enabled = true;
            }

            MFProgressBar.Maximum = initialCount;
        }