private void ShortcutDelete(TreeNode tn = null)
        {
            if (tn == null)
            {
                tn = tvStartMenu.SelectedNode;
            }

            DesktopComposer.Implementation.Shortcut sh = GetShorcutFromNode(tn);
            if (sh != null)
            {
                Shortcuts.Remove(sh);
                tn.Remove();
            }
            else
            {
                // There's no Shortcut Object, So is a Menu
                if (tn.Nodes.Count > 0)
                {
                    foreach (TreeNode tnn in tn.Nodes)
                    {
                        //Recursion
                        ShortcutDelete(tnn);
                    }
                }
            }
            tn.Remove();
            InvokeDataChanged();
        }
        private void ShortcutProperties(bool isNew = false)
        {
            _shorcutProperties = new FormShortcutProperties();
            DesktopComposer.Implementation.Shortcut shortcut;
            if (isNew)
            {
                shortcut = new DesktopComposer.Implementation.Shortcut
                {
                    MenuPath = NodeRelativePath(tvStartMenu.SelectedNode.FullPath, true)
                };
            }
            else
            {
                shortcut = GetShorcutFromNode();
            }

            if (_shorcutProperties.ShowDialog(shortcut) == DialogResult.OK)
            {
                if (isNew)
                {
                    _Shortcuts.Add(shortcut);
                    AddNode(shortcut);
                }
                else
                {
                    tvStartMenu.SelectedNode.Text = shortcut.DisplayName;
                    imlIcons.Images[imlIcons.Images.IndexOfKey(tvStartMenu.SelectedNode.ImageKey)] = shortcut.IconCacheSmall.ToBitmap();
                }
                InvokeDataChanged();
            }
        }
