Ejemplo n.º 1
0
        /// <summary>
        /// Tries to replace the element defined by element name and its Id attribute in the
        /// text editor with the specified xml.
        /// </summary>
        /// <param name="id">The Id attribute of the element.</param>
        /// <param name="elementName">The name of the element.</param>
        /// <param name="textAreaControl">The text area control to update.</param>
        /// <param name="xml">The replacement xml.</param>
        bool ReplaceElement(string id, string elementName, TextAreaControl textAreaControl, string xml)
        {
            WixDocumentEditor documentEditor = new WixDocumentEditor(textAreaControl);
            IDocument         document       = textAreaControl.Document;
            DomRegion         region         = WixDocument.GetElementRegion(new StringReader(document.TextContent), elementName, id);

            if (!region.IsEmpty)
            {
                documentEditor.Replace(region, xml);
                return(true);
            }
            return(false);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Merges the changes made to the wix document by overwriting the dialog element.
        /// </summary>
        void IWixDialogDesignerGenerator.MergeFormChanges(string dialogId, XmlElement dialogElement)
        {
            // Get the text region we are replacing.
            IDocument document = view.DesignerCodeFileDocument;
            DomRegion region   = WixDocument.GetElementRegion(new StringReader(document.TextContent), "Dialog", dialogId);

            if (region.IsEmpty)
            {
                throw new FormsDesignerLoadException(String.Format(StringParser.Parse("${res:ICSharpCode.WixBinding.DialogDesignerGenerator.DialogIdNotFoundMessage}"), dialogId));
            }
            // Get the replacement dialog xml.
            TextEditorControl     textEditorControl = ((ITextEditorControlProvider)view.PrimaryViewContent).TextEditorControl;
            ITextEditorProperties properties        = textEditorControl.TextEditorProperties;
            string replacementXml = WixDocument.GetXml(dialogElement, properties.LineTerminator, properties.ConvertTabsToSpaces, properties.IndentationSize);

            // Replace the xml and select the inserted text.
            WixDocumentEditor editor = new WixDocumentEditor(textEditorControl.ActiveTextAreaControl);

            editor.Replace(region, replacementXml);
        }