Пример #1
0
        private void specialFolderSubItem_Click(object sender, EventArgs e)
        {
            XmlElement selectedNode = tree.SelectedNode.Tag as XmlElement;

            if (selectedNode == null)
            {
                return;
            }

            MenuItem menuItem = sender as MenuItem;

            if (menuItem != null)
            {
                XmlElement newProp = Wizard.WixFiles.WxsDocument.CreateElement("Directory", WixFiles.WixNamespaceUri);

                newProp.SetAttribute("Id", menuItem.Text);
                newProp.SetAttribute("Name", menuItem.Text);

                selectedNode.AppendChild(newProp);
                TreeNode newNode = new TreeNode();
                newNode.Text               = menuItem.Text;
                newNode.ImageIndex         = ImageListFactory.GetImageIndex("Directory");
                newNode.SelectedImageIndex = newNode.ImageIndex;
                newNode.Tag = newProp;
                newNode.EnsureVisible();

                tree.SelectedNode.Nodes.Add(newNode);
                tree.SelectedNode.Expand();
            }
        }
Пример #2
0
        private void newComponentMenuItem_Click(object sender, EventArgs e)
        {
            XmlElement selectedNode = tree.SelectedNode.Tag as XmlElement;

            if (selectedNode == null)
            {
                return;
            }

            EnterStringForm frm = new EnterStringForm();

            frm.Text = "Enter component id";
            if (DialogResult.OK == frm.ShowDialog())
            {
                XmlElement newProp = Wizard.WixFiles.WxsDocument.CreateElement("Component", WixFiles.WixNamespaceUri);

                newProp.SetAttribute("Id", frm.SelectedString);
                newProp.SetAttribute("DiskId", "1");
                newProp.SetAttribute("KeyPath", "yes");
                newProp.SetAttribute("Guid", Guid.NewGuid().ToString("D"));

                selectedNode.AppendChild(newProp);
                TreeNode newNode = new TreeNode();
                newNode.Text               = frm.SelectedString;
                newNode.ImageIndex         = ImageListFactory.GetImageIndex("Component");
                newNode.SelectedImageIndex = newNode.ImageIndex;
                newNode.Tag = newProp;
                newNode.EnsureVisible();

                tree.SelectedNode.Nodes.Add(newNode);
                tree.SelectedNode.Expand();
            }
        }
Пример #3
0
        protected void CreateNewCustomElement(string elementName)
        {
            WixFiles.UndoManager.BeginNewCommandRange();

            if (CurrentParent == null)
            {
                MessageBox.Show(String.Format("No location found to add \"{0}\" element, need element like module or product!", elementName));
                return;
            }

            XmlElement newElement = WixFiles.WxsDocument.CreateElement(elementName, WixFiles.WixNamespaceUri);
            TreeNode   action     = new TreeNode(elementName);

            action.Tag = newElement;

            int imageIndex = ImageListFactory.GetImageIndex(elementName);

            if (imageIndex >= 0)
            {
                action.ImageIndex         = imageIndex;
                action.SelectedImageIndex = imageIndex;
            }

            InsertNewXmlNode(CurrentParent, newElement);

            currTreeView.Nodes.Add(action);
            currTreeView.SelectedNode = action;

            ShowProperties(newElement);
        }
Пример #4
0
        protected TreeNode CreateNewSubElement(string typeName)
        {
            if (currTreeView.SelectedNode == null)
            {
                return(null);
            }

            XmlNode node = currTreeView.SelectedNode.Tag as XmlNode;

            if (node == null)
            {
                return(null);
            }

            WixFiles.UndoManager.BeginNewCommandRange();

            XmlElement newElement = node.OwnerDocument.CreateElement(typeName, WixFiles.GetNamespaceUri(typeName));
            TreeNode   control    = new TreeNode(typeName);

            control.Tag = newElement;

            int imageIndex = ImageListFactory.GetImageIndex(typeName);

            if (imageIndex >= 0)
            {
                control.ImageIndex         = imageIndex;
                control.SelectedImageIndex = imageIndex;
            }

            InsertNewXmlNode(node, newElement);

            currTreeView.SelectedNode.Nodes.Add(control);

            return(control);
        }
