Example #1
0
        protected override HtmlElement CreateDOMElementForDisplayMode(string displayMode)
        {
            switch (displayMode)
            {
                case "Small":
                    _elmImage = new Image();
                    _elmImage.Style.Cursor = "default";
                    _elmImageCont = Utility.CreateClusteredImageContainerNew(
                                                                    ImgContainerSize.Size2by16,
                                                                    Properties.Image,
                                                                    Properties.ImageClass,
                                                                    _elmImage,
                                                                    true,
                                                                    false,
                                                                    Properties.ImageTop,
                                                                    Properties.ImageLeft
                                                                    );

                    _elmSmall = new Span();
                    _elmSmall.ClassName = "ms-cui-ctl ms-cui-ctl-small ms-cui-separator";
                    _elmSmall.AppendChild(_elmImageCont);
                    return _elmSmall;
                default:
                    EnsureValidDisplayMode(displayMode);
                    break;
            }
            return null;
        }
Example #2
0
 internal void AttachTitle()
 {
     _elmTitle = (ListItem)Browser.Document.GetById(Id + "-title");
     _elmTitleA = (Anchor)_elmTitle.ChildNodes[0];
     _elmTitleSpan = (Span)_elmTitleA.ChildNodes[0];
     _elmATText = (Span)_elmTitleA.ChildNodes[1];
 }
Example #3
0
        internal override void AttachDOMElementsForDisplayMode(string displayMode)
        {
            Span elm = (Span)Browser.Document.GetById(Id + "-" + displayMode);
            this.StoreElementForDisplayMode(elm, displayMode);

            switch (displayMode)
            {
                case "Small":
                    _elmImageCont = elm;
                    break;
            }
        }
Example #4
0
 /// <summary>
 /// Created the DOMElement for the given displaymode
 /// </summary>
 protected override HtmlElement CreateDOMElementForDisplayMode(string displayMode)
 {
     switch (displayMode)
     {
         case "Menu":
             // This is needed so that hierarchy is built
             m_elmDefault = new Span();
             return m_elmDefault;
         default:
             this.EnsureValidDisplayMode(displayMode);
             return null;
     }
 }
Example #5
0
 internal void EnsureHiddenATDOMElement()
 {
     if (CUIUtility.IsNullOrUndefined(_elmATText))
         _elmATText = new Span();
 }
Example #6
0
        protected override HtmlElement CreateDOMElementForDisplayMode(string displayMode)
        {
            string alt = string.IsNullOrEmpty(Properties.Alt) ?
                        Properties.LabelText : Properties.Alt;
            alt = CUIUtility.SafeString(alt);

            switch (displayMode)
            {
                case "Small":
                    // Create DOM elements
                    _elmSmall = new Span();
                    _elmSmall.ClassName = "ms-cui-cbx";
                    _elmSmall.SetAttribute("mscui:controltype", ControlType);

                    _elmSmallCheckboxInput = new Input();
                    _elmSmallCheckboxInput.Type = "checkbox";
                    _elmSmallCheckboxInput.ClassName = "ms-cui-cbx-input";
                    _elmSmallCheckboxInput.Id = _id + "-Small-checkbox";
                    if (string.IsNullOrEmpty(Properties.ToolTipTitle))
                    {
                        _elmSmallCheckboxInput.Title = alt;
                    }

                    _elmSmallCheckboxInput.SetAttribute("role", AriaRole);
                    Utility.SetAriaTooltipProperties(Properties, _elmSmallCheckboxInput);

                    // Set up event handlers
                    AttachEvents(_elmSmallCheckboxInput, null);

                    //Build DOM Structure
                    _elmSmall.AppendChild(_elmSmallCheckboxInput);

                    return _elmSmall;
                case "Medium":
                    // Create DOM elements
                    _elmMedium = new Span();
                    _elmMedium.ClassName = "ms-cui-cbx";
                    _elmMedium.SetAttribute("mscui:controltype", ControlType);

                    _elmMediumCheckboxInput = new Input();
                    _elmMediumCheckboxInput.Type = "checkbox";
                    _elmMediumCheckboxInput.ClassName = "ms-cui-cbx-input";
                    _elmMediumCheckboxInput.Id = _id + "-Medium-checkbox";
                    if (string.IsNullOrEmpty(Properties.ToolTipTitle))
                    {
                        _elmMediumCheckboxInput.Title = alt;

                    }
                    _elmMediumCheckboxInput.SetAttribute("role", AriaRole);
                    Utility.SetAriaTooltipProperties(Properties, _elmMediumCheckboxInput);

                    bool hasLabel = false;
                    if (!string.IsNullOrEmpty(Properties.LabelText))
                    {
                        _elmMediumLabel = new MSLabel();
                        if (BrowserUtility.InternetExplorer7)
                        {
                            _elmMediumLabel.SetAttribute("htmlFor", _id + "-Medium-checkbox");
                        }
                        else
                        {
                            _elmMediumLabel.SetAttribute("for", _id + "-Medium-checkbox");
                        }
                        UIUtility.SetInnerText(_elmMediumLabel, Properties.LabelText);
                        hasLabel = true;
                    }

                    // Set up event handlers
                    AttachEvents(_elmMediumCheckboxInput, _elmMediumLabel);

                    // Build DOM Structure
                    _elmMedium.AppendChild(_elmMediumCheckboxInput);
                    if (hasLabel)
                        _elmMedium.AppendChild(_elmMediumLabel);

                    return _elmMedium;
                default:
                    EnsureValidDisplayMode(displayMode);
                    return null;
            }
        }
