private void dgrExtensions_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == deleteColumn.Index) { dgrExtensions.Rows.RemoveAt(e.RowIndex); // update row index(Display) values for (int i = 0; i < dgrExtensions.Rows.Count; i++) { dgrExtensions[indexColumn.Name, i].Value = i + 1; } } else if (e.ColumnIndex == BrowseColumn.Index) { // show dialog to select files and folders in Components tree ComponentsForm componentsForm = new ComponentsForm(true); Point pointToScreen = PointToScreen(dgrExtensions.Location); int x = pointToScreen.X + dgrExtensions.Columns[0].Width + dgrExtensions.Columns[1].Width + dgrExtensions.Columns[2].Width + dgrExtensions.Columns[3].Width - componentsForm.Width; int y = pointToScreen.Y + dgrExtensions.ColumnHeadersHeight + dgrExtensions.Rows[e.RowIndex].Height * e.RowIndex; componentsForm.Location = new Point(x, y); if (componentsForm.ShowDialog() == DialogResult.OK) { if (componentsForm.SelectedComponentNode != null) { ComponentNode componentNode = (ComponentNode)componentsForm.SelectedComponentNode.Tag; dgrExtensions[applicationColumn.Name, e.RowIndex].Value = (new FileInfo(componentNode.Property.SourcePath)).Name; dgrExtensions.Rows[e.RowIndex].Tag = componentsForm.SelectedComponentNode; } } } else { dgrExtensions.BeginEdit(true); } }
private static List <BuildLogMessage> CheckFeatureExists(TreeView tree, TreeNode node, Modules module) { List <BuildLogMessage> messages = new List <BuildLogMessage>(); TreeNodeCollection nodes = node == null ? tree.Nodes : node.Nodes; foreach (TreeNode childNode in nodes) { if (childNode.Tag != null && childNode.Tag is ComponentNode) { ComponentNode componentNode = (ComponentNode)childNode.Tag; if (componentNode.Property.Feature != null && Common.FeatureExists(componentNode.Property.Feature.Id) == false) { BuildLogMessage buildMessage = new BuildLogMessage(); buildMessage.Message = "Feature " + componentNode.Property.Feature.Name + " assigned to the file: " + childNode.FullPath + " is not found in the feature tree."; buildMessage.Type = LogType.ERROR; buildMessage.Module = Modules.Components; messages.Add(buildMessage); } } if (childNode.Nodes.Count > 0) { messages.AddRange(CheckFeatureExists(tree, childNode, module)); } } return(messages); }
private void GetComponentTotals(TreeNode parentNode, ref long totalSize, ref int totalFolders, ref int totalFiles, ref int totalServices, ref int totalAssemblies) { foreach (TreeNode node in parentNode.Nodes) { ComponentNode componentNode = (ComponentNode)node.Tag; if (componentNode.Type == ComponentType.RootFolder || componentNode.Type == ComponentType.Folder) { totalFolders++; GetComponentTotals(node, ref totalSize, ref totalFolders, ref totalFiles, ref totalServices, ref totalAssemblies); } else { if (componentNode.Type == ComponentType.File) { totalFiles++; } else if (componentNode.Type == ComponentType.Service) { totalServices++; } else if (componentNode.Type == ComponentType.Assembly) { totalAssemblies++; } FileInfo fileInfo = new FileInfo(componentNode.Property.SourcePath); totalSize += fileInfo.Length; } } }
private void SetFileImage(TreeNode node) { ComponentNode componentNode = (ComponentNode)node.Tag; if (componentNode != null) { if (componentNode.Type == ComponentType.File) { node.ImageIndex = sysilsSmall.IconIndex(componentNode.Property.SourcePath, true); node.SelectedImageIndex = sysilsSmall.IconIndex(componentNode.Property.SourcePath, true, ShellIconStateConstants.ShellIconStateOpen); } else if (componentNode.Type == ComponentType.Folder || componentNode.Type == ComponentType.RootFolder) { node.ImageIndex = node.SelectedImageIndex = folderImageIndex; foreach (TreeNode childNode in node.Nodes) { SetFileImage(childNode); } } else if (componentNode.Type == ComponentType.InternetShortcut) { node.ImageIndex = node.SelectedImageIndex = sysilsSmall.IconIndex(Globals.imagesFolder + Globals.imgInternet, true); } } }
private static List <BuildLogMessage> CheckFileSrc(TreeView tree, TreeNode node, Modules module) { List <BuildLogMessage> messages = new List <BuildLogMessage>(); List <TreeNode> errorNodes = new List <TreeNode>(); TreeNodeCollection nodes = node == null ? tree.Nodes : node.Nodes; foreach (TreeNode childNode in nodes) { ComponentNode componentNode = (ComponentNode)childNode.Tag; if (componentNode.Type == ComponentType.File) { if (File.Exists(componentNode.Property.SourcePath) == false) { errorNodes.Add(childNode); } } if (childNode.Nodes.Count > 0) { messages.AddRange(CheckFileSrc(tree, childNode, module)); } } // add messages foreach (TreeNode errorNode in errorNodes) { BuildLogMessage message = new BuildLogMessage(); message.Message = "Source file not found:" + errorNode.Text + ". (" + errorNode.FullPath + ")"; message.Type = LogType.ERROR; message.Module = module; messages.Add(message); } return(messages); }
private void tvComponents_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { if (tvComponents.SelectedNode != null) { // set selectedNode property and close window ComponentNode componentNode = (ComponentNode)tvComponents.SelectedNode.Tag; if (componentNode.Type != ComponentType.Folder || componentNode.Type != ComponentType.RootFolder) { if (ComponentNodeSelected != null) { ComponentNodeSelected(this, null); } } } tvComponents.NodeMouseDoubleClick -= new TreeNodeMouseClickEventHandler(tvComponents_NodeMouseDoubleClick); pnlComponents.Controls.Clear(); if (this.modalDlg) { this.DialogResult = DialogResult.OK; } else { this.Hide(); } }
private void edit_SystemFolder_Click(object sender, EventArgs e) { ComponentNode node = (ComponentNode)tvSystemFolder.SelectedNode.Tag; if (node != null && node.Type == ComponentType.Folder) { tvSystemFolder.SelectedNode.BeginEdit(); } }
private void edit_Shortcuts_Click(object sender, EventArgs e) { ComponentNode node = (ComponentNode)tvShortcuts.SelectedNode.Tag; if (node != null && node.Type == ComponentType.Folder && tvShortcuts.SelectedNode.Level != 0) { tvShortcuts.SelectedNode.BeginEdit(); } }
private void CreateProgIdComponent(DataGridViewRow rowData) { ComponentNode exeData = (ComponentNode)((TreeNode)rowData.Tag).Tag; Wix.Component exeComponent = (Wix.Component)exeData.Property.WixNode; Wix.File exeFile = (Wix.File)exeComponent.Items[0]; string extenstion = (string)rowData.Cells[extensionColumn.Name].Value; if (extenstion.StartsWith(".")) { extenstion = extenstion.Remove(0, 1); } string regKey = Path.GetFileNameWithoutExtension(exeFile.Source) + "." + extenstion; //keyReg Wix.Registry reg1 = new Wix.Registry(); reg1.Id = regKey; reg1.Root = Wix.RegistryRoot.HKCR; reg1.RootSpecified = true; reg1.Action = Wix.RegistryAction.write; reg1.ActionSpecified = true; reg1.Type = Wix.RegistryType.@string; reg1.TypeSpecified = true; reg1.Key = regKey; reg1.Value = (string)rowData.Cells[DescriptionColumn.Name].Value; //reg1.KeyPath = Wix.YesNoType.yes; reg1.KeyPathSpecified = true; // command or application to run Wix.Registry reg2 = new Wix.Registry(); reg2.Id = regKey + ".command"; reg2.Root = Wix.RegistryRoot.HKCR; reg2.RootSpecified = true; reg2.Action = Wix.RegistryAction.write; reg2.ActionSpecified = true; reg2.Type = Wix.RegistryType.@string; reg2.TypeSpecified = true; reg2.Key = regKey + @"\shell\open\command"; reg2.Value = "\"[#" + exeFile.Id + "]\" \"%1\""; //default icon Wix.Registry reg3 = new Wix.Registry(); reg3.Id = regKey + ".icon"; reg3.Root = Wix.RegistryRoot.HKCR; reg3.RootSpecified = true; reg3.Action = Wix.RegistryAction.write; reg3.ActionSpecified = true; reg3.Type = Wix.RegistryType.@string; reg3.TypeSpecified = true; reg3.Key = regKey + @"\DefaultIcon"; reg3.Value = "\"[#" + exeFile.Id + "]\""; //.<extension> key Wix.Registry reg4 = new Wix.Registry(); reg4.Id = regKey + ".association"; reg4.Root = Wix.RegistryRoot.HKCR; reg4.RootSpecified = true; reg4.Action = Wix.RegistryAction.write; reg4.ActionSpecified = true; reg4.Type = Wix.RegistryType.@string; reg4.TypeSpecified = true; reg4.Key = "." + extenstion; reg4.Value = regKey; object[] items = new object[4] { reg1, reg2, reg3, reg4 }; exeComponent.Items = Common.AddItemToArray(exeComponent.Items, items); }
private void tvComponents_BeforeLabelEdit(object sender, NodeLabelEditEventArgs e) { if (tvComponents.SelectedNode != null) { ComponentNode node = (ComponentNode)tvComponents.SelectedNode.Tag; if (node.Type == ComponentType.RootFolder) { e.CancelEdit = true; } } }
private void tvComponents_ItemDrag(object sender, ItemDragEventArgs e) { TreeNode sourceNode = (TreeNode)e.Item; tvComponents.SelectedNode = sourceNode; ComponentNode component = (ComponentNode)sourceNode.Tag; if (component != null && component.Type == ComponentType.File) { DoDragDrop(sourceNode, DragDropEffects.Move | DragDropEffects.Copy); } }
private void GetShortcutSummary(TreeNode shortcutNode, DataTable shortcutsTable) { foreach (TreeNode node in shortcutNode.Nodes) { ComponentNode componentNode = (ComponentNode)node.Tag; if (componentNode.Type == ComponentType.RootFolder || componentNode.Type == ComponentType.Folder) { GetShortcutSummary(node, shortcutsTable); } else if (componentNode.Type == ComponentType.Service || componentNode.Type == ComponentType.File || componentNode.Type == ComponentType.Assembly) { shortcutsTable.Rows.Add(node.FullPath, "", componentNode.Property.SourcePath);//TODO:Installation location of shortcut } } }
private void ApplyFeature(TreeNode node, FeatureProperty selectedFeature) { ComponentNode componentNode = (ComponentNode)node.Tag; if (componentNode.Type == ComponentType.Folder || componentNode.Type == ComponentType.RootFolder) { foreach (TreeNode childNodes in node.Nodes) { ApplyFeature(childNodes, selectedFeature); } } else { componentNode.Property.Feature = selectedFeature; } }
private void GetFilesSummary(TreeNode parentNode, DataTable filesTable) { foreach (TreeNode node in parentNode.Nodes) { ComponentNode componentNode = (ComponentNode)node.Tag; if (componentNode.Type == ComponentType.RootFolder || componentNode.Type == ComponentType.Folder) { GetFilesSummary(node, filesTable); } else if (componentNode.Type == ComponentType.Service || componentNode.Type == ComponentType.File || componentNode.Type == ComponentType.Assembly) { FileInfo fileInfo = new FileInfo(componentNode.Property.SourcePath); filesTable.Rows.Add(node.FullPath, componentNode.Property.SourcePath, fileInfo.Length); } } }
private void tvShortcuts_DragDrop(object sender, DragEventArgs e) { //TreeNode sourceNode = (TreeNode)e.Item; Point pos = tvShortcuts.PointToClient(new Point(e.X, e.Y)); TreeNode targetNode = tvShortcuts.GetNodeAt(pos); ComponentNode tag = (ComponentNode)targetNode.Tag; if (targetNode != null && (tag != null && tag.Type == ComponentType.Folder) || targetNode.Level == 0) { TreeNode node = (TreeNode)e.Data.GetData(typeof(TreeNode)); TreeNode nodeCopy = new TreeNode(node.Text, tvComponents.SelectedNode.ImageIndex, tvComponents.SelectedNode.SelectedImageIndex); nodeCopy.Tag = node.Tag; // assign complete ComponentNode object of component node ((ComponentNode)nodeCopy.Tag).SecondaryTreeNode = node; // assign Component Tree node itself targetNode.Nodes.Add(nodeCopy); tvShortcuts.Invalidate(); } }
private void applyPatch_Components_Click(object sender, EventArgs e) { if (tvComponents.SelectedNode != null) { OpenFileDialog dlg = new OpenFileDialog(); dlg.Multiselect = false; if (dlg.ShowDialog() == DialogResult.OK) { ComponentNode componentNode = (ComponentNode)tvComponents.SelectedNode.Tag; if (componentNode != null) { componentNode.Property.PatchFile = dlg.FileName; ChangeNodeColor(tvComponents.SelectedNode, true, Globals.PatchFileColor); } } } }
private void CalculateFilesFoldersCount(TreeNode node) { ComponentNode componentNode = (ComponentNode)node.Tag; if (componentNode.Type == ComponentType.Folder || componentNode.Type == ComponentType.RootFolder) { FoldersCount++; } else { filesCount++; } foreach (TreeNode childNode in node.Nodes) { CalculateFilesFoldersCount(childNode); } }
private void Delete_Components_Folder() { if (tvComponents.SelectedNode != null) { TreeNode selectedNode = tvComponents.SelectedNode; ComponentNode componentNode = (ComponentNode)selectedNode.Tag; if (componentNode.Type == ComponentType.RootFolder) { tvComponents.Nodes[0].Remove(); } else { tvComponents.SelectedNode.Remove(); } // change files, folders count CalculateFilesFoldersCount_Start(); } }
private void tvShortcuts_AfterSelect(object sender, TreeViewEventArgs e) { TreeNode selectedNode = tvShortcuts.SelectedNode; if (selectedNode != null) { ComponentNode componentNode = (ComponentNode)selectedNode.Tag; if (componentNode.Type == ComponentType.InternetShortcut) { tabShortcutProperty.SelectedIndex = 1; pgShortcuts.SelectedObject = componentNode.Property.ShortcutProperty; } else { tabShortcutProperty.SelectedIndex = 0; pgShortcuts.SelectedObject = null; } } }
private void CheckComponentNodeExists(TreeNode node) { if (node.Tag != null) /*Normally NULL for root nodes*/ { ComponentNode componentNode = (ComponentNode)node.Tag; if (componentNode.SecondaryTreeNode != null && componentNode.SecondaryTreeNode.TreeView == null) { BuildLogMessage buildMessage = new BuildLogMessage(); buildMessage.Message = String.Format("Source file of shortcut file: {0} is not found in components tree. Please check whether the component tree structure is maintained.", node.FullPath); buildMessage.Type = LogType.ERROR; buildMessage.Module = Modules.Components; BuildLogger.Add(buildMessage); } } foreach (TreeNode childNode in node.Nodes) { CheckComponentNodeExists(childNode); } }
private void tvComponents_AfterSelect(object sender, TreeViewEventArgs e) { ComponentNode node = (ComponentNode)e.Node.Tag; if (node.Type == ComponentType.File || node.Type == ComponentType.Assembly) { pgComponent.SelectedObject = node.Property; pgServices.SelectedObject = null; tabControlProperties.SelectedIndex = 0; // Disable context menu options browseFilesToolStripMenuItem.Enabled = false; mnuAddService.Enabled = false; addAssemblyToolStripMenuItem.Enabled = false; addFolderToolStripMenuItem.Enabled = false; windowsFolderToolStripMenuItem.Enabled = false; } else if (node.Type == ComponentType.Service) { pgComponent.SelectedObject = node.Property; pgServices.SelectedObject = node.Property.ServiceProperty; tabControlProperties.SelectedIndex = 1; // Disable context menu options browseFilesToolStripMenuItem.Enabled = false; mnuAddService.Enabled = false; addAssemblyToolStripMenuItem.Enabled = false; addFolderToolStripMenuItem.Enabled = false; windowsFolderToolStripMenuItem.Enabled = false; } else { pgComponent.SelectedObject = null; pgServices.SelectedObject = null; tabControlProperties.SelectedIndex = 0; // enable context menu options browseFilesToolStripMenuItem.Enabled = true; mnuAddService.Enabled = true; addAssemblyToolStripMenuItem.Enabled = true; addFolderToolStripMenuItem.Enabled = true; windowsFolderToolStripMenuItem.Enabled = true; } }
private bool CanAddFolder_File(TreeNode selectedNode) { if (selectedNode == null) { return(false); } ComponentNode componentNode = (ComponentNode)selectedNode.Tag; if (componentNode.Type == ComponentType.RootFolder) { if (selectedNode.Nodes.Count > 0) { TreeNode childNode = selectedNode.Nodes[0]; ComponentNode componentNode1 = (ComponentNode)childNode.Tag; if (componentNode1.Type == ComponentType.RootFolder) { return(false); } } } return(true); }
private void ShowFeatures(TreeNode selectedNode) { FeaturesForm featureForm = new FeaturesForm(); if (featureForm.ShowDialog() == DialogResult.OK) { FeatureProperty selectedFeature = featureForm.SelectedProperty; ComponentNode componentNode = (ComponentNode)selectedNode.Tag; if (componentNode.Type == ComponentType.Folder || componentNode.Type == ComponentType.RootFolder) { // recursively apply selected feature to all nodes under the selected node foreach (TreeNode node in selectedNode.Nodes) { ApplyFeature(node, selectedFeature); } } else { componentNode.Property.Feature = selectedFeature; } } }
private void ApplyPatchNodeColor(TreeNode node) { ComponentNode componentNode = (ComponentNode)node.Tag; if (componentNode != null) { if (componentNode.Type == ComponentType.File || componentNode.Type == ComponentType.Assembly || componentNode.Type == ComponentType.Service) { if (String.IsNullOrEmpty(componentNode.Property.PatchFile) == false) { ChangeNodeColor(node, true, Globals.PatchFileColor); } } else if (componentNode.Type == ComponentType.Folder || componentNode.Type == ComponentType.RootFolder) { foreach (TreeNode childNode in node.Nodes) { ApplyPatchNodeColor(childNode); } } } }
private static List <BuildLogMessage> CheckProperties(TreeView tree, TreeNode node, Modules module) { List <BuildLogMessage> messages = new List <BuildLogMessage>(); TreeNodeCollection nodes = node == null ? tree.Nodes : node.Nodes; foreach (TreeNode childNode in nodes) { if (childNode.Tag != null && childNode.Tag.GetType() == typeof(ComponentNode)) { ComponentNode componentNode = (ComponentNode)childNode.Tag; if (componentNode.Type == ComponentType.InternetShortcut) { if (String.IsNullOrEmpty(componentNode.Property.ShortcutProperty.URL)) { BuildLogMessage message = new BuildLogMessage(); message.Message = "Internet shortcut URL is not set : " + childNode.FullPath; message.Type = LogType.ERROR; message.Module = module; messages.Add(message); } else { BuildLogMessage message = ValidateUrl("Internet shortcut URL", componentNode.Property.ShortcutProperty.URL, module); if (message != null) { messages.Add(message); } } } } if (childNode.Nodes.Count > 0) { messages.AddRange(CheckProperties(tree, childNode, module)); } } return(messages); }
private void addFile_Shortcuts_Click(object sender, EventArgs e) { if (tvShortcuts.SelectedNode != null) { ComponentsForm componentsForm = new ComponentsForm(true); if (componentsForm.ShowDialog() == DialogResult.OK) { TreeNode selectedComponentNode = componentsForm.SelectedComponentNode; ComponentNode tag = (ComponentNode)tvShortcuts.SelectedNode.Tag; if ((tag != null && tag.Type == ComponentType.Folder) || tvShortcuts.SelectedNode.Level == 0) { TreeNode newNode = new TreeNode(selectedComponentNode.Text, selectedComponentNode.ImageIndex, selectedComponentNode.SelectedImageIndex); newNode.Tag = selectedComponentNode.Tag; // assign complete ComponentNode object of component node ((ComponentNode)newNode.Tag).SecondaryTreeNode = selectedComponentNode; // assign Component Tree node itself tvShortcuts.SelectedNode.Nodes.Add(newNode); tvShortcuts.Invalidate(); } } // Show component tree again pnlComponents.Controls.Clear(); pnlComponents.Controls.Add(ControlsManager.TreeViews["Components"]); } }
private void SetShortcuts(Wix.File file, TreeNode cmpNode, TreeNode treeNode, Wix.Directory directory, ShortcutType type) { foreach (TreeNode shortcutNode in treeNode.Nodes) { ComponentNode componentNode = (ComponentNode)shortcutNode.Tag; if (componentNode.Type == ComponentType.Folder) { SetShortcuts(file, cmpNode, shortcutNode, (Wix.Directory)componentNode.Property.WixNode, type); } else if (componentNode.Type == ComponentType.File) { if (componentNode.Property == ((ComponentNode)cmpNode.Tag).Property) { Wix.Shortcut shortcut = new Wix.Shortcut(); shortcut.Id = Common.GetId(); shortcut.Directory = directory.Id; if (type == ShortcutType.Desktop) { file.Items[1] = shortcut; } else if (type == ShortcutType.StartMenu) { file.Items[0] = shortcut; } shortcut.Name = Common.GetShortname(shortcutNode.Text); if (shortcut.Name != shortcutNode.Text) { shortcut.LongName = shortcutNode.Text; } shortcut.WorkingDirectory = "INSTALLDIR"; //shortcut.Icon = new NvnInstaller.WixClasses.Icon( shortcut.IconIndex = "0"; } } } }
private void BuildWixDirectory(Wix.Directory rootDir, TreeNode treeNode, bool isShortcutDir) { rootDir.Items = new object[treeNode.Nodes.Count]; for (int i = 0; i < treeNode.Nodes.Count; i++) { TreeNode node = treeNode.Nodes[i]; ComponentNode componentNode = (ComponentNode)node.Tag; #region Folder if (componentNode.Type == ComponentType.Folder) { // create Wix directory Wix.Directory dir = new Wix.Directory(); dir.Id = Common.GetId(); dir.Name = Common.GetShortname(node.Text); componentNode.Property.WixNode = dir; if (dir.Name != node.Text) { dir.LongName = node.Text; } // add directory to parent directory rootDir.Items[i] = dir; // loop again BuildWixDirectory(dir, node, isShortcutDir); } #endregion #region File else if (isShortcutDir == false && componentNode.Type == ComponentType.File) { // add component Wix.Component component = new Wix.Component(); component.Id = Common.GetId(); component.Guid = Guid.NewGuid().ToString(); componentNode.Property.WixNode = component; // create file node Wix.File file = new Wix.File(); file.Id = componentNode.Property.Id; file.Name = Common.GetShortname(node.Text); if (file.Name != node.Text) { file.LongName = node.Text; } file.DiskId = "1"; // Only one disk supported file.Source = componentNode.Property.SourcePath; file.KeyPathSpecified = true; file.KeyPath = Wix.YesNoType.yes; file.VitalSpecified = true; file.Vital = componentNode.Property.Vital; // add file to component component.Items = new Wix.File[1]; component.Items[0] = file; file.Items = new object[2]; if (node.TreeView == tvComponents) { // look in Start Menu SetShortcuts(file, node, tvShortcuts.Nodes[0], this.menuDirectory, ShortcutType.StartMenu); // look in Desktop SetShortcuts(file, node, tvShortcuts.Nodes[1], this.desktopDirectory, ShortcutType.Desktop); } // Set component ref in FeatureNode Support.SetComponentRef(component, componentNode.Property.Feature); // add component to Directory node rootDir.Items[i] = component; } #endregion #region Assembly else if (isShortcutDir == false && componentNode.Type == ComponentType.Assembly) { // add component Wix.Component component = new Wix.Component(); component.Id = Common.GetId(); component.Guid = Guid.NewGuid().ToString(); componentNode.Property.WixNode = component; // create file node Wix.File file = new Wix.File(); file.Id = componentNode.Property.Id; FileInfo fileInfo = new FileInfo(componentNode.Property.SourcePath); string assemblyName = node.Text.Remove(0, 10).Replace(']', ' ').Trim(); file.Name = Common.GetShortname(assemblyName); if (file.Name != assemblyName) { file.LongName = assemblyName; } //Install assembly to GAC file.AssemblySpecified = true; file.Assembly = Wix.FileAssembly.net; file.DiskId = "1"; // Only one disk supported file.Source = componentNode.Property.SourcePath; file.KeyPathSpecified = true; file.KeyPath = Wix.YesNoType.yes; file.VitalSpecified = true; file.Vital = componentNode.Property.Vital; // add file to component component.Items = new Wix.File[1]; component.Items[0] = file; file.Items = new object[2]; if (node.TreeView == tvComponents) { // look in Start Menu SetShortcuts(file, node, tvShortcuts.Nodes[0], this.menuDirectory, ShortcutType.StartMenu); // look in Desktop SetShortcuts(file, node, tvShortcuts.Nodes[1], this.desktopDirectory, ShortcutType.Desktop); } // Set component ref in FeatureNode Support.SetComponentRef(component, componentNode.Property.Feature); // add component to Directory node rootDir.Items[i] = component; } #endregion #region Service else if (isShortcutDir == false && componentNode.Type == ComponentType.Service) { // create component object Wix.Component component = new Wix.Component(); component.Id = Common.GetId(); component.Guid = Guid.NewGuid().ToString(); componentNode.Property.WixNode = component; component.Items = new object[3]; // Create File Node Wix.File file = new Wix.File(); file.Id = componentNode.Property.Id; file.Name = Common.GetShortname(node.Text); if (file.Name != node.Text) { file.LongName = node.Text; } file.Source = componentNode.Property.SourcePath; file.DiskId = "1"; // Only one disk supported file.KeyPathSpecified = true; file.KeyPath = Wix.YesNoType.yes; // add file to component component.Items[0] = file; // create ServiceInstall node Wix.ServiceInstall serviceInstall = new Wix.ServiceInstall(); serviceInstall.Id = Common.GetId(); serviceInstall.Name = componentNode.Property.ServiceProperty.Name == null ? node.Text : componentNode.Property.ServiceProperty.Name; serviceInstall.DisplayName = componentNode.Property.ServiceProperty.DisplayName == null ? node.Text : componentNode.Property.ServiceProperty.DisplayName; serviceInstall.Type = componentNode.Property.ServiceProperty.InstallType; serviceInstall.Start = componentNode.Property.ServiceProperty.InstallStart; serviceInstall.ErrorControl = componentNode.Property.ServiceProperty.InstallErrorControl; // add serviceInstall node to component node component.Items[1] = serviceInstall; // Create Service Control Nodes Wix.ServiceControl serviceControl = new Wix.ServiceControl(); serviceControl.Id = Common.GetId(); serviceControl.Name = componentNode.Property.ServiceProperty.Name == null ? node.Text : componentNode.Property.ServiceProperty.Name; serviceControl.StartSpecified = true; serviceControl.Start = Wix.ServiceControlStart.install; serviceControl.StopSpecified = true; serviceControl.Stop = Wix.ServiceControlStop.uninstall; serviceControl.RemoveSpecified = true; serviceControl.Remove = Wix.ServiceControlRemove.uninstall; // add to component node component.Items[2] = serviceControl; // Set component ref in FeatureNode Support.SetComponentRef(component, componentNode.Property.Feature); // add component to Directory node rootDir.Items[i] = component; } #endregion #region Internet Shortcut else if (componentNode.Type == ComponentType.InternetShortcut) { /* Create file *.url in local folder with content like below * [InternetShortcut] * URL=http://www.google.com */ InternetShortcutProperty shortcutProperty = componentNode.Property.ShortcutProperty; string urlFile = Globals.localFolder + node.Text + ".url"; using (TextWriter writer = new StreamWriter(urlFile)) { writer.WriteLine("[InternetShortcut]"); writer.WriteLine("URL=" + shortcutProperty.URL); } // create component node in the respective shortcut directory // add component Wix.Component component = new Wix.Component(); component.Id = Common.GetId(); component.Guid = Guid.NewGuid().ToString(); // create file node Wix.File file = new Wix.File(); file.Id = Common.GetId(); file.Name = Common.GetShortname(node.Text); if (file.Name != node.Text) { file.LongName = node.Text + ".url"; } file.DiskId = "1"; // Only one disk supported file.Source = urlFile; file.KeyPathSpecified = true; file.KeyPath = Wix.YesNoType.yes; file.VitalSpecified = true; file.Vital = NvnInstaller.WixClasses.YesNoType.yes; // add file to component component.Items = new Wix.File[1]; component.Items[0] = file; // Set component ref in FeatureNode Support.SetComponentRef(component, shortcutProperty.Feature); // add component to Directory node rootDir.Items[i] = component; } #endregion } }
private void tvSystemFolder_AfterSelect(object sender, TreeViewEventArgs e) { ComponentNode componentNode = (ComponentNode)e.Node.Tag; pgSystemFolderComponents.SelectedObject = componentNode.Property; }