コード例 #1
0
        private void TitleClickCallback()
        {
            // If a double click has been processed since the single click was
            // then we need to ignore the single click since it was really part of
            // a double click.
            if (!_shouldProcessSingleClick)
            {
                return;
            }
            _selectedByUser = true;

            Ribbon.EnsureCurrentControlStateCommitted();

            Selected = true;

            // close any open tooltips
            Ribbon.CloseOpenTootips();

            // TODO(josefl): This line should be able to be removed.
            // I'm leaving it because it is late in Office14 and I don't want to risk
            // regressing anything.  It will not hurt to have it here too even though
            // it will be called as a sideeffect of setting Selected to true above. O14:637517
            Ribbon.LastFocusedControl = null;

#if PERF_METRICS
            PMetrics.PerfMark(PMarker.perfCUIRibbonTabSwitchWarmEnd);
#endif
        }
コード例 #2
0
ファイル: flyoutanchor.cs プロジェクト: tralivali1234/IL2JS
        protected override void OnClick(HtmlEvent evt)
        {
            bool enabled = Enabled;

#if PERF_METRICS
            if (enabled && !MenuLaunched)
            {
                PMetrics.PerfMark(PMarker.perfCUIFlyoutAnchorOnClickStart);
            }
#endif
            CloseToolTip();
            Utility.CancelEventUtility(evt, false, true);
            if (!enabled || MenuLaunched)
            {
                return;
            }

            Root.LastCommittedControl = this;
            ControlComponent comp = DisplayedComponent;
            Anchor           elm  = (Anchor)comp.ElementInternal;
            LaunchMenuInternal(elm);
            if (!string.IsNullOrEmpty(Properties.Command))
            {
                comp.RaiseCommandEvent(Properties.Command,
                                       CommandType.MenuCreation,
                                       null);
            }
#if PERF_METRICS
            PMetrics.PerfMark(PMarker.perfCUIFlyoutAnchorOnClickEnd);
#endif
        }
コード例 #3
0
ファイル: page.cs プロジェクト: tralivali1234/IL2JS
        private void RibbonInitFunc1()
        {
            RibbonBuildOptions rbOpts = new RibbonBuildOptions();

            rbOpts.LazyTabInit             = true;
            rbOpts.ShallowTabs             = true;
            rbOpts.LazyMenuInit            = true;
            rbOpts.AttachToDOM             = false;
            rbOpts.InitialScalingIndex     = 0;
            rbOpts.ValidateServerRendering = false;

            rbOpts.ShowQATId                  = "";
            rbOpts.ShowJewelId                = "";
            rbOpts.ShownContextualGroups      = null;
            rbOpts.FixedPositioningEnabled    = false;
            rbOpts.NormalizedContextualGroups = null;

            rbOpts.DataExtensions           = null;
            rbOpts.TrimEmptyGroups          = true;
            rbOpts.ScalingHint              = "-1819788779";
            rbOpts.ClientID                 = "RibbonContainer";
            rbOpts.Minimized                = _ribbon.GetField <bool>("buildMinimized");
            rbOpts.LaunchedByKeyboard       = _ribbon.GetField <bool>("launchedByKeyboard");
            rbOpts.InitialTabSelectedByUser = _ribbon.GetField <bool>("initialTabSelectedByUser");

            rbOpts.ShownTabs = new Dictionary <string, bool>();
            rbOpts.ShownTabs.Add("Ribbon.Read", true);
            rbOpts.ShownTabs.Add("Ribbon.Library", true);
            rbOpts.ShownTabs.Add("Ribbon.Document", true);

            rbOpts.InitiallyVisibleContextualGroups = new Dictionary <string, bool>();
            rbOpts.InitiallyVisibleContextualGroups.Add("Ribbon.LibraryContextualGroup", true);

            rbOpts.TrimmedIds = new Dictionary <string, bool>();
            rbOpts.TrimmedIds.Add("Ribbon.List.GanttView", true);
            rbOpts.TrimmedIds.Add("Ribbon.List.Share.AlertMe", true);
            rbOpts.TrimmedIds.Add("Ribbon.Library.Share.AlertMe", true);
            rbOpts.TrimmedIds.Add("Ribbon.Documents.FormActions", true);
            rbOpts.TrimmedIds.Add("Ribbon.ListItem.Share.AlertMe", true);
            rbOpts.TrimmedIds.Add("Ribbon.Documents.Share.AlertMe", true);
            rbOpts.TrimmedIds.Add("Ribbon.List.Actions.AllMeetings", true);
            rbOpts.TrimmedIds.Add("Ribbon.WebPartPage.Share.AlertMe", true);
            rbOpts.TrimmedIds.Add("Ribbon.Library.Actions.AllMeetings", true);
            rbOpts.TrimmedIds.Add("Ribbon.Calendar.Events.Share.AlertMe", true);
            rbOpts.TrimmedIds.Add("Ribbon.Calendar.Calendar.Share.AlertMe", true);
            rbOpts.TrimmedIds.Add("Ribbon.ListItem.Actions.ChangeItemOrder", true);
            rbOpts.TrimmedIds.Add("Ribbon.WebPartInsert.InsertRelatedDataToListForm", true);

            // Get parent Ribbon Container and prepare to build
            HtmlElement   ribbonCont = Browser.Document.GetById("RibbonContainer");
            RibbonBuilder builder    = new RibbonBuilder(rbOpts, ribbonCont, PageManager.Instance);

            // Set the data source and build tab
            DataSource dataSource = new DataSource("\u002f_layouts\u002fcommandui.ashx", "-829476993", "1033");

            builder.DataSource = dataSource;
            builder.BuildRibbonAndInitialTab(_ribbon.GetField <string>("initialTabId"));

            PMetrics.PerfReport();
        }
