예제 #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;
        }
예제 #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;
            }
        }
예제 #3
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;
            }
        }
예제 #4
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;
        }
예제 #5
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;
            }
        }
예제 #6
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;
            }
        }
예제 #7
0
파일: group.cs 프로젝트: modulexcite/IL2JS
        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();
        }
예제 #8
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;
        }
예제 #9
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;
        }
예제 #10
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;
            }
        }
예제 #11
0
        internal static Span CreateClusteredImageContainerNew(ImgContainerSize size,
                                                                     string imageSource,
                                                                     string imageClass,
                                                                     Image elmImage,
                                                                     bool inlineBlockDisplay,
                                                                     bool blockDisplay,
                                                                     string imageTop,
                                                                     string imageLeft)
        {
            Span cont = new Span();
            if (blockDisplay)
                Utility.EnsureCSSClassOnElement(cont, "ms-cui-block");

            string cssClass = ImageSizeToClass[(int)size];

            // Cluster mode detection
            bool hasTop = !string.IsNullOrEmpty(imageTop);
            bool hasLeft = !string.IsNullOrEmpty(imageLeft);
            bool hasClass = !string.IsNullOrEmpty(imageClass);

            // These classes are needed for unclustered ribbon icon disabling.
            if (inlineBlockDisplay)
                cssClass += " ms-cui-img-cont-float";
            else
                cssClass += " ms-cui-img-container";

            // Revisit this.  Right now we dont' append here to help on performance
            if (hasClass)
                elmImage.ClassName = imageClass;

            cont.ClassName += " " + cssClass;
            if (!string.IsNullOrEmpty(imageSource))
            {
                cont.AppendChild(elmImage);
                elmImage.Src = imageSource;
                if (hasTop)
                    elmImage.Style.Top = imageTop + "px";
                if (hasLeft)
                    elmImage.Style.Left = imageLeft + "px";
            }
            return cont;
        }
예제 #12
0
파일: button.cs 프로젝트: modulexcite/IL2JS
        private HtmlElement CreateDropDownDOMElementForDisplayMode(string displayMode)
        {
            Anchor d;

            // After we create the DOM element and the clone it, we set the member variable DOM 
            // element to null so that we do not leak it.
            // O14:394328
            switch (displayMode)
            {
                case "Large":
                    d = (Anchor)CreateDOMElementForDisplayModeCore(displayMode, false).CloneNode(true);
                    _elmLarge = null;
                    d.Style.Height = "auto";
                    ((HtmlElement)d.ChildNodes[1]).Style.Height = "auto";
                    _elmFssbLarge = d;
                    break;
                case "Medium":
                    d = (Anchor)CreateDOMElementForDisplayModeCore(displayMode, false).CloneNode(true);
                    _elmMedium = null;
                    _elmFssbMedium = d;
                    break;
                case "Small":
                    d = (Anchor)CreateDOMElementForDisplayModeCore(displayMode, false).CloneNode(true);
                    _elmSmall = null;
                    _elmFssbSmall = d;
                    break;
                case "Menu":
                    _elmFsddMenu = (Anchor)CreateDOMElementForDisplayModeCore("Menu", false).CloneNode(true);
                    _elmMenu16 = null;
                    return _elmFsddMenu;
                case "Text":
                    Anchor textA = new Anchor();
                    Utility.NoOpLink(textA);
                    _elmFsddText = new Span();
                    _elmFsddText.ClassName = "ms-cui-textmenuitem";
                    UIUtility.SetInnerText(textA, Properties.LabelText);
                    _elmFsddText.AppendChild(textA);
                    return _elmFsddText;
                default:
                    EnsureValidDisplayMode(displayMode);
                    return null;
            }

            return d;
        }
