/// <summary> /// MenuSection constructor. /// </summary> /// <param name="ribbon">The Ribbon that created this MenuSection and that it is a part of.</param> /// <param name="id">The Component id of this MenuSection.</param> /// <param name="title">The Title of this MenuSection.</param> /// <param name="description">The Description of this MenuSection.</param> /// <param name="dict">A bag of properties of this MenuSection</param> /// <param name="maxheight">The maximum height of this MenuSection</param> /// <param name="scrollable">Whether this MenuSection is scrollable</param> /// <param name="displayMode">The display mode of the children of this MenuSection</param> public MenuSection(Root root, string id, string title, string description, bool scrollable, string maxheight, string displayMode) : base(root, id, title, description) { _scrollable = scrollable; _maxHeight = maxheight; _displayMode = displayMode; }
/// <summary> /// ContextMenu Contructor. /// </summary> /// <param name="root">The Root that this Menu was created by and is a part of.</param> /// <param name="id">The Component id of this Menu.</param> /// <param name="title">The Title of this Menu.</param> /// <param name="description">The Description of this Menu.</param> internal ContextMenu(Root root, string id, string title, string description, string maxWidth) : base(root, id, title, description, maxWidth) { }
public ControlComponent(Root root, string id, string displayMode, Control control) : base(root, id, displayMode, "") { _control = control; }
/// <summary> /// Menu Contructor. /// </summary> /// <param name="ribbon">The Ribbon that this Menu was created by and is a part of.</param> /// <param name="id">The Component id of this Menu.</param> /// <param name="title">The Title of this Menu.</param> /// <param name="description">The Description of this Menu.</param> internal Menu(Root root, string id, string title, string description, string maxWidth) : base(root, id, title, description) { _maxWidth = maxWidth; }
/// <summary> /// Constructs a command UI Component. /// </summary> /// <param name="root">the Root Component that this Component is under</param> /// <param name="id">the id of this Component</param> /// <param name="title">the title of this Component</param> /// <param name="description">the description of this Component</param> protected Component(Root root, string id, string title, string description) { _id = id; _root = root; _title = title; _description = description; CreateChildArray(); }
/// <summary> /// ToolTip Contructor. /// </summary> /// <param name="ribbon">The Ribbon that this ToolTip was created by and is a part of.</param> /// <param name="id">The Component id of this ToolTip.</param> /// <param name="title">The Title of this ToolTip.</param> /// <param name="description">The Description of this ToolTip.</param> /// <owner alias="HillaryM" /> internal ToolTip(Root root, string id, string title, string description, ControlProperties properties) : base(root, id, title, description) { _properties = properties; if (!string.IsNullOrEmpty(properties.ToolTipShortcutKey)) { // switch display based on text direction if (Root.TextDirection == Direction.LTR) { this.TitleInternal = String.Format("{0} ({1})", Title, Properties.ToolTipShortcutKey); } else { this.TitleInternal = String.Format("({1}) {0}", Title, Properties.ToolTipShortcutKey); } } }
/// <summary> /// Called to let the IRootUser know that the Root has been refreshed(through polling). /// </summary> /// <param name="root">the Root that has been refreshed</param> public abstract void OnRootRefreshed(Root root);
/// <summary> /// Queries whether a particular command is currently enabled. /// </summary> /// <param name="commandId">the id of the command</param> /// <param name="root">the Root that is making the request</param> /// <returns>true if the command is enabled</returns> public abstract bool IsRootCommandEnabled(string commandId, Root root);
/// <summary> /// A command was executed inside the Root. /// </summary> /// <param name="commandId">the id of the command</param> /// <param name="properties">the properties of the command</param> /// <param name="root">the Root in which the command was executed</param> /// <returns>true if the command was executed successfully</returns> public abstract bool ExecuteRootCommand(string commandId, Dictionary<string, string> properties, CommandInformation commandInfo, Root root);
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 = " "; } 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; }
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); }
// Called up to cleanup anything that this Control needs to cleanup. public virtual void Dispose() { ReleaseEventHandlers(); _root = null; _components = null; _displayModes = null; if (!CUIUtility.IsNullOrUndefined(_cachedDOMElements)) { _cachedDOMElements.Clear(); _cachedDOMElements = null; } if (!CUIUtility.IsNullOrUndefined(_toolTip)) _toolTip.Dispose(); }
/// <summary> /// MenuLauncher contructor. /// </summary> /// <param name="root">The Root that this MenuLauncher was created by and is part of.</param> /// <param name="id">The Component id of this MenuLauncher.</param> /// <param name="properties">Dictionary of Control parameters</param> /// <param name="menu">The Menu that this MenuLauncher should launch.</param> public MenuLauncher(Root root, string id, ControlProperties properties, MenuType menu) : base(root, id, properties) { _menu = menu; }
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; }
/// <summary> /// Creates a new Strip. /// </summary> /// <param name="ribbon">The Toolbar that this ButtonDock was created by and is a part of.</param> /// <param name="id">The Component id of this ButtonDock.</param> internal ButtonDock(Root root, string id, ButtonDockProperties properties) : base(root, id, "", "") { _alignment = CUIUtility.SafeString(properties.Alignment); }
/// <summary> /// Creates a new Strip. /// </summary> /// <param name="root">The ContextMenuRoot that this ContextMenuDock was created by and is a part of.</param> /// <param name="id">The id of this ContextMenuDock.</param> public ContextMenuDock(Root root, string id) : base(root, id, "", "") { }
/// <summary> /// Initializes the Root member of this Component. Normally this is set via the Component constructor. This is just used in the Root constructor since the Root reference can not be passed in to it. /// </summary> /// <param name="root">The Root that this Component's Root member should be set to.</param> protected void InitRootMember(Root root) { if (!CUIUtility.IsNullOrUndefined(_root)) throw new ArgumentNullException("Root member has already been set for this Component."); _root = root; }
/// <summary> /// Called to clean up anything that this component needs to /// Usually releasing event handlers and cleaning up any circular references. /// </summary> public virtual void Dispose() { if (!CUIUtility.IsNullOrUndefined(_children)) { foreach (Component c in _children) c.Dispose(); _children = null; } _parent = null; _root = null; _delayedInitData = null; _delayedInitHandler = null; _delayedInitOptions = null; _elmDOM = null; }
/// <summary> /// ContextMenuLauncher constructor /// </summary> /// <param name="root">The Root that this MenuLauncher was created by and is part of.</param> /// <param name="id">The Component id of this MenuLauncher.</param> /// <param name="properties">Dictionary of Control properties</param> /// <param name="menu">The Menu that this MenuLauncher should launch.</param> internal ContextMenuLauncher(Root root, string id, ControlProperties properties, MenuType menu) : base(root, id, properties, menu) { //base class sets the Menu property on menu }
/// <summary> /// Control constructor. /// </summary> /// <param name="ribbon">The Ribbon that this Control will be a part of.</param> /// <param name="id">Unique identifier for this Control. ie: "fseaPaste"</param> /// <param name="prms">Dictionary of parameters to this Control.</param> protected Control(Root root, string id, ControlProperties properties) { _root = root; _id = id; _properties = properties; _components = new List<ControlComponent>(); _displayModes = ","; _cachedDOMElements = new Dictionary<string, HtmlElement>(); // TODO(shaozhu): Remove registerControl() after dynamic menu is // supported. root.RegisterControl(this); }
/// <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) { }
/// <summary> /// Creates a Gallery /// </summary> /// <param name="root">The Ribbon that this Gallery was created by and is a part of.</param> /// <param name="id">The Component id of this Gallery.</param> /// <param name="title">The Title of this Gallery.</param> /// <param name="description">The Description of this Gallery</param> /// <param name="properties">The properties of this Gallery</param> public Gallery(Root root, string id, string title, string description, GalleryProperties properties) : base(root, id, title, description) { Properties = properties; Width = Int32.Parse(Properties.Width); ElementDimensions = Gallery.ConvertStringToGalleryElementDimensions(Properties.ElementDimensions); }