Example #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);
        }
Example #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);
        }
Example #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);
        }
Example #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);
        }
Example #5
0
 protected override void OnLaunchedMenuClosed()
 {
     RemoveHighlight();
     DisplayedComponent.RaiseCommandEvent(Properties.CommandMenuClose,
                                          CommandType.MenuClose,
                                          null);
 }
Example #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);
        }
Example #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);
            }
        }
Example #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));
        }
Example #9
0
        protected void LaunchMenuInternal(HtmlElement elmHadFocus)
        {
            LaunchMenu(elmHadFocus);

            DisplayedComponent.RaiseCommandEvent(Properties.CommandMenuOpen,
                                                 CommandType.MenuCreation,
                                                 null);
        }
Example #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);
        }
Example #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);
            }
        }
Example #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();
     }
 }
Example #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);
            }
        }
Example #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);
            }
        }
Example #15
0
        private void OnMouseout(HtmlEvent args)
        {
            OnEndFocus();
            if (!Enabled)
            {
                return;
            }

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

            DisplayedComponent.RaiseCommandEvent(Properties.CommandRevert,
                                                 CommandType.PreviewRevert,
                                                 StateProperties);
        }
Example #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);
        }
Example #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);
        }
Example #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);
            }
        }
Example #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);
        }
Example #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);
        }
Example #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);
            }
        }
Example #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);
        }
Example #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);
            }
        }
Example #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);
        }
Example #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);
        }
Example #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]));
            }
        }
Example #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);
            }
        }
Example #28
0
 protected void SendMenuCreationCommandEvent()
 {
     DisplayedComponent.RaiseCommandEvent(Properties.CommandMenuOpen,
                                          CommandType.MenuCreation,
                                          null);
 }