protected MenuCommand InternalTrackPopup(Point screenPosTR, Point screenPosTL, MenuCommandCollection menuCollection, PopupMenu parentMenu, bool selectFirst, MenuControl parentControl, bool popupRight, bool popupDown, bool animateIn, ref int returnDir) { // Default the drawing direction _direction = Direction.Horizontal; // Remember the MenuControl that initiated us _parentControl = parentControl; // We have a parent popup menu that should be consulted about operation _parentMenu = parentMenu; // Is this the first time a menu at this level has been animated _animateIn = animateIn; // Remember any currect menu item collection MenuCommandCollection oldCollection = _menuCommands; // Use the passed in collection of menu commands _menuCommands = menuCollection; // Remember screen positions _screenPos = screenPosTR; _aboveScreenPos = screenPosTR; _leftScreenPos = screenPosTL; // Remember display directions _popupRight = popupRight; _popupDown = popupDown; MenuCommand ret = InternalTrackPopup(selectFirst); // Restore to original collection _menuCommands = oldCollection; // Remove references no longer required _parentControl = null; _parentMenu = null; // Return the direction key that caused dismissal returnDir = _returnDir; return ret; }
internal MenuCommand TrackPopup(Point screenPos, Point aboveScreenPos, Direction direction, MenuCommandCollection menuCollection, int borderGap, bool selectFirst, MenuControl parentControl, bool animateIn, ref int returnDir) { // Remember which direction the MenuControl is drawing in _direction = direction; // Remember the MenuControl that initiated us _parentControl = parentControl; // Remember the gap in drawing the top border _borderGap = borderGap; // Is this the first time a menu at this level has been animated _animateIn = animateIn; // Remember any currect menu item collection MenuCommandCollection oldCollection = _menuCommands; // Use the passed in collection of menu commands _menuCommands = menuCollection; // Remember screen positions _screenPos = screenPos; _aboveScreenPos = aboveScreenPos; _leftScreenPos = screenPos; MenuCommand ret = InternalTrackPopup(selectFirst); // Restore to original collection _menuCommands = oldCollection; // Remove reference no longer required _parentControl = null; // Return the direction key that caused dismissal returnDir = _returnDir; return ret; }
public PopupMenu() { // Create collection objects _drawCommands = new ArrayList(); _menuCommands = new MenuCommandCollection(); // Default the properties _returnDir = 0; _extraSize = 0; _popupItem = -1; _trackItem = -1; _childMenu = null; _exitLoop = false; _popupDown = true; _mouseOver = false; _excludeTop = true; _popupRight = true; _parentMenu = null; _excludeOffset = 0; _parentControl = null; _returnCommand = null; _controlLBrush = null; _controlEBrush = null; _controlLLBrush = null; _highlightInfrequent = false; _showInfrequent = false; _style = VisualStyle.IDE; _rememberExpansion = true; _lastMousePos = new Point(-1,-1); _direction = Direction.Horizontal; _textFont = SystemInformation.MenuFont; // Animation details _animateTime = 100; _animate = Animate.System; _animateStyle = Animation.System; _animateFirst = true; _animateIn = true; // Create and initialise the timer object (but do not start it running!) _timer = new Timer(); _timer.Interval = _selectionDelay; _timer.Tick += new EventHandler(OnTimerExpire); // Define default colors _textColor = SystemColors.MenuText; _highlightTextColor = SystemColors.HighlightText; DefineHighlightColors(SystemColors.Highlight); DefineColors(SystemColors.Control); }