Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        private void Decrease(int mult)
        {
            if (!Enabled)
            {
                return;
            }

            if (!ValidateAndSave(_currentUnit, _value - mult * _currentUnit.Step))
            {
                // If multiplier prevents value from reaching min, force to min
                if (_value > _currentUnit.Min)
                {
                    ValidateAndSave(_currentUnit, _currentUnit.Min);
                }
                else
                {
                    ResetToPreviousValue();
                    return;
                }
            }

            CommandType ct = CommandType.IgnoredByMenu;

            StateProperties[SpinnerCommandProperties.ChangeType]     = "decrease";
            StateProperties[SpinnerCommandProperties.ChangedByMouse] = _changedByMouse.ToString();
            DisplayedComponent.RaiseCommandEvent(_cmdChanged,
                                                 ct,
                                                 StateProperties);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
 protected override void OnLaunchedMenuClosed()
 {
     RemoveHighlight();
     DisplayedComponent.RaiseCommandEvent(Properties.CommandMenuClose,
                                          CommandType.MenuClose,
                                          null);
 }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
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);
            }
        }
Exemplo n.º 8
0
        internal override bool OnPreBubbleCommand(CommandEventArgs command)
        {
            // A command has been issued from a component somewhere under this
            // DropDown.  We want to determine if it is a option select command.
            // This would let us know that we need to do some processing so that
            // the anchor has the appropriate value in it etc.
            if (command.Type == CommandType.OptionSelection)
            {
                MenuItem item = (MenuItem)command.Source;
                if (!(item.Control is ISelectableControl))
                {
                    return(base.OnPreBubbleCommand(command));
                }

                ISelectableControl isc = (ISelectableControl)item.Control;
                // If an item is currently selected, deselect it first
                if (!CUIUtility.IsNullOrUndefined(_selectedControl))
                {
                    _selectedControl.Deselect();
                }
                SelectMenuItem(isc);
            }

            if (command.Type == CommandType.OptionSelection ||
                command.Type == CommandType.OptionPreview ||
                command.Type == CommandType.OptionPreviewRevert)
            {
                string myCommand;
                switch (command.Type)
                {
                case CommandType.OptionSelection:
                    myCommand = Properties.Command;
                    break;

                case CommandType.OptionPreview:
                    myCommand = Properties.CommandPreview;
                    break;

                case CommandType.OptionPreviewRevert:
                    myCommand = Properties.CommandRevert;
                    break;

                default:
                    // This case should not be hit, but it allows compilation
                    myCommand = Properties.Command;
                    break;
                }

                // Stop the command here and send our own
                DisplayedComponent.RaiseCommandEvent(myCommand,
                                                     command.Type,
                                                     command.Parameters);
                base.OnPreBubbleCommand(command);
                return(false);
            }

            // if any other command type
            return(base.OnPreBubbleCommand(command));
        }
