Example #1
0
        private void MenuAddShortcut_Click(object sender, EventArgs e)
        {
            if (featuresTree.SelectedNode != null)
            {
                SetupFeature  current  = (SetupFeature)featuresTree.SelectedNode.Tag;
                SetupShortcut shortcut = new SetupShortcut();
                shortcut.srcPath = "[APPLICATIONFOLDER]";
                if ((null != current.configurableDirectory) && ("" != current.configurableDirectory))
                {
                    shortcut.srcPath = "[" + current.configurableDirectory + "]";
                }
                shortcut.dstPath     = "[APPLICATIONFOLDER]\\New Shortcut";
                shortcut.description = "Some Description";

                current.shortcuts.Add(shortcut);
                ReloadShortcuts();

                // Set the new one as selected
                foreach (ListViewItem item in shortcutList.Items)
                {
                    if (item.Tag.Equals(shortcut))
                    {
                        item.Selected = true;
                        break;
                    }
                }
            }
        }
Example #2
0
 private void shortcutList_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
 {
     //shortcutProperties.DataBindings.Clear();
     shortcutProperties.SelectedObject = null;
     if (null != e.Item)
     {
         SetupShortcut sc = (SetupShortcut)e.Item.Tag;
         shortcutProperties.SelectedObject = sc;
     }
 }
Example #3
0
 private void shortcutProperties_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
 {
     if ((null != shortcutList.SelectedItems) && (shortcutList.SelectedItems.Count > 0))
     {
         ListViewItem  item     = shortcutList.SelectedItems[0];
         SetupShortcut shortcut = (SetupShortcut)shortcutProperties.SelectedObject;
         item.Text             = Path.GetFileName(shortcut.dstPath);
         item.SubItems[1].Text = Path.GetDirectoryName(shortcut.dstPath);
         item.SubItems[2].Text = shortcut.srcPath;
     }
 }
        private XmlElement AddShortcut(SetupShortcut shortcut, SetupFeature feature, string directoryId, string shortcutType)
        {
            XmlElement sc_node = doc.CreateElement("Shortcut");

            if (null == shortcutType)
            {
                sc_node.SetAttribute("Id", shortcut.shortcutId);
            }
            else
            {
                sc_node.SetAttribute("Id", shortcutType + "_" + shortcut.shortcutId);
            }

            if ((null != shortcut.commandArguments) && ("" != shortcut.commandArguments))
                sc_node.SetAttribute("Arguments", shortcut.commandArguments);

            sc_node.SetAttribute("Description", shortcut.description);

            if (null == directoryId)
            {
                sc_node.SetAttribute("Directory", GetDirectoryNode(
                    Path.GetDirectoryName(shortcut.dstPath), null).mXmlNode.GetAttribute("Id"));
            }
            else
            {
                sc_node.SetAttribute("Directory", directoryId);
            }

            sc_node.SetAttribute("Name", Path.GetFileName(shortcut.dstPath));

            if ((null != shortcut.workingDir) && ("" != shortcut.workingDir))
            {
                TargetDir dir = GetDirectoryNode(shortcut.workingDir, null);
                string id = dir.mXmlNode.GetAttribute("Id");
                sc_node.SetAttribute("WorkingDirectory", id);
            }

            XmlElement target_dir = GetDirectoryNode(Path.GetDirectoryName(shortcut.srcPath), null).mXmlNode;
            XmlElement target_node = null;
            string target_name = Path.GetFileName(shortcut.srcPath);

            // Scan the target-dir for a directory with the target-name
            foreach (XmlNode xml_node in target_dir.ChildNodes)
            {
                if ((xml_node.NodeType == XmlNodeType.Element)
                    && (xml_node.Name == "Directory"))
                {
                    XmlElement subdir = (XmlElement)xml_node;
                    string name = subdir.GetAttribute("Name");
                    if (name == target_name)
                    {
                        target_node = subdir;
                        break;
                    }
                }
            }

            // Scan the dir for a file with the target_name
            if (null == target_node)
            {
                foreach (XmlNode xml_node in target_dir.GetElementsByTagName("File"))
                {
                    XmlElement file = (XmlElement)xml_node;
                    string name = file.GetAttribute("Name");
                    if (name == target_name)
                    {
                        target_node = file;
                        break;
                    }
                }
            }

            if (null == target_node)
            {
                throw new ApplicationException(
                    "The shortcut \"" + shortcut.dstPath + "\" in feature \"" +
                    feature.featureName + "\" does not resolve.\r\n" +
                    "I cannot find any file or directory on the target system " +
                    "with the path \"" + shortcut.srcPath + "\".");

            }

            //sc_node.SetAttribute("Target", "[" + target_node.GetAttribute("Id") + "]");
            target_node.AppendChild(sc_node);

            return sc_node;
        }
Example #5
0
        private void MenuAddShortcut_Click(object sender, EventArgs e)
        {
            if (featuresTree.SelectedNode != null)
            {
                SetupFeature current = (SetupFeature)featuresTree.SelectedNode.Tag;
                SetupShortcut shortcut = new SetupShortcut();
                shortcut.srcPath = "[APPLICATIONFOLDER]";
                if ((null != current.configurableDirectory) && ("" != current.configurableDirectory))
                    shortcut.srcPath = "[" + current.configurableDirectory + "]";
                shortcut.dstPath = "[APPLICATIONFOLDER]\\New Shortcut";
                shortcut.description = "Some Description";

                current.shortcuts.Add(shortcut);
                ReloadShortcuts();

                // Set the new one as selected
                foreach (ListViewItem item in shortcutList.Items)
                {
                    if (item.Tag.Equals(shortcut))
                    {
                        item.Selected = true;
                        break;
                    }
                }
            }
        }