Example #7
0
        protected override HtmlElement CreateDOMElementForDisplayMode(string displayMode)
        {
            string alt = CUIUtility.SafeString(Properties.Alt);
            string altArrow = CUIUtility.SafeString(Properties.AltArrow);
            bool needsLabel = true;
            if (string.IsNullOrEmpty(altArrow) && !string.IsNullOrEmpty(Properties.ToolTipTitle))
                altArrow = Properties.ToolTipTitle;

            MSLabel elmHiddenLabel;
            switch (displayMode)
            {
                case "Text": // Remove once project's ribbon doesn't use it anymore
                case "Medium":
                    // Top Level Element
                    _elmMedium = new Span();
                    _elmMedium.ClassName = "ms-cui-dd";
                    _elmMedium.SetAttribute("mscui:controltype", ControlType);

                    // Selected Item Element
                    _elmMediumSelectedItem = new Span();
                    _elmMediumSelectedItem.ClassName = "ms-cui-dd-text";
                    _elmMediumSelectedItem.Style.Width = Properties.Width;

                    string dictKey = DropDownCommandProperties.SelectedItemId;
                    string itemId = StateProperties.ContainsKey(dictKey) ? StateProperties[dictKey] : "";
                    if (string.IsNullOrEmpty(itemId))
                        itemId = Properties.InitialItem;
                    if (!string.IsNullOrEmpty(itemId))
                        SelectMenuItemById(itemId);

                    // Arrow Button Element
                    _elmMediumBtnA = new Anchor();
                    _elmMediumBtnA.SetAttribute("role", AriaRole);
                    _elmMediumBtnA.SetAttribute("aria-haspopup", "true");
                    Utility.EnsureCSSClassOnElement(_elmMediumBtnA, "ms-cui-dd-arrow-button");
                    Utility.SetAriaTooltipProperties(Properties, _elmMediumBtnA);
                    Utility.NoOpLink(_elmMediumBtnA);
                    _elmMediumBtnA.Id = Id;
                    _elmMediumArwImg = new Image();

                    _elmMediumArwImgCont = Utility.CreateClusteredImageContainerNew(
                                                                           ImgContainerSize.Size5by3,
                                                                           Root.Properties.ImageDownArrow,
                                                                           Root.Properties.ImageDownArrowClass,
                                                                           _elmMediumArwImg,
                                                                           true,
                                                                           false,
                                                                           Root.Properties.ImageDownArrowTop,
                                                                           Root.Properties.ImageDownArrowLeft
                                                                           );

                    if (string.IsNullOrEmpty(Properties.ToolTipTitle))
                    {
                        _elmMediumBtnA.SetAttribute("title", altArrow);
                        _elmMediumSelectedItem.Title = alt;
                        _elmMediumArwImg.Alt = altArrow;
                        needsLabel = false;
                    }

                    // Set up event handlers for the Drop Down Arrow Button
                    AttachEventsForDisplayMode("Medium");

                    // Build DOM Structure
                    _elmMedium.AppendChild(_elmMediumSelectedItem);
                    _elmMedium.AppendChild(_elmMediumBtnA);
                    _elmMediumBtnA.AppendChild(_elmMediumArwImgCont);

                    if (needsLabel)
                    {
                        elmHiddenLabel = Utility.CreateHiddenLabel(altArrow);
                        _elmMediumBtnA.AppendChild(elmHiddenLabel);
                    }

                    return _elmMedium;
                default:
                    EnsureValidDisplayMode(displayMode);
                    return null;
            }
        }
Example #8
0
        internal override void AttachDOMElementsForDisplayMode(string displayMode)
        {
            Span elm = (Span)Browser.Document.GetById(Id + "-" + displayMode);
            StoreElementForDisplayMode(elm, displayMode);

            switch (displayMode)
            {
                case "Text":
                case "Medium":
                    _elmMedium = elm;
                    _elmMediumSelectedItem = (Span)_elmMedium.ChildNodes[0];
                    _elmMediumBtnA = (Anchor)_elmMedium.ChildNodes[1];
                    _elmMediumArwImgCont = (Span)_elmMediumBtnA.ChildNodes[0];
                    _elmMediumArwImg = (Image)_elmMediumArwImgCont.ChildNodes[0];
                    break;
            }
        }
Example #9
0
 /// <summary>
 /// Creates the Label element for menus if it is not yet created
 /// </summary>
 /// <owner alias="JKern" />
 protected void CreateMenuLabelDOMElementIfNeeded(string displayMode)
 {
     if (CUIUtility.IsNullOrUndefined(_elmMenuLbl))
     {
         _elmMenuLbl = new Span();
         _elmMenuLbl.ClassName = "ms-cui-ctl-mediumlabel";
         UIUtility.SetInnerText(_elmMenuLbl, Properties.LabelText);
     }
 }
Example #10
0
        internal override void AttachDOMElementsForDisplayMode(string displayMode)
        {
            Span elm = (Span)Browser.Document.GetById(Id + "-" + displayMode);
            StoreElementForDisplayMode(elm, displayMode);

            // If we are attaching, we clear the initial item since this is dynamically
            // generated from a DOM element from a subitem.  This will cause the new
            // DOM element to be generated the first time that this is queried.
            StateProperties[DropDownCommandProperties.SelectedItemId] = "";

            // Only do hookup for non-menu display modes for now
            switch (displayMode)
            {
                case "Medium":
                    _elmMedium = elm;
                    _elmMediumInput = (Input)_elmMedium.ChildNodes[0];
                    _elmMediumBtnA = (Anchor)_elmMedium.ChildNodes[1];
                    _elmMediumArwImgCont = (Span)_elmMediumBtnA.ChildNodes[0];
                    _elmMediumArwImg = (Image)_elmMediumArwImgCont.ChildNodes[0];

                    Utility.SetUnselectable(_elmMediumInput, false, false);
                    break;
            }
        }
Example #11
0
        private void ShowGlass()
        {
            if (_glassIsShown)
                return;

            if (_elmGlass == null)
            {
                _elmGlass = Utility.CreateGlassElement();
                _elmGlass.Click += OnGlassClick;
                ElementInternal.AppendChild(_elmGlass);
            }

            _elmGlass.Style.Display = "";
            _glassIsShown = true;
        }
Example #12
0
        internal override void RefreshInternal()
        {
            // TODO: possible perf implication.
            // We do not always have to remove the children.
            EnsureDOMElementAndEmpty();

            if (CUIUtility.IsNullOrUndefined(_elmTitle))
            {
                _elmTitle = new Span();
                _elmTitle.ClassName = "ms-cui-groupTitle";
            }
            else
            {
                _elmTitle = (Span)Utility.RemoveChildNodes(_elmTitle);
            }

            if (CUIUtility.IsNullOrUndefined(_elmBody))
            {
                _elmBody = new Span();
                _elmBody.ClassName = "ms-cui-groupBody";
            }
            else
            {
                _elmBody = (Span)Utility.RemoveChildNodes(_elmBody);
            }

            if (CUIUtility.IsNullOrUndefined(_elmSeparator))
            {
                _elmSeparator = new Span();
                _elmSeparator.ClassName = "ms-cui-groupSeparator";
            }

            // Refresh the text of the group name
            string title = Title;
            if (!string.IsNullOrEmpty(title))
            {
                UIUtility.SetInnerText(_elmTitle, title);

            }

            _elmTitle.Title = Title;

            if (!CUIUtility.IsNullOrUndefined(_selectedLayout) &&
                typeof(GroupPopupLayout).IsInstanceOfType(_selectedLayout))
            {
                _selectedLayout.EnsureDOMElement();
                ElementInternal.AppendChild(_selectedLayout.ElementInternal);
                ElementInternal.AppendChild(_elmSeparator);
                _selectedLayout.EnsureRefreshed();
            }
            else
            {
                Span elmContainer = new Span();
                elmContainer.ClassName = "ms-cui-groupContainer";

                elmContainer.AppendChild(_elmBody);
                elmContainer.AppendChild(_elmTitle);

                ElementInternal.AppendChild(elmContainer);
                ElementInternal.AppendChild(_elmSeparator);

                if (!CUIUtility.IsNullOrUndefined(_selectedLayout))
                {
                    _selectedLayout.EnsureDOMElement();
                    _elmBody.AppendChild(_selectedLayout.ElementInternal);
                    _selectedLayout.EnsureRefreshed();
                }
            }

            base.RefreshInternal();
        }