Пример #5
0
        private void RecurseDirectories(string[] subFolders, TreeNode treeNode, XmlNode parentDirectoryElement)
        {
            foreach (string folder in subFolders)
            {
                DirectoryInfo dirInfo = new DirectoryInfo(folder);

                if (FileImport.NeedToIgnore(dirInfo.Name))
                {
                    continue;
                }

                XmlElement newElement = parentDirectoryElement.OwnerDocument.CreateElement("Directory", WixFiles.WixNamespaceUri);

                newElement.SetAttribute("Id", FileImport.GenerateValidIdentifier(dirInfo.Name, newElement, wixFiles));

                newElement.SetAttribute(WixEditSettings.Instance.LongName, FileImport.GenerateValidLongName(dirInfo.Name));
                if (WixEditSettings.Instance.IsUsingWix2())
                {
                    newElement.SetAttribute(WixEditSettings.Instance.ShortName, FileImport.GenerateValidShortName(PathHelper.GetShortDirectoryName(dirInfo, wixFiles, parentDirectoryElement)));
                }

                TreeNode newNode = new TreeNode(newElement.GetAttribute(WixEditSettings.Instance.LongName));
                newNode.Tag = newElement;

                if (firstShowableNode == null)
                {
                    firstShowableNode = newNode;
                }

                int imageIndex = ImageListFactory.GetImageIndex("Directory");
                if (imageIndex >= 0)
                {
                    newNode.ImageIndex         = imageIndex;
                    newNode.SelectedImageIndex = imageIndex;
                }

                XmlNodeList sameNodes = parentDirectoryElement.SelectNodes("wix:Directory", wixFiles.WxsNsmgr);
                if (sameNodes.Count > 0)
                {
                    parentDirectoryElement.InsertAfter(newElement, sameNodes[sameNodes.Count - 1]);
                }
                else
                {
                    parentDirectoryElement.AppendChild(newElement);
                }

                treeNode.Nodes.Add(newNode);

                string[] subFiles = Directory.GetFiles(dirInfo.FullName);
                if (subFiles.Length > 0)
                {
                    FileImport.AddFiles(wixFiles, subFiles, newNode, newElement);
                }

                string[] subSubFolders = Directory.GetDirectories(dirInfo.FullName);
                RecurseDirectories(subSubFolders, newNode, newElement);
            }
        }
Пример #6
0
        private static void AddDirectoryTreeNodes(XmlNodeList dirNodes, TreeNodeCollection treeNodes)
        {
            foreach (XmlNode dirNode in dirNodes)
            {
                if (dirNode.Name != "Directory")
                {
                    continue;
                }

                XmlElement dirElement = (XmlElement)dirNode;

                TreeNode treeNode = new TreeNode();
                treeNode.Tag        = dirElement;
                treeNode.Text       = dirElement.GetAttribute("Name");
                treeNode.ImageIndex = ImageListFactory.GetImageIndex("Directory");

                treeNodes.Add(treeNode);
                treeNode.Expand();

                AddDirectoryTreeNodes(dirNode.ChildNodes, treeNode.Nodes);
            }
        }
Пример #7
0
        public void Import(TreeNode treeNode)
        {
            XmlElement newElement = componentElement.OwnerDocument.CreateElement("File", WixFiles.WixNamespaceUri);

            newElement.SetAttribute("Id", GenerateValidIdentifier(fileInfo.Name, newElement, wixFiles));
            newElement.SetAttribute(LongName, GenerateValidLongName(fileInfo.Name));
            if (WixEditSettings.Instance.IsUsingWix2())
            {
                newElement.SetAttribute(ShortName, GenerateValidShortName(PathHelper.GetShortFileName(fileInfo, wixFiles, componentElement)));
            }
            newElement.SetAttribute("Source", PathHelper.GetRelativePath(fileInfo.FullName, wixFiles));

            TreeNode newNode = new TreeNode(newElement.GetAttribute(LongName));

            newNode.Tag = newElement;

            int imageIndex = ImageListFactory.GetImageIndex("File");

            if (imageIndex >= 0)
            {
                newNode.ImageIndex         = imageIndex;
                newNode.SelectedImageIndex = imageIndex;
            }

            XmlNodeList sameNodes = componentElement.SelectNodes("wix:File", wixFiles.WxsNsmgr);

            if (sameNodes.Count > 0)
            {
                componentElement.InsertAfter(newElement, sameNodes[sameNodes.Count - 1]);
            }
            else
            {
                componentElement.AppendChild(newElement);
            }

            treeNode.Nodes.Add(newNode);
        }