Esempio n. 3
0
        private void ShortcutProperties(bool isNew = false)
        {
            _shorcutProperties = new FormShortcutProperties();
            DesktopComposer.Implementation.Shortcut shortcut;
            if (isNew)
            {
                shortcut = new DesktopComposer.Implementation.Shortcut
                {
                    MenuPath = NodeRelativePath(tvStartMenu.SelectedNode.FullPath, true)
                };
            }
            else
            {
                shortcut = GetShorcutFromNode();
            }

            if (_shorcutProperties.ShowDialog(shortcut) == DialogResult.OK)
            {
                if (isNew)
                {
                    _Shortcuts.Add(shortcut);
                    AddNode(shortcut);
                }
                else
                {
                    //Update Node
                }
                InvokeDataChanged();
            }
        }
        public DialogResult ShowDialog(DesktopComposer.Implementation.Shortcut shortcut)
        {
            if (shortcut == null)
            {
                return(DialogResult.Cancel);
            }

            _shortcut = shortcut;
            _acls     = (ACLs)shortcut.ACLs.Clone();

            textDisplayName.Text      = _shortcut.DisplayName;
            textTarget.Text           = _shortcut.TargetPath;
            textArguments.Text        = _shortcut.Arguments;
            textHotkey.Text           = _shortcut.Hotkey;
            textWorkingDirectory.Text = _shortcut.WorkingDirectory;
            aclEditor.ACLs            = _acls;

            chkPinOnTaskBar.Checked        = _shortcut.PutOnTaskBar;
            chkPutOnDesktop.Checked        = _shortcut.PutOnDesktop;
            chkPutOnStartMenu.Checked      = _shortcut.PutOnStartMenu;
            chkDeployDisabled.Checked      = _shortcut.DeployDisabled;
            chkAclDenyByDefault.Checked    = _shortcut.ACLDenyByDefault;
            chkCheckIfTargetExists.Checked = _shortcut.CheckIfTargetExists;

            comboWinMode.SelectedValue = _shortcut.WindowStyle.ToString();

            if (_shortcut.IconCacheLarge != null)
            {
                pBIcon.Image = _shortcut.IconCacheLarge.ToBitmap();
            }

            _tempIcon = null;

            return(this.ShowDialog());
        }
 private DesktopComposer.Implementation.Shortcut GetShorcutFromNode(TreeNode tn = null)
 {
     if (tn == null)
     {
         tn = tvStartMenu.SelectedNode;
     }
     DesktopComposer.Implementation.Shortcut sh = (DesktopComposer.Implementation.Shortcut)tn.Tag;
     return(sh);
 }
        private void NodeDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            TreeView tv   = (TreeView)sender;
            TreeNode node = e.Node;

            if (node != null)
            {
                DesktopComposer.Implementation.Shortcut shortcut = (DesktopComposer.Implementation.Shortcut)node.Tag;
                if (shortcut != null)
                {
                    ShortcutProperties();
                    //Refresh TreeNode
                    node.Text = shortcut.DisplayName;
                }
            }
        }
        private void ShortcutRename(TreeNode tn = null)
        {
            if (tn == null)
            {
                tn = tvStartMenu.SelectedNode;
            }

            DesktopComposer.Implementation.Shortcut sh = GetShorcutFromNode(tn);
            if (sh != null)
            {
                sh.DisplayName = tn.Text;
            }
            else
            {
                UpdateShortcutsPath(tn);
            }
            InvokeDataChanged();
        }
        private void UpdateShortcutsPath(TreeNode tn)
        {
            DesktopComposer.Implementation.Shortcut sh = GetShorcutFromNode(tn);
            if (sh != null)
            {
                string nRelativePath = NodeRelativePath(tn.FullPath);

                sh.MenuPath = nRelativePath;

                Console.WriteLine("Setting Menu Path of {0},({1})", sh.DisplayName, tn.FullPath);
            }
            else
            {
                // There's no Shortcut Object, So is a Menu
                if (tn.Nodes.Count > 0)
                {
                    foreach (TreeNode tnn in tn.Nodes)
                    {
                        //Recursively Update the Path
                        UpdateShortcutsPath(tnn);
                    }
                }
            }
        }
        private TreeNode AddNode(DesktopComposer.Implementation.Shortcut shortcut)
        {
            TreeNode lastNode  = null;
            TreeNode foundNode = null;
            string   subPathAgg;
            char     pathSeparator = '\\';
            bool     createNode;

            subPathAgg = "Start";

            //Build Path
            foreach (string subPath in shortcut.MenuPath.Split(pathSeparator))
            {
                createNode  = false;
                subPathAgg += subPath;

                foundNode = FindNodeFromPath(subPathAgg, tvStartMenu.Nodes, true);

                if (foundNode != null)
                {
                    if (NodeIsFolder(foundNode))
                    {
                        lastNode = foundNode;
                    }
                    else
                    {
                        createNode = true;
                    }
                }
                else
                {
                    createNode = true;
                }

                if (subPath != "" && createNode)
                {
                    if (lastNode == null)
                    {
                        lastNode = tvStartMenu.Nodes.Add(subPath);
                    }
                    else
                    {
                        lastNode = lastNode.Nodes.Add(subPath);
                    }

                    lastNode.ImageKey         = "FOLDER_CLOSED";
                    lastNode.SelectedImageKey = "FOLDER_CLOSED";
                }

                subPathAgg += pathSeparator;
            }
            //Set Shortcut to node Tag
            lastNode     = lastNode.Nodes.Add(shortcut.DisplayName);
            lastNode.Tag = shortcut;

            if (shortcut.IconCacheSmall != null)
            {
                if (!imlIcons.Images.ContainsKey(shortcut.ObjectID.ToString()))
                {
                    imlIcons.Images.Add(shortcut.ObjectID.ToString(), shortcut.IconCacheSmall);
                }
                lastNode.ImageKey         = shortcut.ObjectID.ToString();
                lastNode.SelectedImageKey = lastNode.ImageKey;
            }
            else
            {
                //Default Icon
                if (!imlIcons.Images.ContainsKey(shortcut.ObjectID.ToString()))
                {
                    imlIcons.Images.Add(shortcut.ObjectID.ToString(), (Image)imlIcons.Images[imlIcons.Images.IndexOfKey("APPLICATION_DEFAULT")].Clone());
                    lastNode.ImageKey         = shortcut.ObjectID.ToString();
                    lastNode.SelectedImageKey = lastNode.ImageKey;
                }
            }
            return(lastNode);
        }