コード例 #1
0
ファイル: menu.cs プロジェクト: tralivali1234/IL2JS
        // Iterate recursively through the subtree of child components until either
        // a match is found or the end of the subtree is reached
        private ISelectableControl GetItemByIdInternal(Component comp, string id)
        {
            ISelectableControl tmp;

            if (comp is ControlComponent)
            {
                ControlComponent concomp = (ControlComponent)comp;
                if (concomp.Control is ISelectableControl)
                {
                    ISelectableControl isc = (ISelectableControl)concomp.Control;
                    if (isc.GetMenuItemId() == id)
                    {
                        return(isc);
                    }
                }
            }

            List <Component> children = comp.Children;

            if (!CUIUtility.IsNullOrUndefined(children))
            {
                foreach (Component c in children)
                {
                    tmp = GetItemByIdInternal(c, id);
                    if (tmp != null)
                    {
                        return(tmp);
                    }
                }
            }
            return(null);
        }
コード例 #2
0
        protected override void OnDynamicMenuPopulated()
        {
            // If we are dynamically populating the menu, we should build the lookup
            // table for autocomplete now
            ControlComponent   cc  = null;
            Control            c   = null;
            ISelectableControl isc = null;
            IMenuItem          imi = null;

            string menuitemid = "";
            string labeltext  = "";

            if (CUIUtility.IsNullOrUndefined(Menu))
            {
                return;
            }

            foreach (MenuSection ms in Menu.Children)
            {
                foreach (Component comp in ms.Children)
                {
                    // Only check if this is a MenuItem
                    // Ignore Galleries and GroupPopouts
                    if (comp is MenuItem)
                    {
                        cc = (ControlComponent)comp;
                        c  = cc.Control;

                        // Get MenuItemId
                        if (c is ISelectableControl)
                        {
                            isc        = (ISelectableControl)c;
                            menuitemid = isc.GetMenuItemId();
                        }
                        // Get Label Text
                        if (c is IMenuItem)
                        {
                            imi       = (IMenuItem)c;
                            labeltext = imi.GetTextValue();
                        }

                        // If we have both MenuItemId and Label Text, add the item to the table
                        if (!(string.IsNullOrEmpty(menuitemid) || string.IsNullOrEmpty(labeltext)))
                        {
                            MenuItems[labeltext] = menuitemid;
                            labeltext            = "";
                            menuitemid           = "";
                        }
                    }
                }
            }
        }
コード例 #3
0
        protected override void SelectMenuItem(ISelectableControl isc)
        {
            if (_selectedControl == isc)
            {
                return;
            }

            _selectedControl = isc;
            StateProperties[ComboBoxCommandProperties.SelectedItemId] = isc.GetMenuItemId();

            IMenuItem imi = (IMenuItem)(Control)isc;

            _elmMediumInput.Value = imi.GetTextValue();
        }
コード例 #4
0
ファイル: menuitem.cs プロジェクト: tralivali1234/IL2JS
 internal override bool FocusOnItemById(string menuItemId)
 {
     if (Control is ISelectableControl)
     {
         ISelectableControl isc = (ISelectableControl)Control;
         if (isc.GetMenuItemId() == menuItemId)
         {
             if (Visible && Enabled)
             {
                 ReceiveFocus();
                 Focused = true;
                 return(true);
             }
         }
     }
     return(false);
 }
コード例 #5
0
ファイル: dropdown.cs プロジェクト: tralivali1234/IL2JS
        protected virtual void SelectMenuItem(ISelectableControl isc)
        {
            if (_selectedControl == isc)  // same menu item selected
            {
                return;
            }

            _selectedControl = isc;
            StateProperties[DropDownCommandProperties.SelectedItemId] = isc.GetMenuItemId();

            // If SelectedItemDisplayMode is not set, Medium to "Text"
            string selectedItemDisplayMode;

            if (string.IsNullOrEmpty(Properties.SelectedItemDisplayMode))
            {
                selectedItemDisplayMode = "Text";
            }
            else
            {
                selectedItemDisplayMode = Properties.SelectedItemDisplayMode;
            }

            Anchor selectedItem;

            if (selectedItemDisplayMode == "Text")
            {
                string text = isc.GetTextValue();
                selectedItem = new Anchor();
                UIUtility.SetInnerText(selectedItem, text);
            }
            else
            {
                selectedItem = (Anchor)_selectedControl.GetDropDownDOMElementForDisplayMode(selectedItemDisplayMode);
            }

            if (_elmMediumSelectedItem.HasChildNodes())
            {
                Anchor oldSelectedItem = (Anchor)_elmMediumSelectedItem.FirstChild;
                _elmMediumSelectedItem.ReplaceChild(selectedItem, oldSelectedItem);
            }
            else
            {
                _elmMediumSelectedItem.AppendChild(selectedItem);
            }
        }
