예제 #1
0
        DomRegion GetTextEditorRegionForDialogElement(string dialogId)
        {
            IDocument         document  = view.DesignerCodeFileDocument;
            WixDocumentReader wixReader = new WixDocumentReader(document.Text);

            return(wixReader.GetElementRegion("Dialog", dialogId));
        }
예제 #2
0
        Location FindProductElementEndLocation(ITextEditor textEditor, WixDocument document)
        {
            XmlElement        productElement = document.GetProduct();
            string            productId      = productElement.GetAttribute("Id");
            WixDocumentReader wixReader      = new WixDocumentReader(textEditor.Document.Text);

            return(wixReader.GetEndElementLocation("Product", productId));
        }
예제 #3
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="xml">The replacement xml.</param>
		public DomRegion ReplaceElement(string elementAttributeId, string elementName, string replacementXml)
		{
			WixDocumentReader wixReader = new WixDocumentReader(document.Text);
			DomRegion region = wixReader.GetElementRegion(elementName, elementAttributeId);
			if (!region.IsEmpty) {
				Replace(region, replacementXml);
			}
			return region;
		}
예제 #4
0
        /// <summary>
        /// Adds dialog ids to the list.
        /// </summary>
        void AddDialogListItems(string fileName)
        {
            WorkbenchTextFileReader workbenchTextFileReader = new WorkbenchTextFileReader();

            using (TextReader reader = workbenchTextFileReader.Create(fileName)) {
                WixDocumentReader wixReader = new WixDocumentReader(reader);
                setupDialogListView.AddDialogs(fileName, wixReader.GetDialogIds());
            }
        }
        /// <summary>
        /// From the current cursor position in the text editor determine the
        /// selected dialog id.
        /// </summary>
        string GetDialogIdSelectedInTextEditor()
        {
            ITextEditor textEditor = ActiveTextEditor;

            if (textEditor != null)
            {
                WixDocumentReader wixReader = new WixDocumentReader(textEditor.Document.Text);
                return(wixReader.GetDialogId(textEditor.Caret.Line));
            }
            return(null);
        }
        /// <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="xml">The replacement xml.</param>
        public DomRegion ReplaceElement(string elementAttributeId, string elementName, string replacementXml)
        {
            WixDocumentReader wixReader = new WixDocumentReader(document.Text);
            DomRegion         region    = wixReader.GetElementRegion(elementName, elementAttributeId);

            if (!region.IsEmpty)
            {
                Replace(region, replacementXml);
            }
            return(region);
        }
