Esempio n. 1
0
        private void FillTab(Tab tab, object data, RibbonBuildContext rbc)
        {
            JSObject groupsNode = DataNodeWrapper.GetFirstChildNodeWithName(data, DataNodeWrapper.GROUPS);
            JSObject[] groupChildren = DataNodeWrapper.GetNodeChildren(groupsNode);
            Dictionary<string, string> emptyTrimmedGroupIds = new Dictionary<string, string>();
            for (int i = 0; i < groupChildren.Length; i++)
            {
                if (IsNodeTrimmed(groupChildren[i]))
                    continue;

                Group group = BuildGroup(groupChildren[i], rbc);
                // If the build option TrimEmptyGroups is null, and the Group is empty
                // then null is returned by BuildGroup()
                if (!CUIUtility.IsNullOrUndefined(group))
                {
                    tab.AddChild(group);
                }
                else
                {
                    // If the group has an Id, then we store it so that we can ignore any scaling
                    // information that relates it it.  If it does not have an id, then any scaling info
                    // will not work anyways and it is an invalid node.  Groups must have ids.
                    string id = DataNodeWrapper.GetAttribute(groupChildren[i], DataNodeWrapper.ID);
                    if (!string.IsNullOrEmpty(id))
                        emptyTrimmedGroupIds[id] = id;
                }
            }

            JSObject scaling = DataNodeWrapper.GetFirstChildNodeWithName(data,
                                                                   DataNodeWrapper.SCALING);
            JSObject[] children = DataNodeWrapper.GetNodeChildren(scaling);
            string _scaleWarningMessage = "";
            bool _scaleWarning = false;

            for (int i = 0; i < children.Length; i++)
            {
                string name = DataNodeWrapper.GetNodeName(children[i]);
                string groupId = DataNodeWrapper.GetAttribute(children[i], DataNodeWrapper.GROUPID);

                if (name == DataNodeWrapper.MAXSIZE)
                {
                    // Don't include the scale step if the group that it refers to has been trimmed
                    if (IsIdTrimmed(groupId) || (emptyTrimmedGroupIds.ContainsKey(groupId) &&
                            !CUIUtility.IsNullOrUndefined(emptyTrimmedGroupIds[groupId])))
                        continue;

                    tab.Scaling.SetGroupMaxSize(groupId,
                                                DataNodeWrapper.GetAttribute(children[i], DataNodeWrapper.SIZE));
                }
                else if (name == DataNodeWrapper.SCALE)
                {
                    // Don't include the scale step if the group that it refers to has been trimmed
                    if (IsIdTrimmed(groupId) || (emptyTrimmedGroupIds.ContainsKey(groupId) &&
                            !CUIUtility.IsNullOrUndefined(emptyTrimmedGroupIds[groupId])))
                        continue;

                    tab.Scaling.AddScalingStep(new ScalingStep(groupId,
                                                               DataNodeWrapper.GetAttribute(children[i], DataNodeWrapper.SIZE),
                                                               DataNodeWrapper.GetAttribute(children[i], DataNodeWrapper.POPUPSIZE),
                                                               _scaleWarningMessage,
                                                               _scaleWarning));
                    _scaleWarningMessage = "";
                    _scaleWarning = false;
                }
                else if (name == DataNodeWrapper.LOWSCALEWARNING)
                {
                    _scaleWarningMessage = DataNodeWrapper.GetAttribute(children[i], DataNodeWrapper.MESSAGE);
                    _scaleWarning = true;
                }
                else
                {
                    throw new InvalidOperationException("Was expecting a node with name MaxSize or Scale.");
                }
            }

            // Start at the largest scale
            tab.ScaleMax();
        }
Esempio n. 2
0
        public override void Dispose()
        {
            Disposed = true;

            Root root = this.Root;
            if (!CUIUtility.IsNullOrUndefined(root))
            {
                int timer = root.TooltipLauncherTimer;
                if (!CUIUtility.IsNullOrUndefined(timer))
                {
                    Browser.Window.ClearTimeout(timer);
                }

                root.CloseOpenTootips();
            }

            // This property set will remove the event handler
            WindowResizedHandlerEnabled = false;

            ElementInternal.KeyDown -= OnRibbonEscKeyPressed;
            if (_eventHandlerAttached)
            {
                ElementInternal.KeyDown -= OnKeydownGroupShortcuts;
                Browser.Document.KeyDown -= OnKeydownRibbonShortcuts;
            }

            base.Dispose();
            _previousTab = null;
            _selectedTab = null;
            _elmRibbonTopBars = null;
            _elmTabTitles = null;
            _elmJewelPlaceholder = null;
            _elmTabContainer = null;
            _elmTabRowLeft = null;
            _elmTabRowRight = null;
            _elmQATPlaceholder = null;
            _elmQATRowCenter = null;
            _elmQATRowRight = null;
            _elmTopBar1 = null;
            _elmTopBar2 = null;

            foreach (ContextualGroup cg in _contextualGroups.Values)
            {
                cg.Dispose();

            }
            _contextualGroups.Clear();
            _contextualGroups = null;
        }
