Пример #1
0
 /// <summary>
 /// Gets the dialog element location given the filename and the dialog id.
 /// </summary>
 static Location GetDialogElementLocation(string fileName, string id)
 {
     try {
         WorkbenchTextFileReader workbenchTextFileReader = new WorkbenchTextFileReader();
         using (TextReader reader = workbenchTextFileReader.Create(fileName)) {
             return(WixDocument.GetStartElementLocation(reader, "Dialog", id));
         }
     } catch (XmlException ex) {
         WixBindingService.ShowErrorInErrorList(fileName, ex);
     }
     return(Location.Empty);
 }
Пример #2
0
        /// <summary>
        /// Adds all the dialog ids from all the files in the project to the list view.
        /// </summary>
        /// <remarks>
        /// If an error occurs an error item is added to the list. The error
        /// list is only cleared the first time an error occurs
        /// since there may be multiple errors, one in each Wix file.
        /// Also we do not clear the error list unless we have an error
        /// so any previously added errors from a build, for example, are not
        /// cleared unless we have to.
        /// </remarks>
        void ShowDialogList()
        {
            // Make sure we do not leave any errors in the error list from a previous call.
            if (setupDialogListView.HasErrors)
            {
                WixBindingService.ClearErrorList();
            }

            setupDialogListView.Items.Clear();

            WixProject openWixProject = ProjectService.CurrentProject as WixProject;

            if (openWixProject != null)
            {
                bool clearedErrorList = false;
                foreach (FileProjectItem wixFile in openWixProject.WixFiles)
                {
                    if (File.Exists(wixFile.FileName))
                    {
                        try {
                            AddDialogListItems(wixFile.FileName);
                        } catch (XmlException ex) {
                            // Clear the error list the first time only.
                            if (!clearedErrorList)
                            {
                                clearedErrorList = true;
                                WixBindingService.ClearErrorList();
                            }
                            setupDialogListView.AddError(wixFile.FileName, ex);
                            WixBindingService.AddErrorToErrorList(wixFile.FileName, ex);
                        }
                    }
                }
                if (clearedErrorList)
                {
                    WixBindingService.ShowErrorList();
                }
            }
        }