Example #13
0
 internal override void AttachDOMElements()
 {
     base.AttachDOMElements();
     if (!CUIUtility.IsNullOrUndefined(_selectedLayout) &&
         !typeof(GroupPopupLayout).IsInstanceOfType(_selectedLayout))
     {
         // We are in the normal case and not in the group popup case
         HtmlElement elmContainer = (HtmlElement)ElementInternal.ChildNodes[0];
         _elmSeparator = (Span)ElementInternal.ChildNodes[1];
         _elmBody = (Span)elmContainer.ChildNodes[0];
         _elmTitle = (Span)elmContainer.ChildNodes[1];
     }
 }
Example #14
0
        static protected Anchor CreateStandardControlDOMElementCore(
            Control control,
            Root root,
            string displayMode,
            string id,
            string image32by32,
            string image32by32Class,
            string image32by32Top,
            string image32by32Left,
            string image16by16,
            string image16by16Class,
            string image16by16Top,
            string image16by16Left,
            string labelText,
            string labelCss,
            string alt,
            string description,
            string tooltipTitle,
            bool menu,
            bool arrow)
        {
            // O14:503464 - Missing label text should be empty instead of "undefined"
            if (string.IsNullOrEmpty(labelText))
                labelText = "";

            bool isMenu = false;
            bool needsHiddenLabel = true;
            Anchor elm = Utility.CreateNoOpLink();

            string outerStyle = null;
            if (displayMode == "Large")
                outerStyle = "ms-cui-ctl-large";
            else if (displayMode == "Medium")
                outerStyle = "ms-cui-ctl-medium";
            else if (displayMode == "Menu16" || displayMode == "Menu")
            {
                outerStyle = "ms-cui-ctl-menu";
                isMenu = true;
            }
            else if (displayMode == "Menu32")
            {
                outerStyle = "ms-cui-ctl-menu ms-cui-ctl-menu32";
                isMenu = true;
            }
            else
                outerStyle = "ms-cui-ctl";

            Utility.EnsureCSSClassOnElement(elm, outerStyle);

            if (displayMode == "Menu")
                Utility.EnsureCSSClassOnElement(elm, "ms-cui-textmenuitem");

            if (!string.IsNullOrEmpty(tooltipTitle))
                elm.SetAttribute("aria-describedby", id + "_ToolTip");

            elm.SetAttribute("mscui:controltype", control.ControlType);

            // Create the image
            Image elmImage = new Image();

            string imageUrl = null;
            string imageClass = null;
            string imageTop = null;
            string imageLeft = null;
            ImgContainerSize imgSize = ImgContainerSize.None;

            elmImage.Alt = "";
            alt = string.IsNullOrEmpty(alt) ? labelText : alt;
            elm.SetAttribute("role", control.AriaRole);
            if (control is FlyoutAnchor)
                elm.SetAttribute("aria-haspopup", "true");

            if(string.IsNullOrEmpty(tooltipTitle)) 
            {
                elm.Title = alt;
                elmImage.Alt = alt;
                needsHiddenLabel = false;
            }

            if (displayMode == "Large" || displayMode == "Menu32")
            {
                imageUrl = image32by32;
                imageClass = image32by32Class;
                imageTop = image32by32Top;
                imageLeft = image32by32Left;
                imgSize = ImgContainerSize.Size32by32;
            }
            else
            {
                imageUrl = image16by16;
                imageClass = image16by16Class;
                imageTop = image16by16Top;
                imageLeft = image16by16Left;
                imgSize = ImgContainerSize.Size16by16;
            }

            Span elmImageCont = Utility.CreateClusteredImageContainerNew(
                                                                       imgSize,
                                                                       imageUrl,
                                                                       imageClass,
                                                                       elmImage,
                                                                       true,
                                                                       false,
                                                                       imageTop,
                                                                       imageLeft);
            Span elmIconContainer = new Span();
            elmIconContainer.ClassName = displayMode == "Large" ? "ms-cui-ctl-largeIconContainer" : "ms-cui-ctl-iconContainer";
            elmIconContainer.AppendChild(elmImageCont);

            // Create the label
            // The small display mode of controls does not have label text
            // However, controls with arrows like FlyoutAnchor still need
            // this element.
            SPLabel hiddenLabel = null;
            HtmlElement elmLabel = null;
            if (needsHiddenLabel)
            {
                hiddenLabel = Utility.CreateHiddenLabel(alt);

            }
            if (displayMode != "Small" || arrow)
            {
                elmLabel = new Span();
                if (displayMode != "Small")
                {
                    if (displayMode == "Large")
                    {
                        Utility.EnsureCSSClassOnElement(elmLabel, "ms-cui-ctl-largelabel");
                        elmLabel.InnerHtml = Utility.FixLargeControlText(labelText, arrow);
                    }
                    else
                    {
                        string text = labelText;
                        if (arrow)
                            text = text + " ";

                        Utility.EnsureCSSClassOnElement(elmLabel, "ms-cui-ctl-mediumlabel");
                        UIUtility.SetInnerText(elmLabel, text);
                    }
                    if (!string.IsNullOrEmpty(labelCss))
                    {
                        elmLabel.Style.CssText = labelCss;
                    }
                }
                else
                {
                    // If the displaymode is Small and there is an arrow
                    Utility.EnsureCSSClassOnElement(elmLabel, "ms-cui-ctl-smalllabel");
                    UIUtility.SetInnerText(elmLabel, " ");
                }
            }
            else if (needsHiddenLabel)
            {
                elmLabel = Utility.CreateHiddenLabel(alt);
            }

            // Create the arrow image if one was specified
            Span elmArrowCont = null;
            if (arrow)
            {
                Image elmArrowImage = new Image();
                elmArrowImage.Alt = "";
                if(string.IsNullOrEmpty(tooltipTitle)) 
                {
                    elmArrowImage.Alt = alt;
                }
                elmArrowCont = Utility.CreateClusteredImageContainerNew(
                                                                ImgContainerSize.Size5by3,
                                                                root.Properties.ImageDownArrow,
                                                                root.Properties.ImageDownArrowClass,
                                                                elmArrowImage,
                                                                true,
                                                                false,
                                                                root.Properties.ImageDownArrowTop,
                                                                root.Properties.ImageDownArrowLeft);
            }

            // This is used for Menu32.  It can have a description under the label text.
            Span elmTextContainer = null;
            Span elmDescriptionText = null;
            Span elmMenu32Clear = null;
            if (displayMode == "Menu32")
            {
                elmTextContainer = new Span();
                elmTextContainer.ClassName = "ms-cui-ctl-menulabel";
                Utility.EnsureCSSClassOnElement(elmLabel, "ms-cui-btn-title");
                elmTextContainer.AppendChild(elmLabel);
                if (!string.IsNullOrEmpty(description))
                {
                    elmDescriptionText = new Span();
                    Utility.EnsureCSSClassOnElement(elmDescriptionText, "ms-cui-btn-menu-description");
                    UIUtility.SetInnerText(elmDescriptionText, description);
                    elmDescriptionText.Style.Display = "block";
                    elmTextContainer.AppendChild(elmDescriptionText);
                }
                elmMenu32Clear = new Span();
                elmMenu32Clear.ClassName = "ms-cui-ctl-menu32clear";
                elmMenu32Clear.InnerHtml = "&nbsp;";
            }

            elm.AppendChild(elmIconContainer);

            if (!CUIUtility.IsNullOrUndefined(elmLabel))
            {
                if (!CUIUtility.IsNullOrUndefined(elmTextContainer))
                {
                    elm.AppendChild(elmTextContainer);
                    elm.AppendChild(elmMenu32Clear);
                }
                else
                {
                    elm.AppendChild(elmLabel);
                    if (displayMode == "Small" && arrow && needsHiddenLabel) // if no alt is present add a hidden label for MSAA
                        elm.AppendChild(hiddenLabel);
                }
                if (!CUIUtility.IsNullOrUndefined(elmArrowCont))
                    elmLabel.AppendChild(elmArrowCont);
            }

            if (isMenu)
            {
                Span elmMenuGlass = Utility.CreateGlassElement();
                elm.AppendChild(elmMenuGlass);
            }

            return elm;
        }