Exemplo n.º 9
0
        protected void LaunchMenuInternal(HtmlElement elmHadFocus)
        {
            LaunchMenu(elmHadFocus);

            DisplayedComponent.RaiseCommandEvent(Properties.CommandMenuOpen,
                                                 CommandType.MenuCreation,
                                                 null);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Invoked when the Menu is opened
        /// </summary>
        protected void OnMenuButtonClick(HtmlEvent evt)
        {
            if (!Enabled)
            {
                return;
            }

            LaunchContextMenu(null, evt);
            DisplayedComponent.RaiseCommandEvent(Properties.CommandMenuOpen,
                                                 CommandType.MenuCreation,
                                                 null);
        }
Exemplo n.º 11
0
        private void EnsureClickPreviewReverted()
        {
            if (previewClickCommandSent && !string.IsNullOrEmpty(Properties.CommandRevert))
            {
                Dictionary <string, string> dict = new Dictionary <string, string>();
                dict[ColorPickerCommandProperties.Color] = previewPickerResult.Color;
                dict[ColorPickerCommandProperties.Style] = previewPickerResult.Style;

                DisplayedComponent.RaiseCommandEvent(Properties.CommandRevert,
                                                     CommandType.PreviewRevert,
                                                     dict);
            }
        }
Exemplo n.º 12
0
 private void EnsureClickPreviewReverted()
 {
     if (previewClickCommandSent)
     {
         string revClkCmd = Properties.CommandRevert;
         if (!string.IsNullOrEmpty(revClkCmd))
         {
             CommandProperties[InsertTableCommandProperties.Rows]    = (prevRow + 1).ToString();
             CommandProperties[InsertTableCommandProperties.Columns] = (prevCol + 1).ToString();
             DisplayedComponent.RaiseCommandEvent(revClkCmd,
                                                  CommandType.PreviewRevert,
                                                  CommandProperties);
         }
         CancelClickPreviewRevert();
     }
 }
Exemplo n.º 13
0
        protected void ValidateAndSave()
        {
            Dictionary <string, string> commandDict = new Dictionary <string, string>();

            // If value is not a valid menu item
            if (!SelectMenuItemById(_pendingMenuItemId))
            {
                ControlComponent comp = DisplayedComponent;
                if (!Utility.IsTrue(CBProperties.AutoComplete))
                {
                    string menuitemid = GetMenuItem(_elmMediumInput.Value);
                    if (!string.IsNullOrEmpty(menuitemid) &&
                        SelectMenuItemById(menuitemid))
                    {
                        IsFreeForm = false;
                        commandDict["IsFreeForm"]     = "false";
                        commandDict["CommandValueId"] = _selectedControl.GetCommandValueId();
                        comp.RaiseCommandEvent(CBProperties.Command, CommandType.OptionSelection, commandDict);
                        return;
                    }
                }
                // If autocomplete was off, but we haven't returned yet, then the value was not a valid item in the menu
                // If free-form entry is allowed, send the value to the PageManager
                if (_allowFreeForm)
                {
                    IsFreeForm = true;
                    commandDict["IsFreeForm"] = "true";
                    commandDict["Value"]      = _elmMediumInput.Value;
                    StateProperties[ComboBoxCommandProperties.Value] = _elmMediumInput.Value;
                    comp.RaiseCommandEvent(CBProperties.Command, CommandType.OptionSelection, commandDict);
                }
                // If free-form entry is not allowed, reset to the last valid value and stop
                else
                {
                    ResetToPreviousValue();
                    return;
                }
            }
            // If the value is a valid menu item, send it as a CommandValueId to the PageManager
            else
            {
                IsFreeForm = false;
                commandDict["IsFreeForm"]     = "false";
                commandDict["CommandValueId"] = _selectedControl.GetCommandValueId();
                DisplayedComponent.RaiseCommandEvent(CBProperties.Command, CommandType.OptionSelection, commandDict);
            }
        }
Exemplo n.º 14
0
        protected override void OnClick(HtmlEvent evt)
        {
            if (!CUIUtility.IsNullOrUndefined(typeof(PMetrics)))
            {
                PMetrics.PerfMark(PMarker.perfCUIRibbonToggleButtonOnClickStart);
            }

            CloseToolTip();
            Utility.CancelEventUtility(evt, false, true);

            if (!Enabled)
            {
                return;
            }

            Root.LastCommittedControl = this;

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

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

            // Send out the command
            StateProperties[ToggleButtonCommandProperties.On] =
                (!Utility.IsTrue(StateProperties[ToggleButtonCommandProperties.On])).ToString();
            DisplayedComponent.RaiseCommandEvent(Properties.Command,
                                                 ct,
                                                 StateProperties);
            if (Root.PollForState)
            {
                PollForStateAndUpdate();
            }
            else
            {
                SetState(Utility.IsTrue(StateProperties[ToggleButtonCommandProperties.On]));
            }

            if (!CUIUtility.IsNullOrUndefined(typeof(PMetrics)))
            {
                PMetrics.PerfMark(PMarker.perfCUIRibbonToggleButtonOnClickEnd);
            }
        }
Exemplo n.º 15
0
        private void OnMouseout(HtmlEvent args)
        {
            OnEndFocus();
            if (!Enabled)
            {
                return;
            }

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

            DisplayedComponent.RaiseCommandEvent(Properties.CommandRevert,
                                                 CommandType.PreviewRevert,
                                                 StateProperties);
        }
Exemplo n.º 16
0
        private void OnFocus(HtmlEvent args)
        {
            OnBeginFocus();
            if (!Enabled)
            {
                return;
            }

            Root.LastFocusedControl = this;
            if (string.IsNullOrEmpty(Properties.CommandPreview))
            {
                return;
            }

            DisplayedComponent.RaiseCommandEvent(Properties.CommandPreview,
                                                 CommandType.Preview,
                                                 StateProperties);
        }
Exemplo n.º 17
0
        private void OnSelectedItemMouseout(HtmlEvent args)
        {
            OnEndFocus();
            if (!Enabled)
            {
                return;
            }

            switch (DisplayedComponent.Title)
            {
            case "Large":
                Utility.RemoveCSSClassFromElement(_elmLargeSelectedItem,
                                                  "ms-cui-ctl-light-hoveredOver");
                Utility.RemoveCSSClassFromElement(_elmLargeBtn,
                                                  "ms-cui-ctl-split-hover");
                break;

            case "Medium":
                Utility.RemoveCSSClassFromElement(_elmMediumSelectedItem,
                                                  "ms-cui-ctl-light-hoveredOver");
                Utility.RemoveCSSClassFromElement(_elmMediumBtn,
                                                  "ms-cui-ctl-split-hover");
                break;

            case "Small":
                Utility.RemoveCSSClassFromElement(_elmSmallSelectedItem,
                                                  "ms-cui-ctl-light-hoveredOver");
                Utility.RemoveCSSClassFromElement(_elmSmallBtn,
                                                  "ms-cui-ctl-split-hover");
                break;
            }

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

            Dictionary <string, string> commandTemp = new Dictionary <string, string>();

            commandTemp["CommandValueId"] = _selectedControl.GetCommandValueId();
            DisplayedComponent.RaiseCommandEvent(Properties.CommandRevert,
                                                 CommandType.PreviewRevert,
                                                 commandTemp);
        }
Exemplo n.º 18
0
        private void SendClickPreviewCommand(int idx)
        {
            // Store the fact that we sent out a live preview command
            // and its coordinates
            prevCol = GetColFromIndex(idx);
            prevRow = GetRowFromIndex(idx);
            previewClickCommandSent = true;

            string prevClkCmd = Properties.CommandPreview;

            if (!string.IsNullOrEmpty(prevClkCmd))
            {
                CommandProperties[InsertTableCommandProperties.Rows]    = (prevRow + 1).ToString();
                CommandProperties[InsertTableCommandProperties.Columns] = (prevCol + 1).ToString();
                DisplayedComponent.RaiseCommandEvent(prevClkCmd,
                                                     CommandType.Preview,
                                                     CommandProperties);
            }
        }
Exemplo n.º 19
0
        protected void OnButtonClick(HtmlEvent evt)
        {
            Utility.CancelEventUtility(evt, false, true);

            CloseToolTip();
            if (!Enabled || !_buttonEnabled)
            {
                return;
            }

            Root.LastCommittedControl = this;
            focusOnArrow = false;

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

            dict["CommandValueId"] = Properties.CommandValueId;
            DisplayedComponent.RaiseCommandEvent(Properties.Command,
                                                 CommandType.General,
                                                 dict);
        }
Exemplo n.º 20
0
        protected void OnMouseOut(HtmlEvent args)
        {
            OnEndFocus();
            if (!Enabled)
            {
                return;
            }

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

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

            dict["CommandValueId"] = Properties.CommandValueId;
            DisplayedComponent.RaiseCommandEvent(Properties.CommandRevert,
                                                 CommandType.PreviewRevert,
                                                 dict);
        }
Exemplo n.º 21
0
        private void SendClickPreviewCommand(HtmlElement cell)
        {
            if (!string.IsNullOrEmpty(Properties.CommandPreview))
            {
                // Store the fact that we sent out a live preview command
                // and its coordinates
                previewClickCommandSent = true;

                ColorPickerResult           result = GetColorPickerResultFromSelectedCell(cell);
                Dictionary <string, string> dict   = new Dictionary <string, string>();
                dict[ColorPickerCommandProperties.Color] = result.Color;
                dict[ColorPickerCommandProperties.Style] = result.Style;

                previewPickerResult = result;

                DisplayedComponent.RaiseCommandEvent(Properties.CommandPreview,
                                                     CommandType.Preview,
                                                     dict);
            }
        }
Exemplo n.º 22
0
        private void OnSelectedItemClick(HtmlEvent evt)
        {
#if PERF_METRICS
            PMetrics.PerfMark(PMarker.perfCUIRibbonEditWikiPageStart);
#endif
            CloseToolTip();
            Utility.CancelEventUtility(evt, false, true);

            if (!Enabled)
            {
                return;
            }

            CommandType ct = CommandType.OptionSelection;

            Dictionary <string, string> commandTemp = new Dictionary <string, string>();
            commandTemp["CommandValueId"] = _selectedControl.GetCommandValueId();
            DisplayedComponent.RaiseCommandEvent(Properties.Command,
                                                 ct,
                                                 commandTemp);
        }
Exemplo n.º 23
0
        private void OnChange(HtmlEvent args)
        {
            CloseToolTip();
            if (!Enabled)
            {
                return;
            }

            // Send out the command
            StateProperties[TextBoxCommandProperties.Value] = this.Value;
            DisplayedComponent.RaiseCommandEvent(Properties.Command,
                                                 CommandType.General,
                                                 StateProperties);
            if (Root.PollForState)
            {
                PollForStateAndUpdate();
            }
            else
            {
                SetState(null);
            }
        }
Exemplo n.º 24
0
        private void OnChanged(HtmlEvent args)
        {
            CloseToolTip();

            if (!Enabled)
            {
                return;
            }

            if (!ValidateInput())
            {
                ResetToPreviousValue();
                return;
            }

            CommandType ct = CommandType.General;

            StateProperties[SpinnerCommandProperties.ChangeType]     = "manual";
            StateProperties[SpinnerCommandProperties.ChangedByMouse] = false.ToString();
            DisplayedComponent.RaiseCommandEvent(_cmdChanged,
                                                 ct,
                                                 StateProperties);
        }
Exemplo n.º 25
0
        protected void OnMenuButtonClick(HtmlEvent args)
        {
            if (CUIUtility.IsNullOrUndefined(args))
            {
                return;
            }

            Utility.CancelEventUtility(args, false, true);
            CloseToolTip();
            if (!Enabled || !_menuButtonEnabled)
            {
                return;
            }

            Root.FixedPositioningEnabled = false;
            Root.LastCommittedControl    = this;
            focusOnArrow = true;

            HtmlElement prev = args.TargetElement;

            LaunchMenu(prev);
            DisplayedComponent.RaiseCommandEvent(Properties.CommandMenuOpen, CommandType.MenuCreation, null);
        }
Exemplo n.º 26
0
        protected override void OnClick(HtmlEvent evt)
        {
            CloseToolTip();
            Utility.CancelEventUtility(evt, false, true);

            if (!Enabled)
            {
                return;
            }

            Toggle();

            CommandType ct     = CommandType.General;
            string      cmdtpe = Properties.CommandType;
            Dictionary <string, string> dict = StateProperties;

            dict[GalleryButtonCommandProperties.CommandValueId] = Properties.CommandValueId;
            dict["MenuItemId"]      = Properties.MenuItemId;
            dict["SourceControlId"] = Properties.Id;
            if (!CUIUtility.IsNullOrUndefined(cmdtpe) && cmdtpe == "OptionSelection")
            {
                ct = CommandType.OptionSelection;
            }

            DisplayedComponent.RaiseCommandEvent(Properties.Command,
                                                 ct,
                                                 dict);

            if (Root.PollForState)
            {
                PollForStateAndUpdate();
            }
            else
            {
                SetState(Utility.IsTrue(StateProperties[GalleryButtonCommandProperties.On]));
            }
        }
Exemplo n.º 27
0
        protected override void OnClick(HtmlEvent args)
        {
            if (!CUIUtility.IsNullOrUndefined(typeof(PMetrics)))
            {
                PMetrics.PerfMark(PMarker.perfCUIRibbonButtonOnClickStart);
            }

            Utility.CancelEventUtility(args, true, true);
            CloseToolTip();
            if (!Enabled)
            {
                return;
            }

            Root.LastCommittedControl = this;

            CommandType ct = CommandType.General;
            Dictionary <string, string> dict = this.StateProperties;
            string cmdtpe = Properties.CommandType;

            if (!string.IsNullOrEmpty(cmdtpe) && cmdtpe == "OptionSelection")
            {
                ct = CommandType.OptionSelection;
            }
            dict["CommandValueId"]  = this._commandValueId;
            dict["MenuItemId"]      = this._menuItemId;
            dict["SourceControlId"] = this.Id;
            DisplayedComponent.RaiseCommandEvent(Properties.Command,
                                                 ct,
                                                 dict);

            if (!CUIUtility.IsNullOrUndefined(typeof(PMetrics)))
            {
                PMetrics.PerfMark(PMarker.perfCUIRibbonButtonOnClickEnd);
            }
        }
Exemplo n.º 28
0
 protected void SendMenuCreationCommandEvent()
 {
     DisplayedComponent.RaiseCommandEvent(Properties.CommandMenuOpen,
                                          CommandType.MenuCreation,
                                          null);
 }