Esempio n. 1
0
        private void OnBlur(HtmlEvent args)
        {
            OnEndFocus();
            if (!Enabled)
            {
                return;
            }

            ControlComponent comp = DisplayedComponent;

            if (comp is MenuItem)
            {
                ((MenuItem)comp).Focused = false;
            }

            if (string.IsNullOrEmpty(Properties.CommandRevert))
            {
                return;
            }

            CommandType ct     = CommandType.PreviewRevert;
            string      cmdtpe = Properties.CommandType;

            if (!string.IsNullOrEmpty(cmdtpe) && cmdtpe == "OptionSelection")
            {
                ct = CommandType.OptionPreviewRevert;
                StateProperties[ToggleButtonCommandProperties.CommandValueId] = _commandValueId;
            }

            comp.RaiseCommandEvent(Properties.CommandRevert,
                                   ct,
                                   StateProperties);
        }
Esempio n. 2
0
        internal override bool FocusNext(HtmlEvent evt)
        {
            int moveCount = 1;

            if (!CUIUtility.IsNullOrUndefined(evt) && evt.KeyCode == (int)Key.Down)
            {
                moveCount = ColumnSize;
            }

            if (_focusedIndex + moveCount < 0)
            {
                _focusedIndex = -1;
                moveCount     = 1;
            }


            if (_focusedIndex + moveCount < _colorCells.Count)
            {
                SetFocusOnCell(_focusedIndex + moveCount);
                return(true);
            }
            RemoveHighlighting();
            _focusedIndex -= _colorCells.Count;
            return(false);
        }
Esempio n. 3
0
        protected void HandleMouseFocus(HtmlEvent args)
        {
            OnBeginFocus();
            if (!Enabled)
            {
                return;
            }
            ControlComponent comp = DisplayedComponent;

            if (comp is MenuItem)
            {
                ((MenuItem)comp).Focused = true;
            }
            if (string.IsNullOrEmpty(Properties.CommandPreview))
            {
                return;
            }

            Dictionary <string, string> dict = this.StateProperties;

            dict["CommandValueId"] = this._commandValueId;
            dict["MenuItemId"]     = this._menuItemId;

            CommandType ct     = CommandType.Preview;
            string      cmdtpe = Properties.CommandType;

            if (!string.IsNullOrEmpty(cmdtpe) && cmdtpe == "OptionSelection")
            {
                ct = CommandType.OptionPreview;
            }

            comp.RaiseCommandEvent(Properties.CommandPreview,
                                   ct,
                                   dict);
        }
Esempio n. 4
0
        private void OnMouseout(HtmlEvent args)
        {
            OnEndFocus();
            if (!Enabled)
            {
                return;
            }

            if (string.IsNullOrEmpty(Properties.CommandRevert))
            {
                return;
            }

            CommandType ct     = CommandType.PreviewRevert;
            string      cmdtpe = Properties.CommandType;

            if (!string.IsNullOrEmpty(cmdtpe) && cmdtpe == "OptionSelection")
            {
                ct = CommandType.OptionPreviewRevert;
                StateProperties[ToggleButtonCommandProperties.CommandValueId] = _commandValueId;
            }

            DisplayedComponent.RaiseCommandEvent(Properties.CommandRevert,
                                                 ct,
                                                 StateProperties);
        }
Esempio n. 5
0
 /// <summary>
 /// Handle the keypress of the help key (F1)
 /// </summary>
 /// <param name="evt"></param>
 /// <owner alias="HillaryM" />
 protected void OnHelpKeyPress(HtmlEvent args)
 {
     if (!CUIUtility.IsNullOrUndefined(_toolTip))
     {
         _toolTip.OnKeyPress(args);
     }
 }
Esempio n. 6
0
 protected void OnInputBlur(HtmlEvent args)
 {
     // O14:574004 - we need to clear the pending autocomplete on blur
     // if the user left, they don't need autocomplete
     ClearPendingAutoComplete();
     OnArrowButtonBlur(args);
 }