Example #15
0
        static protected Span CreateTwoAnchorControlDOMElementCore(
            Control control,
            Root root,
            string displayMode,
            string id,
            string image32by32,
            string image32by32Class,
            string image32by32Top,
            string image32by32Left,
            string image16by16,
            string image16by16Class,
            string image16by16Top,
            string image16by16Left,
            string labelText,
            string alt,
            string tooltipTitle,
            bool arrow)
        {
            bool needsHiddenLabel = true;
            labelText = CUIUtility.SafeString(labelText);

            // Create the outer <span> element for this two anchor control
            Span elm = new Span();

            if (displayMode == "Large")
                elm.ClassName = "ms-cui-ctl-large";
            else if (displayMode == "Medium")
                elm.ClassName = "ms-cui-ctl ms-cui-ctl-medium";
            else
                elm.ClassName = "ms-cui-ctl ms-cui-ctl-small";

            if (!string.IsNullOrEmpty(tooltipTitle))
                elm.SetAttribute("aria-describedby", id + "_ToolTip");

            elm.SetAttribute("mscui:controltype", control.ControlType);

            Anchor elmA1 = Utility.CreateNoOpLink();
            Anchor elmA2 = Utility.CreateNoOpLink();

            elmA1.ClassName = "ms-cui-ctl-a1";
            elmA2.ClassName = "ms-cui-ctl-a2";
            alt = string.IsNullOrEmpty(alt) ? labelText : alt;

            // Setting aria properties for screen readers
            elmA1.SetAttribute("role", control.AriaRole);
            elmA2.SetAttribute("role", control.AriaRole);
            elmA2.SetAttribute("aria-haspopup", "true");

            Span elmA1Internal = new Span();
            elmA1Internal.ClassName = "ms-cui-ctl-a1Internal";

            // Create the image
            Image elmImage = new Image();
            string imageUrl = null;
            string imageClass = null;
            string imageTop = null;
            string imageLeft = null;
            ImgContainerSize imgSize = ImgContainerSize.None;
            elmImage.Alt = "";

            // Display alt only if no supertooltip is present
            if(string.IsNullOrEmpty(tooltipTitle)) 
            {
                elmA1.Title = alt;
                elmA2.Title = alt;
                elmImage.Alt = alt;
                needsHiddenLabel = false;
            }

            if (displayMode == "Large" || displayMode == "Menu32")
            {
                imageUrl = image32by32;
                imageClass = image32by32Class;
                imageTop = image32by32Top;
                imageLeft = image32by32Left;
                imgSize = ImgContainerSize.Size32by32;
            }
            else
            {
                imageUrl = image16by16;
                imageClass = image16by16Class;
                imageTop = image16by16Top;
                imageLeft = image16by16Left;
                imgSize = ImgContainerSize.Size16by16;
            }

            Span elmImageCont = Utility.CreateClusteredImageContainerNew(
                                                                       imgSize,
                                                                       imageUrl,
                                                                       imageClass,
                                                                       elmImage,
                                                                       true,
                                                                       false,
                                                                       imageTop,
                                                                       imageLeft);

            // Controls lacking a label and with supertooltips need hidden labels
            SPLabel elmHiddenBtnLabel = null;
            SPLabel elmHiddenArrowLabel = null;
            if (needsHiddenLabel)
            {
                elmHiddenBtnLabel = Utility.CreateHiddenLabel(alt);
                elmHiddenArrowLabel = Utility.CreateHiddenLabel(alt);
            }

            // Create the label
            // The small display mode of controls does not have label text
            // However, controls with arrows like FlyoutAnchor still need
            // this element.
            Span elmLabel = null;
            if (displayMode != "Small" || arrow)
            {
                elmLabel = new Span();
                if (displayMode != "Small")
                {
                    if (displayMode == "Large")
                    {
                        Utility.EnsureCSSClassOnElement(elmLabel, "ms-cui-ctl-largelabel");
                        elmLabel.InnerHtml = Utility.FixLargeControlText(labelText, arrow);
                    }
                    else if (displayMode == "Medium")
                    {
                        Utility.EnsureCSSClassOnElement(elmLabel, "ms-cui-ctl-mediumlabel");
                        UIUtility.SetInnerText(elmLabel, labelText);
                    }
                }
            }

            Span elmArrowCont = null;
            if (arrow)
            {
                Image elmArrowImage = new Image(); 
                if(string.IsNullOrEmpty(tooltipTitle)) 
                {
                    elmArrowImage.Alt = alt;
                }
                elmArrowCont = Utility.CreateClusteredImageContainerNew(
                                                                ImgContainerSize.Size5by3,
                                                                root.Properties.ImageDownArrow,
                                                                root.Properties.ImageDownArrowClass,
                                                                elmArrowImage,
                                                                true,
                                                                false,
                                                                root.Properties.ImageDownArrowTop,
                                                                root.Properties.ImageDownArrowLeft);
            }

            elm.AppendChild(elmA1);
            elm.AppendChild(elmA2);
            elmA1.AppendChild(elmA1Internal);
            elmA1Internal.AppendChild(elmImageCont);

            if (!CUIUtility.IsNullOrUndefined(elmLabel))
            {
                if (displayMode == "Large")
                {
                    elmA2.AppendChild(elmLabel);
                    if (needsHiddenLabel)
                        elmA1.AppendChild(elmHiddenBtnLabel);
                }
                else
                {
                    elmA1Internal.AppendChild(elmLabel);
                    if (needsHiddenLabel)
                        elmA2.AppendChild(elmHiddenArrowLabel);
                }

                if (displayMode == "Small" && needsHiddenLabel)
                {
                    elmA1.AppendChild(elmHiddenBtnLabel);
                }
            }
            if (!CUIUtility.IsNullOrUndefined(elmArrowCont))
            {
                if (displayMode == "Large")
                {
                    elmLabel.AppendChild(elmArrowCont);
                }
                else
                {
                    elmA2.AppendChild(elmArrowCont);
                }
            }

            return elm;
        }