예제 #13
0
        protected override HtmlElement CreateDOMElementForDisplayMode(string displayMode)
        {
            if (displayMode != "Default")
            {
                EnsureValidDisplayMode(displayMode);
                return null;
            }

            string alt = CUIUtility.SafeString(Properties.Alt);

            // Create Elements
            _elmDefault = new Span();

            _elmDefault.Id = Properties.Id + "-Default";
            _elmDefault.ClassName = "ms-cui-jewel-jewelMenuLauncher";

            _elmDefaultA = new Anchor();
            Utility.NoOpLink(_elmDefaultA);
            _elmDefaultA.Title = alt;

            _inLabelMode = !string.IsNullOrEmpty(Properties.LabelText);

            if (!_inLabelMode)
            {
                _elmDefaultImg = new Image();

                _elmDefaultImgCont = Utility.CreateClusteredImageContainerNew(
                                                                     ImgContainerSize.Size56by24,
                                                                     Properties.Image,
                                                                     Properties.ImageClass,
                                                                     _elmDefaultImg,
                                                                     true,
                                                                     false,
                                                                     Properties.ImageTop,
                                                                     Properties.ImageLeft);
                _elmDefaultImg.Alt = alt;
                _elmDefaultA.AppendChild(_elmDefaultImgCont);
            }
            else
            {
                bool hasLeftImage = !string.IsNullOrEmpty(Properties.ImageLeftSide);
                bool hasRightImage = !string.IsNullOrEmpty(Properties.ImageRightSide);

                if (hasLeftImage)
                {
                    _elmLeft = new Span();
                    _elmLeft.ClassName = "ms-cui-jewel-left";
                    _elmLeft.Id = Properties.Id + "-Default-left";
                    Utility.PrepareClusteredBackgroundImageContainer(_elmLeft,
                                                                     Properties.ImageLeftSide,
                                                                     Properties.ImageLeftSideClass,
                                                                     Properties.ImageLeftSideTop,
                                                                     Properties.ImageLeftSideLeft,
                                                                     null,
                                                                     Properties.Height);

                    _elmLeft.Style.Width = Properties.ImageLeftSideWidth + "px";
                    _elmLeft.Style.Height = Properties.Height + "px";
                    _elmDefaultA.AppendChild(_elmLeft);
                }

                _elmMiddle = new Span();
                _elmMiddle.ClassName = "ms-cui-jewel-middle";
                _elmMiddle.Id = Properties.Id + "-Default-middle";
                Utility.PrepareClusteredBackgroundImageContainer(_elmMiddle,
                                                                 Properties.Image,
                                                                 Properties.ImageClass,
                                                                 Properties.ImageTop,
                                                                 Properties.ImageLeft,
                                                                 null,
                                                                 Properties.Height);
                _elmLabel = new Span();
                if (!string.IsNullOrEmpty(Properties.LabelCss))
                    _elmLabel.Style.CssText = Properties.LabelCss;
                _elmLabel.ClassName = "ms-cui-jewel-label";
                if (!string.IsNullOrEmpty(Properties.Height))
                    _elmLabel.Style.MarginTop = (Math.Floor(Int32.Parse(Properties.Height) - 14 /* 8px for text, 6px for existing padding */) / 2) + "px";
                UIUtility.SetInnerText(_elmLabel, Properties.LabelText);
                _elmMiddle.AppendChild(_elmLabel);
                _elmDefaultA.AppendChild(_elmMiddle);

                if (hasRightImage)
                {
                    _elmRight = new Span();
                    _elmRight.ClassName = "ms-cui-jewel-right";
                    _elmRight.Id = Properties.Id + "-Default-right";
                    Utility.PrepareClusteredBackgroundImageContainer(_elmRight,
                                                                     Properties.ImageRightSide,
                                                                     Properties.ImageRightSideClass,
                                                                     Properties.ImageRightSideTop,
                                                                     Properties.ImageRightSideLeft,
                                                                     null,
                                                                     Properties.Height);

                    _elmRight.Style.Width = Properties.ImageRightSideWidth + "px";
                    _elmRight.Style.Height = Properties.Height + "px";
                    _elmDefaultA.AppendChild(_elmRight);
                }
            }

            // Setup Event Handlers
            AttachEventsForDisplayMode(displayMode);

            // Build DOM Structure
            _elmDefault.AppendChild(_elmDefaultA);

            return _elmDefault;
        }
예제 #14
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;
            }
        }