예제 #7
0
		/// <summary>
		/// Gets the dialog element location given the filename and the dialog id.
		/// </summary>
		static TextLocation GetDialogElementLocation(string fileName, string id)
		{
			try {
				WorkbenchTextFileReader workbenchTextFileReader = new WorkbenchTextFileReader();
				using (TextReader reader = workbenchTextFileReader.Create(fileName)) {
					WixDocumentReader wixReader = new WixDocumentReader(reader);
					return wixReader.GetStartElementLocation("Dialog", id);
				}
			} catch (XmlException ex) {
				WixBindingService.ShowErrorInErrorList(fileName, ex);
			}
			return TextLocation.Empty;
		}
 /// <summary>
 /// Gets the dialog element location given the filename and the dialog id.
 /// </summary>
 static TextLocation GetDialogElementLocation(string fileName, string id)
 {
     try {
         WorkbenchTextFileReader workbenchTextFileReader = new WorkbenchTextFileReader();
         using (TextReader reader = workbenchTextFileReader.Create(fileName)) {
             WixDocumentReader wixReader = new WixDocumentReader(reader);
             return(wixReader.GetStartElementLocation("Dialog", id));
         }
     } catch (XmlException ex) {
         WixBindingService.ShowErrorInErrorList(fileName, ex);
     }
     return(TextLocation.Empty);
 }
		public void SetUpFixture()
		{
			WixDocumentReader wixReader = new WixDocumentReader(GetWixXml());
			dialogIds = wixReader.GetDialogIds();
			welcomeDialogId = dialogIds[0];
			progressDialogId = dialogIds[1];
			
			wixReader = new WixDocumentReader(GetWixXml());
			welcomeDialogLocation = wixReader.GetStartElementLocation("Dialog", welcomeDialogId);
		
			wixReader = new WixDocumentReader(GetWixXml());
			missingDialogLocation = wixReader.GetStartElementLocation("Dialog", "missingDialogId");
		}
		public void SingleDirectoryElement()
		{
			string xml = "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>\r\n" +
				"\t<Fragment>\r\n" +
				"\t\t<Directory Id='TARGETDIR' Name='SourceDir'>\r\n" +
				"\t\t</Directory>\r\n" +
				"\t</Fragment>\r\n" +
				"</Wix>";
			WixDocumentReader wixReader = new WixDocumentReader(xml);
			DomRegion region = wixReader.GetElementRegion("Directory", "TARGETDIR");
			DomRegion expectedRegion = new DomRegion(3, 3, 4, 14);
			Assert.AreEqual(expectedRegion, region);
		}
		public void EmptyElement()
		{
			string xml = "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>\r\n" +
				"\t<Product Name='DialogTest' \r\n" +
				"\t         Version='1.0' \r\n" +
				"\t         Language='1013' \r\n" +
				"\t         Manufacturer='#develop' \r\n" +
				"\t         Id='????????-????-????-????-????????????'/>\r\n" +
				"</Wix>";
			WixDocumentReader wixReader = new WixDocumentReader(xml);
			TextLocation location = wixReader.GetEndElementLocation("Product", "????????-????-????-????-????????????");
			TextLocation expectedLocation = TextLocation.Empty;
			Assert.AreEqual(expectedLocation, location);
		}
		public void ElementStartsImmediatelyAfterDialogEndElement()
		{
			string xml = "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>\r\n" +
				"\t<Fragment>\r\n" +
				"\t\t<UI>\r\n" +
				"<Dialog Id='WelcomeDialog'></Dialog><Property/>\r\n" +
				"\t\t</UI>\r\n" +
				"\t</Fragment>\r\n" +
				"</Wix>";
			
			WixDocumentReader wixReader = new WixDocumentReader(xml);
			DomRegion region = wixReader.GetElementRegion("Dialog", "WelcomeDialog");
			DomRegion expectedRegion = new DomRegion(4, 1, 4, 36);
			Assert.AreEqual(expectedRegion, region);
		}
		public void EmptyDialogElement()
		{
			string xml = "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>\r\n" +
				"\t<Fragment>\r\n" +
				"\t\t<UI>\r\n" +
				"<Dialog Id='WelcomeDialog'/>\r\n" +
				"\t\t</UI>\r\n" +
				"\t</Fragment>\r\n" +
				"</Wix>";
			
			WixDocumentReader wixReader = new WixDocumentReader(xml);
			DomRegion region = wixReader.GetElementRegion("Dialog", "WelcomeDialog");
			DomRegion expectedRegion = new DomRegion(4, 1, 4, 28);
			Assert.AreEqual(expectedRegion, region);
		}
        /// <summary>
        /// Gets the first dialog id in the file.
        /// </summary>
        string GetFirstDialogIdInTextEditor()
        {
            ITextEditor textEditor = ActiveTextEditor;

            if (textEditor != null)
            {
                WixDocumentReader           wixReader = new WixDocumentReader(textEditor.Document.Text);
                ReadOnlyCollection <string> ids       = wixReader.GetDialogIds();
                if (ids.Count > 0)
                {
                    return(ids[0]);
                }
            }
            return(null);
        }
		public void DialogSpansTwoLines()
		{
			string xml = "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>\r\n" +
				"\t<Fragment>\r\n" +
				"\t\t<UI>\r\n" +
				"\t\t\t<Dialog Id='WelcomeDialog' Height='100' Width='200'>\r\n" +
				"\t\t\t</Dialog>\r\n" +
				"\t\t</UI>\r\n" +
				"\t</Fragment>\r\n" +
				"</Wix>";
			
			WixDocumentReader wixReader = new WixDocumentReader(xml);
			DomRegion region = wixReader.GetElementRegion("Dialog", "WelcomeDialog");
			DomRegion expectedRegion = new DomRegion(4, 4, 5, 12);
			Assert.AreEqual(expectedRegion, region);
		}
 /// <summary>
 /// Jumps to dialog element with corresponding dialog id. This is only used
 /// when the user opens a dialog from the Setup dialogs window or the cursor
 /// was not near a dialog when the designer was switched to. Jumping to the
 /// dialog selected ensures that when the user switches back, if they did
 /// not make any changes, then the dialog xml is displayed.
 /// </summary>
 void JumpToDialogElement(string dialogId)
 {
     try {
         if (dialogId != null)
         {
             ITextEditor textEditor = ActiveTextEditor;
             if (textEditor != null)
             {
                 WixDocumentReader wixReader = new WixDocumentReader(textEditor.Document.Text);
                 TextLocation      location  = wixReader.GetStartElementLocation("Dialog", dialogId);
                 textEditor.JumpTo(location.Line, 1);
             }
         }
     } catch (XmlException) {
         // Ignore
     }
 }
		public void SetUpFixture()
		{
			wixReader = new WixDocumentReader(GetWixXml());
		}
		DomRegion GetTextEditorRegionForDialogElement(string dialogId)
		{
			IDocument document = view.DesignerCodeFileDocument;
			WixDocumentReader wixReader = new WixDocumentReader(document.Text);
			return wixReader.GetElementRegion("Dialog", dialogId);
		}