Пример #8
0
        private void NewFolder()
        {
            EnterStringForm frm = new EnterStringForm();

            frm.Text = "Enter Directory Name";
            if (DialogResult.OK == frm.ShowDialog())
            {
                XmlNode    node         = tree.SelectedNode.Tag as XmlNode;
                XmlElement newDirectory = node.OwnerDocument.CreateElement("Directory", WixFiles.WixNamespaceUri);
                newDirectory.SetAttribute("Name", frm.SelectedString);
                newDirectory.SetAttribute("Id", FileImport.GenerateValidIdentifier(frm.SelectedString, newDirectory, Wizard.WixFiles));
                node.AppendChild(newDirectory);

                TreeNode treeNode = new TreeNode();
                treeNode.Text               = frm.SelectedString;
                treeNode.ImageIndex         = ImageListFactory.GetImageIndex("Directory");
                treeNode.SelectedImageIndex = treeNode.ImageIndex;
                treeNode.SelectedImageIndex = treeNode.ImageIndex;
                treeNode.Tag = newDirectory;
                tree.SelectedNode.Nodes.Add(treeNode);
                tree.SelectedNode.Expand();
                treeNode.EnsureVisible();
            }
        }
Пример #9
0
        public static void AddFiles(WixFiles wixFiles, string[] files, TreeNode treeNode, XmlNode parentDirectoryElement)
        {
            foreach (string file in files)
            {
                FileInfo fileInfo = new FileInfo(file);

                if (NeedToIgnore(fileInfo.Name))
                {
                    continue;
                }

                XmlElement newComponentElement = parentDirectoryElement.OwnerDocument.CreateElement("Component", WixFiles.WixNamespaceUri);

                newComponentElement.SetAttribute("Id", FileImport.GenerateValidIdentifier(fileInfo.Name, newComponentElement, wixFiles));
                newComponentElement.SetAttribute("DiskId", "1");
                newComponentElement.SetAttribute("Guid", Guid.NewGuid().ToString().ToUpper());

                parentDirectoryElement.AppendChild(newComponentElement);

                TreeNode newComponentNode = new TreeNode(newComponentElement.GetAttribute("Id"));
                newComponentNode.Tag = newComponentElement;

                int imageIndex = ImageListFactory.GetImageIndex("Component");
                if (imageIndex >= 0)
                {
                    newComponentNode.ImageIndex         = imageIndex;
                    newComponentNode.SelectedImageIndex = imageIndex;
                }

                treeNode.Nodes.Add(newComponentNode);

                XmlElement newFileElement = parentDirectoryElement.OwnerDocument.CreateElement("File", WixFiles.WixNamespaceUri);

                newFileElement.SetAttribute("Id", FileImport.GenerateValidIdentifier(fileInfo.Name, newFileElement, wixFiles));
                newFileElement.SetAttribute(WixEditSettings.Instance.LongName, FileImport.GenerateValidLongName(fileInfo.Name));
                if (WixEditSettings.Instance.IsUsingWix2())
                {
                    newFileElement.SetAttribute(WixEditSettings.Instance.ShortName, FileImport.GenerateValidShortName(PathHelper.GetShortFileName(fileInfo, wixFiles, newComponentElement)));
                }
                newFileElement.SetAttribute("Source", PathHelper.GetRelativePath(fileInfo.FullName, wixFiles));

                TreeNode newFileNode = new TreeNode(newFileElement.GetAttribute(WixEditSettings.Instance.LongName));
                newFileNode.Tag = newFileElement;

                imageIndex = ImageListFactory.GetImageIndex("File");
                if (imageIndex >= 0)
                {
                    newFileNode.ImageIndex         = imageIndex;
                    newFileNode.SelectedImageIndex = imageIndex;
                }

                XmlNodeList sameNodes = newComponentElement.SelectNodes("wix:File", wixFiles.WxsNsmgr);
                if (sameNodes.Count > 0)
                {
                    newComponentElement.InsertAfter(newFileElement, sameNodes[sameNodes.Count - 1]);
                }
                else
                {
                    newComponentElement.AppendChild(newFileElement);
                }

                newComponentNode.Nodes.Add(newFileNode);
            }
        }