Example #16
0
        internal override void AttachDOMElementsForDisplayMode(string displayMode)
        {
            Anchor elm = (Anchor)Browser.Document.GetById(Id + "-" + displayMode);
            if (!CUIUtility.IsNullOrUndefined(elm))
                StoreElementForDisplayMode(elm, displayMode);

            // Only do hookup for non-menu display modes
            // This is also called from CreateDOMElementForDisplayMode() so if "elm" is null
            // then we should already have the outer DOMElement.
            switch (displayMode)
            {
                case "Large":
                    if (!CUIUtility.IsNullOrUndefined(elm))
                        _elmLarge = elm;
                    _elmLargeImg = (Image)_elmLarge.ChildNodes[0].ChildNodes[0];
                    _elmLargeArrowImg = (Image)_elmLarge.LastChild.LastChild.ChildNodes[0];
                    break;
                case "Medium":
                    if (!CUIUtility.IsNullOrUndefined(elm))
                        _elmMedium = elm;
                    _elmMediumImg = (Image)_elmMedium.ChildNodes[0].ChildNodes[0];
                    _elmMediumArrowImg = (Image)_elmMedium.LastChild.LastChild.ChildNodes[0];
                    break;
                case "Small":
                    if (!CUIUtility.IsNullOrUndefined(elm))
                        _elmSmall = elm;
                    _elmSmallImg = (Image)_elmSmall.ChildNodes[0].ChildNodes[0];
                    _elmSmallArrowImg = (Image)_elmSmall.LastChild.LastChild.ChildNodes[0];
                    break;
                case "Thin":
                    _elmThin = elm;
                    _elmThinArrowImgCont = (Span)elm.FirstChild;
                    _elmThinArrowImg = (Image)_elmThinArrowImgCont.FirstChild;
                    break;
            }
        }
Example #17
0
        /// <summary>
        /// Creates a DOMElement for a menu display mode
        /// </summary>
        /// <param name="displayMode">The display mode to create</param>
        /// <param name="cssClass">The CSS Class to wrap this element in</param>
        /// <param name="alt">The alt text</param>
        /// <param name="icon">The path to the icon image (if applicable)</param>
        /// <param name="iconclass">The CSS class to apply to the icon</param>
        /// <returns>A DOMElement for this menu display mode of this control</returns>
        protected Anchor CreateMenuDOMElement(
            string displayMode,
            string cssClass,
            string alt,
            string icon,
            string iconclass,
            string icontop,
            string iconleft)
        {
            // Create DOM Elements
            Anchor elm = Utility.CreateNoOpLink();
            elm.ClassName = cssClass;
            elm.Title = alt;
            elm.SetAttribute("mscui:controltype", ControlType);
            Utility.SetAriaTooltipProperties(this.Properties, elm);
            Span elmIcon = null;

            // Create icons if necessary
            switch (displayMode)
            {
                case "Menu16":
                    {
                        if (CUIUtility.IsNullOrUndefined(_elmMenuImg16))
                        {
                            _elmMenuImg16 = new Image();
                            _elmMenuImg16Cont = Utility.CreateClusteredImageContainerNew(
                                                                            ImgContainerSize.Size16by16,
                                                                            icon,
                                                                            iconclass,
                                                                            _elmMenuImg16,
                                                                            true,
                                                                            true,
                                                                            icontop,
                                                                            iconleft);

                            _elmMenuImg16.Alt = alt;
                            elmIcon = _elmMenuImg16Cont;
                        }
                        break;
                    }
                case "Menu32":
                    {
                        if (CUIUtility.IsNullOrUndefined(_elmMenuImg32))
                        {
                            _elmMenuImg32 = new Image();
                            _elmMenuImg32Cont = Utility.CreateClusteredImageContainerNew(
                                                                            ImgContainerSize.Size32by32,
                                                                            icon,
                                                                            iconclass,
                                                                            _elmMenuImg32,
                                                                            true,
                                                                            true,
                                                                            icontop,
                                                                            iconleft);

                            _elmMenuImg32.Alt = alt;
                            elmIcon = _elmMenuImg32Cont;
                        }
                        break;
                    }
            }

            // Label
            CreateMenuLabelDOMElementIfNeeded(displayMode);

            // Arrow image
            if (CUIUtility.IsNullOrUndefined(_elmMenuArrowImg))
            {
                _elmMenuArrowImg = new Image();
                _elmMenuArrowImgCont = Utility.CreateClusteredImageContainerNew(
                                                                       ImgContainerSize.Size13by13,
                                                                       Root.Properties.ImageSideArrow,
                                                                       Root.Properties.ImageSideArrowClass,
                                                                       _elmMenuArrowImg,
                                                                       false,
                                                                       true,
                                                                       Root.Properties.ImageSideArrowTop,
                                                                       Root.Properties.ImageSideArrowLeft
                                                                       );

                Utility.EnsureCSSClassOnElement(_elmMenuArrowImgCont, "ms-cui-fa-menu-arrow");
            }

            // Build DOM Structure
            if (elmIcon != null)
            {
                Span elmIconContainer = new Span();
                elmIconContainer.ClassName = "ms-cui-ctl-iconContainer";
                elmIconContainer.AppendChild(elmIcon);
                elm.AppendChild(elmIconContainer);
            }

            elm.AppendChild(_elmMenuLbl);
            elm.AppendChild(_elmMenuArrowImgCont);

            return elm;
        }
Example #18
0
 public override void Dispose()
 {
     base.Dispose();
     _elmMedium = null;
     _elmMediumArwImg = null;
     _elmMediumArwImgCont = null;
     _elmMediumBtnA = null;
     _elmMediumInput = null;
 }
