Exemplo n.º 1
0
        private void RevertCurrentCommandState()
        {
            // Is there a current state to revert back?
            if (_currentCmdState != null)
            {
                // Is the command currently open?
                if (_currentCmdState.State == ItemState.Open)
                {
                    // Cast to expected interface
                    ICommandOpen commandOpen = _currentCmdState.Command as ICommandOpen;

                    // Ask the command to close itself now
                    commandOpen.Close();

                    // No longer have logical capture of mouse
                    _mouseCapture = false;
                }

                // Revert it back to normal state
                _currentCmdState.State = ItemState.Normal;

                // Make sure it is repainted
                Invalidate(_currentCmdState.DrawRect);

                // Remove command from being current
                _currentCmdState = null;
            }
        }
Exemplo n.º 2
0
        private void MakeStateOpen(CommandState commandDown, Point pt)
        {
            // Remove any tooltip
            KillTooltip();

            // If current command is not the new one, then revert it
            RevertCurrentCommandState(commandDown);

            // Make this the new command
            _currentCmdState = commandDown;

            // Do we have a valid command to open?
            if (_currentCmdState != null)
            {
                // Switch to the hot tracking mode
                _currentCmdState.State = ItemState.Open;

                // Make sure it is repainted
                Invalidate(_currentCmdState.DrawRect);

                // Cast to expected interface
                ICommandOpen commandOpen = commandDown.Command as ICommandOpen;

                // Ask the command to open itself now
                commandOpen.Open(pt);
            }
        }
Exemplo n.º 3
0
        private bool CanCommandOpen(CommandState state)
        {
            // Cast the embedded command to relevant interface
            ICommandOpen commandOpen = state.Command as ICommandOpen;

            // Does the target have correct interface and request to be opened?
            if ((commandOpen != null) && commandOpen.CanOpen())
            {
                return(true);
            }

            // Failed, cannot open
            return(false);
        }