Esempio n. 1
0
 internal override bool OnPreBubbleCommand(CommandEventArgs command)
 {
     if (_menuLaunched && command.Type != CommandType.MenuCreation &&
         command.Type != CommandType.Preview &&
         command.Type != CommandType.PreviewRevert &&
         command.Type != CommandType.OptionPreview &&
         command.Type != CommandType.OptionPreviewRevert &&
         command.Type != CommandType.IgnoredByMenu &&
         command.Type != CommandType.MenuClose)
     {
         if (!CUIUtility.IsNullOrUndefined(command.SourceControl))
         {
             MenuItem selectedItem = (MenuItem)command.SourceControl.DisplayedComponent;
             _menu.SelectedMenuItem = selectedItem;
         }
         Root.CloseMenuStack(this);
     }
     return(true);
 }
Esempio n. 2
0
        /// <summary>
        /// Unregister a command handler for the command with the passed in id.
        /// </summary>
        /// <param name="commandId">The command that the handler is unregistering for.</param>
        /// <param name="handler">The handler that should be unregistered for the passed in command id.</param>
        public virtual void UnregisterCommandHandler(string commandId, ICommandHandler handler)
        {
            if (string.IsNullOrEmpty(commandId) || CUIUtility.IsNullOrUndefined(handler))
            {
                throw new ArgumentNullException("commandId and handler may not be null or undefined");
            }

            List <ICommandHandler> handlers = GetHandlerRecordForCommand(commandId);

            if (CUIUtility.IsNullOrUndefined(handlers))
            {
                return;
            }

            if (handlers.Contains(handler))
            {
                handlers.Remove(handler);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Removes a page component from this PageManager.
        /// </summary>
        /// <param name="component">the component that is to be removed</param>
        public void RemovePageComponent(PageComponent component)
        {
            if (CUIUtility.IsNullOrUndefined(_components) || !_components.Contains(component))
            {
                return;
            }

            _commandDispatcher.UnregisterMultipleCommandHandler((ICommandHandler)component,
                                                                component.GetGlobalCommands());
            _components.Remove(component);
            // Add this component to the focus manager if it is focusable
            if (component.IsFocusable())
            {
                _focusManager.RemovePageComponent(component);
            }

            // Remove the component from the hash of their ids
            _componentIds[component.GetId()] = null;
        }
Esempio n. 4
0
        internal void SetContextualText(string positionText, string contextualText, string groupName, int tabPos, int totalTabs)
        {
            if (CUIUtility.IsNullOrUndefined(_elmATText))
            {
                EnsureHiddenATDOMElement();
            }

            if (Contextual)
            {
                contextualText = String.Format(contextualText, groupName, tabPos, totalTabs);
            }
            else
            {
                contextualText = String.Format(positionText, tabPos, totalTabs);
            }
            UIUtility.SetInnerText(_elmATText, contextualText);
            Utility.EnsureCSSClassOnElement(_elmATText, "ms-cui-hidden");
            _elmTitleA.AppendChild(_elmATText);
        }
Esempio n. 5
0
        internal void OnKeyPress(HtmlEvent evt)
        {
            // To make OACR happy
            if (evt != null)
            {
                // using F2 key
                int helpKeyPC  = 113;
                int helpKeyMac = 123;

                if (((evt.KeyCode == helpKeyPC) || (evt.KeyCode == helpKeyMac)))
                {
                    string keyword = null;
                    if (!string.IsNullOrEmpty(_properties.ToolTipHelpKeyWord))
                    {
                        keyword = _properties.ToolTipHelpKeyWord;
                    }
                    if ((!CUIUtility.IsNullOrUndefined(_disabledInfoProperties)) &&
                        (!string.IsNullOrEmpty(_disabledInfoProperties.HelpKeyWord)))
                    {
                        // if the control is disabled, the disabled info HelpKeyword overrules any previously-set help keyword
                        keyword = _disabledInfoProperties.HelpKeyWord;
                    }
                    if (!string.IsNullOrEmpty(keyword))
                    {
                        Dictionary <string, string> dict = new Dictionary <string, string>();
                        dict["HelpKeyword"] = keyword;
                        if (!string.IsNullOrEmpty(Root.Properties.ToolTipHelpCommand))
                        {
                            RaiseCommandEvent(Root.Properties.ToolTipHelpCommand, CommandType.General, dict);
                        }
                    }

                    // prevent the key's default action
                    Utility.CancelEventUtility(evt, true, true);
                }
                else
                {
                    // Close open tooltips
                    Root.CloseOpenTootips();
                }
            }
        }
Esempio n. 6
0
        internal bool SelectMenuItemById(string menuItemId)
        {
            // We must have a MenuItemId and a Menu in order to select an item
            // The Menu can be null if this control's menu gets populated dynamically
            if (string.IsNullOrEmpty(menuItemId) || CUIUtility.IsNullOrUndefined(Menu))
            {
                return(false);
            }

            ISelectableControl isc = Menu.GetItemById(menuItemId);

            if (CUIUtility.IsNullOrUndefined(isc))
            {
                return(false);
            }

            SelectMenuItem(isc);
            _itemEverSelected = true;
            return(true);
        }
Esempio n. 7
0
        /// <summary>
        /// Close this Control's tool tip.
        /// </summary>
        /// <owner alias="HillaryM" />
        internal virtual void CloseToolTip()
        {
            if (!CUIUtility.IsNullOrUndefined(_root))
            {
                // clear launching timer
                Browser.Window.ClearInterval(_root.TooltipLauncherTimer);
            }

            if (!CUIUtility.IsNullOrUndefined(_toolTip))
            {
                _toolTip.Hide();

                _toolTipLaunched = false;
                OnToolTipClosed();

                // Remove the tooltip floating div from the DOM
                UIUtility.RemoveNode(_toolTip.ElementInternal);
                _toolTip = null;
            }
        }
Esempio n. 8
0
        public override void ReceiveFocus()
        {
            OnBeginFocus();
            ControlComponent comp = DisplayedComponent;

            if (CUIUtility.IsNullOrUndefined(comp))
            {
                return;
            }

            ((MenuItem)comp).Focused = true;
            if (!CUIUtility.IsNullOrUndefined(_elmMenu))
            {
                _elmMenu.PerformFocus();
            }
            if (!CUIUtility.IsNullOrUndefined(_elmSMenu))
            {
                _elmSMenu.PerformFocus();
            }
        }
Esempio n. 9
0
        internal override void PollForStateAndUpdate()
        {
            // Fix for bug O14:93091 - polling occurs when the spinner DOM element is not
            // yet created, so a JS error happens when calling ValidateAndSave()
            if (CUIUtility.IsNullOrUndefined(_elmDefault))
            {
                return;
            }

            bool succeeded = PollForStateAndUpdateInternal(Properties.Command,
                                                           Properties.QueryCommand,
                                                           StateProperties,
                                                           true);

            Unit u = FindUnitByNameOrAbbreviation((string)StateProperties[SpinnerCommandProperties.Unit]);

            if (!ValidateAndSave(u, Double.Parse(StateProperties[SpinnerCommandProperties.Value])))
            {
                throw new ArgumentOutOfRangeException("Invalid valid and/or unit returned when polling");
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Sets Enabled recursively on all this component and all the components below it
        /// This is used when a subtree needs to be completely disabled but some of the components
        /// have already been set to Enabled=false so they will not call it on their children
        /// because the value is not changing.  This function will force the whole subtree
        /// to become disabled regardless of the Enabled state of the Components in it.
        /// </summary>
        /// <param name="enabled">the value of Enabled that should be set on the components of this subtree</param>
        internal virtual void SetEnabledRecursively(bool enabled)
        {
            bool changed = _enabled != enabled;

            _enabled = enabled;

            // Set Enabled for its children if there are any
            if (!CUIUtility.IsNullOrUndefined(_children))
            {
                foreach (Component c in _children)
                {
                    c.SetEnabledRecursively(enabled);
                }
            }

            // If the Enabled value was changed for this component then we let it know
            if (changed)
            {
                OnEnabledChanged(enabled);
            }
        }
Esempio n. 11
0
        /*
         * /// <summary>
         * /// Subclassers can hook in here if they want to run their own logic to
         * /// get the sought after cui data.
         * /// </summary>
         * /// <param name="query">The cui query that is to be run.</param>
         * public virtual void RunQuery(DataQuery query)
         * {
         *  string version = _version;
         *  if (!string.IsNullOrEmpty(query.Version))
         *      version = query.Version;
         *
         *  string lcid = _lcid;
         *  if (!string.IsNullOrEmpty(query.Lcid))
         *      lcid = query.Lcid;
         *
         *  string dataUrl = _dataUrl;
         *  if (!string.IsNullOrEmpty(query.DataUrl))
         *      dataUrl = query.DataUrl;
         *
         *  string url;
         *  string type = null;
         *
         *  // The dataUrl passed in might already have parameters
         *  if (dataUrl.IndexOf('?') == -1)
         *      url = dataUrl + "?ver=";
         *  else
         *      url = dataUrl + "&ver=";
         *
         *  url = url + version + "&id=" + query.Id + "&lcid=" + lcid + "&qt=";
         *
         *  switch (query.QueryType)
         *  {
         *      case DataQueryType.All:
         *          type = "all";
         *          break;
         *      case DataQueryType.RibbonTab:
         *          type = "ribbontab";
         *          break;
         *      case DataQueryType.RibbonShallow:
         *          type = "ribbonshallow";
         *          break;
         *      case DataQueryType.Root:
         *          type = "root";
         *          break;
         *      case DataQueryType.RibbonVisibleTabDeep:
         *          type = "ribbonvisibletabdeep";
         *          break;
         *  }
         *
         *  url += type;
         #if PERF_METRICS
         *  PMetrics.PerfMark(PMarker.perfCUIRibbonQueryDataStart);
         #endif
         *  HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
         *  req.Method = "GET";
         *  req.ContentType = "text/html";
         *
         *  QueryRecord rec = new QueryRecord();
         *  rec.id = query.Id;
         *  rec.queryType = query.QueryType;
         *  rec.data = query.Data;
         *  rec.handler = query.Handler;
         *
         *  object data= new object();
         *  RequestState state = new RequestState(req, data, rec);
         *  IAsyncResult result = req.BeginGetResponse(new AsyncCallback(OnDataReturned),state);
         *
         *  //Register the timeout callback
         *  ThreadPool.RegisterWaitForSingleObject(result.AsyncWaitHandle,
         *      new WaitOrTimerCallback(ScanTimeoutCallback), state, (30 * 1000), true);
         * }
         *
         * /// <summary>
         * /// Subsclassers could hook in here if they wanted to subprocess the
         * /// resulting JSON.
         * /// </summary>
         * /// <param name="executor">the web executor that has returned from async request</param>
         * protected virtual void OnDataReturned(IAsyncResult result)
         * {
         #if PERF_METRICS
         *  PMetrics.PerfMark(PMarker.perfCUIRibbonQueryDataEnd);
         #endif
         *  RequestState state = (RequestState)result.AsyncState;
         *  WebRequest request = (WebRequest)state.Request;
         *
         *  HttpWebResponse response =(HttpWebResponse)request.EndGetResponse(result);
         *  Stream s = (Stream)response.GetResponseStream();
         *  StreamReader readStream = new StreamReader(s);
         *
         *  // Get the complete contents of the message
         *  string dataString = readStream.ReadToEnd();
         *  response.Close();
         *  s.Close();
         *  readStream.Close();
         *
         *  QueryRecord rec = state.Query;
         *  DataQueryResult res = new DataQueryResult();
         *  res.ContextData = rec.data;
         *  res.Id = rec.id;
         *
         *  // If the request succeeded
         *  // TODO(josefl) figure out right way to find out if it succeeded
         *  if (!string.IsNullOrEmpty(dataString))
         *  {
         *      res.Success = true;
         *      res.QueryData = dataString;
         *      rec.handler(res);
         *  }
         *  else
         *  {
         *      res.Success = false;
         *      // Return that the data retrieval failed
         *      rec.handler(res);
         *  }
         * }
         *
         * private static void ScanTimeoutCallback (object state, bool timedOut)
         * {
         *  if (timedOut)
         *  {
         *      RequestState reqState = (RequestState)state;
         *      if (reqState != null)
         *          reqState.Request.Abort();
         *  }
         * }
         */

        /// <summary>
        /// Subclassers can hook in here if they want to run their own logic to
        /// get the sought after cui data.
        /// </summary>
        /// <param name="query">The cui query that is to be run.</param>
        public virtual void RunQuery(DataQuery query)
        {
            QueryRecord rec = new QueryRecord();

            rec.id        = query.Id;
            rec.queryType = query.QueryType;
            rec.data      = query.Data;
            rec.handler   = query.Handler;

            RibbonData rData = new RibbonData();

            JSObject dataBlock;

            if (query.TabQuery)
            {
                dataBlock = rData.GetTabQueryData(query.Id);
            }
            else
            {
                dataBlock = rData.GetQueryData(query.Id);
            }

            DataQueryResult res = new DataQueryResult();

            res.ContextData = rec.data;
            res.Id          = rec.id;

            if (!CUIUtility.IsNullOrUndefined(dataBlock))
            {
                res.Success   = true;
                res.QueryData = dataBlock;
                rec.handler(res);
            }
            else
            {
                // Return that the data retrieval failed
                res.Success = false;
                rec.handler(res);
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Constructs a toolbar from its JSON data.
        /// </summary>
        private Toolbar BuildToolbarFromData(object data, ToolbarBuildContext context)
        {
            JSObject toolbarElement = DataNodeWrapper.GetFirstChildNodeWithName(data, DataNodeWrapper.TOOLBAR);

            if (CUIUtility.IsNullOrUndefined(toolbarElement))
            {
                throw new ArgumentNullException("No toolbar element was present in the data");
            }

            bool hasJewel = !CUIUtility.IsNullOrUndefined(DataNodeWrapper.GetFirstChildNodeWithName(data, DataNodeWrapper.JEWEL));

            Toolbar = new Toolbar(
                DataNodeWrapper.GetAttribute(toolbarElement, DataNodeWrapper.ID),
                DataNodeWrapper.GetNodeAttributes(toolbarElement).To <ToolbarProperties>(),
                this,
                hasJewel);

            Toolbar.ClientID      = Options.ClientID;
            Toolbar.UseDataCookie = true;

            Toolbar.RefreshInternal(); // We need to refresh before we can attach the jewel.

            if (hasJewel)
            {
                Toolbar.AttachAndBuildJewelFromData(data);
            }

            // Build the ButtonDocks (the Docks will build their subcontrols).
            JSObject docks = DataNodeWrapper.GetFirstChildNodeWithName(toolbarElement, DataNodeWrapper.BUTTONDOCKS);

            JSObject[] dockChildren = DataNodeWrapper.GetNodeChildren(docks);

            for (int i = 0; i < dockChildren.Length; i++)
            {
                ButtonDock dock = BuildButtonDock(dockChildren[i], context);
                Toolbar.AddChild(dock);
            }

            return(Toolbar);
        }
Esempio n. 13
0
        /// <summary>
        /// Attaches events to the DOMElements for the given display mode
        /// </summary>
        /// <param name="displayMode">The display mode to attach events for</param>
        /// <owner alias="JKern" />
        internal override void AttachEventsForDisplayMode(string displayMode)
        {
            Anchor elm = GetDisplayedDOMElement(displayMode);

            if (CUIUtility.IsNullOrUndefined(elm))
            {
                return;
            }

            elm.Click    += OnClick;
            elm.Blur     += OnBlur;
            elm.KeyPress += OnKeyPress;
            elm.Focus    += OnTabFocus;
            if (BrowserUtility.InternetExplorer)
            {
                if (displayMode.StartsWith("Menu"))
                {
                    elm.MouseEnter += OnMouseenter;
                    elm.MouseLeave += OnMouseleave;
                }
                else
                {
                    elm.MouseEnter += OnFocus;
                    elm.MouseLeave += OnBlur;
                }
            }
            else
            {
                if (displayMode.StartsWith("Menu"))
                {
                    elm.MouseOver += OnMouseover;
                    elm.MouseOut  += OnMouseout;
                }
                else
                {
                    elm.MouseOver += OnFocus;
                    elm.MouseOut  += OnBlur;
                }
            }
        }
Esempio n. 14
0
        /// <summary>
        /// Method called when a Help Command is raised.
        /// </summary>
        /// <remarks>
        /// This function checks that the raised command is indeed a help command and if so takes the
        /// appropriate action.
        /// </remarks>
        /// <param name="commandId">The id of the executed command.</param>
        /// <param name="properties">The properties of the executed command.</param>
        /// <param name="sequence">The sequence number for the executed command.</param>
        /// <returns>True if the command is handled.False otherwise.</returns>
        /// <owner alias="HillaryM" />
        public override bool HandleCommand(string commandId, Dictionary <string, string> properties, int sequence)
        {
            if (string.IsNullOrEmpty(commandId) ||
                CUIUtility.IsNullOrUndefined(properties))
            {
                return(false);
            }

            if (commandId == HelpCommandNames.RequestContextualHelp)
            {
                HandlingCommand = true;
                string helpKeyord = properties["HelpKeyword"];
                Browser.Window.Alert("Unable to navigate to help at this time");
                HandlingCommand = false;
            }
            else
            {
                // not recognized command
                return(false);
            }
            return(true);
        }
Esempio n. 15
0
        /// <summary>
        /// Close this MenuLauncher's Menu.
        /// </summary>
        internal virtual void CloseMenu()
        {
            // There are cases where the Menu was closed by some other function, so this may get called more than once on one menu
            if (!_menuLaunched)
            {
                return;
            }

            // Remove the menu floating div from the DOM
            UIUtility.RemoveNode(_menu.ElementInternal);
            if (!CUIUtility.IsNullOrUndefined(_elmBackFrame))
            {
                UIUtility.RemoveNode(_elmBackFrame);
            }

            _menu.OnMenuClosed();

            // Now remove the Menu Component from the Ribbon Component Hierarchy
            // TODO: should we remove this or leave it in the hierarchy?
            // Perhaps remove it so that it could be added to a scaled other version of this control
            Component parent = _menu.Parent;

            parent.IgnoreDirtyingEvents = true;
            parent.RemoveChild(_menu.Id);
            parent.IgnoreDirtyingEvents = false;
            _menuLaunched  = false;
            _menu.Launched = false;

            Root.EndModal(this);
            // Only return focus to ribbon if user closed menu using keyboard
            if (!CUIUtility.IsNullOrUndefined(_elmHadFocus) && LaunchedByKeyboard)
            {
                _elmHadFocus.PerformFocus();
            }

            _elmHadFocus       = null;
            LaunchedByKeyboard = false;
            OnLaunchedMenuClosed();
        }
Esempio n. 16
0
        private void FocusOnAppropriateMenuItem(HtmlEvent evt)
        {
            if (CUIUtility.IsNullOrUndefined(_menu.SelectedMenuItem) && !CUIUtility.IsNullOrUndefined(_selectedControl))
            {
                Control          ctl      = (Control)_selectedControl;
                ControlComponent dispComp = ctl.DisplayedComponent;
                if (dispComp is MenuItem)
                {
                    _menu.SelectedMenuItem = (MenuItem)dispComp;
                }
            }

            // Let focus remain on triggering element if using jaws
            // LaunchedByKeyboard true for onkeydown, not jaws onclick
            if (LaunchedByKeyboard)
            {
                _menu.FocusOnFirstItem(evt);
            }
            else
            {
                // If nothing has been selected before then we auto-select the first item in some cases
                MenuItem selectedItem = _menu.SelectedMenuItem;
                if (!CUIUtility.IsNullOrUndefined(selectedItem))
                {
                    // This auto selection only happens for ToggleButtons in DropDowns where one of the
                    // menu items represents the "currently selected item" in the DropDown.
                    // Currently selected font in a font dropdown for example.
                    Control selectedItemControl = selectedItem.Control;
                    if (selectedItemControl is ToggleButton && selectedItemControl is ISelectableControl)
                    {
                        ISelectableControl isc = (ISelectableControl)selectedItemControl;
                        if (!_menu.FocusOnItemById(isc.GetMenuItemId()))
                        {
                            _menu.FocusOnFirstItem(evt);
                        }
                    }
                }
            }
        }
Esempio n. 17
0
        internal static string ConvertXMLStringToJSON(string xml)
        {
            XmlDocument document = new XmlDocument(xml);

            if (CUIUtility.IsNullOrUndefined(document))
            {
                return(string.Empty);
            }

            if (document.ChildNodes.Length == 0)
            {
                return(string.Empty);
            }

            StringBuilder sb = new StringBuilder();

            sb.Append("(");
            sb.Append(ConvertNodeToJSON(document.ChildNodes[0]));
            sb.Append(")");

            return(sb.ToString());
        }
Esempio n. 18
0
        /// <summary>
        /// Checks whether any command handlers can accept the execution of a command.
        /// </summary>
        /// <param name="commandId">The id of the command that is being checked.</param>
        /// <returns>Returns true if one or more command handlers can execute the command.</returns>
        public bool IsCommandEnabled(string commandId)
        {
            List <ICommandHandler> handlers = GetHandlerRecordForCommand(commandId);

            if (CUIUtility.IsNullOrUndefined(handlers))
            {
                return(false);
            }

            for (int i = 0; i < handlers.Count; i++)
            {
                ICommandHandler handler = (ICommandHandler)handlers[i];

                // If at least one handler handles the command,
                // then we return that the command is enabled
                if (CallCommandHandlerForEnabled(handler, commandId))
                {
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 19
0
        /// <summary>
        /// Builds the toolbar and attaches it to the page.
        /// Called once the DataQuery completes and the toolbar data is available.
        /// </summary>
        private void OnReturnToolbarData(DataQueryResult res)
        {
            ToolbarBuildContext context = (ToolbarBuildContext)res.ContextData;

            // Apply any extensions to the data.
            res.QueryData = ApplyDataExtensions(res.QueryData);

            Toolbar = BuildToolbarFromData(res.QueryData, context);
            Toolbar.ToolbarBuilder = this;
            BuildClient.OnComponentCreated(Toolbar, Toolbar.Id);
            Toolbar.RefreshInternal();

            Placeholder.AppendChild(Toolbar.ElementInternal);

            // If there's a jewel on the toolbar, position the left buttondock adjacent to it
            foreach (ButtonDock dock in Toolbar.Children)
            {
                if (dock.Alignment == DataNodeWrapper.LEFTALIGN)
                {
                    Div jewelContainer = (Div)Browser.Document.GetById("jewelcontainer");
                    if (!CUIUtility.IsNullOrUndefined(jewelContainer))
                    {
                        if (Toolbar.TextDirection == Direction.LTR)
                        {
                            dock.ElementInternal.Style.Left = jewelContainer.OffsetWidth + "px";
                        }
                        else
                        {
                            dock.ElementInternal.Style.Right = jewelContainer.OffsetWidth + "px";
                        }
                    }
                    break;
                }
            }

            Utility.EnsureCSSClassOnElement(Placeholder, "loaded");
            BuildClient.OnComponentBuilt(Toolbar, Toolbar.Id);
        }
Esempio n. 20
0
        internal void PositionToolTip()
        {
            HtmlElement flyOut   = this.ElementInternal;
            HtmlElement launcher = this.Parent.ElementInternal;

            if (CUIUtility.IsNullOrUndefined(flyOut) || CUIUtility.IsNullOrUndefined(launcher))
            {
                return;
            }

            // Set temporary position on flyOut and get dimensions
            flyOut.Style.Top  = "0px";
            flyOut.Style.Left = "0px";
            Dictionary <string, int> d = Root.GetAllElementDimensions(flyOut, launcher);
            int flyOutWidth            = d["flyOutWidth"];

            // check if launching control is within ribbon body
            if ((Parent.ComponentTopPosition > Root.ComponentTopPosition) &&
                ((Parent.ComponentTopPosition + Parent.ComponentHeight) < (Root.ComponentTopPosition + Root.ComponentHeight)))
            {
                d["launcherTop"]    = Root.ComponentTopPosition;
                d["launcherHeight"] = Root.ComponentHeight;
            }
            else
            {
                // if the tooltip is launched within a menu, we offset it vertically and horizontally to prevent occluding menu items
                int launcherTop  = d["launcherTop"];
                int launcherLeft = d["launcherLeft"];

                launcherLeft     += _tooltipHorizontalOffsetInMenus;
                launcherTop      += _tooltipVerticalOffsetInMenus;
                d["launcherLeft"] = launcherLeft;
                d["launcherTop"]  = launcherTop;
            }
            Root.SetFlyOutCoordinates(flyOut, d, false);
            // O14: 545739 - the setFlyoutCoordinates method sets the midwidth of the flyout. We don't want this set for tootips
            flyOut.Style.MinWidth = flyOutWidth + "px";
        }
Esempio n. 21
0
 /// <summary>
 /// Starts timer that will launch tooltip if this control has focus for 500 ms.
 /// </summary>
 /// <owner alias="HillaryM" />
 public virtual void OnBeginFocus()
 {
     Browser.Window.ClearInterval(Root.TooltipLauncherTimer);
     // if there is currently an open tooltip and it was not launched by this control, close it
     if (!CUIUtility.IsNullOrUndefined(Root.TooltipLauncher))
     {
         if (Root.TooltipLauncher.Id == this.Id)
         {
             // launch tooltip immediately (bug O14: 299699)
             LaunchToolTip();
             return;
         }
         else
         {
             Root.CloseOpenTootips();
             Root.TooltipLauncherTimer = Browser.Window.SetTimeout(new Action(LaunchToolTip), 500);
         }
     }
     else
     {
         Root.TooltipLauncherTimer = Browser.Window.SetTimeout(new Action(LaunchToolTip), 500);
     }
 }
Esempio n. 22
0
        private void AddTabsToRibbon(JSObject[] tabs, string contextualGroupId, RibbonBuildContext rbc)
        {
            bool shownTabsSpecified = !CUIUtility.IsNullOrUndefined(RibbonBuildOptions.ShownTabs);

            for (int j = 0; j < tabs.Length; j++)
            {
                if (shownTabsSpecified)
                {
                    // Only construct the tabs/tabheaders that have been made available
                    string tabId = DataNodeWrapper.GetAttribute(tabs[j], DataNodeWrapper.ID);
                    if (!string.IsNullOrEmpty(tabId))
                    {
                        if (!RibbonBuildOptions.ShownTabs.ContainsKey(tabId) ||
                            CUIUtility.IsNullOrUndefined(RibbonBuildOptions.ShownTabs[tabId]))
                        {
                            continue;
                        }
                    }
                }
                Tab tab = BuildTab(tabs[j], rbc, contextualGroupId);
                Ribbon.AddChild(tab);
            }
        }
Esempio n. 23
0
        internal bool ExecuteCommandInternal(string commandId, Dictionary <string, string> properties, int sequenceNumber)
        {
            List <ICommandHandler> handlers = GetHandlerRecordForCommand(commandId);

            if (CUIUtility.IsNullOrUndefined(handlers))
            {
                return(false);
            }

            bool success = false;

            for (int i = 0; i < handlers.Count; i++)
            {
                ICommandHandler handler = (ICommandHandler)handlers[i];

                // If at least one handler handles the command, then we return success
                if (CallCommandHandler(handler, commandId, properties, sequenceNumber))
                {
                    success = true;
                }
            }
            return(success);
        }
Esempio n. 24
0
 protected override void ReleaseEventHandlers()
 {
     if (!CUIUtility.IsNullOrUndefined(_elmLarge))
     {
         RemoveEvents(_elmLarge, true);
     }
     if (!CUIUtility.IsNullOrUndefined(_elmMedium))
     {
         RemoveEvents(_elmMedium, true);
     }
     if (!CUIUtility.IsNullOrUndefined(_elmSmall))
     {
         RemoveEvents(_elmSmall, true);
     }
     if (!CUIUtility.IsNullOrUndefined(_elmMenu32))
     {
         RemoveEvents(_elmMenu32, false);
     }
     if (!CUIUtility.IsNullOrUndefined(_elmMenu16))
     {
         RemoveEvents(_elmMenu16, false);
     }
 }
Esempio n. 25
0
        protected void OnMenuButtonClick(HtmlEvent args)
        {
            if (CUIUtility.IsNullOrUndefined(args))
            {
                return;
            }

            Utility.CancelEventUtility(args, false, true);
            CloseToolTip();
            if (!Enabled || !_menuButtonEnabled)
            {
                return;
            }

            Root.FixedPositioningEnabled = false;
            Root.LastCommittedControl    = this;
            focusOnArrow = true;

            HtmlElement prev = args.TargetElement;

            LaunchMenu(prev);
            DisplayedComponent.RaiseCommandEvent(Properties.CommandMenuOpen, CommandType.MenuCreation, null);
        }
Esempio n. 26
0
        protected override void OnClick(HtmlEvent evt)
        {
            CloseToolTip();
            Utility.CancelEventUtility(evt, false, true);

            if (!Enabled)
            {
                return;
            }

            Toggle();

            CommandType ct     = CommandType.General;
            string      cmdtpe = Properties.CommandType;
            Dictionary <string, string> dict = StateProperties;

            dict[GalleryButtonCommandProperties.CommandValueId] = Properties.CommandValueId;
            dict["MenuItemId"]      = Properties.MenuItemId;
            dict["SourceControlId"] = Properties.Id;
            if (!CUIUtility.IsNullOrUndefined(cmdtpe) && cmdtpe == "OptionSelection")
            {
                ct = CommandType.OptionSelection;
            }

            DisplayedComponent.RaiseCommandEvent(Properties.Command,
                                                 ct,
                                                 dict);

            if (Root.PollForState)
            {
                PollForStateAndUpdate();
            }
            else
            {
                SetState(Utility.IsTrue(StateProperties[GalleryButtonCommandProperties.On]));
            }
        }
Esempio n. 27
0
        public bool BuildRibbonAndInitialTab(string initialTabId)
        {
            if (string.IsNullOrEmpty(initialTabId))
            {
                throw new ArgumentNullException("Initial tab for ribbon is null or undefined");
            }

            if (InQuery)
            {
                return(false);
            }

            RibbonBuildContext rbc = new RibbonBuildContext();

            rbc.InitialTabId = initialTabId;

            // If this is server rendered, then we want to set and use the initial
            // scaling index for this first tab.
            if (!CUIUtility.IsNullOrUndefined(RibbonBuildOptions.AttachToDOM) &&
                RibbonBuildOptions.AttachToDOM)
            {
                rbc.InitialScalingIndex = this.RibbonBuildOptions.InitialScalingIndex;
            }

            InQuery = true;
            DataQuery query = new DataQuery();

            query.TabQuery  = false;
            query.Id        = rbc.InitialTabId;
            query.QueryType = DataQueryType.RibbonVisibleTabDeep;
            query.Handler   = new DataReturnedEventHandler(OnReturnRibbonAndInitialTab);
            query.Data      = rbc;

            DataSource.RunQuery(query);
            return(true);
        }
Esempio n. 28
0
        public override void OnBeginFocus()
        {
            string dictKey           = DropDownCommandProperties.Value;
            string selectedItemTitle = StateProperties.ContainsKey(dictKey) ? StateProperties[dictKey] : "";

            if (string.IsNullOrEmpty(selectedItemTitle))
            {
                // get currently selected item ID
                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))
                {
                    currentSelectedItemId = Properties.InitialItem;
                }

                // get the title of the selected item
                // The Menu can be null if this control's menu gets populated dynamically
                if ((!string.IsNullOrEmpty(currentSelectedItemId)) &&
                    (!CUIUtility.IsNullOrUndefined(Menu)))
                {
                    ISelectableControl isc = Menu.GetItemById(currentSelectedItemId);
                    if (!CUIUtility.IsNullOrUndefined(isc))
                    {
                        selectedItemTitle = isc.GetTextValue();
                    }
                }
            }
            if (!string.IsNullOrEmpty(selectedItemTitle))
            {
                Properties.ToolTipSelectedItemTitle = selectedItemTitle;
            }
            base.OnBeginFocus();
        }
Esempio n. 29
0
        protected override void OnClick(HtmlEvent args)
        {
            if (!CUIUtility.IsNullOrUndefined(typeof(PMetrics)))
            {
                PMetrics.PerfMark(PMarker.perfCUIRibbonButtonOnClickStart);
            }

            Utility.CancelEventUtility(args, true, true);
            CloseToolTip();
            if (!Enabled)
            {
                return;
            }

            Root.LastCommittedControl = this;

            CommandType ct = CommandType.General;
            Dictionary <string, string> dict = this.StateProperties;
            string cmdtpe = Properties.CommandType;

            if (!string.IsNullOrEmpty(cmdtpe) && cmdtpe == "OptionSelection")
            {
                ct = CommandType.OptionSelection;
            }
            dict["CommandValueId"]  = this._commandValueId;
            dict["MenuItemId"]      = this._menuItemId;
            dict["SourceControlId"] = this.Id;
            DisplayedComponent.RaiseCommandEvent(Properties.Command,
                                                 ct,
                                                 dict);

            if (!CUIUtility.IsNullOrUndefined(typeof(PMetrics)))
            {
                PMetrics.PerfMark(PMarker.perfCUIRibbonButtonOnClickEnd);
            }
        }
Esempio n. 30
0
        internal override bool FocusNext(HtmlEvent evt)
        {
            if (_focusedIndex == -1)
            {
                _focusedIndex = 0;
            }

            int i = _focusedIndex;

            while (i < Children.Count)
            {
                Component comp = Children[i];

                if (comp.FocusNext(evt))
                {
                    // If focus is not moving, don't reset the focus of the menu item
                    if (i != _focusedIndex)
                    {
                        if (!CUIUtility.IsNullOrUndefined(Children[_focusedIndex]))
                        {
                            ((Component)Children[_focusedIndex]).ResetFocusedIndex();
                        }
                        _focusedIndex = i;
                    }
                    return(true);
                }
                i++;
            }

            if (Children.Count > 0)
            {
                ((Component)Children[_focusedIndex]).ResetFocusedIndex();
            }
            _focusedIndex = -1;
            return(false);
        }