Beispiel #1
0
        private void ImportFoldersInDirectory(TreeNode node, XmlNode directoryNode, string[] folders)
        {
            if (directoryNode.Name == "Directory")
            {
                bool mustExpand = (node.Nodes.Count == 0);

                CurrentTreeView.SuspendLayout();

                WixFiles.UndoManager.BeginNewCommandRange();
                try
                {
                    DirectoryImport dirImport = new DirectoryImport(WixFiles, folders, directoryNode);
                    dirImport.Import(node);
                }
                catch (WixEditException ex)
                {
                    MessageBox.Show(String.Format("Failed to complete import: {0}\r\n\r\nThe import is aborted and could be partially completed.", ex.Message), "Import Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (Exception ex)
                {
                    ErrorReportHandler r = new ErrorReportHandler(ex, this.TopLevelControl, "An exception occured during the import! Please press OK to report this error to the WixEdit website, so this error can be fixed.");
                    r.ReportInSeparateThread();
                }

                CurrentTreeView.ResumeLayout();
            }
        }
Beispiel #2
0
        private void ImportFilesInComponent(TreeNode node, XmlNode componentNode, string[] files)
        {
            if (componentNode.Name == "Component")
            {
                bool mustExpand = (node.Nodes.Count == 0);

                CurrentTreeView.SuspendLayout();

                bool foundReg = false;
                foreach (string file in files)
                {
                    if (Path.GetExtension(file).ToLower() == ".reg")
                    {
                        foundReg = true;
                        break;
                    }
                }

                bool importRegistryFiles = false;
                if (foundReg == true)
                {
                    DialogResult result = MessageBox.Show(this, "Import Registry (*.reg) files to Registry elements?", "Import?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                    if (result == DialogResult.Cancel)
                    {
                        return;
                    }
                    else if (result == DialogResult.Yes)
                    {
                        importRegistryFiles = true;
                    }
                }

                WixFiles.UndoManager.BeginNewCommandRange();
                StringBuilder errorMessageBuilder = new StringBuilder();

                foreach (string file in files)
                {
                    FileInfo fileInfo = new FileInfo(file);
                    try
                    {
                        if (fileInfo.Extension.ToLower() == ".reg" && importRegistryFiles)
                        {
                            RegistryImport regImport = new RegistryImport(WixFiles, fileInfo, componentNode);
                            regImport.Import(node);
                        }
                        else
                        {
                            FileImport fileImport = new FileImport(WixFiles, fileInfo, componentNode);
                            fileImport.Import(node);
                        }
                    }
                    catch (WixEditException ex)
                    {
                        errorMessageBuilder.AppendFormat("{0} ({1})\r\n", fileInfo.Name, ex.Message);
                    }
                    catch (Exception ex)
                    {
                        string        message = String.Format("An exception occured during the import of \"{0}\"! Please press OK to report this error to the WixEdit website, so this error can be fixed.", fileInfo.Name);
                        ExceptionForm form    = new ExceptionForm(message, ex);
                        if (form.ShowDialog() == DialogResult.OK)
                        {
                            ErrorReporter reporter = new ErrorReporter();
                            reporter.Report(ex);
                        }
                    }
                }

                if (errorMessageBuilder.Length > 0)
                {
                    MessageBox.Show(this, "Import failed for the following files:\r\n\r\n" + errorMessageBuilder.ToString(), "Import failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                ShowNode(componentNode);

                if (mustExpand)
                {
                    node.Expand();
                }

                CurrentTreeView.ResumeLayout();
            }
        }