Ejemplo n.º 1
0
        public HostCommandNode GetHostCommandByShortcut(string shortcut)
        {
            var commands = HostOperationsMenuTree.CommandNodesToEnumerable();

            var foundCommand = commands.FirstOrDefault(c => !string.IsNullOrWhiteSpace(c.Shortcut) && c.Shortcut.Equals(shortcut));

            return(foundCommand);
        }
Ejemplo n.º 2
0
        public HostCommandNode GetIsDoubleClickHostCommand()
        {
            var commands = HostOperationsMenuTree.CommandNodesToEnumerable();

            var foundCommand = commands.FirstOrDefault(c => c.IsDoubleClick);

            return(foundCommand);
        }
Ejemplo n.º 3
0
        private void EnsureDoubleClickHostCommandIsUnique(HostCommandNode hostCommandNode)
        {
            if (!hostCommandNode.IsDoubleClick)
            {
                return;
            }

            var commands = HostOperationsMenuTree.CommandNodesToEnumerable();

            foreach (var commandNode in commands)
            {
                if (commandNode.IsDoubleClick && commandNode != hostCommandNode)
                {
                    _dialogCoordinator.ShowMessageAsync(this, "Oops..", $"The '{commandNode.Name}' is already set as double click operation, please uncheck it first.");

                    hostCommandNode.IsDoubleClick = false;
                }
            }
        }
Ejemplo n.º 4
0
        private void EnsureShortcutIsUnique(HostCommandNode hostCommandNode)
        {
            if (string.IsNullOrEmpty(hostCommandNode.Shortcut))
            {
                return;
            }

            var commands = HostOperationsMenuTree.CommandNodesToEnumerable();

            foreach (var commandNode in commands)
            {
                if (commandNode.Shortcut.Equals(hostCommandNode.Shortcut) && commandNode != hostCommandNode)
                {
                    _dialogCoordinator.ShowMessageAsync(this, "Oops..", $"The '{commandNode.Shortcut}' is already taken by '{commandNode.Name}' operation, please change it first.");

                    hostCommandNode.Shortcut = string.Empty;
                }
            }
        }
Ejemplo n.º 5
0
        private void AddNewHostCommand(object obj)
        {
            var treeView         = (TreeView)obj;
            var selectedTreeItem = treeView.SelectedItem as IMenuTreeNode;

            var newHostNode = new HostCommandNode();

            if (selectedTreeItem == null)
            {
                HostOperationsMenuTree.Add(newHostNode);
            }
            else if (selectedTreeItem is MenuTreeNode)
            {
                (selectedTreeItem as MenuTreeNode).Children.Add(newHostNode);
            }
            else if (selectedTreeItem is HostCommandNode)
            {
                var hostCommandNodeCollection = FindHostCommandNodeCollection(selectedTreeItem as HostCommandNode, HostOperationsMenuTree);
                hostCommandNodeCollection.Add(newHostNode);
            }
            treeView.SetSelectedItem(newHostNode);
        }