コード例 #4
0
ファイル: inserttable.cs プロジェクト: tralivali1234/IL2JS
        private void OnCellClick(HtmlEvent evt)
        {
            if (!CUIUtility.IsNullOrUndefined(typeof(PMetrics)))
            {
                PMetrics.PerfMark(PMarker.perfCUIRibbonInsertTableOnClickStart);
            }

            Utility.CancelEventUtility(evt, false, true);
            if (!Enabled)
            {
                return;
            }

            Div element = GetOuterDiv(evt.TargetElement);

            int idx    = GetIndexFromElement(element);
            int column = GetColFromIndex(idx);
            int row    = GetRowFromIndex(idx);

            // We don't want to send a preview revert command since the user has picked one
            // by clicking.
            CancelClickPreviewRevert();

            CommandProperties[InsertTableCommandProperties.Rows]    = (row + 1).ToString();
            CommandProperties[InsertTableCommandProperties.Columns] = (column + 1).ToString();
            DisplayedComponent.RaiseCommandEvent(Properties.Command,
                                                 CommandType.General,
                                                 CommandProperties);

            if (!CUIUtility.IsNullOrUndefined(typeof(PMetrics)))
            {
                PMetrics.PerfMark(PMarker.perfCUIRibbonInsertTableOnClickEnd);
            }
        }
コード例 #5
0
ファイル: menulauncher.cs プロジェクト: tralivali1234/IL2JS
        protected void AddAndPositionBackFrameInternal()
        {
#if PERF_METRICS
            PMetrics.PerfMark(PMarker.perfCUIAddAndPositionBackFrameStart);
#endif
            Browser.Document.Body.AppendChild(BackFrame);
            Utility.PositionBackFrame(BackFrame, _menu.ElementInternal);
#if PERF_METRICS
            PMetrics.PerfMark(PMarker.perfCUIAddAndPositionBackFrameEnd);
#endif
        }
コード例 #6
0
ファイル: togglebutton.cs プロジェクト: modulexcite/IL2JS
        protected override void OnClick(HtmlEvent evt)
        {
            if (!CUIUtility.IsNullOrUndefined(typeof(PMetrics)))
            {
                PMetrics.PerfMark(PMarker.perfCUIRibbonToggleButtonOnClickStart);
            }

            CloseToolTip();
            Utility.CancelEventUtility(evt, false, true);

            if (!Enabled)
            {
                return;
            }

            Root.LastCommittedControl = this;

            CommandType ct     = CommandType.General;
            string      cmdtpe = Properties.CommandType;

            if (!string.IsNullOrEmpty(cmdtpe) && cmdtpe == "OptionSelection")
            {
                ct = CommandType.OptionSelection;
                StateProperties[ToggleButtonCommandProperties.CommandValueId] = _commandValueId;
            }

            // Send out the command
            StateProperties[ToggleButtonCommandProperties.On] =
                (!Utility.IsTrue(StateProperties[ToggleButtonCommandProperties.On])).ToString();
            DisplayedComponent.RaiseCommandEvent(Properties.Command,
                                                 ct,
                                                 StateProperties);
            if (Root.PollForState)
            {
                PollForStateAndUpdate();
            }
            else
            {
                SetState(Utility.IsTrue(StateProperties[ToggleButtonCommandProperties.On]));
            }

            if (!CUIUtility.IsNullOrUndefined(typeof(PMetrics)))
            {
                PMetrics.PerfMark(PMarker.perfCUIRibbonToggleButtonOnClickEnd);
            }
        }