Example #19
0
        /// <summary>
        /// Creates the DOM Element for the given display mode of this Flyout Anchor
        /// </summary>
        /// <param name="displayMode">The identifier of a valid display mode for this control</param>
        /// <returns>A DOMElement that represents this control for the given display mode</returns>
        /// <owner alias="JKern" />
        protected override HtmlElement CreateDOMElementForDisplayMode(string displayMode)
        {
            string alt = string.IsNullOrEmpty(Properties.Alt) ? 
                Properties.LabelText : Properties.Alt;

            switch (displayMode)
            {
                case "Menu":
                    _elmMenu = CreateMenuDOMElement("Menu",
                        "ms-cui-textmenuitem ms-cui-fa-menuitem ms-cui-ctl-menu",
                        alt,
                        null,
                        null,
                        null,
                        null);

                    AttachEventsForDisplayMode(displayMode);
                    _elmMenu.SetAttribute("aria-haspopup", "true");
                    return _elmMenu;
                case "Menu16":
                    _elmMenu16 = CreateMenuDOMElement("Menu16",
                        "ms-cui-fa-menuitem ms-cui-ctl-menu",
                        alt,
                        Properties.Image16by16,
                        Properties.Image16by16Class,
                        Properties.Image16by16Top,
                        Properties.Image16by16Left);

                    AttachEventsForDisplayMode(displayMode);
                    _elmMenu16.SetAttribute("aria-haspopup", "true");
                    return _elmMenu16;
                case "Menu32":
                    _elmMenu32 = CreateMenuDOMElement("Menu32",
                        "ms-cui-fa-menuitem ms-cui-ctl-menu",
                        alt,
                        Properties.Image32by32,
                        Properties.Image32by32Class,
                        Properties.Image32by32Top,
                        Properties.Image32by32Left);
                    _elmMenu32.SetAttribute("aria-haspopup", "true");

                    AttachEventsForDisplayMode(displayMode);
                    return _elmMenu32;

                case "Large":
                    _elmLarge = CreateStandardControlDOMElement(
                                    this,
                                    Root,
                                    "Large",
                                    Properties,
                                    false,
                                    true);
                    _elmLarge.SetAttribute("aria-haspopup", "true");

                    if (IsGroupPopup)
                        Utility.EnsureCSSClassOnElement(_elmLarge, "ms-cui-ctl-large-groupPopup");

                    AttachEventsForDisplayMode("Large");
                    return _elmLarge;

                case "Medium":
                    _elmMedium = CreateStandardControlDOMElement(
                                    this,
                                    Root,
                                    "Medium",
                                    Properties,
                                    false,
                                    true);
                    // Set up event handlers
                    AttachEventsForDisplayMode("Medium");
                    _elmMedium.SetAttribute("aria-haspopup", "true");
                    return _elmMedium;

                case "Small":
                    _elmSmall = CreateStandardControlDOMElement(
                                    this,
                                    Root,
                                    "Small",
                                    Properties,
                                    false,
                                    true);

                    // Set up event handlers
                    AttachEventsForDisplayMode("Small");
                    _elmSmall.SetAttribute("aria-haspopup", "true");
                    return _elmSmall;

                case "Thin":
                    _elmThin = Utility.CreateNoOpLink();
                    _elmThin.ClassName = "ms-cui-ctl-thin";

                    _elmThinArrowImg = new Image();
                    _elmThinArrowImg.Alt = "";
                    if(string.IsNullOrEmpty(Properties.ToolTipTitle))
                    {
                        _elmThin.Title = alt;
                        _elmThinArrowImg.Alt = alt;
                    }

                    Root root = this.Root;
                    _elmThinArrowImgCont = Utility.CreateClusteredImageContainerNew(
                                                                    ImgContainerSize.Size5by3,
                                                                    root.Properties.ImageDownArrow,
                                                                    root.Properties.ImageDownArrowClass,
                                                                    _elmThinArrowImg,
                                                                    true,
                                                                    false,
                                                                    root.Properties.ImageDownArrowTop,
                                                                    root.Properties.ImageDownArrowLeft);

                    _elmThin.AppendChild(_elmThinArrowImgCont);

                    // Attach Events
                    AttachEventsForDisplayMode("Thin");
                    _elmThin.SetAttribute("aria-haspopup", "true");
                    return _elmThin;
                default:
                    EnsureValidDisplayMode(displayMode);
                    break;
            }
            return null;
        }
Example #20
0
        protected override HtmlElement CreateDOMElementForDisplayMode(string displayMode)
        {
            switch (displayMode)
            {
                case "Medium":
                    string alt = CUIUtility.SafeString(CBProperties.Alt);
                    string altArrow = CUIUtility.SafeString(CBProperties.AltArrow);

                    // Top Level Element
                    _elmMedium = new Span();
                    _elmMedium.ClassName = "ms-cui-cb";
                    _elmMedium.SetAttribute("mscui:controltype", ControlType);

                    // Input Element
                    _elmMediumInput = new Input();
                    _elmMediumInput.SetAttribute("name", CBProperties.Command);
                    _elmMediumInput.Type = "text";
                    _elmMediumInput.Style.Width = CBProperties.Width;
                    _elmMediumInput.ClassName = "ms-cui-cb-input";
                    _elmMediumInput.SetAttribute("autocomplete", "off");
                    _elmMediumInput.Id = CBProperties.Id;
                    if (string.IsNullOrEmpty(Properties.ToolTipTitle))
                        _elmMediumInput.Title = alt;
                    Utility.SetImeMode(_elmMediumInput, ((ComboBoxProperties)Properties).ImeEnabled);

                    string itemId = (string)StateProperties[ComboBoxCommandProperties.SelectedItemId];
                    if (string.IsNullOrEmpty(itemId))
                        itemId = CBProperties.InitialItem;
                    if (!string.IsNullOrEmpty(itemId))
                        SelectMenuItemById(itemId);

                    Utility.SetAriaTooltipProperties(Properties, _elmMediumInput);

                    // Arrow Button Element
                    _elmMediumBtnA = new Anchor();
                    Utility.EnsureCSSClassOnElement(_elmMediumBtnA, "ms-cui-dd-arrow-button");
                    Utility.NoOpLink(_elmMediumBtnA);

                    _elmMediumBtnA.TabIndex = -1; // Only the input box should be tab-able
                    _elmMediumBtnA.SetAttribute("aria-haspopup", "true");

                    _elmMediumArwImg = new Image();

                    _elmMediumArwImgCont = Utility.CreateClusteredImageContainerNew(
                                                                            ImgContainerSize.Size5by3,
                                                                            Root.Properties.ImageDownArrow,
                                                                            Root.Properties.ImageDownArrowClass,
                                                                            _elmMediumArwImg,
                                                                            true,
                                                                            false,
                                                                            Root.Properties.ImageDownArrowTop,
                                                                            Root.Properties.ImageDownArrowLeft
                                                                            );

                    if (string.IsNullOrEmpty(Properties.ToolTipTitle))
                    {
                        _elmMediumArwImg.Alt = altArrow;
                        _elmMediumBtnA.Title = altArrow;
                    }

                    // Set up event handlers for the Drop Down Arrow Button
                    AttachEventsForDisplayMode("Medium");

                    // Build DOM Structure
                    _elmMedium.AppendChild(_elmMediumInput);
                    _elmMedium.AppendChild(_elmMediumBtnA);

                    _elmMediumBtnA.AppendChild(_elmMediumArwImgCont);
                    return _elmMedium;
                default:
                    EnsureValidDisplayMode(displayMode);
                    return null;
            }
        }
Example #21
0
 public override void Dispose()
 {
     base.Dispose();
     _elmMedium = null;
     _elmMediumArwImg = null;
     _elmMediumArwImgCont = null;
     _elmMediumBtnA = null;
     _elmMediumSelectedItem = null;
 }