예제 #19
0
		/// <summary>
		/// Jumps to dialog element with corresponding dialog id. This is only used
		/// when the user opens a dialog from the Setup dialogs window or the cursor
		/// was not near a dialog when the designer was switched to. Jumping to the
		/// dialog selected ensures that when the user switches back, if they did
		/// not make any changes, then the dialog xml is displayed.
		/// </summary>
		void JumpToDialogElement(string dialogId)
		{
			try {
				if (dialogId != null) {
					ITextEditor textEditor = ActiveTextEditor;
					if (textEditor != null) {
						WixDocumentReader wixReader = new WixDocumentReader(textEditor.Document.Text);
						TextLocation location = wixReader.GetStartElementLocation("Dialog", dialogId);
						textEditor.JumpTo(location.Line, 1);
					}
				}
			} catch (XmlException) {
				// Ignore
			}
		}
		DomRegion GetTextEditorRegionForDialogElement(string dialogId)
		{
			WixDocumentReader wixReader = new WixDocumentReader(view.GetDocumentXml());
			return wixReader.GetElementRegion("Dialog", dialogId);
		}
예제 #21
0
		/// <summary>
		/// Adds dialog ids to the list.
		/// </summary>
		void AddDialogListItems(string fileName)
		{
			WorkbenchTextFileReader workbenchTextFileReader = new WorkbenchTextFileReader();
			using (TextReader reader = workbenchTextFileReader.Create(fileName)) {
				WixDocumentReader wixReader = new WixDocumentReader(reader);
				setupDialogListView.AddDialogs(fileName, wixReader.GetDialogIds());
			}
		}
        DomRegion GetTextEditorRegionForDialogElement(string dialogId)
        {
            WixDocumentReader wixReader = new WixDocumentReader(view.GetDocumentXml());

            return(wixReader.GetElementRegion("Dialog", dialogId));
        }
예제 #23
0
		/// <summary>
		/// From the current cursor position in the text editor determine the
		/// selected dialog id.
		/// </summary>
		string GetDialogIdSelectedInTextEditor()
		{
			ITextEditor textEditor = ActiveTextEditor;
			if (textEditor != null) {
				WixDocumentReader wixReader = new WixDocumentReader(textEditor.Document.Text);
				return wixReader.GetDialogId(textEditor.Caret.Line);
			}
			return null;
		}
예제 #24
0
		TextLocation FindProductElementEndLocation(ITextEditor textEditor, WixDocument document)
		{
			XmlElement productElement = document.GetProduct();
			string productId = productElement.GetAttribute("Id");
			WixDocumentReader wixReader = new WixDocumentReader(textEditor.Document.Text);
			return wixReader.GetEndElementLocation("Product", productId);
		}
예제 #25
0
		/// <summary>
		/// Gets the first dialog id in the file.
		/// </summary>
		string GetFirstDialogIdInTextEditor()
		{
			ITextEditor textEditor = ActiveTextEditor;
			if (textEditor != null) {
				WixDocumentReader wixReader = new WixDocumentReader(textEditor.Document.Text);
				ReadOnlyCollection<string> ids = wixReader.GetDialogIds();
				if (ids.Count > 0) {
					return ids[0];
				}
			}
			return null;
		}