Пример #10
0
        public FileSheet(WizardForm creator)
            : base(creator)
        {
            this.AutoScroll = true;

            titleLabel         = new Label();
            titleLabel.Text    = "Add files and folders to install.";
            titleLabel.Dock    = DockStyle.Top;
            titleLabel.Height  = 20;
            titleLabel.Left    = 0;
            titleLabel.Top     = 0;
            titleLabel.Padding = new Padding(5, 5, 5, 0);
            titleLabel.Font    = new Font("Verdana",
                                          10,
                                          FontStyle.Bold,
                                          GraphicsUnit.Point
                                          );
            titleLabel.BackColor = Color.White;

            descriptionLabel           = new Label();
            descriptionLabel.Text      = "Select Files and Directories you want to add to the installer";
            descriptionLabel.Dock      = DockStyle.Top;
            descriptionLabel.Height    = 50 - titleLabel.Height;
            descriptionLabel.Left      = 0;
            descriptionLabel.Top       = titleLabel.Height;
            descriptionLabel.Padding   = new Padding(8, 3, 5, 0);
            descriptionLabel.BackColor = Color.White;

            this.Controls.Add(descriptionLabel);

            this.Controls.Add(titleLabel);


            lineLabel             = new Label();
            lineLabel.Anchor      = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
            lineLabel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            lineLabel.Location    = new Point(0, titleLabel.Height + descriptionLabel.Height);
            lineLabel.Size        = new Size(this.Width, 2);

            this.Controls.Add(lineLabel);

            tree = new TreeView();
            tree.HideSelection = false;
            tree.Anchor        = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
            tree.Location      = new Point(4, titleLabel.Height + descriptionLabel.Height + lineLabel.Height + 5);
            tree.Width         = this.Width - 8 - 100 - 8;
            tree.Height        = this.Height - tree.Top - 7;
            tree.ImageList     = ImageListFactory.GetImageList();
            tree.MouseDown    += new MouseEventHandler(tree_MouseDown);

            this.Controls.Add(tree);

            newFolderButton          = new Button();
            newFolderButton.Anchor   = AnchorStyles.Top | AnchorStyles.Right;
            newFolderButton.Location = new Point(tree.Location.X + tree.Width + 8, tree.Top);
            newFolderButton.Width    = 100;
            newFolderButton.Height   = 23;
            newFolderButton.Text     = "New folder";
            newFolderButton.Click   += new EventHandler(newFolderButton_Click);

            this.Controls.Add(newFolderButton);

            removeButton          = new Button();
            removeButton.Anchor   = AnchorStyles.Top | AnchorStyles.Right;
            removeButton.Location = new Point(tree.Location.X + tree.Width + 8, newFolderButton.Bottom + 8);
            removeButton.Width    = 100;
            removeButton.Height   = 23;
            removeButton.Text     = "Remove folder";
            removeButton.Click   += new EventHandler(removeButton_Click);

            this.Controls.Add(removeButton);

            importDirectoryButton          = new Button();
            importDirectoryButton.Anchor   = AnchorStyles.Top | AnchorStyles.Right;
            importDirectoryButton.Location = new Point(tree.Location.X + tree.Width + 8, removeButton.Bottom + 8);
            importDirectoryButton.Width    = 100;
            importDirectoryButton.Height   = 23;
            importDirectoryButton.Text     = "Import directory";
            importDirectoryButton.Click   += new EventHandler(importDirectoryButton_Click);

            this.Controls.Add(importDirectoryButton);

            importFilesButton          = new Button();
            importFilesButton.Anchor   = AnchorStyles.Top | AnchorStyles.Right;
            importFilesButton.Location = new Point(tree.Location.X + tree.Width + 8, importDirectoryButton.Bottom + 8);
            importFilesButton.Width    = 100;
            importFilesButton.Height   = 23;
            importFilesButton.Text     = "Import files";
            importFilesButton.Click   += new EventHandler(importFilesButton_Click);

            this.Controls.Add(importFilesButton);

            contextMenu        = new ContextMenu();
            contextMenu.Popup += new EventHandler(contextMenu_Popup);
            // tree.ContextMenu = contextMenu;

            importFilesMenuItem        = new IconMenuItem("&Import Files", new Bitmap(WixFiles.GetResourceStream("bmp.import.bmp")));
            importFilesMenuItem.Click += new System.EventHandler(importFilesMenuItem_Click);
            contextMenu.MenuItems.Add(importFilesMenuItem);

            newFolderMenuItem        = new IconMenuItem("&New Folder", new Bitmap(WixFiles.GetResourceStream("bmp.new.bmp")));
            newFolderMenuItem.Click += new System.EventHandler(newFolderMenuItem_Click);
            contextMenu.MenuItems.Add(newFolderMenuItem);

            importFolderMenuItem        = new IconMenuItem("&Import Folder", new Bitmap(WixFiles.GetResourceStream("bmp.import.bmp")));
            importFolderMenuItem.Click += new System.EventHandler(importFolderMenuItem_Click);
            contextMenu.MenuItems.Add(importFolderMenuItem);

            newSpecialFolderMenuItem = new IconMenuItem("New Special Folder", new Bitmap(WixFiles.GetResourceStream("bmp.new.bmp")));
            foreach (string specialFolder in specialFolders)
            {
                IconMenuItem subItem = new IconMenuItem(specialFolder);
                subItem.Click += new EventHandler(specialFolderSubItem_Click);
                newSpecialFolderMenuItem.MenuItems.Add(subItem);
            }
            contextMenu.MenuItems.Add(newSpecialFolderMenuItem);

            newComponentMenuItem        = new IconMenuItem("New Component", new Bitmap(WixFiles.GetResourceStream("bmp.new.bmp")));
            newComponentMenuItem.Click += new EventHandler(newComponentMenuItem_Click);
            contextMenu.MenuItems.Add(newComponentMenuItem);

            deleteMenuItem        = new IconMenuItem("&Delete", new Bitmap(WixFiles.GetResourceStream("bmp.delete.bmp")));
            deleteMenuItem.Click += new EventHandler(deleteMenuItem_Click);
            contextMenu.MenuItems.Add(deleteMenuItem);


            XmlDocument         wxsDoc   = Wizard.WixFiles.WxsDocument;
            XmlNamespaceManager wxsNsmgr = Wizard.WixFiles.WxsNsmgr;

            XmlNodeList        dirNodes  = wxsDoc.SelectNodes("/wix:Wix/*/wix:Directory", wxsNsmgr);
            TreeNodeCollection treeNodes = tree.Nodes;

            InitTreeView(dirNodes);
        }
