Exemplo n.º 1
0
 public ControlComponent(Root root,
                         string id,
                         string displayMode,
                         Control control)
     : base(root, id, displayMode, "")
 {
     _control = control;
 }
Exemplo n.º 2
0
        /// <summary>
        /// THE MENU FRAMEWORK IS UNDER ACTIVE DEVELOPMENT AND IS SUBJECT TO CHANGE.  A Component that is an item in a Menu.
        /// </summary>
        /// <param name="ribbon">The Ribbon that this MenuItem was created by and is a part of.</param>
        /// <param name="id">The Component id of this MenuItem.</param>
        /// <param name="displayMode">The display mode of this MenuItem's Control that this MenuItem represents.</param>
        /// <param name="control">The Control that created this MenuItem.</param>
        public MenuItem(Root root, string id, string displayMode, Control control)
            : base(root, id, displayMode, control)
        {

        }
Exemplo n.º 3
0
 /// <summary>
 /// Creates a MenuItem
 /// </summary>
 /// <param name="id">Component id of the MenuItem</param>
 /// <param name="displayMode">display mode of the Control that this MenuItem represents</param>
 /// <param name="control">the control to which this MenuItem belongs</param>
 /// <returns>the created MenuItem</returns>
 internal MenuItem CreateMenuItem(string id,
                                  string displayMode,
                                  Control control)
 {
     return new MenuItem(this, id, displayMode, control);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Creates a ControlComponent
 /// </summary>
 /// <param name="id">Component id of the ControlComponent</param>
 /// <param name="displayMode">the display mode of the Control that this ControlComponent represents.  ie "Large", "Medium" etc.</param>
 /// <param name="control">The Control that this ControlComponent belongs to</param>
 /// <returns>the created ControlComponent</returns>
 internal ControlComponent CreateControlComponent(string id,
                                                  string displayMode,
                                                  Control control)
 {
     return new ControlComponent(this, id, displayMode, control);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Register control.
 /// </summary>
 /// <param name="control"></param>
 internal void RegisterControl(Control control)
 {
     _controls[control.Id] = control;
 }
Exemplo n.º 6
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;
        }
Exemplo n.º 7
0
 static protected Anchor CreateStandardControlDOMElement(
     Control control,
     Root root,
     string displayMode,
     ControlProperties properties,
     bool menu,
     bool arrow)
 {
     // We cast the properties to FlyoutAnchor properties because it has the superset
     // of all the possible properties that we will want to use.
     JSObject tempProps = JSObject.From<ControlProperties>(properties);
     FlyoutAnchorProperties props = tempProps.To<FlyoutAnchorProperties>();
     return CreateStandardControlDOMElementCore(
         control,
         root,
         displayMode,
         props.Id,
         props.Image32by32,
         props.Image32by32Class,
         props.Image32by32Top,
         props.Image32by32Left,
         props.Image16by16,
         props.Image16by16Class,
         props.Image16by16Top,
         props.Image16by16Left,
         props.LabelText,
         props.LabelCss,
         props.Alt,
         props.Description,
         props.ToolTipTitle,
         menu,
         arrow);
 }
Exemplo n.º 8
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;
        }
Exemplo n.º 9
0
 public override void Dispose()
 {
     Control.Dispose();
     _control = null;
     base.Dispose();
 }