コード例 #6
0
ファイル: menulauncher.cs プロジェクト: tralivali1234/IL2JS
        private void FocusOnAppropriateMenuItem(HtmlEvent evt)
        {
            if (CUIUtility.IsNullOrUndefined(_menu.SelectedMenuItem) && !CUIUtility.IsNullOrUndefined(_selectedControl))
            {
                Control          ctl      = (Control)_selectedControl;
                ControlComponent dispComp = ctl.DisplayedComponent;
                if (dispComp is MenuItem)
                {
                    _menu.SelectedMenuItem = (MenuItem)dispComp;
                }
            }

            // Let focus remain on triggering element if using jaws
            // LaunchedByKeyboard true for onkeydown, not jaws onclick
            if (LaunchedByKeyboard)
            {
                _menu.FocusOnFirstItem(evt);
            }
            else
            {
                // If nothing has been selected before then we auto-select the first item in some cases
                MenuItem selectedItem = _menu.SelectedMenuItem;
                if (!CUIUtility.IsNullOrUndefined(selectedItem))
                {
                    // This auto selection only happens for ToggleButtons in DropDowns where one of the
                    // menu items represents the "currently selected item" in the DropDown.
                    // Currently selected font in a font dropdown for example.
                    Control selectedItemControl = selectedItem.Control;
                    if (selectedItemControl is ToggleButton && selectedItemControl is ISelectableControl)
                    {
                        ISelectableControl isc = (ISelectableControl)selectedItemControl;
                        if (!_menu.FocusOnItemById(isc.GetMenuItemId()))
                        {
                            _menu.FocusOnFirstItem(evt);
                        }
                    }
                }
            }
        }
コード例 #7
0
ファイル: dropdown.cs プロジェクト: modulexcite/IL2JS
        protected virtual void SelectMenuItem(ISelectableControl isc)
        {
            if (_selectedControl == isc)  // same menu item selected
                return;

            _selectedControl = isc;
            StateProperties[DropDownCommandProperties.SelectedItemId] = isc.GetMenuItemId();

            // If SelectedItemDisplayMode is not set, Medium to "Text"
            string selectedItemDisplayMode;
            if (string.IsNullOrEmpty(Properties.SelectedItemDisplayMode))
                selectedItemDisplayMode = "Text";
            else
                selectedItemDisplayMode = Properties.SelectedItemDisplayMode;

            Anchor selectedItem;

            if (selectedItemDisplayMode == "Text")
            {
                string text = isc.GetTextValue();
                selectedItem = new Anchor();
                UIUtility.SetInnerText(selectedItem, text);
            }
            else
                selectedItem = (Anchor)_selectedControl.GetDropDownDOMElementForDisplayMode(selectedItemDisplayMode);

            if (_elmMediumSelectedItem.HasChildNodes())
            {
                Anchor oldSelectedItem = (Anchor)_elmMediumSelectedItem.FirstChild;
                _elmMediumSelectedItem.ReplaceChild(selectedItem, oldSelectedItem);
            }
            else
                _elmMediumSelectedItem.AppendChild(selectedItem);
        }
コード例 #8
0
ファイル: mrusplitbutton.cs プロジェクト: tralivali1234/IL2JS
        protected override void SelectMenuItem(ISelectableControl isc)
        {
            // Same item selected and we are not in the middle of building a DOM element
            // In this case we need to construct the selected item DOM element for this new display mode.
            if (_selectedControl == isc && !_buildingDOMElement)
            {
                return;
            }

            // We either get the current display mode of this control through what is presently
            // shown in the ribbon.  If not, then we are creating it and just setting the initially shown
            // item.  In this case, we want to set the menu item to the one that we are currently creating.
            string displayMode = !CUIUtility.IsNullOrUndefined(DisplayedComponent) ?
                                 DisplayedComponent.Title : CurrentlyCreatedDisplayMode;

            Span itemContainer;

            switch (displayMode)
            {
            case "Large":
                itemContainer = _elmLargeSelectedItem;
                break;

            case "Medium":
                itemContainer = _elmMediumSelectedItem;
                break;

            case "Small":
                itemContainer = _elmSmallSelectedItem;
                break;

            default:
                throw new ArgumentOutOfRangeException("Invalid display mode on split button while selecting a menu item");
            }

            _selectedControl = isc;
            StateProperties[DropDownCommandProperties.SelectedItemId] = isc.GetMenuItemId();

            Control iscControl = (Control)isc;

            if (iscControl.DisplayedComponent is MenuItem)
            {
                Menu.SelectedMenuItem = (MenuItem)iscControl.DisplayedComponent;
            }
            Span selectedItem = (Span)_selectedControl.GetDropDownDOMElementForDisplayMode(displayMode);

            // The drop down element should not have a <BR> in it because it is
            // used in an MRUSplitButton and there is only room for one line of text.
            if (selectedItem.ChildNodes.Length > 1)
            {
                HtmlElement elm = (HtmlElement)selectedItem.ChildNodes[1];
                if (elm.ChildNodes.Length > 1)
                {
                    if (((HtmlElement)elm.ChildNodes[1]).TagName.ToLower() == "br")
                    {
                        Span elmText = new Span();
                        UIUtility.SetInnerText(elmText, " ");
                        elm.ReplaceChild(elmText, elm.ChildNodes[1]);
                    }
                }
            }

            // Set the ID to null since this DOM element is now hosted in this MRUSplitButton.
            selectedItem.Id = Id + "-SelectedItem";
            if (itemContainer.HasChildNodes())
            {
                HtmlElement oldSelectedItem = (HtmlElement)itemContainer.FirstChild;
                itemContainer.ReplaceChild(selectedItem, oldSelectedItem);
            }
            else
            {
                itemContainer.AppendChild(selectedItem);
            }

            selectedItem.Click    += OnSelectedItemClick;
            selectedItem.DblClick += OnDblClick;
        }
