internal void AttachTitle() { _elmTitle = (ListItem)Browser.Document.GetById(Id + "-title"); _elmTitleA = (Anchor)_elmTitle.ChildNodes[0]; _elmTitleSpan = (Span)_elmTitleA.ChildNodes[0]; _elmATText = (Span)_elmTitleA.ChildNodes[1]; }
internal override void AttachDOMElementsForDisplayMode(string displayMode) { EnsureValidDisplayMode(displayMode); _elmDefault = (Span)Browser.Document.GetById(Id + "-" + displayMode); StoreElementForDisplayMode(_elmDefault, displayMode); _elmDefaultA = (Anchor)_elmDefault.ChildNodes[0]; _inLabelMode = !string.IsNullOrEmpty(Properties.LabelText); if (!_inLabelMode) { _elmDefaultImgCont = (Span)_elmDefaultA.ChildNodes[0]; _elmDefaultImg = (Image)_elmDefaultImgCont.ChildNodes[0]; } else { _elmLeft = (Span)Browser.Document.GetById(Id + "-" + displayMode + "-left"); _elmRight = (Span)Browser.Document.GetById(Id + "-" + displayMode + "-right"); _elmMiddle = (Span)Browser.Document.GetById(Id + "-" + displayMode + "-middle"); if (!CUIUtility.IsNullOrUndefined(_elmMiddle)) _elmLabel = (Span)_elmMiddle.FirstChild; } }
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; } }
internal override void AttachDOMElementsForDisplayMode(string displayMode) { Span elm = (Span)Browser.Document.GetById(Id + "-" + displayMode); StoreElementForDisplayMode(elm, displayMode); switch (displayMode) { case "Text": case "Medium": _elmMedium = elm; _elmMediumSelectedItem = (Span)_elmMedium.ChildNodes[0]; _elmMediumBtnA = (Anchor)_elmMedium.ChildNodes[1]; _elmMediumArwImgCont = (Span)_elmMediumBtnA.ChildNodes[0]; _elmMediumArwImg = (Image)_elmMediumArwImgCont.ChildNodes[0]; break; } }
internal override void PollForStateAndUpdate() { string itemKey = DropDownCommandProperties.SelectedItemId; string currentSelectedItemId = StateProperties.ContainsKey(itemKey) ? StateProperties[itemKey] : ""; // If we currently don't have an item set, then we set it here to let the application know // since this is what we'll fall back to unless they set something else. if (string.IsNullOrEmpty(currentSelectedItemId)) StateProperties[DropDownCommandProperties.SelectedItemId] = Properties.InitialItem; PollForStateAndUpdateInternal(Properties.Command, Properties.QueryCommand, StateProperties, false); string newSelectedItemId = StateProperties[DropDownCommandProperties.SelectedItemId]; // If the currently selected item is null, use the display text if (!string.IsNullOrEmpty(newSelectedItemId)) { // We want to select the item if it is different than the one that we currently // have or if we have never selected one (this happens when if (currentSelectedItemId != newSelectedItemId || !_itemEverSelected) { if (!SelectMenuItemById(newSelectedItemId)) { throw new InvalidOperationException("The menu item id requested via polling does not exist"); } } } else { string valueKey = DropDownCommandProperties.Value; string title = StateProperties.ContainsKey(valueKey) ? StateProperties[valueKey] : ""; if (!string.IsNullOrEmpty(title)) { // O14:330988 Put it in an <a> tag so it picks up the correct style. Anchor newAnchor = new Anchor(); newAnchor.InnerHtml = title; _elmMediumSelectedItem.AppendChild(newAnchor); } } }
public override void Dispose() { base.Dispose(); _elmThin = null; _elmThinArrowImg = null; _elmThinArrowImgCont = null; _elmLarge = null; _elmLargeArrowImg = null; _elmLargeImg = null; _elmMedium = null; _elmMediumArrowImg = null; _elmMediumImg = null; _elmMenu = null; _elmMenu16 = null; _elmMenu32 = null; _elmMenuArrowImg = null; _elmMenuArrowImgCont = null; _elmMenuImg16 = null; _elmMenuImg16Cont = null; _elmMenuImg32 = null; _elmMenuImg32Cont = null; _elmMenuLbl = null; _elmSmall = null; _elmSmallArrowImg = null; _elmSmallImg = null; }
private void LaunchMenuInternal(Anchor launcher) { CloseToolTip(); Highlight(true); Root.FixedPositioningEnabled = false; _focusSet = false; ControlComponent comp = DisplayedComponent; bool isInMenu = comp.DisplayMode.StartsWith("Menu"); if (isInMenu) { // We know that if we're in a Menu, the structure must be Menu > MenuSection > MenuItem // and the DisplayedComponent must be the MenuItem Menu parentMenu = (Menu)comp.Parent.Parent; parentMenu.OpenSubMenuLauncher = this; } LaunchMenu(launcher); if (!isInMenu) { return; } Menu.ElementInternal.MouseOver += OnMenuMouseover; if (BrowserUtility.InternetExplorer) { Menu.ElementInternal.MouseLeave += OnMenuMouseleave; } else { Menu.ElementInternal.MouseOut += OnMenuMouseout; } }
internal static Anchor CreateNoOpLink() { Anchor elm = new Anchor(); elm.Href = "javascript:;"; elm.SetAttribute("onclick", "return false;"); return elm; }
internal override void AttachDOMElementsForDisplayMode(string displayMode) { Span elm = (Span)Browser.Document.GetById(Id + "-" + displayMode); StoreElementForDisplayMode(elm, displayMode); switch (displayMode) { case "Medium": _elmDefault = elm; _elmDefaultInput = (Input)_elmDefault.ChildNodes[0]; _elmDefaultArwBox = (Span)_elmDefault.ChildNodes[1]; _elmDefaultUpArw = (Anchor)_elmDefaultArwBox.ChildNodes[0]; _elmDefaultDownArw = (Anchor)_elmDefaultArwBox.ChildNodes[1]; _upArwImgCont = (Span)_elmDefaultUpArw.ChildNodes[0]; _downArwImgCont = (Span)_elmDefaultDownArw.ChildNodes[0]; _upArwImg = (Image)_upArwImgCont.ChildNodes[0]; _downArwImg = (Image)_downArwImgCont.ChildNodes[0]; break; } }
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; }
public override void Dispose() { base.Dispose(); _elmLarge = null; _elmMedium = null; _elmSmall = null; _elmMenu16 = null; _elmMenu32 = null; _elmFssbLarge = null; _elmFssbMedium = null; _elmFssbSmall = null; _elmFsddMenu = null; _elmFsddText = null; }
internal override void AttachDOMElementsForDisplayMode(string displayMode) { Anchor elm = (Anchor)Browser.Document.GetById(Id + "-" + displayMode); StoreElementForDisplayMode(elm, displayMode); // Only do hookup for non-menu display modes for now switch (displayMode) { case "Large": _elmLarge = elm; break; case "Medium": _elmMedium = elm; break; case "Small": _elmSmall = elm; break; } }
private Anchor CreateDOMElementForDisplayModeCore(string displayMode, bool attachEvents) { string alt = string.IsNullOrEmpty(Properties.Alt) ? GetLabel() : Properties.Alt; switch (displayMode) { case "Large": _elmLarge = CreateStandardControlDOMElement( this, Root, "Large", Properties, false, false); if (attachEvents) AttachEventsForDisplayMode("Large"); return _elmLarge; case "Medium": _elmMedium = CreateStandardControlDOMElement( this, Root, "Medium", Properties, false, false); // Set up event handlers if (attachEvents) AttachEventsForDisplayMode("Medium"); return _elmMedium; case "Small": _elmSmall = CreateStandardControlDOMElement( this, Root, "Small", Properties, false, false); // Set up event handlers if (attachEvents) AttachEventsForDisplayMode("Small"); return _elmSmall; case "Menu": // REVIEW(josefl): Perhaps we should just combine Menu16 and Menu into one and the same // display mode that will show the image if it is there. // TODO(JKern): Add no-icon menu display mode here case "Menu16": _elmMenu16 = CreateStandardControlDOMElement( this, Root, "Menu16", Properties, true, false); if (attachEvents) AttachEventsForDisplayMode("Menu16"); return _elmMenu16; case "Menu32": _elmMenu32 = CreateStandardControlDOMElement( this, Root, "Menu32", Properties, true, false); if (attachEvents) AttachEventsForDisplayMode("Menu32"); return _elmMenu32; default: EnsureValidDisplayMode(displayMode); return null; } }
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; }
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; } }
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; } }
public override void Dispose() { base.Dispose(); _elmLarge = null; _elmLargeArrowImg = null; _elmLargeBtn = null; _elmLargeSelectedItem = null; _elmMedium = null; _elmMediumArrowImg = null; _elmMediumBtn = null; _elmMediumSelectedItem = null; _elmSmall = null; _elmSmallArrowImg = null; _elmSmallBtn = null; _elmSmallSelectedItem = null; }
public override void Dispose() { base.Dispose(); _downArwImg = null; _downArwImgCont = null; _upArwImg = null; _upArwImgCont = null; _elmDefault = null; _elmDefaultArwBox = null; _elmDefaultDownArw = null; _elmDefaultInput = null; _elmDefaultUpArw = null; }
internal override void AttachDOMElementsForDisplayMode(string displayMode) { Anchor elm = (Anchor)Browser.Document.GetById(Id + "-" + displayMode); if (!CUIUtility.IsNullOrUndefined(elm)) StoreElementForDisplayMode(elm, displayMode); // Only do hookup for non-menu display modes // This is also called from CreateDOMElementForDisplayMode() so if "elm" is null // then we should already have the outer DOMElement. switch (displayMode) { case "Large": if (!CUIUtility.IsNullOrUndefined(elm)) _elmLarge = elm; _elmLargeImg = (Image)_elmLarge.ChildNodes[0].ChildNodes[0]; _elmLargeArrowImg = (Image)_elmLarge.LastChild.LastChild.ChildNodes[0]; break; case "Medium": if (!CUIUtility.IsNullOrUndefined(elm)) _elmMedium = elm; _elmMediumImg = (Image)_elmMedium.ChildNodes[0].ChildNodes[0]; _elmMediumArrowImg = (Image)_elmMedium.LastChild.LastChild.ChildNodes[0]; break; case "Small": if (!CUIUtility.IsNullOrUndefined(elm)) _elmSmall = elm; _elmSmallImg = (Image)_elmSmall.ChildNodes[0].ChildNodes[0]; _elmSmallArrowImg = (Image)_elmSmall.LastChild.LastChild.ChildNodes[0]; break; case "Thin": _elmThin = elm; _elmThinArrowImgCont = (Span)elm.FirstChild; _elmThinArrowImg = (Image)_elmThinArrowImgCont.FirstChild; break; } }
protected override HtmlElement CreateDOMElementForDisplayMode(string displayMode) { switch (displayMode) { case "Menu": _elmDefault = new Table(); _elmDefault.SetAttribute("mscui:controltype", ControlType); _elmDefaultTbody = new TableBody(); _elmDefaultTbody.ClassName = "ms-cui-it"; _elmDefault.SetAttribute("cellspacing", "0"); _elmDefault.SetAttribute("cellpadding", "0"); _elmDefaultTbody.SetAttribute("cellspacing", "0"); _elmDefaultTbody.SetAttribute("cellpadding", "0"); _elmDefault.MouseOut += OnControlMouseOut; EnsureDivArrays(); TableRow elmRow; TableCell elmCell; Anchor elmCellA; Div elmDiv; Div elmDivOuter; int idx = 0; for (int i = 0; i < 10; i++) { elmRow = new TableRow(); _elmDefaultTbody.AppendChild(elmRow); for (int j = 0; j < 10; j++) { elmCell = new TableCell(); elmCell.Style.Padding = "0px"; elmRow.AppendChild(elmCell); elmCellA = new Anchor(); Utility.NoOpLink(elmCellA); Utility.SetAriaTooltipProperties(Properties, elmCellA); elmCellA.Focus += OnCellFocus; elmDiv = new Div(); elmDiv.ClassName = "ms-cui-it-inactiveCell"; elmDivOuter = new Div(); elmDivOuter.Id = this.Id + "-" + idx; elmDivOuter.ClassName = "ms-cui-it-inactiveCellOuter"; elmCell.MouseOver += OnCellHover; elmCell.Click += OnCellClick; elmCell.AppendChild(elmDivOuter); elmDivOuter.AppendChild(elmDiv); elmDiv.AppendChild(elmCellA); _innerDivs[idx] = elmDiv; _outerDivs[idx] = elmDivOuter; idx++; } } _elmDefault.AppendChild(_elmDefaultTbody); return _elmDefault; default: EnsureValidDisplayMode(displayMode); break; } return null; }
/// <summary> /// Creates the DOM Element for the given display mode of this Flyout Anchor /// </summary> /// <param name="displayMode">The identifier of a valid display mode for this control</param> /// <returns>A DOMElement that represents this control for the given display mode</returns> /// <owner alias="JKern" /> protected override HtmlElement CreateDOMElementForDisplayMode(string displayMode) { string alt = string.IsNullOrEmpty(Properties.Alt) ? Properties.LabelText : Properties.Alt; switch (displayMode) { case "Menu": _elmMenu = CreateMenuDOMElement("Menu", "ms-cui-textmenuitem ms-cui-fa-menuitem ms-cui-ctl-menu", alt, null, null, null, null); AttachEventsForDisplayMode(displayMode); _elmMenu.SetAttribute("aria-haspopup", "true"); return _elmMenu; case "Menu16": _elmMenu16 = CreateMenuDOMElement("Menu16", "ms-cui-fa-menuitem ms-cui-ctl-menu", alt, Properties.Image16by16, Properties.Image16by16Class, Properties.Image16by16Top, Properties.Image16by16Left); AttachEventsForDisplayMode(displayMode); _elmMenu16.SetAttribute("aria-haspopup", "true"); return _elmMenu16; case "Menu32": _elmMenu32 = CreateMenuDOMElement("Menu32", "ms-cui-fa-menuitem ms-cui-ctl-menu", alt, Properties.Image32by32, Properties.Image32by32Class, Properties.Image32by32Top, Properties.Image32by32Left); _elmMenu32.SetAttribute("aria-haspopup", "true"); AttachEventsForDisplayMode(displayMode); return _elmMenu32; case "Large": _elmLarge = CreateStandardControlDOMElement( this, Root, "Large", Properties, false, true); _elmLarge.SetAttribute("aria-haspopup", "true"); if (IsGroupPopup) Utility.EnsureCSSClassOnElement(_elmLarge, "ms-cui-ctl-large-groupPopup"); AttachEventsForDisplayMode("Large"); return _elmLarge; case "Medium": _elmMedium = CreateStandardControlDOMElement( this, Root, "Medium", Properties, false, true); // Set up event handlers AttachEventsForDisplayMode("Medium"); _elmMedium.SetAttribute("aria-haspopup", "true"); return _elmMedium; case "Small": _elmSmall = CreateStandardControlDOMElement( this, Root, "Small", Properties, false, true); // Set up event handlers AttachEventsForDisplayMode("Small"); _elmSmall.SetAttribute("aria-haspopup", "true"); return _elmSmall; case "Thin": _elmThin = Utility.CreateNoOpLink(); _elmThin.ClassName = "ms-cui-ctl-thin"; _elmThinArrowImg = new Image(); _elmThinArrowImg.Alt = ""; if(string.IsNullOrEmpty(Properties.ToolTipTitle)) { _elmThin.Title = alt; _elmThinArrowImg.Alt = alt; } Root root = this.Root; _elmThinArrowImgCont = Utility.CreateClusteredImageContainerNew( ImgContainerSize.Size5by3, root.Properties.ImageDownArrow, root.Properties.ImageDownArrowClass, _elmThinArrowImg, true, false, root.Properties.ImageDownArrowTop, root.Properties.ImageDownArrowLeft); _elmThin.AppendChild(_elmThinArrowImgCont); // Attach Events AttachEventsForDisplayMode("Thin"); _elmThin.SetAttribute("aria-haspopup", "true"); return _elmThin; default: EnsureValidDisplayMode(displayMode); break; } return null; }
internal override void AttachDOMElementsForDisplayMode(string displayMode) { Span elm = (Span)Browser.Document.GetById(Id + "-" + displayMode); StoreElementForDisplayMode(elm, displayMode); // If we are attaching, we clear the initial item since this is dynamically // generated from a DOM element from a subitem. This will cause the new // DOM element to be generated the first time that this is queried. StateProperties[DropDownCommandProperties.SelectedItemId] = ""; // Only do hookup for non-menu display modes for now switch (displayMode) { case "Medium": _elmMedium = elm; _elmMediumInput = (Input)_elmMedium.ChildNodes[0]; _elmMediumBtnA = (Anchor)_elmMedium.ChildNodes[1]; _elmMediumArwImgCont = (Span)_elmMediumBtnA.ChildNodes[0]; _elmMediumArwImg = (Image)_elmMediumArwImgCont.ChildNodes[0]; Utility.SetUnselectable(_elmMediumInput, false, false); break; } }
protected virtual void SelectMenuItem(ISelectableControl isc) { if (_selectedControl == isc) // same menu item selected return; _selectedControl = isc; StateProperties[DropDownCommandProperties.SelectedItemId] = isc.GetMenuItemId(); // If SelectedItemDisplayMode is not set, Medium to "Text" string selectedItemDisplayMode; if (string.IsNullOrEmpty(Properties.SelectedItemDisplayMode)) selectedItemDisplayMode = "Text"; else selectedItemDisplayMode = Properties.SelectedItemDisplayMode; Anchor selectedItem; if (selectedItemDisplayMode == "Text") { string text = isc.GetTextValue(); selectedItem = new Anchor(); UIUtility.SetInnerText(selectedItem, text); } else selectedItem = (Anchor)_selectedControl.GetDropDownDOMElementForDisplayMode(selectedItemDisplayMode); if (_elmMediumSelectedItem.HasChildNodes()) { Anchor oldSelectedItem = (Anchor)_elmMediumSelectedItem.FirstChild; _elmMediumSelectedItem.ReplaceChild(selectedItem, oldSelectedItem); } else _elmMediumSelectedItem.AppendChild(selectedItem); }
public override void Dispose() { base.Dispose(); _elmMedium = null; _elmMediumArwImg = null; _elmMediumArwImgCont = null; _elmMediumBtnA = null; _elmMediumInput = null; }
public override void Dispose() { base.Dispose(); _elmMedium = null; _elmMediumArwImg = null; _elmMediumArwImgCont = null; _elmMediumBtnA = null; _elmMediumSelectedItem = null; }
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; } }
// This needs to be Ensured separately from the body of the tab // so that we can refresh the body of the tab on demand. /// <summary> /// Ensures that the title of this tab is refreshed based on the current properties of the Tab. /// </summary> internal void EnsureTitleRefreshed() { string ctxTabClasses = " "; // If the anchor element hasn't been instantiated, then it is possible // that the title element has only been shallowly instantiated and all its // parts still need to be created and the event handlers set. if (CUIUtility.IsNullOrUndefined(_elmTitleA)) { EnsureTitleDOMElement(); _elmTitleA = new Anchor(); Utility.NoOpLink(_elmTitleA); _elmTitleA.ClassName = "ms-cui-tt-a"; _elmTitleSpan = new Span(); _elmTitleSpan.ClassName = "ms-cui-tt-span"; _elmTitle.AppendChild(_elmTitleA); _elmTitleA.AppendChild(_elmTitleSpan); AttachEvents(); } else { ctxTabClasses += _elmTitle.ClassName.IndexOf("ms-cui-ct-first") > -1 ? "ms-cui-ct-first " : ""; ctxTabClasses += _elmTitle.ClassName.IndexOf("ms-cui-ct-last") > -1 ? "ms-cui-ct-last" : ""; ctxTabClasses = ctxTabClasses.TrimEnd(); } _elmTitle.ClassName = GetTitleCSSClassName() + ctxTabClasses; _elmTitle.Id = Id + "-title"; _elmTitle.SetAttribute("role", "tab"); _elmTitle.SetAttribute("aria-selected", _selected.ToString()); // Refresh the title, text and description UIUtility.SetInnerText(_elmTitleSpan, Title); _elmTitle.Title = Title; if (!string.IsNullOrEmpty(Description)) { _elmTitleA.SetAttribute("title", Description); } else { _elmTitleA.SetAttribute("title", Title); } }
internal override void AttachDOMElementsForDisplayMode(string displayMode) { Span elm = (Span)Browser.Document.GetById(Id + "-" + displayMode); StoreElementForDisplayMode(elm, displayMode); switch (displayMode) { case "Large": _elmLarge = elm; _elmLargeSelectedItem = (Span)_elmLarge.ChildNodes[0]; _elmLargeBtn = (Anchor)_elmLarge.ChildNodes[1]; _elmLargeArrowImg = (Image)_elmLargeBtn.ChildNodes[0].ChildNodes[0]; break; case "Medium": _elmMedium = elm; _elmMediumSelectedItem = (Span)_elmMedium.ChildNodes[0]; _elmMediumBtn = (Anchor)_elmMedium.ChildNodes[1]; _elmMediumArrowImg = (Image)_elmMediumBtn.ChildNodes[0].ChildNodes[0]; break; case "Small": _elmSmall = elm; _elmSmallSelectedItem = (Span)_elmSmall.ChildNodes[0]; _elmSmallBtn = (Anchor)_elmSmall.ChildNodes[1]; _elmSmallArrowImg = (Image)_elmSmallBtn.ChildNodes[0].ChildNodes[0]; break; } }
public override void Dispose() { _elmTitleA.Click -= OnTitleClick; _elmTitleA.KeyPress -= OnTitleKeyPress; _elmTitleA.DblClick -= OnTitleDblClick; base.Dispose(); _elmATText = null; _elmTitle = null; _elmTitleA = null; _elmTitleSpan = null; }
/// <summary> /// Create some rows or cells in _colorTable /// </summary> /// <param name="colorRules"></param> /// <param name="styleName"></param> private void AddColorCells(HtmlElement colorTableBody, ColorStyle[] colorRules) { int rowNumber = 0; TableRow row = new TableRow(); int totalRows = colorRules.Length / ColumnSize; for (int i = 0; i < colorRules.Length; i++) { if ((i % ColumnSize) == 0) { row = new TableRow(); colorTableBody.AppendChild(row); rowNumber++; } TableCell cell = new TableCell(); cell.ClassName = NormalCellCssClassName; cell.SetAttribute("arrayPosition", i.ToString()); // Make the first row have spacing. if (rowNumber == 1) { cell.Style.Padding = "2px"; cell.Style.Height = "16px"; } row.AppendChild(cell); Anchor link = new Anchor(); link.Href = "javascript:"; string displayName = colorRules[i].Title; link.Title = displayName; link.ClassName = CellAnchorCssClassName; link.Focus += OnCellFocus; Div elmDiv = new Div(); string color = colorRules[i].DisplayColor; elmDiv.Style.BackgroundColor = color; elmDiv.ClassName = CellDivClassName; int size = DefaultCellHeight; if (rowNumber == 1 || rowNumber == 2) { elmDiv.Style.BorderTopWidth = "1px"; size--; } if (rowNumber == 1 || rowNumber == totalRows) { elmDiv.Style.BorderBottomWidth = "1px"; size--; } if (size != DefaultCellHeight) { elmDiv.Style.Height = size + "px"; } Div internalelmDiv = new Div(); internalelmDiv.ClassName = CellInternalDivClassName; link.MouseOver += OnCellHover; link.MouseOut += OnCellBlur; link.Click += OnCellClick; cell.AppendChild(link); link.AppendChild(elmDiv); elmDiv.AppendChild(internalelmDiv); cell.SetAttribute(ColorInformation + "Color", colorRules[i].Color); cell.SetAttribute(ColorInformation + "Style", colorRules[i].Style); // add the cell to _colorCells so that we could reset the highlight _colorCells.Add(cell); } }