Esempio n. 7
0
        internal override bool FocusPrevious(HtmlEvent evt)
        {
            int count = Children.Count;

            if (_focusedIndex == -1)
            {
                _focusedIndex = count - 1;
            }

            int i = _focusedIndex;

            while (i > -1)
            {
                Component comp = Children[i];

                if (comp.FocusPrevious(evt))
                {
                    // If focus is not moving, don't reset the focus of the menu item
                    if (i != _focusedIndex)
                    {
                        ((Component)Children[_focusedIndex]).ResetFocusedIndex();
                        _focusedIndex = i;
                    }
                    return(true);
                }
                i--;
            }
            if (count > 0)
            {
                ((Component)Children[_focusedIndex]).ResetFocusedIndex();
            }
            _focusedIndex = -1;
            return(false);
        }
Esempio n. 8
0
        private void OnSelectAllCbxClick(HtmlEvent args)
        {
            if (_selectionCount == 4)
            {
                for (int idx = 1; idx < 5; idx++)
                {
                    Input itemCbx = _itemCbxCache[idx];
                    if (_itemSelected[idx])
                    {
                        itemCbx.Checked = false;
                        ToggleSelectionState(itemCbx, idx, false);
                    }
                }
            }
            else
            {
                for (int idx = 1; idx < 5; idx++)
                {
                    Input itemCbx = _itemCbxCache[idx];
                    if (!_itemSelected[idx])
                    {
                        itemCbx.Checked = true;
                        ToggleSelectionState(itemCbx, idx, true);
                    }
                }
            }

            // Signal state changed so Ribbon will recompute state
            PageManager.Instance.CommandDispatcher.ExecuteCommand(Commands.CommandIds.ApplicationStateChanged, null);
        }
Esempio n. 9
0
        internal override bool FocusNext(HtmlEvent evt)
        {
            if (_focusedIndex == -1)
            {
                _focusedIndex = 0;
            }

            int i = _focusedIndex;

            while (i < Children.Count)
            {
                Component comp = Children[i];

                if (comp.FocusNext(evt))
                {
                    // If focus is not moving, don't reset the focus of the gallery item
                    if (i != _focusedIndex)
                    {
                        ((Component)Children[_focusedIndex]).ResetFocusedIndex();
                        _focusedIndex = i;
                    }
                    return(true);
                }
                i++;
            }
            ((Component)Children[_focusedIndex]).ResetFocusedIndex();
            _focusedIndex = -1;
            return(false);
        }
Esempio n. 10
0
        private void OnCellClick(HtmlEvent args)
        {
            Utility.CancelEventUtility(args, false, true);
            if (!Enabled)
            {
                return;
            }

            HtmlElement element = args.TargetElement;

            HtmlElement cell = Utility.GetNearestContainingParentElementOfType(element, "td");

            ColorPickerResult           result = GetColorPickerResultFromSelectedCell(cell);
            Dictionary <string, string> dict   = new Dictionary <string, string>();

            dict[ColorPickerCommandProperties.Color] = result.Color;
            dict[ColorPickerCommandProperties.Style] = result.Style;

            // We don't want to send a preview revert command since the user has picked one
            // by clicking.
            CancelClickPreviewRevert();
            DisplayedComponent.RaiseCommandEvent(Properties.Command,
                                                 CommandType.General,
                                                 dict);
        }
Esempio n. 11
0
        protected void OnFocus(HtmlEvent args)
        {
            OnBeginFocus();
            if (!Enabled)
            {
                return;
            }

            Root.LastFocusedControl = this;

            if (string.IsNullOrEmpty(Properties.CommandPreview))
            {
                return;
            }

            CommandType ct     = CommandType.Preview;
            string      cmdtpe = Properties.CommandType;

            StateProperties[GalleryButtonCommandProperties.CommandValueId] = Properties.CommandValueId;
            if (!CUIUtility.IsNullOrUndefined(cmdtpe) && cmdtpe == "OptionSelection")
            {
                ct = CommandType.OptionPreview;
            }

            DisplayedComponent.RaiseCommandEvent(Properties.CommandPreview,
                                                 ct,
                                                 StateProperties);
        }