Example #22
0
 internal override void AttachDOMElementsForDisplayMode(string displayMode)
 {
     Span elm = (Span)Browser.Document.GetById(Id + "-" + displayMode);
     StoreElementForDisplayMode(elm, displayMode);
     switch (displayMode)
     {
         case "Large":
             _elmLarge = elm;
             _elmLargeSelectedItem = (Span)_elmLarge.ChildNodes[0];
             _elmLargeBtn = (Anchor)_elmLarge.ChildNodes[1];
             _elmLargeArrowImg = (Image)_elmLargeBtn.ChildNodes[0].ChildNodes[0];
             break;
         case "Medium":
             _elmMedium = elm;
             _elmMediumSelectedItem = (Span)_elmMedium.ChildNodes[0];
             _elmMediumBtn = (Anchor)_elmMedium.ChildNodes[1];
             _elmMediumArrowImg = (Image)_elmMediumBtn.ChildNodes[0].ChildNodes[0];
             break;
         case "Small":
             _elmSmall = elm;
             _elmSmallSelectedItem = (Span)_elmSmall.ChildNodes[0];
             _elmSmallBtn = (Anchor)_elmSmall.ChildNodes[1];
             _elmSmallArrowImg = (Image)_elmSmallBtn.ChildNodes[0].ChildNodes[0];
             break;
     }
 }
Example #23
0
        internal override void AttachDOMElementsForDisplayMode(string displayMode)
        {
            Span elm = (Span)Browser.Document.GetById(Id + "-" + displayMode);
            this.StoreElementForDisplayMode(elm, displayMode);

            // Only do hookup for non-menu display modes for now
            switch (displayMode)
            {
                case "Medium":
                    _elmMedium = elm;
                    _elmMediumCheckboxInput = (Input)elm.FirstChild;
                    _elmMediumLabel = (MSLabel)elm.ChildNodes[1];
                    break;
                case "Small":
                    _elmSmall = elm;
                    _elmSmallCheckboxInput = (Input)elm.FirstChild;
                    break;
            }
        }
Example #24
0
        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;
        }
Example #25
0
 public override void Dispose()
 {
     base.Dispose();
     _elmMedium = null;
     _elmMediumCheckboxInput = null;
     _elmMediumLabel = null;
     _elmSmall = null;
     _elmSmallCheckboxInput = null;
 }
Example #26
0
        protected override HtmlElement CreateDOMElementForDisplayMode(string displayMode)
        {
            bool needsLabel = true;
            string alt = CUIUtility.SafeString(Properties.Alt);
            string width = (displayMode == "Medium" && !string.IsNullOrEmpty(Properties.Width)) ? Properties.Width : "auto";
            MSLabel hiddenLabel;
            string itemId = StateProperties[DropDownCommandProperties.SelectedItemId];
            if (string.IsNullOrEmpty(itemId))
                itemId = Properties.InitialItem;

            _buildingDOMElement = true;

            switch (displayMode)
            {
                case "Large":

                    _elmLarge = new Span();
                    _elmLarge.SetAttribute("mscui:controltype", ControlType);
                    // _elmLarge.ClassName = "ms-cui-sb";
                    Utility.EnsureCSSClassOnElement(_elmLarge, "ms-cui-ctl-large");

                    _elmLargeSelectedItem = new Span();
                    _elmLargeSelectedItem.ClassName = "ms-cui-mrusb-selecteditem";

                    if (!SelectMenuItemById(itemId))
                    {
                        if (!Utility.IsTrue(Properties.PopulateDynamically))
                        {
                            throw new InvalidOperationException("No menu item with id '" + Properties.InitialItem + "' exists in this control's menu");
                        }
                        else
                        {
                            _elmLargeSelectedItem.Style.Width = "32px";
                            _elmLargeSelectedItem.Style.Height = "32px";
                        }
                    }

                    _elmLargeBtn = new Anchor();
                    _elmLargeBtn.ClassName = "ms-cui-ctl-a2";
                    _elmLargeBtn.Style.Display = "block";
                    _elmLargeBtn.SetAttribute("role", AriaRole);
                    _elmLargeBtn.SetAttribute("aria-haspopup", true.ToString());

                    Utility.NoOpLink(_elmLargeBtn);
                    Utility.SetAriaTooltipProperties(Properties, _elmLargeBtn);

                    _elmLargeArrowImg = new Image();
                    Span elmLargeArrowImgCont = Utility.CreateClusteredImageContainerNew(
                                                                                      ImgContainerSize.Size5by3,
                                                                                      Root.Properties.ImageDownArrow,
                                                                                      Root.Properties.ImageDownArrowClass,
                                                                                      _elmLargeArrowImg,
                                                                                      true,
                                                                                      false,
                                                                                      Root.Properties.ImageDownArrowTop,
                                                                                      Root.Properties.ImageDownArrowLeft
                                                                                      );

                    if(string.IsNullOrEmpty(Properties.ToolTipTitle)) 
                    {
                        needsLabel = false;
                        _elmLargeBtn.Title = alt;
                        _elmLargeArrowImg.Alt = alt;
                    }

                    // Set up event handlers for the drop down button
                    AttachEventsForDisplayMode(displayMode);

                    // Build DOM structure
                    _elmLargeBtn.AppendChild(elmLargeArrowImgCont);

                    if (needsLabel)
                    {
                        hiddenLabel = Utility.CreateHiddenLabel(alt);
                        _elmLargeBtn.AppendChild(hiddenLabel);
                    }
                    _elmLarge.AppendChild(_elmLargeSelectedItem);
                    _elmLarge.AppendChild(_elmLargeBtn);

                    _buildingDOMElement = false;
                    return _elmLarge;
                case "Medium":
                    _elmMedium = new Span();
                    _elmMedium.SetAttribute("mscui:controltype", ControlType);
                    _elmMedium.ClassName = "ms-cui-ctl-medium ms-cui-ctl";

                    _elmMediumSelectedItem = new Span();
                    _elmMediumSelectedItem.ClassName = "ms-cui-mrusb-selecteditem";
                    _elmMediumSelectedItem.Style.Width = width;
                    if (!SelectMenuItemById(itemId))
                        throw new InvalidOperationException("No menu item with id '" + Properties.InitialItem + "' exists in this control's menu");

                    _elmMediumBtn = new Anchor();
                    Utility.NoOpLink(_elmMediumBtn);
                    Utility.SetAriaTooltipProperties(Properties, _elmMediumBtn);
                    _elmMediumBtn.ClassName = "ms-cui-ctl";
                    _elmMediumBtn.SetAttribute("role", AriaRole);
                    _elmMediumBtn.SetAttribute("aria-haspopup", true.ToString());
                    _elmMediumArrowImg = new Image();
                    if(string.IsNullOrEmpty(Properties.ToolTipTitle)) 
                    {
                        needsLabel = false;
                        _elmMediumBtn.Title = alt;
                        _elmMediumArrowImg.Alt = alt;
                    }

                    Span _elmMediumArrowImgCont = Utility.CreateClusteredImageContainerNew(
                                                                             ImgContainerSize.Size5by3,
                                                                             Root.Properties.ImageDownArrow,
                                                                             Root.Properties.ImageDownArrowClass,
                                                                             _elmMediumArrowImg,
                                                                             true,
                                                                             false,
                                                                             Root.Properties.ImageDownArrowTop,
                                                                             Root.Properties.ImageDownArrowLeft
                                                                             );


                    // Set up event handlers for the drop down button
                    AttachEventsForDisplayMode(displayMode);

                    //Build DOM structure
                    _elmMediumBtn.AppendChild(_elmMediumArrowImgCont);
                    if (needsLabel)
                    {
                        hiddenLabel = Utility.CreateHiddenLabel(alt);
                        _elmMediumBtn.AppendChild(hiddenLabel);
                    }
                    _elmMedium.AppendChild(_elmMediumSelectedItem);
                    _elmMedium.AppendChild(_elmMediumBtn);

                    _buildingDOMElement = false;
                    return _elmMedium;
                case "Small":
                    _elmSmall = new Span();
                    _elmSmall.SetAttribute("mscui:controltype", ControlType);
                    _elmSmall.ClassName = "ms-cui-ctl-medium ms-cui-ctl";
                    _elmSmallSelectedItem = new Span();
                    _elmSmallSelectedItem.ClassName = "ms-cui-mrusb-selecteditem";
                    _elmSmallSelectedItem.Style.Width = width;
                    if (!SelectMenuItemById(itemId))
                        throw new InvalidOperationException("No menu item with id '" + Properties.InitialItem + "' exists in this control's menu");

                    _elmSmallBtn = new Anchor();
                    Utility.NoOpLink(_elmSmallBtn);
                    Utility.SetAriaTooltipProperties(Properties, _elmSmallBtn);
                    _elmSmallBtn.SetAttribute("role", AriaRole);
                    _elmSmallBtn.SetAttribute("aria-haspopup", true.ToString());
                    _elmSmallBtn.ClassName = "ms-cui-ctl ms-cui-mrusb-arwbtn";
                    _elmSmallArrowImg = new Image();

                    if(string.IsNullOrEmpty(Properties.ToolTipTitle)) 
                    {
                        _elmSmallBtn.Title = alt;
                        _elmSmallArrowImg.Alt = alt;
                        needsLabel = false;
                    }

                    Span _elmSmallArrowImgCont = Utility.CreateClusteredImageContainerNew(
                                                                             ImgContainerSize.Size5by3,
                                                                             Root.Properties.ImageDownArrow,
                                                                             Root.Properties.ImageDownArrowClass,
                                                                             _elmSmallArrowImg,
                                                                             true,
                                                                             false,
                                                                             Root.Properties.ImageDownArrowTop,
                                                                             Root.Properties.ImageDownArrowLeft
                                                                             );

                    // Set up event handlers for the drop down button
                    AttachEventsForDisplayMode(displayMode);

                    //Build DOM structure
                    _elmSmallBtn.AppendChild(_elmSmallArrowImgCont);
                    if (needsLabel)
                    {
                        hiddenLabel = Utility.CreateHiddenLabel(alt);
                        _elmSmallBtn.AppendChild(hiddenLabel);
                    }
                    _elmSmall.AppendChild(_elmSmallSelectedItem);
                    _elmSmall.AppendChild(_elmSmallBtn);

                    _buildingDOMElement = false;
                    return _elmSmall;
                default:
                    _buildingDOMElement = false;
                    EnsureValidDisplayMode(displayMode);
                    return null;
            }
        }