コード例 #9
0
ファイル: mrusplitbutton.cs プロジェクト: modulexcite/IL2JS
        protected override void SelectMenuItem(ISelectableControl isc)
        {
            // Same item selected and we are not in the middle of building a DOM element
            // In this case we need to construct the selected item DOM element for this new display mode.
            if (_selectedControl == isc && !_buildingDOMElement)
                return;

            // We either get the current display mode of this control through what is presently 
            // shown in the ribbon.  If not, then we are creating it and just setting the initially shown 
            // item.  In this case, we want to set the menu item to the one that we are currently creating.
            string displayMode = !CUIUtility.IsNullOrUndefined(DisplayedComponent) ?
                DisplayedComponent.Title : CurrentlyCreatedDisplayMode;

            Span itemContainer;
            switch (displayMode)
            {
                case "Large":
                    itemContainer = _elmLargeSelectedItem;
                    break;
                case "Medium":
                    itemContainer = _elmMediumSelectedItem;
                    break;
                case "Small":
                    itemContainer = _elmSmallSelectedItem;
                    break;
                default:
                    throw new ArgumentOutOfRangeException("Invalid display mode on split button while selecting a menu item");
            }

            _selectedControl = isc;
            StateProperties[DropDownCommandProperties.SelectedItemId] = isc.GetMenuItemId();

            Control iscControl = (Control)isc;

            if (iscControl.DisplayedComponent is MenuItem)
                Menu.SelectedMenuItem = (MenuItem)iscControl.DisplayedComponent;
            Span selectedItem = (Span)_selectedControl.GetDropDownDOMElementForDisplayMode(displayMode);

            // The drop down element should not have a <BR> in it because it is
            // used in an MRUSplitButton and there is only room for one line of text.
            if (selectedItem.ChildNodes.Length > 1)
            {
                HtmlElement elm = (HtmlElement)selectedItem.ChildNodes[1];
                if (elm.ChildNodes.Length > 1)
                {
                    if (((HtmlElement)elm.ChildNodes[1]).TagName.ToLower() == "br")
                    {
                        Span elmText = new Span();
                        UIUtility.SetInnerText(elmText, " ");
                        elm.ReplaceChild(elmText, elm.ChildNodes[1]);
                    }
                }
            }

            // Set the ID to null since this DOM element is now hosted in this MRUSplitButton.
            selectedItem.Id = Id + "-SelectedItem";
            if (itemContainer.HasChildNodes())
            {
                HtmlElement oldSelectedItem = (HtmlElement)itemContainer.FirstChild;
                itemContainer.ReplaceChild(selectedItem, oldSelectedItem);
            }
            else
                itemContainer.AppendChild(selectedItem);

            selectedItem.Click += OnSelectedItemClick;
            selectedItem.DblClick += OnDblClick;
        }
コード例 #10
0
ファイル: combobox.cs プロジェクト: modulexcite/IL2JS
        protected override void SelectMenuItem(ISelectableControl isc)
        {
            if (_selectedControl == isc)
                return;

            _selectedControl = isc;
            StateProperties[ComboBoxCommandProperties.SelectedItemId] = isc.GetMenuItemId();

            IMenuItem imi = (IMenuItem)(Control)isc;
            _elmMediumInput.Value = imi.GetTextValue();
        }