Esempio n. 3
0
        // Adding this back in for merge TODO(josefl): should remove later 
        internal void SelectTab(Tab tab)
        {
            if (tab.Contextual && !tab.Visible)
                ShowContextualGroup(tab.ContextualGroupId);

            _selectedTab = tab;
            tab.SetSelectedInternal(true, true);
            OnDirtyingChange();
        }
Esempio n. 4
0
 private void UpdatePreviousSelectedTab(Tab newlySelectedTab)
 {
     _previousTab = newlySelectedTab;
 }
Esempio n. 5
0
        internal void MakeTabSelectedInternal(Tab tab)
        {
            if (!CUIUtility.IsNullOrUndefined(tab))
            {
                OnDirtyingChange();
                tab.SetSelectedInternal(true, false);
                if (!tab.Contextual)
                    SetContextualColor(ContextualColor.None);

                if (!CUIUtility.IsNullOrUndefined(_selectedTab) && _selectedTab != tab)
                    _selectedTab.SetSelectedInternal(false, false);
                _selectedTab = tab;
                MinimizedInternal = false;
            }

            // Need to make sure that we clear the last focused control when tabs are switched
            // O14:673517
            LastFocusedControl = null;
        }
Esempio n. 6
0
        internal void UpdateDOMForSelectedTab()
        {
            // Make sure that the tab has its top level DOMElement
            if (!CUIUtility.IsNullOrUndefined(_selectedTab))
                _selectedTab.EnsureDOMElement();

            // Keep the last selected non-contextual tab so that we can revert to it
            // if a selected contextual tab becomes hidden.  This code assumes
            // that non-contextual tabs are always visible and never hidden during
            // the runtime of the ribbon.
            if (!CUIUtility.IsNullOrUndefined(_selectedTab) && !_selectedTab.Contextual)
                _lastSelectedNonContextualTab = _selectedTab;

            // If this tab is empty or null then remove the body of the ribbon
            if (CUIUtility.IsNullOrUndefined(_selectedTab) || _selectedTab.Children.Count == 0)
            {
                // Remove the tab container div
                if (!CUIUtility.IsNullOrUndefined(ElementInternal) &&
                    !CUIUtility.IsNullOrUndefined(_elmTabContainer) &&
                     ElementInternal.LastChild == _elmTabContainer)
                {
                    ElementInternal.RemoveChild(_elmTabContainer);
                }
            }
            else if (!CUIUtility.IsNullOrUndefined(_elmTabContainer))
            {
                // If _selectedTab is not empty, then we need to make sure that
                // _elmTabContainer is attached to the ribbon
                ElementInternal.AppendChild(_elmTabContainer);
            }

            // REVIEW(josefl): Will the controls handle this on their own?
            // _selectedTab.PollIfRootPolledSinceLastPoll();

            // At this point there is nothing left to do if the selected tab was set to null
            if (CUIUtility.IsNullOrUndefined(_selectedTab))
                return;

            // Now make sure that the selected tab's DOMElement is up to date
            bool wasDirty = _selectedTab.Dirty;
            _selectedTab.EnsureRefreshed();

            // If the tab is empty, we don't append the DOM Element so that the Ribbon
            // tab section will get minimized.
            // _elmTabContainer may be null if the ribbon has never been refreshed
            if (_selectedTab.Children.Count > 0 && !CUIUtility.IsNullOrUndefined(_elmTabContainer))
            {
                // We do not want to remove the tab body from the DOM if it is already there.
                bool alreadyThere = false; ;
                if (_elmTabContainer.HasChildNodes())
                {
                    alreadyThere = _elmTabContainer.FirstChild == _selectedTab.ElementInternal;
                    if (!alreadyThere)
                        _elmTabContainer.RemoveChild(_elmTabContainer.FirstChild);
                }

                if (!alreadyThere)
                    _elmTabContainer.AppendChild(_selectedTab.ElementInternal);
            }

            if (!string.IsNullOrEmpty(this.RibbonProperties.TabSwitchCommand) &&
                (_previousTab != _selectedTab))
            {
                Dictionary<string, string> props = new Dictionary<string, string>();
                if (!CUIUtility.IsNullOrUndefined(_previousTab) && _previousTab != _selectedTab)
                {
                    props["OldContextId"] = _previousTab.Id;
                    props["OldContextCommand"] = _previousTab.Command;
                }
                else
                {
                    props["OldContextId"] = "";
                    props["OldContextCommand"] = "";
                }
                if (!CUIUtility.IsNullOrUndefined(_selectedTab))
                {
                    props["NewContextId"] = _selectedTab.Id;
                    props["NewContextCommand"] = _selectedTab.Command;
                    props["ChangedByUser"] = _selectedTab.SelectedByUser.ToString();
                }

                RaiseCommandEvent(this.RibbonProperties.TabSwitchCommand,
                                  CommandType.TabSelection,
                                  props);

                UpdatePreviousSelectedTab(_selectedTab);
            }

            // Reset this to the default value since we explicitly set it to true
            // if the tab changed as the result of a click.
            if (!CUIUtility.IsNullOrUndefined(_selectedTab))
            {
                _selectedTab.SelectedByUser = false;
                if (_selectedTab.LaunchedByKeyboard)
                    _selectedTab.SetRefreshFocus();
            }
        }