Пример #11
0
        protected void AddTreeNodesRecursive(XmlNode file, TreeNodeCollection nodes)
        {
            if (file.Name.StartsWith("#"))
            {
                return;
            }

            TreeNode node = new TreeNode(GetDisplayName(file));

            node.Tag = file;

            int imageIndex = -1;

            if (file.Name == "File" && file.Attributes["Source"] != null)
            {
                string filePath = Path.Combine(Wizard.WixFiles.WxsDirectory.FullName, file.Attributes["Source"].Value);
                if (File.Exists(filePath))
                {
                    string key = Path.GetExtension(filePath).ToUpper();
                    imageIndex = tree.ImageList.Images.IndexOfKey(key);
                    if (imageIndex < 0)
                    {
                        try
                        {
                            Icon ico = FileIconFactory.GetFileIcon(filePath);
                            if (ico != null)
                            {
                                tree.ImageList.Images.Add(key, ico);
                                imageIndex = tree.ImageList.Images.Count - 1;
                            }
                        } // if icon retrieved from icon factory
                        catch { }
                    }     // if image not already in tree image list
                }         // if file exists
            }             // node is a file and Source attribute is not null
            if (imageIndex < 0)
            {
                imageIndex = ImageListFactory.GetImageIndex(file.Name);
            }
            if (imageIndex >= 0)
            {
                node.ImageIndex         = imageIndex;
                node.SelectedImageIndex = imageIndex;
            }

            nodes.Add(node);

            if (file.ChildNodes.Count > 10000)
            {
                TreeNode tooManyNodes = new TreeNode("<< Too many children to display >>");
                node.ImageIndex         = ImageListFactory.GetUnsupportedImageIndex();
                node.SelectedImageIndex = node.ImageIndex;
                node.Nodes.Add(tooManyNodes);

                return;
            }

            foreach (XmlNode child in file.ChildNodes)
            {
                if (child.NodeType == XmlNodeType.ProcessingInstruction)
                {
                    continue;
                }

                AddTreeNodesRecursive(child, node.Nodes);
            }
        }
