protected override void OnDropDownOpening(EventArgs e)
        {
            base.DropDownItems.Clear();

            SelectedItemCollection selection = Command.GetSelection();
            
            List<IXenConnection> connections = ConnectionsManager.XenConnectionsCopy;
            connections.Sort();

            foreach (IXenConnection connection in connections)
            {
                if (Helpers.GetPool(connection) != null)
                {
                    String poolName = Helpers.GetName(connection).EscapeAmpersands().Ellipsise(Helpers.DEFAULT_NAME_TRIM_LENGTH);
                    AddHostToPoolCommand cmd = new AddHostToPoolCommand(Command.MainWindowCommandInterface, selection.AsXenObjects<Host>(), Helpers.GetPool(connection), true);
                    base.DropDownItems.Add(new CommandToolStripMenuItem(cmd, poolName, Resources._000_PoolConnected_h32bit_16));
                }
            }

            if (base.DropDownItems.Count <= 0)
            {
                ToolStripMenuItem hostMenuItem = new ToolStripMenuItem(Messages.HOST_MENU_EMPTY);
                hostMenuItem.Font = Program.DefaultFont;
                hostMenuItem.Enabled = false;
                base.DropDownItems.Add(hostMenuItem);
            }

            base.DropDownItems.Add(new ToolStripSeparator());
            base.DropDownItems.Add(new CommandToolStripMenuItem(new NewPoolCommand(Command.MainWindowCommandInterface, selection)));
        }
        protected override void OnDropDownOpening(EventArgs e)
        {
            base.DropDownItems.Clear();

            SelectedItemCollection selection = Command.GetSelection();

            List <IXenConnection> connections = ConnectionsManager.XenConnectionsCopy;

            connections.Sort();

            foreach (IXenConnection connection in connections)
            {
                if (Helpers.GetPool(connection) != null)
                {
                    String poolName          = Helpers.GetName(connection).EscapeAmpersands().Ellipsise(Helpers.DEFAULT_NAME_TRIM_LENGTH);
                    AddHostToPoolCommand cmd = new AddHostToPoolCommand(Command.MainWindowCommandInterface, selection.AsXenObjects <Host>(), Helpers.GetPool(connection), true);
                    base.DropDownItems.Add(new CommandToolStripMenuItem(cmd, poolName, Images.StaticImages._000_PoolConnected_h32bit_16));
                }
            }

            if (base.DropDownItems.Count > 0)
            {
                base.DropDownItems.Add(new ToolStripSeparator());
            }

            base.DropDownItems.Add(new CommandToolStripMenuItem(new NewPoolCommand(Command.MainWindowCommandInterface, selection)));
        }
 protected override bool CanExecuteCore()
 {
     Pool targetPool = GetTargetNodeAncestorAsXenObjectOrGroupingTag<Pool>();
     
     if (targetPool != null)
     {
         AddHostToPoolCommand cmd = new AddHostToPoolCommand(MainWindowCommandInterface, GetDraggedItemsAsXenObjects<Host>(), targetPool, true);
         return cmd.CanExecute();
     }
     return false;
 }