Esempio n. 12
0
        private void OnKeydown(HtmlEvent args)
        {
            if (!Enabled)
            {
                return;
            }
            if (_keySpin)
            {
                return;
            }

            _changedByMouse = false;
            int key = args.KeyCode;

            if (key == (int)Key.Up)
            {
                StartSpin(INC);
                Utility.EnsureCSSClassOnElement(_elmDefaultUpArw, "ms-cui-spn-btnup-down");
            }
            else if (key == (int)Key.Down)
            {
                StartSpin(DEC);
                Utility.EnsureCSSClassOnElement(_elmDefaultDownArw, "ms-cui-spn-btndown-down");
            }
            else
            {
                return;
            }

            _keySpin = true;
        }
Esempio n. 13
0
        protected void OnKeyPress(HtmlEvent args)
        {
            if (!Enabled)
            {
                return;
            }

            // Make OACR happy
            if (CUIUtility.IsNullOrUndefined(args))
            {
                return;
            }

            int key = args.KeyCode;

            if (key == (int)Key.Enter || key == (int)Key.Space || key == (int)Key.Down)
            {
                LaunchedByKeyboard = true;

                if (MenuLaunched)
                {
                    CloseMenu();
                }
                else
                {
                    LaunchJewelMenu();
                }

                Utility.CancelEventUtility(args, false, true);
            }
            // No need to check for escape to close here because the modal element will do that for us (O14:391733)
        }
Esempio n. 14
0
        protected override void LaunchMenuInternal(HtmlEvent args)
        {
            bool launchSucceeded = false;

            Root.FixedPositioningEnabled = false;

            switch (DisplayedComponent.Title)
            {
            case "Large":
                launchSucceeded = LaunchMenu(_elmLargeBtn, new Action(SendMenuCreationCommandEvent));
                break;

            case "Medium":
                launchSucceeded = LaunchMenu(_elmMediumBtn, new Action(SendMenuCreationCommandEvent));
                break;

            case "Small":
                launchSucceeded = LaunchMenu(_elmSmallBtn, new Action(SendMenuCreationCommandEvent));
                break;
            }
            if (launchSucceeded)
            {
                // _selectedControl.FocusOnDisplayedComponent();
                // Send out the menu launch command if it has been specified
                SendMenuCreationCommandEvent();
            }
        }
Esempio n. 15
0
        private void OnMenuMouseout(HtmlEvent args)
        {
            OnEndFocus();
            if (Utility.IsDescendantOf(DisplayedComponent.ElementInternal, args.RelatedTarget))
            {
                return;
            }

            if (MenuLaunched)
            {
                // If mouse is over any menu that is nested in this one, don't close
                int mlIndex = Root.MenuLauncherStack.IndexOf(this);
                for (int i = mlIndex; i < Root.MenuLauncherStack.Count; i++)
                {
                    if (Utility.IsDescendantOf(Root.MenuLauncherStack[i].Menu.ElementInternal, args.RelatedTarget))
                    {
                        return;
                    }
                }

                SetCloseMenuStackTimeout();
            }

            RemoveHighlight();
        }
Esempio n. 16
0
        public override void OnModalKeyPress(HtmlEvent args)
        {
            if (!CUIUtility.IsNullOrUndefined(args))
            {
                if ((((Root.TextDirection == Direction.LTR && args.KeyCode == (int)Key.Left) ||
                      (Root.TextDirection == Direction.RTL && args.KeyCode == (int)Key.Right)) &&
                     (DisplayedComponent.DisplayMode).StartsWith("Menu")) || args.KeyCode == (int)Key.Esc)
                {
                    Root.CloseMenuStack(this);
                    return;
                }
            }

            if (IsGroupPopup)
            {
                if (_focusSet)
                {
                    return;
                }
                if (Menu.SetFocusOnFirstControl())
                {
                    _focusSet = true;
                }

                Utility.CancelEventUtility(args, false, true);
            }
            else
            {
                base.OnModalKeyPress(args);
            }
        }
