예제 #1
0
        protected void RefreshGrid()
        {
            CurrentList = WixFiles.WxsDocument.SelectNodes(CurrentXPath, WixFiles.WxsNsmgr);

            CurrentGrid.SelectedObject = null;
            CurrentGrid.SelectedObject = GetPropertyAdapter();

            CurrentGrid.Update();
        }
예제 #2
0
        protected void ShowProperties(XmlNode xmlNode)
        {
            XmlAttributeAdapter attAdapter = null;

            if (xmlNode != null)
            {
                attAdapter = new XmlAttributeAdapter(xmlNode, WixFiles);
            }

            CurrentGrid.SelectedObject = attAdapter;
            CurrentGrid.Update();

            return;
        }
예제 #3
0
        protected void OnDeletePropertyGridItem(object sender, EventArgs e)
        {
            XmlNode element = GetSelectedProperty();

            if (element == null)
            {
                throw new WixEditException("No element found to delete!");
            }

            // Temporarily store the XmlAttributeAdapter, while resetting the CurrentGrid.
            PropertyAdapterBase attAdapter = (PropertyAdapterBase)CurrentGrid.SelectedObject;

            CurrentGrid.SelectedObject = null;

            WixFiles.UndoManager.BeginNewCommandRange();
            attAdapter.RemoveProperty(element);

            // Update the CurrentGrid.
            CurrentGrid.SelectedObject = attAdapter;
            CurrentGrid.Update();
        }
예제 #4
0
        public void OnNewPropertyGridItem(object sender, EventArgs e)
        {
            WixFiles.UndoManager.BeginNewCommandRange();

            // Temporarily store the XmlAttributeAdapter
            XmlAttributeAdapter attAdapter = (XmlAttributeAdapter)CurrentGrid.SelectedObject;

            ArrayList attributes = new ArrayList();

            XmlNodeList xmlAttributes = attAdapter.XmlNodeDefinition.SelectNodes("xs:attribute", WixFiles.XsdNsmgr);

            foreach (XmlNode at in xmlAttributes)
            {
                string attName = at.Attributes["name"].Value;
                if (attAdapter.XmlNode.Attributes[attName] == null)
                {
                    attributes.Add(attName);
                }
            }

            if (attAdapter.XmlNodeDefinition.Name == "xs:extension")
            {
                bool hasInnerText = false;
                foreach (GridItem it in CurrentGrid.SelectedGridItem.Parent.GridItems)
                {
                    if (it.Label == "InnerText")
                    {
                        hasInnerText = true;
                        break;
                    }
                }
                if (hasInnerText == false)
                {
                    attributes.Add("InnerText");
                }
            }

            attributes.Sort();

            SelectStringForm frm = new SelectStringForm();

            frm.PossibleStrings = attributes.ToArray(typeof(String)) as String[];
            if (DialogResult.OK != frm.ShowDialog() ||
                frm.SelectedStrings.Length == 0)
            {
                return;
            }

            // Show dialog to choose from available items.
            XmlAttribute att = null;

            foreach (string newAttributeName in frm.SelectedStrings)
            {
                if (string.Equals(newAttributeName, "InnerText"))
                {
                    attAdapter.ShowInnerTextIfEmpty = true;
                }
                else
                {
                    att = WixFiles.WxsDocument.CreateAttribute(newAttributeName);
                    attAdapter.XmlNode.Attributes.Append(att);
                }
            }

            CurrentGrid.SelectedObject = null;
            // Update the CurrentGrid.
            CurrentGrid.SelectedObject = attAdapter;
            CurrentGrid.Update();

            string firstNewAttributeName = frm.SelectedStrings[0];

            foreach (GridItem it in CurrentGrid.SelectedGridItem.Parent.GridItems)
            {
                if (it.Label == firstNewAttributeName)
                {
                    CurrentGrid.SelectedGridItem = it;
                    break;
                }
            }
        }