Example #27
0
        // This needs to be Ensured separately from the body of the tab
        // so that we can refresh the body of the tab on demand.
        /// <summary>
        /// Ensures that the title of this tab is refreshed based on the current properties of the Tab.
        /// </summary>
        internal void EnsureTitleRefreshed()
        {
            string ctxTabClasses = " ";

            // If the anchor element hasn't been instantiated, then it is possible
            // that the title element has only been shallowly instantiated and all its
            // parts still need to be created and the event handlers set.
            if (CUIUtility.IsNullOrUndefined(_elmTitleA))
            {
                EnsureTitleDOMElement();

                _elmTitleA = new Anchor();
                Utility.NoOpLink(_elmTitleA);
                _elmTitleA.ClassName = "ms-cui-tt-a";

                _elmTitleSpan = new Span();
                _elmTitleSpan.ClassName = "ms-cui-tt-span";
                _elmTitle.AppendChild(_elmTitleA);
                _elmTitleA.AppendChild(_elmTitleSpan);

                AttachEvents();
            }
            else
            {
                ctxTabClasses += _elmTitle.ClassName.IndexOf("ms-cui-ct-first") > -1 ? "ms-cui-ct-first " : "";
                ctxTabClasses += _elmTitle.ClassName.IndexOf("ms-cui-ct-last") > -1 ? "ms-cui-ct-last" : "";
                ctxTabClasses = ctxTabClasses.TrimEnd();
            }

            _elmTitle.ClassName = GetTitleCSSClassName() + ctxTabClasses;
            _elmTitle.Id = Id + "-title";
            _elmTitle.SetAttribute("role", "tab");
            _elmTitle.SetAttribute("aria-selected", _selected.ToString());

            // Refresh the title, text and description
            UIUtility.SetInnerText(_elmTitleSpan, Title);
            _elmTitle.Title = Title;

            if (!string.IsNullOrEmpty(Description))
            {
                _elmTitleA.SetAttribute("title", Description);
            }
            else
            {
                _elmTitleA.SetAttribute("title", Title);
            }
        }
Example #28
0
 public override void Dispose()
 {
     base.Dispose();
     _elmLarge = null;
     _elmLargeArrowImg = null;
     _elmLargeBtn = null;
     _elmLargeSelectedItem = null;
     _elmMedium = null;
     _elmMediumArrowImg = null;
     _elmMediumBtn = null;
     _elmMediumSelectedItem = null;
     _elmSmall = null;
     _elmSmallArrowImg = null;
     _elmSmallBtn = null;
     _elmSmallSelectedItem = null;
 }
Example #29
0
        public override void Dispose()
        {
            _elmTitleA.Click -= OnTitleClick;
            _elmTitleA.KeyPress -= OnTitleKeyPress;
            _elmTitleA.DblClick -= OnTitleDblClick;

            base.Dispose();
            _elmATText = null;
            _elmTitle = null;
            _elmTitleA = null;
            _elmTitleSpan = null;
        }
Example #30
0
 public override void Dispose()
 {
     base.Dispose();
     _elmThin = null;
     _elmThinArrowImg = null;
     _elmThinArrowImgCont = null;
     _elmLarge = null;
     _elmLargeArrowImg = null;
     _elmLargeImg = null;
     _elmMedium = null;
     _elmMediumArrowImg = null;
     _elmMediumImg = null;
     _elmMenu = null;
     _elmMenu16 = null;
     _elmMenu32 = null;
     _elmMenuArrowImg = null;
     _elmMenuArrowImgCont = null;
     _elmMenuImg16 = null;
     _elmMenuImg16Cont = null;
     _elmMenuImg32 = null;
     _elmMenuImg32Cont = null;
     _elmMenuLbl = null;
     _elmSmall = null;
     _elmSmallArrowImg = null;
     _elmSmallImg = null;
 }