Esempio n. 17
0
        protected override void OnClick(HtmlEvent evt)
        {
            bool enabled = Enabled;

#if PERF_METRICS
            if (enabled && !MenuLaunched)
            {
                PMetrics.PerfMark(PMarker.perfCUIFlyoutAnchorOnClickStart);
            }
#endif
            CloseToolTip();
            Utility.CancelEventUtility(evt, false, true);
            if (!enabled || MenuLaunched)
            {
                return;
            }

            Root.LastCommittedControl = this;
            ControlComponent comp = DisplayedComponent;
            Anchor           elm  = (Anchor)comp.ElementInternal;
            LaunchMenuInternal(elm);
            if (!string.IsNullOrEmpty(Properties.Command))
            {
                comp.RaiseCommandEvent(Properties.Command,
                                       CommandType.MenuCreation,
                                       null);
            }
#if PERF_METRICS
            PMetrics.PerfMark(PMarker.perfCUIFlyoutAnchorOnClickEnd);
#endif
        }
Esempio n. 18
0
 internal void OnClick(HtmlEvent evt)
 {
     if (this.Root != null)
     {
         Root.CloseOpenTootips();
     }
 }
Esempio n. 19
0
        internal override bool FocusPrevious(HtmlEvent evt)
        {
            int moveCount = 1;

            if (!CUIUtility.IsNullOrUndefined(evt) && evt.KeyCode == (int)Key.Up)
            {
                moveCount = ColumnSize;
            }


            if (_focusedIndex < 0)
            {
                _focusedIndex += _colorCells.Count + moveCount;
            }

            if (_focusedIndex >= moveCount)
            {
                SetFocusOnCell(_focusedIndex - moveCount);
                return(true);
            }

            RemoveHighlighting();
            _focusedIndex -= moveCount;
            return(false);
        }
Esempio n. 20
0
        private void OnItemCbxClick(HtmlEvent args)
        {
            Input cbx    = (Input)args.CurrentTargetElement;
            int   itemId = Int32.Parse(cbx.GetAttribute("itemId"));

            if (_itemSelected[itemId])
            {
                if (_selectionCount == 4)
                {
                    _selectAllCheckbox.Checked = false;
                }

                ToggleSelectionState(cbx, itemId, false);
            }
            else
            {
                if (_selectionCount == 3)
                {
                    _selectAllCheckbox.Checked = true;
                }

                ToggleSelectionState(cbx, itemId, true);
            }

            // Signal state changed so Ribbon will recompute state
            PageManager.Instance.CommandDispatcher.ExecuteCommand(Commands.CommandIds.ApplicationStateChanged, null);
        }
Esempio n. 21
0
 public virtual void OnModalBodyClick(HtmlEvent evt)
 {
     // Firefox specific fix
     Utility.CancelEventUtility(evt, false, true);
     LaunchedByKeyboard = false; // remember we're using the mouse
     Root.CloseMenuStack(this);
 }