예제 #15
0
파일: label.cs 프로젝트: modulexcite/IL2JS
        protected override HtmlElement CreateDOMElementForDisplayMode(string displayMode)
        {
            string forId = Properties.ForId;
            string label = Properties.LabelText;
            switch (displayMode)
            {
                case "Medium":
                    if (!string.IsNullOrEmpty(forId))
                    {
                        _elmDefault = new MSLabel();
                        if (BrowserUtility.InternetExplorer7)
                        {
                            _elmDefault.SetAttribute("htmlFor", forId);
                        }
                        else
                        {
                            _elmDefault.SetAttribute("for", forId);
                        }
                    }
                    else
                    {
                        _elmDefault = new Span();
                    }

                    _elmDefault.SetAttribute("mscui:controltype", ControlType);
                    _elmDefault.ClassName = "ms-cui-ctl-small ms-cui-fslb";

                    if (!string.IsNullOrEmpty(Properties.Image16by16))
                    {
                        _elmDefaultIcon = new Image();
                        Span elmDefaultIconCont = Utility.CreateClusteredImageContainerNew(
                                                                                        ImgContainerSize.Size16by16,
                                                                                        Properties.Image16by16,
                                                                                        Properties.Image16by16Class,
                                                                                        _elmDefaultIcon,
                                                                                        true,
                                                                                        false,
                                                                                        Properties.Image16by16Top,
                                                                                        Properties.Image16by16Left);

                        Span elmDefaultIconContainer = new Span();
                        elmDefaultIconContainer.ClassName = "ms-cui-ctl-iconContainer";
                        elmDefaultIconContainer.AppendChild(elmDefaultIconCont);
                        _elmDefault.AppendChild(elmDefaultIconContainer);
                    }

                    _elmDefaultLabel = new Span();
                    _elmDefaultLabel.ClassName = "ms-cui-ctl-mediumlabel";

                    if (!string.IsNullOrEmpty(label))
                    {
                        UIUtility.SetInnerText(_elmDefaultLabel, label);
                    }

                    _elmDefault.AppendChild(_elmDefaultLabel);
                    return _elmDefault;
                case "Small":
                    if (!string.IsNullOrEmpty(forId))
                    {
                        _elmSmall = new MSLabel();
                        if (BrowserUtility.InternetExplorer7)
                        {
                            _elmSmall.SetAttribute("htmlFor", forId);

                        }
                        else
                        {
                            _elmSmall.SetAttribute("for", forId);
                        }
                    }
                    else
                    {
                        _elmSmall = new Span();
                    }

                    _elmSmall.SetAttribute("mscui:controltype", ControlType);
                    _elmSmall.ClassName = "ms-cui-ctl-small ms-cui-fslb";

                    if (string.IsNullOrEmpty(Properties.Image16by16))
                    {
                        throw new ArgumentNullException("Image16by16", "Small display mode must have an icon set");
                    }

                    _elmSmallIcon = new Image();
                    Span elmSmallIconCont = Utility.CreateClusteredImageContainerNew(
                                                                                  ImgContainerSize.Size16by16,
                                                                                  Properties.Image16by16,
                                                                                  Properties.Image16by16Class,
                                                                                  _elmSmallIcon,
                                                                                  true,
                                                                                  false,
                                                                                  Properties.Image16by16Top,
                                                                                  Properties.Image16by16Left);

                    if (!string.IsNullOrEmpty(label))
                    {
                        _elmSmallIcon.Alt = label;

                    }

                    Span elmSmallIconContainer = new Span();
                    elmSmallIconContainer.ClassName = "ms-cui-ctl-iconContainer";
                    elmSmallIconContainer.AppendChild(elmSmallIconCont);
                    _elmSmall.AppendChild(elmSmallIconContainer);
                    return _elmSmall;
                default:
                    EnsureValidDisplayMode(displayMode);
                    break;
            }
            return null;
        }
예제 #16
0
        private HtmlElement CreateDropDownDOMElementForDisplayMode(string displayMode)
        {
            switch (displayMode)
            {
                case "Menu":
                    _elmFsddMenu = (Span)CreateDOMElementForDisplayModeCore("Menu", false).CloneNode(true);
                    return _elmFsddMenu;
                case "Menu16":
                    _elmFsddMenu = (Span)CreateDOMElementForDisplayModeCore("Menu16", false).CloneNode(true);
                    return _elmFsddMenu;
                case "Text":
                    Anchor textA = new Anchor();
                    Utility.NoOpLink(textA);

                    _elmFsddText = new Span();
                    _elmFsddText.ClassName = "ms-cui-textmenuitem";
                    UIUtility.SetInnerText(textA, Properties.LabelText);
                    _elmFsddText.AppendChild(textA);
                    return _elmFsddText;
                default:
                    return new Span();
            }
        }