Exemplo n.º 1
0
        /// <internalonly/>
        public override void CopyFrom(Style s)
        {
            if (s != null && !s.IsEmpty)
            {
                base.CopyFrom(s);

                if (s is WebPartMenuStyle)
                {
                    WebPartMenuStyle ms = (WebPartMenuStyle)s;

                    // Only copy the BackImageUrl if it isn't in the source Style's registered CSS class
                    if (s.RegisteredCssClass.Length != 0)
                    {
                        if (ms.IsSet(PROP_SHADOWCOLOR))
                        {
                            ViewState.Remove("ShadowColor");
                            ClearBit(PROP_SHADOWCOLOR);
                        }
                    }
                    else
                    {
                        if (ms.IsSet(PROP_SHADOWCOLOR))
                        {
                            this.ShadowColor = ms.ShadowColor;
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <internalonly/>
        public override void MergeWith(Style s)
        {
            if (s != null && !s.IsEmpty)
            {
                if (IsEmpty)
                {
                    // merge into an empty style is equivalent to a copy,
                    // which is more efficient
                    CopyFrom(s);
                    return;
                }

                base.MergeWith(s);

                if (s is WebPartMenuStyle)
                {
                    WebPartMenuStyle ms = (WebPartMenuStyle)s;

                    // Since we're already copying the registered CSS class in base.MergeWith, we don't
                    // need to any attributes that would be included in that class.
                    if (s.RegisteredCssClass.Length == 0)
                    {
                        if (ms.IsSet(PROP_SHADOWCOLOR) && !this.IsSet(PROP_SHADOWCOLOR))
                        {
                            this.ShadowColor = ms.ShadowColor;
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
 public override void MergeWith(Style s)
 {
     if ((s != null) && !s.IsEmpty)
     {
         if (this.IsEmpty)
         {
             this.CopyFrom(s);
         }
         else
         {
             base.MergeWith(s);
             if (s is WebPartMenuStyle)
             {
                 WebPartMenuStyle style = (WebPartMenuStyle)s;
                 if (((s.RegisteredCssClass.Length == 0) && style.IsSet(0x200000)) && !base.IsSet(0x200000))
                 {
                     this.ShadowColor = style.ShadowColor;
                 }
             }
         }
     }
 }
Exemplo n.º 4
0
 public override void CopyFrom(Style s)
 {
     if ((s != null) && !s.IsEmpty)
     {
         base.CopyFrom(s);
         if (s is WebPartMenuStyle)
         {
             WebPartMenuStyle style = (WebPartMenuStyle)s;
             if (s.RegisteredCssClass.Length != 0)
             {
                 if (style.IsSet(0x200000))
                 {
                     base.ViewState.Remove("ShadowColor");
                     base.ClearBit(0x200000);
                 }
             }
             else if (style.IsSet(0x200000))
             {
                 this.ShadowColor = style.ShadowColor;
             }
         }
     }
 }
Exemplo n.º 5
0
        private void RenderMenuPopup(HtmlTextWriter writer, ICollection verbs, string clientID, WebPart associatedWebPart, WebPartManager webPartManager)
        {
            writer.AddAttribute(HtmlTextWriterAttribute.Id, clientID + "Menu");
            writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "none");
            writer.RenderBeginTag(HtmlTextWriterTag.Div);
            bool             isEmpty        = true;
            WebPartMenuStyle menuPopupStyle = this._menuUser.MenuPopupStyle;

            if (menuPopupStyle != null)
            {
                menuPopupStyle.AddAttributesToRender(writer, this._menuUser as WebControl);
                isEmpty = menuPopupStyle.Width.IsEmpty;
            }
            else
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
                writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "1");
                writer.AddStyleAttribute(HtmlTextWriterStyle.BorderCollapse, "collapse");
            }
            if (isEmpty)
            {
                writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "100%");
            }
            writer.RenderBeginTag(HtmlTextWriterTag.Table);
            writer.RenderBeginTag(HtmlTextWriterTag.Tr);
            writer.AddStyleAttribute(HtmlTextWriterStyle.WhiteSpace, "nowrap");
            writer.RenderBeginTag(HtmlTextWriterTag.Td);
            bool isEnabled = associatedWebPart.Zone.IsEnabled;

            foreach (WebPartVerb verb in verbs)
            {
                string description;
                writer.RenderBeginTag(HtmlTextWriterTag.Div);
                if (associatedWebPart != null)
                {
                    description = string.Format(CultureInfo.CurrentCulture, verb.Description, new object[] { associatedWebPart.DisplayTitle });
                }
                else
                {
                    description = verb.Description;
                }
                if (description.Length != 0)
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Title, description);
                }
                bool flag3 = isEnabled && verb.Enabled;
                if (verb is WebPartHelpVerb)
                {
                    string str2 = associatedWebPart.ResolveClientUrl(associatedWebPart.HelpUrl);
                    writer.AddAttribute(HtmlTextWriterAttribute.Href, "javascript:void(0)");
                    if (flag3)
                    {
                        writer.AddAttribute(HtmlTextWriterAttribute.Onclick, "document.body.__wpm.ShowHelp('" + Util.QuoteJScriptString(str2) + "', " + ((int)associatedWebPart.HelpMode).ToString(CultureInfo.InvariantCulture) + ")");
                    }
                }
                else if (verb is WebPartExportVerb)
                {
                    string exportUrl = webPartManager.GetExportUrl(associatedWebPart);
                    writer.AddAttribute(HtmlTextWriterAttribute.Href, "javascript:void(0)");
                    if (flag3)
                    {
                        writer.AddAttribute(HtmlTextWriterAttribute.Onclick, "document.body.__wpm.ExportWebPart('" + Util.QuoteJScriptString(exportUrl) + ((associatedWebPart.ExportMode == WebPartExportMode.All) ? "', true, false)" : "', false, false)"));
                    }
                }
                else
                {
                    string postBackTarget = this._menuUser.PostBackTarget;
                    writer.AddAttribute(HtmlTextWriterAttribute.Href, "javascript:void(0)");
                    if (flag3)
                    {
                        string eventArgument = verb.EventArgument;
                        if (associatedWebPart != null)
                        {
                            eventArgument = verb.GetEventArgument(associatedWebPart.ID);
                        }
                        string str6 = null;
                        if (!string.IsNullOrEmpty(eventArgument))
                        {
                            str6 = "document.body.__wpm.SubmitPage('" + Util.QuoteJScriptString(postBackTarget) + "', '" + Util.QuoteJScriptString(eventArgument) + "');";
                            this._menuUser.Page.ClientScript.RegisterForEventValidation(postBackTarget, eventArgument);
                        }
                        string str7 = null;
                        if (!string.IsNullOrEmpty(verb.ClientClickHandler))
                        {
                            str7 = "document.body.__wpm.Execute('" + Util.QuoteJScriptString(Util.EnsureEndWithSemiColon(verb.ClientClickHandler)) + "')";
                        }
                        string str8 = string.Empty;
                        if ((str6 != null) && (str7 != null))
                        {
                            str8 = "if(" + str7 + "){" + str6 + "}";
                        }
                        else if (str6 != null)
                        {
                            str8 = str6;
                        }
                        else if (str7 != null)
                        {
                            str8 = str7;
                        }
                        if (verb is WebPartCloseVerb)
                        {
                            ProviderConnectionPointCollection providerConnectionPoints = webPartManager.GetProviderConnectionPoints(associatedWebPart);
                            if (((providerConnectionPoints != null) && (providerConnectionPoints.Count > 0)) && webPartManager.Connections.ContainsProvider(associatedWebPart))
                            {
                                str8 = "if(document.body.__wpmCloseProviderWarning.length == 0 || confirm(document.body.__wpmCloseProviderWarning)){" + str8 + "}";
                            }
                        }
                        else if (verb is WebPartDeleteVerb)
                        {
                            str8 = "if(document.body.__wpmDeleteWarning.length == 0 || confirm(document.body.__wpmDeleteWarning)){" + str8 + "}";
                        }
                        writer.AddAttribute(HtmlTextWriterAttribute.Onclick, str8);
                    }
                }
                string str9 = "menuItem";
                if (!verb.Enabled)
                {
                    if (associatedWebPart.Zone.RenderingCompatibility < VersionUtil.Framework40)
                    {
                        writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled");
                    }
                    else if (!string.IsNullOrEmpty(WebControl.DisabledCssClass))
                    {
                        str9 = WebControl.DisabledCssClass + " " + str9;
                    }
                }
                writer.AddAttribute(HtmlTextWriterAttribute.Class, str9);
                writer.RenderBeginTag(HtmlTextWriterTag.A);
                string imageUrl = verb.ImageUrl;
                if (imageUrl.Length != 0)
                {
                    imageUrl = this._menuUser.UrlResolver.ResolveClientUrl(imageUrl);
                }
                else if (verb.Checked)
                {
                    imageUrl = this._menuUser.CheckImageUrl;
                    if (imageUrl.Length == 0)
                    {
                        imageUrl = DefaultCheckImageUrl;
                    }
                }
                else
                {
                    imageUrl = webPartManager.SpacerImageUrl;
                }
                writer.AddAttribute(HtmlTextWriterAttribute.Src, imageUrl);
                writer.AddAttribute(HtmlTextWriterAttribute.Alt, description, true);
                writer.AddAttribute(HtmlTextWriterAttribute.Width, "16");
                writer.AddAttribute(HtmlTextWriterAttribute.Height, "16");
                writer.AddStyleAttribute(HtmlTextWriterStyle.BorderStyle, "none");
                writer.AddStyleAttribute("vertical-align", "middle");
                if (verb.Checked)
                {
                    Style checkImageStyle = this._menuUser.CheckImageStyle;
                    if (checkImageStyle != null)
                    {
                        checkImageStyle.AddAttributesToRender(writer, this._menuUser as WebControl);
                    }
                }
                writer.RenderBeginTag(HtmlTextWriterTag.Img);
                writer.RenderEndTag();
                writer.Write("&nbsp;");
                writer.Write(verb.Text);
                writer.Write("&nbsp;");
                writer.RenderEndTag();
                writer.RenderEndTag();
            }
            writer.RenderEndTag();
            writer.RenderEndTag();
            writer.RenderEndTag();
            writer.RenderEndTag();
        }
        private void RenderMenuPopup(HtmlTextWriter writer, ICollection verbs, string clientID, WebPart associatedWebPart,
                                     WebPartManager webPartManager)
        {
            writer.AddAttribute(HtmlTextWriterAttribute.Id, clientID + "Menu");
            writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "none");
            writer.RenderBeginTag(HtmlTextWriterTag.Div);

            bool             popupSpansFullExtent = true;
            WebPartMenuStyle menuStyle            = _menuUser.MenuPopupStyle;

            if (menuStyle != null)
            {
                menuStyle.AddAttributesToRender(writer, _menuUser as WebControl);
                popupSpansFullExtent = menuStyle.Width.IsEmpty;
            }
            else
            {
                // generate attributes corresponding to defaults on WebPartMenuStyle
                writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
                writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "1");
                writer.AddStyleAttribute(HtmlTextWriterStyle.BorderCollapse, "collapse");
            }
            if (popupSpansFullExtent)
            {
                writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "100%");
            }
            writer.RenderBeginTag(HtmlTextWriterTag.Table);
            writer.RenderBeginTag(HtmlTextWriterTag.Tr);
            writer.AddStyleAttribute(HtmlTextWriterStyle.WhiteSpace, "nowrap");
            writer.RenderBeginTag(HtmlTextWriterTag.Td);

            bool isParentEnabled = associatedWebPart.Zone.IsEnabled;

            foreach (WebPartVerb verb in verbs)
            {
                Debug.Assert(verb != null);
                writer.RenderBeginTag(HtmlTextWriterTag.Div);

                string alt;
                if (associatedWebPart != null)
                {
                    alt = String.Format(CultureInfo.CurrentCulture, verb.Description, associatedWebPart.DisplayTitle);
                }
                else
                {
                    alt = verb.Description;
                }
                if (alt.Length != 0)
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Title, alt);
                }
                bool isEnabled = isParentEnabled && verb.Enabled;

                // Special case help, export, etc.
                if (verb is WebPartHelpVerb)
                {
                    Debug.Assert(associatedWebPart != null);

                    string resolvedHelpUrl =
                        ((IUrlResolutionService)associatedWebPart).ResolveClientUrl(associatedWebPart.HelpUrl);

                    writer.AddAttribute(HtmlTextWriterAttribute.Href, "javascript:void(0)");
                    if (isEnabled)
                    {
                        writer.AddAttribute(HtmlTextWriterAttribute.Onclick,
                                            "document.body.__wpm.ShowHelp('" +
                                            Util.QuoteJScriptString(resolvedHelpUrl) +
                                            "', " +
                                            ((int)associatedWebPart.HelpMode).ToString(CultureInfo.InvariantCulture) + ")");
                    }
                }
                else if (verb is WebPartExportVerb)
                {
                    Debug.Assert(associatedWebPart != null);

                    string exportUrl = webPartManager.GetExportUrl(associatedWebPart);

                    writer.AddAttribute(HtmlTextWriterAttribute.Href, "javascript:void(0)");
                    if (isEnabled)
                    {
                        writer.AddAttribute(HtmlTextWriterAttribute.Onclick,
                                            "document.body.__wpm.ExportWebPart('" +
                                            Util.QuoteJScriptString(exportUrl) +
                                            ((associatedWebPart.ExportMode == WebPartExportMode.All) ?
                                             "', true, false)" :
                                             "', false, false)"));
                    }
                }
                else
                {
                    string target = _menuUser.PostBackTarget;
                    writer.AddAttribute(HtmlTextWriterAttribute.Href, "javascript:void(0)");
                    if (isEnabled)
                    {
                        string eventArgument = verb.EventArgument;
                        if (associatedWebPart != null)
                        {
                            eventArgument = verb.GetEventArgument(associatedWebPart.ID);
                        }

                        string submitScript = null;
                        if (!String.IsNullOrEmpty(eventArgument))
                        {
                            submitScript = "document.body.__wpm.SubmitPage('" +
                                           Util.QuoteJScriptString(target) +
                                           "', '" +
                                           Util.QuoteJScriptString(eventArgument) +
                                           "');";

                            _menuUser.Page.ClientScript.RegisterForEventValidation(target, eventArgument);
                        }

                        string clientClickScript = null;
                        if (!String.IsNullOrEmpty(verb.ClientClickHandler))
                        {
                            clientClickScript = "document.body.__wpm.Execute('" +
                                                Util.QuoteJScriptString(Util.EnsureEndWithSemiColon(verb.ClientClickHandler)) +
                                                "')";
                        }

                        // There must be either an EventArgument or a ClientClickHandler
                        Debug.Assert(submitScript != null || clientClickScript != null);

                        string onclick = String.Empty;
                        if (submitScript != null && clientClickScript != null)
                        {
                            onclick = "if(" + clientClickScript + "){" + submitScript + "}";
                        }
                        else if (submitScript != null)
                        {
                            onclick = submitScript;
                        }
                        else if (clientClickScript != null)
                        {
                            onclick = clientClickScript;
                        }

                        if (verb is WebPartCloseVerb)
                        {
                            Debug.Assert(associatedWebPart != null);

                            // PERF: First check if this WebPart even has provider connection points
                            ProviderConnectionPointCollection connectionPoints =
                                webPartManager.GetProviderConnectionPoints(associatedWebPart);
                            if (connectionPoints != null && connectionPoints.Count > 0 &&
                                webPartManager.Connections.ContainsProvider(associatedWebPart))
                            {
                                onclick = "if(document.body.__wpmCloseProviderWarning.length == 0 || " +
                                          "confirm(document.body.__wpmCloseProviderWarning)){" + onclick + "}";
                            }
                        }
                        else if (verb is WebPartDeleteVerb)
                        {
                            onclick = "if(document.body.__wpmDeleteWarning.length == 0 || " +
                                      "confirm(document.body.__wpmDeleteWarning)){" + onclick + "}";
                        }
                        writer.AddAttribute(HtmlTextWriterAttribute.Onclick, onclick);
                    }
                }

                string disabledClass = "menuItem";
                if (!verb.Enabled)
                {
                    if (associatedWebPart.Zone.RenderingCompatibility < VersionUtil.Framework40)
                    {
                        writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled");
                    }
                    else if (!String.IsNullOrEmpty(WebControl.DisabledCssClass))
                    {
                        disabledClass = WebControl.DisabledCssClass + " " + disabledClass;
                    }
                }
                writer.AddAttribute(HtmlTextWriterAttribute.Class, disabledClass);
                writer.RenderBeginTag(HtmlTextWriterTag.A);

                string img = verb.ImageUrl;
                if (img.Length != 0)
                {
                    img = _menuUser.UrlResolver.ResolveClientUrl(img);
                }
                else
                {
                    if (verb.Checked)
                    {
                        img = _menuUser.CheckImageUrl;
                        if (img.Length == 0)
                        {
                            img = DefaultCheckImageUrl;
                        }
                    }
                    else
                    {
                        img = webPartManager.SpacerImageUrl;
                    }
                }
                writer.AddAttribute(HtmlTextWriterAttribute.Src, img);
                writer.AddAttribute(HtmlTextWriterAttribute.Alt, alt, true);
                writer.AddAttribute(HtmlTextWriterAttribute.Width, "16");
                writer.AddAttribute(HtmlTextWriterAttribute.Height, "16");
                writer.AddStyleAttribute(HtmlTextWriterStyle.BorderStyle, "none");
                writer.AddStyleAttribute("vertical-align", "middle");
                if (verb.Checked)
                {
                    Style checkImageStyle = _menuUser.CheckImageStyle;
                    if (checkImageStyle != null)
                    {
                        checkImageStyle.AddAttributesToRender(writer, _menuUser as WebControl);
                    }
                }
                writer.RenderBeginTag(HtmlTextWriterTag.Img);
                writer.RenderEndTag();  // Img

                writer.Write("&nbsp;");
                writer.Write(verb.Text);
                writer.Write("&nbsp;");

                writer.RenderEndTag();  // A

                writer.RenderEndTag();  // Div
            }

            writer.RenderEndTag();  // Td
            writer.RenderEndTag();  // Tr
            writer.RenderEndTag();  // Table

            writer.RenderEndTag();  // Div
        }