Пример #12
0
        public void Import(TreeNode treeNode)
        {
            TextReader reader = new StreamReader(regFileInfo.FullName);

            string line = reader.ReadLine();

            lineNumber = 1;
            string trimmedLine = "";

            ArrayList createdChildren = new ArrayList();

            bool   currentKeyUsed = false;
            string currentRoot    = null;
            string currentKey     = null;

            while ((line = reader.ReadLine()) != null)
            {
                lineNumber++;
                trimmedLine = line.Trim();

                if (trimmedLine == "")
                {
                    continue;
                }
                else if (trimmedLine.StartsWith("["))
                {
                    if (trimmedLine.EndsWith("]") == false ||
                        trimmedLine.IndexOf("\\") < 0)
                    {
                        throw new ImportException(String.Format("Invalid line (Line {0}): \"{1}\"", lineNumber, trimmedLine));
                    }

                    if (currentKeyUsed == false && currentKey != null && currentRoot != null)
                    {
                        XmlElement registryKey = componentElement.OwnerDocument.CreateElement(registryKeyElementName, WixFiles.WixNamespaceUri);
                        registryKey.SetAttribute("Root", currentRoot);
                        registryKey.SetAttribute("Key", currentKey);

                        createdChildren.Add(registryKey);
                    }

                    currentKey     = null;
                    currentRoot    = null;
                    currentKeyUsed = false;

                    string fullRegKey      = line.Substring(1, line.Length - 2);
                    int    rootSeparatePos = fullRegKey.IndexOf("\\");
                    string fullRoot        = fullRegKey.Substring(0, rootSeparatePos);
                    string root            = GetRootString(fullRoot);
                    if (root == null || fullRegKey.Length - rootSeparatePos - 1 <= 0)
                    {
                        throw new ImportException(String.Format("Invalid line (Line {0}): \"{1}\"", lineNumber, trimmedLine));
                    }
                    string restKey = fullRegKey.Substring(rootSeparatePos + 1, fullRegKey.Length - rootSeparatePos - 1);

                    currentRoot = root;
                    currentKey  = restKey;
                }
                else if (trimmedLine.StartsWith("\"") || trimmedLine.StartsWith("@"))
                {
                    if ((trimmedLine.IndexOf("@") != 0 && trimmedLine.IndexOf("\"", 1) < 0) ||
                        trimmedLine.IndexOf("=") < 0)
                    {
                        throw new ImportException(String.Format("Invalid line (Line {0}): \"{1}\"", lineNumber, trimmedLine));
                    }
                    else if (currentRoot == null || currentKey == null)
                    {
                        throw new ImportException(String.Format("Invalid line (Line {0}), missing key specification: \"{1}\"", lineNumber, trimmedLine));
                    }

                    string nextLine = null;
                    while (trimmedLine.EndsWith("\\"))
                    {
                        trimmedLine = trimmedLine.Remove(trimmedLine.Length - 1, 1);

                        nextLine = reader.ReadLine();
                        lineNumber++;
                        if (nextLine == null)
                        {
                            throw new ImportException(String.Format("Invalid line (Line {0}), missing part of value: \"{1}\"", lineNumber, trimmedLine));
                        }

                        trimmedLine += nextLine.Trim();
                    }

                    int    equalsPos   = trimmedLine.IndexOf("=");
                    string nameString  = trimmedLine.Substring(0, equalsPos).Trim();
                    string valueString = trimmedLine.Substring(equalsPos + 1).Trim();

                    string currentName = GetNameString(nameString);
                    string currentType = GetTypeString(valueString);

                    XmlElement registryKey = componentElement.OwnerDocument.CreateElement(registryValueElementName, WixFiles.WixNamespaceUri);
                    if (currentName != null && currentName != "")
                    {
                        registryKey.SetAttribute("Name", currentName);
                    }
                    registryKey.SetAttribute("Root", currentRoot);
                    registryKey.SetAttribute("Key", currentKey);
                    registryKey.SetAttribute("Type", currentType);

                    SetValue(registryKey, currentType, valueString);

                    createdChildren.Add(registryKey);

                    currentKeyUsed = true;
                }
                else
                {
                    throw new ImportException(String.Format("Invalid line (Line {0}): \"{1}\"", lineNumber, trimmedLine));
                }
            }

            if (currentKeyUsed == false)
            {
                XmlElement registryKey = componentElement.OwnerDocument.CreateElement(registryKeyElementName, WixFiles.WixNamespaceUri);
                registryKey.SetAttribute("Root", currentRoot);
                registryKey.SetAttribute("Key", currentKey);

                createdChildren.Add(registryKey);
            }

            foreach (XmlNode child in createdChildren)
            {
                componentElement.AppendChild(child);

                string       displayName = child.Name;
                string       root        = child.Attributes["Root"].Value;
                string       key         = child.Attributes["Key"].Value;
                XmlAttribute name        = child.Attributes["Name"];
                if (name != null)
                {
                    if (key.EndsWith("\\") == false)
                    {
                        key = key + "\\";
                    }
                    key = key + "@" + name.Value;
                }

                displayName = root + "\\" + key;

                int      imageIndex = ImageListFactory.GetImageIndex(child.Name);
                TreeNode newNode    = new TreeNode(displayName, imageIndex, imageIndex);
                newNode.Tag = child;

                treeNode.Nodes.Add(newNode);
            }
        }
