Exemplo n.º 1
0
 public override void Dispose()
 {
     base.Dispose();
     _elmBody = null;
     _elmDescription = null;
     _elmDescriptionImage = null;
     _elmDescriptionImageCont = null;
     _elmDisabledInfo = null;
     _elmDisabledInfoIcon = null;
     _elmDisabledInfoTitle = null;
     _elmDisabledInfoTitleText = null;
     _elmFooter = null;
     _elmFooterIcon = null;
     _elmFooterIconCont = null;
     _elmFooterTitleText = null;
     _elmInnerDiv = null;
     _elmTitle = null;
     _elmSelectedItemTitle = null;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Creates the HTML for the ToolTip.
        /// </summary>
        /// <owner alias="HillaryM" />
        internal override void RefreshInternal()
        {
            if (NeedsDelayIniting)
                DoDelayedInit();

            EnsureDOMElementAndEmpty();

            // set the aria role
            ElementInternal.SetAttribute("role", "tooltip");

            // set the aria visibility
            ElementInternal.SetAttribute("aria-hidden", "true");

            if (CUIUtility.IsNullOrUndefined(_elmBody))
            {
                _elmBody = new Div();
                _elmBody.ClassName = "ms-cui-tooltip-body";
            }
            else
            {
                _elmBody = (Div)Utility.RemoveChildNodes(_elmBody);
            }
            ElementInternal.AppendChild(_elmBody);

            if (CUIUtility.IsNullOrUndefined(_elmInnerDiv))
            {
                _elmInnerDiv = new Div();
                _elmInnerDiv.ClassName = "ms-cui-tooltip-glow";
                _elmBody.AppendChild(_elmInnerDiv);
            }
            else
            {
                _elmInnerDiv = (Div)Utility.RemoveChildNodes(_elmInnerDiv);
            }

            // set the title and shortcut
            if (CUIUtility.IsNullOrUndefined(_elmTitle))
            {
                _elmTitle = new Heading1();
                if (TitleInternal.Length > _controlTitleLength)
                {
                    UIUtility.SetInnerText(_elmTitle, TitleInternal.Substring(0, _controlTitleLength));
                }
                else
                {
                    UIUtility.SetInnerText(_elmTitle, Title);
                }
                _elmInnerDiv.AppendChild(_elmTitle);
            }

            // set the image if available
            if (CUIUtility.IsNullOrUndefined(_elmDescriptionImage) &&
                !string.IsNullOrEmpty(Properties.ToolTipImage32by32))
            {
                _elmDescriptionImage = new Image();
                _elmDescriptionImageCont = Utility.CreateClusteredImageContainerNew(
                                                                          ImgContainerSize.Size32by32,
                                                                          Properties.ToolTipImage32by32,
                                                                          Properties.ToolTipImage32by32Class,
                                                                          _elmDescriptionImage,
                                                                          true,
                                                                          false,
                                                                          Properties.ToolTipImage32by32Top,
                                                                          Properties.ToolTipImage32by32Left);
                _elmDescriptionImageCont.ClassName = _elmDescriptionImageCont.ClassName + " ms-cui-tooltip-bitmap ";
                _elmInnerDiv.AppendChild(_elmDescriptionImageCont);
            }

            // set the description
            string selectedItemTitle = Properties.ToolTipSelectedItemTitle;
            string descriptionText = Description;
            if (CUIUtility.IsNullOrUndefined(_elmDescription) 
                && (!string.IsNullOrEmpty(descriptionText) ||
                    !string.IsNullOrEmpty(selectedItemTitle)))
            {
                _elmDescription = new Div();
                _elmDescription.ClassName = "ms-cui-tooltip-description";
                if (!string.IsNullOrEmpty(Properties.ToolTipImage32by32))
                {
                    _elmDescription.Style.Width = "80%";
                }
                _elmInnerDiv.AppendChild(_elmDescription);

                string seletedItemTitlePrefix = Root.Properties.ToolTipSelectedItemTitlePrefix;
                if (!string.IsNullOrEmpty(selectedItemTitle) &&
                    !string.IsNullOrEmpty(seletedItemTitlePrefix))
                {
                    string selectedItemText = String.Format(seletedItemTitlePrefix, selectedItemTitle);
                    _elmSelectedItemTitle = new Paragraph();
                    UIUtility.SetInnerText(_elmSelectedItemTitle, selectedItemText);

                    _elmDescription.AppendChild(_elmSelectedItemTitle);
                    _spacerRow3 = new Break();
                    _elmDescription.AppendChild(_spacerRow3);
                }
                if (!string.IsNullOrEmpty(descriptionText))
                {
                    if (descriptionText.Length > _controlDescriptionLength)
                    {
                        _elmDescription.InnerHtml = _elmDescription.InnerHtml + Utility.HtmlEncodeAllowSimpleTextFormatting(descriptionText.Substring(0, _controlDescriptionLength), true);
                    }
                    else
                    {
                        _elmDescription.InnerHtml = _elmDescription.InnerHtml + Utility.HtmlEncodeAllowSimpleTextFormatting(descriptionText, true);
                    }
                }
            }

            // Disabled info explaining why a command is currently disabled
            if (CUIUtility.IsNullOrUndefined(_elmDisabledInfo) && 
                !CUIUtility.IsNullOrUndefined(_disabledInfoProperties) &&
                !string.IsNullOrEmpty(_disabledInfoProperties.Title))
            {
                // provide spacer to distinguish from main description above
                _spacerDiv1 = new Div();
                _spacerDiv1.ClassName = "ms-cui-tooltip-clear";
                _elmInnerDiv.AppendChild(_spacerDiv1);

                _spacerRow1 = new HorizontalRule();
                _elmInnerDiv.AppendChild(_spacerRow1);

                // title for this message
                _elmDisabledInfoTitle = new Div();
                _elmDisabledInfoTitle.ClassName = "ms-cui-tooltip-footer";
                _elmInnerDiv.AppendChild(_elmDisabledInfoTitle);

                _elmDisabledInfoTitleText = new Div();
                UIUtility.SetInnerText(_elmDisabledInfoTitleText, _disabledInfoProperties.Title);

                // icon for this message
                _elmDisabledInfoIcon = new Image();
                _elmDisabledInfoIconCont = Utility.CreateClusteredImageContainerNew(
                                                                            ImgContainerSize.Size16by16,
                                                                            _disabledInfoProperties.Icon,
                                                                            _disabledInfoProperties.IconClass,
                                                                            _elmDisabledInfoIcon,
                                                                            true,
                                                                            false,
                                                                            _disabledInfoProperties.IconTop,
                                                                            _disabledInfoProperties.IconLeft);

                _elmDisabledInfoIconCont.Style.VerticalAlign = "top";

                // switch display based on text direction
                // REVIEW(jkern,josefl): I don't think that we need to manually do this.  We should get it for free in 
                // the browser with the "dir=rtl" attribute.  Check this when the RTL work is done.
                if (Root.TextDirection == Direction.LTR)
                {
                    _elmDisabledInfoTitle.AppendChild(_elmDisabledInfoIconCont);
                    _elmDisabledInfoTitle.AppendChild(_elmDisabledInfoTitleText);
                }
                else
                {
                    _elmDisabledInfoTitle.AppendChild(_elmDisabledInfoTitleText);
                    _elmDisabledInfoTitle.AppendChild(_elmDisabledInfoIconCont);
                }

                // disabled info text
                if (!string.IsNullOrEmpty(_disabledInfoProperties.Description))
                {
                    _elmDisabledInfo = new Div();
                    _elmDisabledInfo.ClassName = "ms-cui-tooltip-description";
                    _elmDisabledInfo.Style.Width = "90%";
                    UIUtility.SetInnerText(_elmDisabledInfo, _disabledInfoProperties.Description);
                    _elmInnerDiv.AppendChild(_elmDisabledInfo);
                }
            }

            // set the footer
            if (!CUIUtility.IsNullOrUndefined(_elmFooter) &&
                !string.IsNullOrEmpty(Root.Properties.ToolTipFooterText) &&
                !string.IsNullOrEmpty(Root.Properties.ToolTipFooterImage16by16) &&
                (((!CUIUtility.IsNullOrUndefined(_disabledInfoProperties)) &&
                    (!string.IsNullOrEmpty(_disabledInfoProperties.HelpKeyWord))) ||
                    (!string.IsNullOrEmpty(Properties.ToolTipHelpKeyWord))))
            {
                _spacerDiv2 = new Div();
                _spacerDiv2.ClassName = "ms-cui-tooltip-clear";
                _elmInnerDiv.AppendChild(_spacerDiv2);

                _spacerRow2 = new HorizontalRule();
                _elmInnerDiv.AppendChild(_spacerRow2);

                _elmFooter = new Div();
                _elmFooter.ClassName = "ms-cui-tooltip-footer";
                _elmInnerDiv.AppendChild(_elmFooter);

                _elmFooterTitleText = new Div();
                UIUtility.SetInnerText(_elmFooterTitleText, Root.Properties.ToolTipFooterText);

                _elmFooterIcon = new Image();

                _elmFooterIconCont = Utility.CreateClusteredImageContainerNew(
                                                                      ImgContainerSize.Size16by16,
                                                                      Root.Properties.ToolTipFooterImage16by16,
                                                                      Root.Properties.ToolTipFooterImage16by16Class,
                                                                      _elmFooterIcon,
                                                                      true,
                                                                      false,
                                                                      Root.Properties.ToolTipFooterImage16by16Top,
                                                                      Root.Properties.ToolTipFooterImage16by16Left
                                                                      );

                _elmFooterIconCont.Style.VerticalAlign = "top";

                // switch display based on text direction
                // REVIEW(jkern,josefl): I don't think that we need to manually do this.  We should get it for free in 
                // the browser with the "dir=rtl" attribute.  Check this when the RTL work is done.
                if (Root.TextDirection == Direction.LTR)
                {
                    _elmFooter.AppendChild(_elmFooterIconCont);
                    _elmFooter.AppendChild(_elmFooterTitleText);
                }
                else
                {
                    _elmFooter.AppendChild(_elmFooterTitleText);
                    _elmFooter.AppendChild(_elmFooterIconCont);
                }
            }

            // build DOM structure
            this.AppendChildrenToElement(_elmBody);
            base.RefreshInternal();
        }