コード例 #7
0
        /// <summary>
        /// Handle when a tab title is clicked.
        /// This causes this tab to become the selected one.
        /// </summary>
        /// <param name="evt"></param>
        private void OnTitleClick(HtmlEvent args)
        {
#if PERF_METRICS
            PMetrics.PerfMark(PMarker.perfCUIRibbonTabSwitchWarmStart);
#endif
            Utility.CancelEventUtility(args, false, true);

            _shouldProcessSingleClick = true;
            // If the tab is selected, then we need to make sure that the user didn't try to double click
            // So, we have to wait a bit to let the the double click event fire.
            // Double clicking only works on the selected tab so if this tab is not selected, then
            // we can process the single click right away.
            if (Selected)
            {
                Browser.Window.SetTimeout(TitleClickCallback, 500);
            }
            else
            {
                TitleClickCallback();
            }
        }
コード例 #8
0
ファイル: mrusplitbutton.cs プロジェクト: tralivali1234/IL2JS
        private void OnSelectedItemClick(HtmlEvent evt)
        {
#if PERF_METRICS
            PMetrics.PerfMark(PMarker.perfCUIRibbonEditWikiPageStart);
#endif
            CloseToolTip();
            Utility.CancelEventUtility(evt, false, true);

            if (!Enabled)
            {
                return;
            }

            CommandType ct = CommandType.OptionSelection;

            Dictionary <string, string> commandTemp = new Dictionary <string, string>();
            commandTemp["CommandValueId"] = _selectedControl.GetCommandValueId();
            DisplayedComponent.RaiseCommandEvent(Properties.Command,
                                                 ct,
                                                 commandTemp);
        }
コード例 #9
0
ファイル: dropdown.cs プロジェクト: tralivali1234/IL2JS
        protected void OnArrowButtonClick(HtmlEvent evt)
        {
            bool enabled = Enabled;

#if PERF_METRICS
            if (enabled)
            {
                PMetrics.PerfMark(PMarker.perfCUIDropDownOnArrowButtonClickStart);
            }
#endif
            CloseToolTip();
            Utility.CancelEventUtility(evt, false, true);

            if (!enabled)
            {
                return;
            }

            Root.LastFocusedControl = this;
            LaunchMenuInternal(evt);
#if PERF_METRICS
            PMetrics.PerfMark(PMarker.perfCUIDropDownOnArrowButtonClickEnd);
#endif
        }
コード例 #10
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);
            }
        }
コード例 #11
0
ファイル: ribbonbuilder.cs プロジェクト: tralivali1234/IL2JS
        private void OnReturnTab(DataQueryResult res)
        {
            RibbonBuildContext rbc = (RibbonBuildContext)res.ContextData;

            if (res.Success)
            {
                JSObject ribbonNode =
                    DataNodeWrapper.GetFirstChildNodeWithName(res.QueryData,
                                                              DataNodeWrapper.RIBBON);
                JSObject tabsNode =
                    DataNodeWrapper.GetFirstChildNodeWithName(ribbonNode,
                                                              DataNodeWrapper.TABS);

                JSObject[] tabs     = null;
                JSObject[] children = DataNodeWrapper.GetNodeChildren(tabsNode);
                if (children.Length == 0)
                {
                    JSObject ctxtabsNode =
                        DataNodeWrapper.GetFirstChildNodeWithName(ribbonNode,
                                                                  DataNodeWrapper.CONTEXTUALTABS);
                    JSObject[] contextualGroups = DataNodeWrapper.GetNodeChildren(ctxtabsNode);
                    for (int i = 0; i < contextualGroups.Length; i++)
                    {
                        JSObject contextualGroup = contextualGroups[i];
                        tabs = DataNodeWrapper.GetNodeChildren(contextualGroup);
                        if (tabs.Length > 0)
                        {
                            break;
                        }
                    }
                }
                else
                {
                    tabs = DataNodeWrapper.GetNodeChildren(tabsNode);
                }

                JSObject templatesNode = DataNodeWrapper.GetFirstChildNodeWithName(res.QueryData,
                                                                                   DataNodeWrapper.TEMPLATES);

                // Apply any extensions to the template data.
                templatesNode = (JSObject)ApplyDataExtensions(templatesNode);

                TemplateManager.Instance.LoadTemplates(templatesNode);

                // Apply any extensions to the tab data.
                // In this case we do not want to apply the extensions to the whole hierarchy
                // including <CommandUI>, <Ribbon> etc because this query is really only for
                // a specific tab.
                object tabData = ApplyDataExtensions(tabs[0]);

                FillTab(rbc.InitializedTab, tabData, rbc);
                // This may need to be parametrized so that tabs can be inited
                // without automatically getting selected when the initing is done.
                rbc.InitializedTab.Ribbon.MakeTabSelectedInternal(rbc.InitializedTab);
                rbc.InitializedTab.OnDelayedInitFinished(true);
            }
            // TODO: how to handle failures

#if PERF_METRICS
            PMetrics.PerfMark(PMarker.perfCUIRibbonTabSwitchWarmPercvdEnd);
#endif
        }