Esempio n. 22
0
        private void OnCellClick(HtmlEvent evt)
        {
            if (!CUIUtility.IsNullOrUndefined(typeof(PMetrics)))
            {
                PMetrics.PerfMark(PMarker.perfCUIRibbonInsertTableOnClickStart);
            }

            Utility.CancelEventUtility(evt, false, true);
            if (!Enabled)
            {
                return;
            }

            Div element = GetOuterDiv(evt.TargetElement);

            int idx    = GetIndexFromElement(element);
            int column = GetColFromIndex(idx);
            int row    = GetRowFromIndex(idx);

            // We don't want to send a preview revert command since the user has picked one
            // by clicking.
            CancelClickPreviewRevert();

            CommandProperties[InsertTableCommandProperties.Rows]    = (row + 1).ToString();
            CommandProperties[InsertTableCommandProperties.Columns] = (column + 1).ToString();
            DisplayedComponent.RaiseCommandEvent(Properties.Command,
                                                 CommandType.General,
                                                 CommandProperties);

            if (!CUIUtility.IsNullOrUndefined(typeof(PMetrics)))
            {
                PMetrics.PerfMark(PMarker.perfCUIRibbonInsertTableOnClickEnd);
            }
        }
Esempio n. 23
0
 protected virtual void LaunchMenuInternal(HtmlEvent args)
 {
     if (LaunchMenu(_elmMediumBtnA, new Action(SendMenuCreationCommandEvent)))
     {
         SendMenuCreationCommandEvent();
     }
 }
Esempio n. 24
0
        protected void OnBlur(HtmlEvent args)
        {
            OnEndFocus();
            if (!Enabled)
            {
                return;
            }

            if (string.IsNullOrEmpty(Properties.CommandRevert))
            {
                return;
            }

            CommandType ct     = CommandType.PreviewRevert;
            string      cmdtpe = Properties.CommandType;

            if (!CUIUtility.IsNullOrUndefined(cmdtpe) && cmdtpe == "OptionSelection")
            {
                ct = CommandType.OptionPreviewRevert;
                StateProperties[GalleryButtonCommandProperties.CommandValueId] = Properties.CommandValueId;
            }

            DisplayedComponent.RaiseCommandEvent(Properties.CommandRevert,
                                                 ct,
                                                 StateProperties);
        }
Esempio n. 25
0
 private void OnFocus(HtmlEvent args)
 {
     OnBeginFocus();
     if (!Enabled)
     {
         return;
     }
 }
Esempio n. 26
0
        /// <summary>
        /// By default this places the menu where mouse was clicked
        /// </summary>
        /// <param name="comp"></param>
        protected virtual Bounds GetMenuPosition(HtmlEvent evt)
        {
            Bounds b = new Bounds(0, 0, 0, 0);

            b.Y = evt.ClientY;
            b.X = evt.ClientX;
            return(b);
        }
Esempio n. 27
0
 private void OnBlur(HtmlEvent args)
 {
     OnEndFocus();
     if (!Enabled)
     {
         return;
     }
 }
Esempio n. 28
0
 private void OnGlassClick(HtmlEvent args)
 {
     if (_currentlyOpenedMenu != null)
     {
         _currentlyOpenedMenu.CloseMenu();
     }
     // The MenuClose event handler above will take care of removing the glass and resetting _currentlyOpenedMenu
 }
Esempio n. 29
0
 /// <summary>
 /// Obsolete API will be removed soon
 /// </summary>
 /// <param name="evt">The DomEvent that triggered the launch(usually a mouse click)</param>
 internal bool LaunchContextMenu(HtmlElement targetElement, HtmlEvent evt)
 {
     _targetElement  = targetElement;
     _launchPosition = GetMenuPosition(evt);
     LaunchMenu(null);
     Menu.FocusOnFirstItem(evt);
     return(true);
 }
Esempio n. 30
0
 IHtmlElement IHtmlElement.OnClient(HtmlEvent e, string script)
 {
     foreach (var item in Elements)
     {
         item.OnClient(e, script);
     }
     return(this);
 }
Esempio n. 31
0
 /// <summary>
 /// Attach an event handler to the element.
 /// </summary>
 /// <param name="eventName">The HTML script event name.</param>
 /// <param name="handler">The event handler.</param>
 public void AttachEvent(HtmlEvent eventName, EventHandler<HtmlEventArgs> handler)
 {
     AttachEvent(eventName.ScriptPropertyName(), handler);
 }