Example #4
0
        protected override bool CanExecuteCore()
        {
            Pool targetPool = GetTargetNodeAncestorAsXenObjectOrGroupingTag <Pool>();

            if (targetPool != null)
            {
                AddHostToPoolCommand cmd = new AddHostToPoolCommand(MainWindowCommandInterface, GetDraggedItemsAsXenObjects <Host>(), targetPool, true);
                return(cmd.CanExecute());
            }
            return(false);
        }
        protected override void OnDropDownOpening(EventArgs e)
        {
            base.DropDownItems.Clear();

            SelectedItemCollection selection  = Command.GetSelection();
            IXenConnection         connection = selection[0].Connection;

            // Add a menu item for each connection we might add to this pool
            foreach (Host host in GetSortedHostList())
            {
                string hostName = Helpers.GetName(host.Connection);

                if (host.RestrictPooling)
                {
                    hostName = String.Format(Messages.HOST_MENU_ADD_SERVER, hostName);
                }

                AddHostToPoolCommand     cmd          = new AddHostToPoolCommand(Command.MainWindowCommandInterface, new Host[] { host }, Helpers.GetPool(connection), true);
                CommandToolStripMenuItem hostMenuItem = new CommandToolStripMenuItem(cmd, hostName.EscapeAmpersands(), Resources._000_TreeConnected_h32bit_16);

                base.DropDownItems.Add(hostMenuItem);
            }

            if (base.DropDownItems.Count <= 0)
            {
                ToolStripMenuItem hostMenuItem = new ToolStripMenuItem(Messages.HOST_MENU_EMPTY);
                hostMenuItem.Enabled = false;
                hostMenuItem.Font    = Program.DefaultFont;
                base.DropDownItems.Add(hostMenuItem);
            }

            if (Helpers.GetPool(connection) != null)
            {
                base.DropDownItems.Add(new ToolStripSeparator());
                // Add a final option for connecting a new server and adding it to the pool in one action
                AddNewHostToPoolCommand  cmd = new AddNewHostToPoolCommand(Command.MainWindowCommandInterface, Helpers.GetPool(connection));
                CommandToolStripMenuItem connectAndAddToPoolMenuItem = new CommandToolStripMenuItem(cmd);

                base.DropDownItems.Add(connectAndAddToPoolMenuItem);
            }
        }
        protected override void OnDropDownOpening(EventArgs e)
        {
            base.DropDownItems.Clear();

            SelectedItemCollection selection = Command.GetSelection();
            IXenConnection connection = selection[0].Connection;

            // Add a menu item for each connection we might add to this pool
            foreach (Host host in GetSortedHostList())
            {
                string hostName = Helpers.GetName(host.Connection);

                AddHostToPoolCommand cmd = new AddHostToPoolCommand(Command.MainWindowCommandInterface, new Host[] { host }, Helpers.GetPool(connection), true);
                CommandToolStripMenuItem hostMenuItem = new CommandToolStripMenuItem(cmd, hostName.EscapeAmpersands(), Resources._000_TreeConnected_h32bit_16);

                base.DropDownItems.Add(hostMenuItem);
            }
            
            if (base.DropDownItems.Count <= 0)
            {
                ToolStripMenuItem hostMenuItem = new ToolStripMenuItem(Messages.HOST_MENU_EMPTY);
                hostMenuItem.Enabled = false;
                hostMenuItem.Font = Program.DefaultFont;
                base.DropDownItems.Add(hostMenuItem);
            }

            if (Helpers.GetPool(connection) != null)
            {
                base.DropDownItems.Add(new ToolStripSeparator());
                // Add a final option for connecting a new server and adding it to the pool in one action
                AddNewHostToPoolCommand cmd = new AddNewHostToPoolCommand(Command.MainWindowCommandInterface, Helpers.GetPool(connection));
                CommandToolStripMenuItem connectAndAddToPoolMenuItem = new CommandToolStripMenuItem(cmd);

                base.DropDownItems.Add(connectAndAddToPoolMenuItem);
            }
        }
        protected override void OnDropDownOpening(EventArgs e)
        {
            base.DropDownItems.Clear();

            SelectedItemCollection selection = Command.GetSelection();
            IXenConnection connection = selection[0].Connection;

            // Add a menu item for each connection we might add to this pool
            foreach (Host host in GetSortedHostList())
            {
                string hostName = Helpers.GetName(host.Connection);

                if (host.RestrictPooling)
                {
                    hostName = String.Format(Messages.HOST_MENU_ADD_SERVER, hostName);
                }

                AddHostToPoolCommand cmd = new AddHostToPoolCommand(Command.MainWindowCommandInterface, new Host[] { host }, Helpers.GetPool(connection), true);
                CommandToolStripMenuItem hostMenuItem = new CommandToolStripMenuItem(cmd, hostName.EscapeAmpersands(), Images.StaticImages._000_TreeConnected_h32bit_16);

                base.DropDownItems.Add(hostMenuItem);
            }

            if (Helpers.GetPool(connection) != null)
            {
                if (base.DropDownItems.Count > 0)
                    base.DropDownItems.Add(new ToolStripSeparator());

                // Add a final option for connecting a new server and adding it to the pool in one action
                AddNewHostToPoolCommand cmd = new AddNewHostToPoolCommand(Command.MainWindowCommandInterface, Helpers.GetPool(connection));
                CommandToolStripMenuItem connectAndAddToPoolMenuItem = new CommandToolStripMenuItem(cmd);

                base.DropDownItems.Add(connectAndAddToPoolMenuItem);
            }
        }
        protected override void OnDropDownOpening(EventArgs e)
        {
            base.DropDownItems.Clear();

            SelectedItemCollection selection = Command.GetSelection();

            List<IXenConnection> connections = ConnectionsManager.XenConnectionsCopy;
            connections.Sort();

            foreach (IXenConnection connection in connections)
            {
                if (Helpers.GetPool(connection) != null)
                {
                    String poolName = Helpers.GetName(connection).EscapeAmpersands().Ellipsise(Helpers.DEFAULT_NAME_TRIM_LENGTH);
                    AddHostToPoolCommand cmd = new AddHostToPoolCommand(Command.MainWindowCommandInterface, selection.AsXenObjects<Host>(), Helpers.GetPool(connection), true);
                    base.DropDownItems.Add(new CommandToolStripMenuItem(cmd, poolName, Images.StaticImages._000_PoolConnected_h32bit_16));
                }
            }

            if (base.DropDownItems.Count > 0)
                base.DropDownItems.Add(new ToolStripSeparator());

            base.DropDownItems.Add(new CommandToolStripMenuItem(new NewPoolCommand(Command.MainWindowCommandInterface, selection)));
        }