Пример #13
0
        private void InitializeComponent()
        {
            currTreeView = new TreeView();
            splitter1    = new Splitter();
            panel1       = new Panel();

            CustomPropertyGrid currGrid            = new CustomPropertyGrid();
            ContextMenu        currGridContextMenu = new ContextMenu();

            panelContextMenu        = new ContextMenu();
            panelContextMenu.Popup += new EventHandler(PopupPanelContextMenu);

            currTreeView.HideSelection      = false;
            currTreeView.Dock               = DockStyle.Left;
            currTreeView.ImageIndex         = -1;
            currTreeView.Location           = new Point(0, 0);
            currTreeView.Name               = "currTreeView";
            currTreeView.SelectedImageIndex = -1;
            currTreeView.Size               = new Size(256, 266);
            currTreeView.TabIndex           = 6;
            currTreeView.ImageList          = ImageListFactory.GetImageList();
            currTreeView.AfterSelect       += new TreeViewEventHandler(OnAfterSelect);
            currTreeViewContextMenu         = new ContextMenu();
            currTreeViewContextMenu.Popup  += new EventHandler(PopupTreeViewContextMenu);
            currTreeView.MouseDown         += new MouseEventHandler(TreeViewMouseDown);
            currTreeView.KeyDown           += new KeyEventHandler(TreeViewKeyDown);

            splitter1.Dock     = DockStyle.Left;
            splitter1.Location = new Point(140, 0);
            splitter1.Name     = "splitter1";
            splitter1.Size     = new Size(2, 266);
            splitter1.TabIndex = 7;
            splitter1.TabStop  = false;

            currGridContextMenu.Popup += new EventHandler(OnPropertyGridPopupContextMenu);

            currGrid.Dock                  = DockStyle.Fill;
            currGrid.Font                  = new Font("Tahoma", 8.25F, FontStyle.Regular, GraphicsUnit.Point, ((System.Byte)(0)));
            currGrid.Location              = new Point(140, 0);
            currGrid.Name                  = "_currGrid";
            currGrid.Size                  = new Size(250, 266);
            currGrid.TabIndex              = 1;
            currGrid.PropertySort          = PropertySort.Alphabetical;
            currGrid.ToolbarVisible        = false;
            currGrid.PropertyValueChanged += new PropertyValueChangedEventHandler(OnPropertyValueChanged);
            currGrid.ContextMenu           = currGridContextMenu;

            panel1.Controls.Add(currGrid);
            panel1.Dock     = DockStyle.Fill;
            panel1.Location = new Point(142, 0);
            panel1.Name     = "panel1";
            panel1.Size     = new Size(409, 266);
            panel1.TabIndex = 9;

            Controls.Add(panel1);
            Controls.Add(splitter1);
            Controls.Add(currTreeView);

            CurrentGrid            = currGrid;
            CurrentGridContextMenu = currGridContextMenu;
        }