Example #1
0
        /// <summary>
        /// Determines whether the command may execute.
        /// The command may be executed in the following cases:
        /// - The currently active form is the one where the associated RadDock resides.
        /// - The currently active form is a FloatingWindow instance, owned by the associated RadDock.
        /// - The currently active form is an AutoHidePopup instance, owned by the associated RadDock.
        /// </summary>
        /// <param name="parameter">The additional parameter provided. Should be a RadDock instance.</param>
        /// <returns></returns>
        public override bool CanExecute(object parameter)
        {
            RadDock dock = parameter as RadDock;

            if (dock == null)
            {
                return(false);
            }

            Form dockParentForm = dock.FindForm();
            Form activeForm     = Form.ActiveForm;

            if (activeForm == dockParentForm)
            {
                return(true);
            }

            //check from floating windows or auto-hide popup, keeping in mind that we may have more than one RadDock on a Form.
            FloatingWindow floatingWindow = activeForm as FloatingWindow;

            if (floatingWindow != null && floatingWindow.DockManager == dock)
            {
                return(true);
            }

            AutoHidePopup autoHidePopup = activeForm as AutoHidePopup;

            if (autoHidePopup != null && autoHidePopup.DockManager == dock)
            {
                return(true);
            }

            return(false);
        }
Example #2
0
        public override bool CanExecute(object parameter)
        {
            if (!base.CanExecute(parameter))
            {
                return(false);
            }

            RadDock dock = parameter as RadDock;

            if (dock != null)
            {
                Form dockParentForm = dock.FindForm();
                Form activeForm     = Form.ActiveForm;
                return(activeForm == dockParentForm || activeForm.Owner == dockParentForm);
            }

            return(false);
        }