コード例 #12
0
ファイル: ribbonbuilder.cs プロジェクト: tralivali1234/IL2JS
        private void OnReturnRibbonAndInitialTab(DataQueryResult res)
        {
            PMetrics.PerfMark(PMarker.perfCUIRibbonInitStart);

            RibbonBuildContext rbc = (RibbonBuildContext)res.ContextData;

            // Apply any extensions to the data.
            res.QueryData = ApplyDataExtensions(res.QueryData);
            Utility.EnsureCSSClassOnElement(Placeholder, "loaded");
            JSObject templates = DataNodeWrapper.GetFirstChildNodeWithName(res.QueryData, DataNodeWrapper.TEMPLATES);

            if (!CUIUtility.IsNullOrUndefined(templates))
            {
                TemplateManager.Instance.LoadTemplates(templates);
            }

            Ribbon = BuildRibbon(res.QueryData, rbc);
            Ribbon.RibbonBuilder = this;
            BuildClient.OnComponentCreated(Ribbon, Ribbon.Id);
            if (RibbonBuildOptions.Minimized)
            {
                Ribbon.MinimizedInternal = true;
            }
            else
            {
                Ribbon.MinimizedInternal = false;
                Tab firstTab = (Tab)Ribbon.GetChild(rbc.InitialTabId);
                if (!CUIUtility.IsNullOrUndefined(firstTab))
                {
                    // We need this in order to set the "ChangedByUser" property of the first
                    // TabSwitch command that comes out of the ribbon correctly.
                    firstTab.SelectedByUser = RibbonBuildOptions.InitialTabSelectedByUser;
                    Ribbon.MakeTabSelectedInternal(firstTab);
                }
            }

            Ribbon.ClientID = RibbonBuildOptions.ClientID;

            bool shouldAttach = !RibbonBuildOptions.Minimized && RibbonBuildOptions.AttachToDOM;

            if (shouldAttach)
            {
                // Scale the ribbon to the scaling index that matches the ribbon that was
                // rendered by the server.  This sets the in memory Ribbon structure to match
                // what was rendered by the server.  This is needed so that Ribbon.AttachInternal()
                // will work properly.
                if (!((RibbonBuildOptions)Options).Minimized)
                {
                    // We subtract one from this scaling index because internally
                    // this scaling index is an entry into an array of "<ScaleStep>" so
                    // the MaxSize for all the groups is actually index "-1" and the first
                    // step is index 0.
                    Ribbon.ScaleIndex(rbc.InitialScalingIndex - 1);
                }

                Ribbon.AttachInternal(true);

                // Attach to the QAT and Jewel
                if (!string.IsNullOrEmpty(RibbonBuildOptions.ShowQATId))
                {
                    Ribbon.BuildAndSetQAT(RibbonBuildOptions.ShowQATId, true, DataSource);
                }
                if (!string.IsNullOrEmpty(RibbonBuildOptions.ShowJewelId))
                {
                    Ribbon.BuildAndSetJewel(RibbonBuildOptions.ShowJewelId, true, DataSource);
                }

#if DEBUG
                // Validate that the server rendered ribbon is identical to the client rendered one
                // for this tab.
                if (Options.ValidateServerRendering)
                {
                    RibbonBuilder rb2 = new RibbonBuilder(this.RibbonBuildOptions,
                                                          this.Placeholder,
                                                          null);

                    DataSource ds = new DataSource(this.DataSource.DataUrl,
                                                   this.DataSource.Version,
                                                   this.DataSource.Lcid);

                    rb2.DataSource = ds;
                    SPRibbon r2 = rb2.BuildRibbon(res.QueryData, rbc);
                    r2.Id           += "-client";
                    r2.ClientID      = RibbonBuildOptions.ClientID + "-client";
                    r2.RibbonBuilder = this;
                    if (!RibbonBuildOptions.Minimized)
                    {
                        r2.Minimized = false;
                    }

                    // Clone all the peripheral sections for the client-rendering version
                    Div p_qrc = (Div)Browser.Document.GetById(RibbonBuildOptions.ClientID + "-" + RibbonPeripheralSection.QATRowCenter);
                    Div p_qrr = (Div)Browser.Document.GetById(RibbonBuildOptions.ClientID + "-" + RibbonPeripheralSection.QATRowRight);
                    Div p_trl = (Div)Browser.Document.GetById(RibbonBuildOptions.ClientID + "-" + RibbonPeripheralSection.TabRowLeft);
                    Div p_trr = (Div)Browser.Document.GetById(RibbonBuildOptions.ClientID + "-" + RibbonPeripheralSection.TabRowRight);

                    Div hiddenClonedPeripherals = new Div();
                    hiddenClonedPeripherals.Style.Display = "none";
                    Browser.Document.Body.AppendChild(hiddenClonedPeripherals);

                    Div clone;
                    if (null != p_qrc)
                    {
                        clone    = (Div)p_qrc.CloneNode(true);
                        clone.Id = clone.Id.Replace(RibbonBuildOptions.ClientID, r2.ClientID);
                        hiddenClonedPeripherals.AppendChild(clone);
                    }
                    if (null != p_qrr)
                    {
                        clone    = (Div)p_qrr.CloneNode(true);
                        clone.Id = clone.Id.Replace(RibbonBuildOptions.ClientID, r2.ClientID);
                        hiddenClonedPeripherals.AppendChild(clone);
                    }
                    if (null != p_trl)
                    {
                        clone    = (Div)p_trl.CloneNode(true);
                        clone.Id = clone.Id.Replace(RibbonBuildOptions.ClientID, r2.ClientID);
                        hiddenClonedPeripherals.AppendChild(clone);
                    }
                    if (null != p_trr)
                    {
                        clone    = (Div)p_trr.CloneNode(true);
                        clone.Id = clone.Id.Replace(RibbonBuildOptions.ClientID, r2.ClientID);
                        hiddenClonedPeripherals.AppendChild(clone);
                    }

                    r2.MakeTabSelectedInternal((Tab)r2.GetChild(rbc.InitialTabId));
                    r2.RefreshInternal();

                    if (!string.IsNullOrEmpty(RibbonBuildOptions.ShowQATId))
                    {
                        r2.BuildAndSetQAT(RibbonBuildOptions.ShowQATId, false, ds);
                    }
                    if (!string.IsNullOrEmpty(RibbonBuildOptions.ShowJewelId))
                    {
                        r2.BuildAndSetJewel(RibbonBuildOptions.ShowJewelId, false, ds);
                    }

                    r2.ScaleIndex(rbc.InitialScalingIndex - 1);
                    r2.CompleteConstruction();

                    // If this returns a message it means that it found some inconsistencies
                    // between the DOM Nodes
                    CompareNodes(Ribbon.ElementInternal, r2.ElementInternal);
                }
#endif
            }
            else
            {
                // Do the minimum amount of work necessary in order to be able to
                // get the outer ribbon element and to be able to attach the Jewel and QAT.
                Ribbon.EnsureDOMElement();

                // Build the QAT and Jewel after the ribbon so that the placeholders
                // will have been created within the ribbon via Ribbon.RefreshInternal()
                if (!string.IsNullOrEmpty(RibbonBuildOptions.ShowQATId))
                {
                    Ribbon.BuildAndSetQAT(RibbonBuildOptions.ShowQATId, false, DataSource);
                }
                if (!string.IsNullOrEmpty(RibbonBuildOptions.ShowJewelId))
                {
                    Ribbon.BuildAndSetJewel(RibbonBuildOptions.ShowJewelId, false, DataSource);
                }

                // Remove anything else that is in the placeholder in case there is a temporary
                // animated gif or a static ribbon in there while the ribbon is loading.
                // We're doing this the slow way since partners might have a reference to this node
                Utility.RemoveChildNodesSlow(Placeholder);
                Placeholder.AppendChild(Ribbon.ElementInternal);
            }

            Ribbon.Scale();
            OnRootBuilt(Ribbon);
            BuildClient.OnComponentBuilt(Ribbon, Ribbon.Id);
            if (RibbonBuildOptions.LaunchedByKeyboard)
            {
                Ribbon.SetFocusOnRibbon();
            }

            PMetrics.PerfMark(PMarker.perfCUIRibbonInitPercvdEnd);
        }