Example #1
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 #2
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 #3
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 #4
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 #5
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 #6
0
        protected override HtmlElement CreateDOMElementForDisplayMode(string displayMode)
        {
            switch (displayMode)
            {
                case "Medium":
                    _elmDefault = new Span();
                    _elmDefault.ClassName = "ms-cui-spn";
                    _elmDefault.SetAttribute("mscui:controltype", ControlType);

                    _elmDefaultInput = new Input();
                    _elmDefaultInput.ClassName = "ms-cui-spn-txtbx";
                    _elmDefaultInput.Id = Id;
                    _elmDefaultInput.SetAttribute("role", "textbox");

                    Utility.SetAriaTooltipProperties(Properties, _elmDefaultInput);
                    Utility.SetImeMode(_elmDefaultInput, Properties.ImeEnabled);

                    _elmDefaultArwBox = new Span();
                    _elmDefaultArwBox.ClassName = "ms-cui-spn-arwbx";

                    _elmDefaultUpArw = new Anchor();
                    _elmDefaultUpArw.ClassName = "ms-cui-spn-btnup";
                    _elmDefaultUpArw.SetAttribute("role", "spinbutton");

                    _elmDefaultDownArw = new Anchor();
                    _elmDefaultDownArw.ClassName = "ms-cui-spn-btndown";
                    _elmDefaultDownArw.SetAttribute("role", "spinbutton");

                    _upArwImg = new Image();
                    _upArwImg.Alt = "";
                    _upArwImgCont = Utility.CreateClusteredImageContainerNew(
                                                                    ImgContainerSize.Size5by3,
                                                                    Root.Properties.ImageUpArrow,
                                                                    Root.Properties.ImageUpArrowClass,
                                                                    _upArwImg,
                                                                    true,
                                                                    false,
                                                                    Root.Properties.ImageUpArrowTop,
                                                                    Root.Properties.ImageUpArrowLeft);
                                                                    
                    
                    Utility.EnsureCSSClassOnElement(_upArwImgCont, "ms-cui-spn-imgcnt");
                    _elmDefaultUpArw.Title = CUIUtility.SafeString(Properties.AltUpArrow);

                    _downArwImg = new Image();
                    _downArwImg.Alt = "";
                    _downArwImgCont = Utility.CreateClusteredImageContainerNew(
                                                                      ImgContainerSize.Size5by3,
                                                                      Root.Properties.ImageDownArrow,
                                                                      Root.Properties.ImageDownArrowClass,
                                                                      _downArwImg,
                                                                      true,
                                                                      false,
                                                                      Root.Properties.ImageDownArrowTop,
                                                                      Root.Properties.ImageDownArrowLeft);

                    Utility.EnsureCSSClassOnElement(_downArwImgCont, "ms-cui-spn-imgcnt");
                    _elmDefaultDownArw.Title = CUIUtility.SafeString(Properties.AltDownArrow);

                    // Set up event handlers
                    AttachEventsForDisplayMode(displayMode);

                    // Build DOM Structure
                    _elmDefault.AppendChild(_elmDefaultInput);
                    _elmDefault.AppendChild(_elmDefaultArwBox);
                    _elmDefaultArwBox.AppendChild(_elmDefaultUpArw);
                    _elmDefaultArwBox.AppendChild(_elmDefaultDownArw);
                    _elmDefaultUpArw.AppendChild(_upArwImgCont);
                    _elmDefaultDownArw.AppendChild(_downArwImgCont);

                    return _elmDefault;
                default:
                    EnsureValidDisplayMode(displayMode);
                    return null;
            }
        }
Example #7
0
        protected override HtmlElement CreateDOMElementForDisplayMode(string displayMode)
        {
            switch (displayMode)
            {
                case "Large":
                case "Menu":
                    string alt = CUIUtility.SafeString(Properties.Alt);
                    // Create elements
                    _elmDefault = new Span();
                    _elmDefault.SetAttribute("mscui:controltype", ControlType);
                    _elmDefault.ClassName = "ms-cui-gallerybutton ms-cui-gallerybutton-" + Utility.GalleryElementDimensionsToSizeString[(int)ElementDimensions];

                    _elmDefaultA = new Anchor();
                    _elmDefaultA.Title = alt;
                    _elmDefaultA.ClassName = "ms-cui-gallerybutton-a";
                    Utility.NoOpLink(_elmDefaultA);
                    Utility.SetAriaTooltipProperties(Properties, _elmDefaultA);
                    _elmDefault.AppendChild(_elmDefaultA);

                    if (!string.IsNullOrEmpty(Properties.InnerHTML))
                    {
                        _elmDefaultA.InnerHtml = Properties.InnerHTML;
                        Utility.SetUnselectable(_elmDefaultA, true, true);
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(Properties.Image))
                        {
                            throw new ArgumentNullException("InnerHTML or Image must be defined for this GalleryButton");
                        }

                        ImgContainerSize size = ImgContainerSize.Size32by32;
                        switch (ElementDimensions)
                        {
                            case GalleryElementDimensions.Size16by16:
                                size = ImgContainerSize.Size16by16;
                                break;
                            case GalleryElementDimensions.Size32by32:
                                size = ImgContainerSize.Size32by32;
                                break;
                            case GalleryElementDimensions.Size48by48:
                                size = ImgContainerSize.Size48by48;
                                break;
                            case GalleryElementDimensions.Size64by48:
                                size = ImgContainerSize.Size64by48;
                                break;
                            case GalleryElementDimensions.Size72by96:
                                size = ImgContainerSize.Size72by96;
                                break;
                            case GalleryElementDimensions.Size96by72:
                                size = ImgContainerSize.Size96by72;
                                break;
                            case GalleryElementDimensions.Size96by96:
                                size = ImgContainerSize.Size96by96;
                                break;
                        }

                        _elmDefaultImage = new Image();
                        _elmDefaultImageCont = Utility.CreateClusteredImageContainerNew(
                                                                               size,
                                                                               Properties.Image,
                                                                               Properties.ImageClass,
                                                                               _elmDefaultImage,
                                                                               true,
                                                                               false,
                                                                               Properties.ImageTop,
                                                                               Properties.ImageLeft);
                        _elmDefaultImage.Alt = alt;
                        _elmDefaultA.AppendChild(_elmDefaultImageCont);
                    }

                    // Setup event handlers
                    AttachEventsForDisplayMode(displayMode);

                    return _elmDefault;
                default:
                    EnsureValidDisplayMode(displayMode);
                    return null;
            }
        }