Beispiel #1
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.PreRender"/> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs"/> object that contains the event data.</param>
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            Page.RegisterRequiresPostBack(this);

            Script.AddResourceScript(Page, "jquery.ui.button.js");
            List<string> opts = new List<string>();

            if(!string.IsNullOrEmpty(CustomIconFile))
            {
                AdvStyle s = new AdvStyle();
                s.BackgroundImageUrl = CustomIconFile;
                if(Toggle)
                    Page.Header.StyleSheet.CreateStyleRule(s, this, "#" + ClientID + " + .ui-state-default .ui-icon");
                else
                    Page.Header.StyleSheet.CreateStyleRule(s, this, "#" + ClientID + ".ui-state-default .ui-icon");
            }

            if(!string.IsNullOrEmpty(CustomHoverIconFile))
            {
                AdvStyle s = new AdvStyle();
                s.BackgroundImageUrl = CustomHoverIconFile;
                if(Toggle)
                {
                    Page.Header.StyleSheet.CreateStyleRule(s, this, "#" + ClientID + " + .ui-state-hover .ui-icon");
                    Page.Header.StyleSheet.CreateStyleRule(s, this, "#" + ClientID + " + .ui-state-focus .ui-icon");
                }
                else
                {
                    Page.Header.StyleSheet.CreateStyleRule(s, this, "#" + ClientID + ".ui-state-hover .ui-icon");
                    Page.Header.StyleSheet.CreateStyleRule(s, this, "#" + ClientID + ".ui-state-focus .ui-icon");
                }
            }

            if(!ShowText)
                opts.Add("text:false");

            if(Toggle)
            {
                if(!Postback && (Text != ActiveText || Primary != ActivePrimary || Secondary != ActiveSecondary))
                {
                    List<string> actOpts = CalcOpts(ActiveText, ActivePrimary, ActiveSecondary);
                    List<string> natOpts = CalcOpts(Text, Primary, Secondary);

                    if(Active)
                        opts.AddRange(actOpts);
                    else
                        opts.AddRange(natOpts);

                    StringBuilder sb = new StringBuilder();
                    sb.AppendFormat("$(\"#{0}\").button({{{1}}})", ClientID, string.Join(",", opts));
                    sb.AppendFormat(".click(function(){{var opts;var act;if($(this).text()==\"{0}\"){{opts={{{1}}};act=true;}}else{{opts={{{2}}};act=false;}}$(this).button(\"option\",opts);$(\"#{3}_act\").val(act);return false;}});",
                        Text, string.Join(",", actOpts), string.Join(",", natOpts), UniqueID);
                    Script.AddStartupScript(this, ClientID + "_tog", sb.ToString());

                    Page.ClientScript.RegisterHiddenField(UniqueID + "_act", Active.ToString().ToLower());
                    return;
                }
                else
                {
                    if(Active)
                        opts.AddRange(CalcOpts(ActiveText, ActivePrimary, ActiveSecondary));
                    else
                        opts.AddRange(CalcOpts(Text, Primary, Secondary));
                }
            }
            else
            {
                opts.AddRange(CalcOpts(null, Primary, Secondary));
            }

            Script.AddStartupScript(this, ClientID, "button", opts);
        }
Beispiel #2
0
        ///
        protected override void OnPreRender(System.EventArgs e)
        {
            Util.RegisterStyle(this, NodeStyle, "NodeStyle");
            Util.RegisterStyle(this, HoverNodeStyle, "HoverStyle");
            Util.RegisterStyle(this, SelectedNodeStyle, "SelectedStyle");

            _bgdStyle = new AdvStyle();
            _bgdStyle.BackgroundImagePosition = BackgroundPosition.LeftCenter;
            _bgdStyle.BackgroundImageRepeat = BackgroundRepeat.RepeatY;
            Page.Header.StyleSheet.RegisterStyle(_bgdStyle, this);

            _bgdPadStyle = new AdvStyle(this.ViewState);
            _bgdPadStyle.PaddingLeft = Unit.Pixel(16);
            _bgdPadStyle.BackgroundImagePosition = BackgroundPosition.LeftCenter;
            _bgdPadStyle.BackgroundImageRepeat = BackgroundRepeat.RepeatY;
            Page.Header.StyleSheet.RegisterStyle(_bgdPadStyle, this);

            Script.AddResourceScript(Page, "TreeView.js");
            ScriptManager.RegisterExpandoAttribute(this, ClientID, "CBoxImg", Page.ClientScript.GetWebResourceUrl(this.GetType(), "ESWCtrls.ResEmbed.Gfxs.tree.cbox.gif"), true);
            ScriptManager.RegisterExpandoAttribute(this, ClientID, "EBoxImg", Page.ClientScript.GetWebResourceUrl(this.GetType(), "ESWCtrls.ResEmbed.Gfxs.tree.ebox.gif"), true);
            ScriptManager.RegisterExpandoAttribute(this, ClientID, "SelectMode", SelectMode.ToString(), false);

            if(SelectMode != SelectMode.None)
            {

                if(SelectMode == SelectMode.Single | SelectMode == SelectMode.SinglePostback)
                {
                    if(Nodes.Selected().Count > 0)
                        ScriptManager.RegisterHiddenField(Page, ClientID + "_selected", Nodes.Selected()[0].InternalID);
                    else
                        ScriptManager.RegisterHiddenField(Page, ClientID + "_selected", "");
                }
            }

            if(_clientEvents != null) _clientEvents.OnPreRender(this);
            Nodes.OnPreRender(this);

            base.OnPreRender(e);
        }
Beispiel #3
0
        ///
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            Script.AddResourceScript(Page, "jquery.dropdownmenu.js");

            List<string> opts = new List<string>();

            if(!ItemStyle.IsEmpty)
                opts.Add(string.Format("itemClass:\"{0}\"", ItemStyle.RenderClass));

            if(!OpenStyle.IsEmpty)
                opts.Add(string.Format("openClass:\"{0}\"", OpenStyle.RenderClass));

            if(!HoverStyle.IsEmpty)
                opts.Add(string.Format("hoverClass:\"{0}\"", HoverStyle.RenderClass));

            if(!TopItemStyle.IsEmpty)
                opts.Add(string.Format("topItemClass:\"{0}\"", TopItemStyle.RenderClass));

            if(!TopHoverStyle.IsEmpty)
                opts.Add(string.Format("topHoverClass:\"{0}\"", TopHoverStyle.RenderClass));

            if(!DisabledStyle.IsEmpty)
                opts.Add(string.Format("disabledClass:\"{0}\"", DisabledStyle.RenderClass));

            if(ArrowDisplay != ArrowDisplayType.None)
                opts.Add(string.Format("arrowDisplayType:\"{0}\"", ArrowDisplay.ToString().ToLower()));

            if(!string.IsNullOrEmpty(DownArrowImage))
                opts.Add(string.Format("arrowDown:{{image:\"{0}\",cssClass:\"{1}\"}}", Page.ResolveUrl(DownArrowImage), DownArrowStyle.RenderClass));

            if(!string.IsNullOrEmpty(RightArrowImage))
                opts.Add(string.Format("arrowRight:{{image:\"{0}\",cssClass:\"{1}\"}}", Page.ResolveUrl(RightArrowImage), RightArrowStyle.RenderClass));

            if(ShowEffect != null)
                opts.Add("showEffect:" + ShowEffect.Render(Page));

            if(HideEffect != null)
                opts.Add("hideEffect:" + HideEffect.Render(Page));

            Script.AddStartupScript(this, ClientID, "ls_dropmenu", opts);

            AdvStyle style = new AdvStyle();
            style.Display = Display.None;
            style.Position = ElementPosition.Absolute;
            Page.Header.StyleSheet.CreateStyleRule(style, this, string.Format("#{0} li ul", ClientID));
        }
Beispiel #4
0
        /// <summary>
        /// Fills this style with the values from another
        /// </summary>
        /// <param name="s">The style to copy from</param>
        public override void CopyFrom(AdvStyle s)
        {
            if(s != null & !s.IsEmpty)
            {
                base.CopyFrom(s);
                if(s.RegisteredCssClass.Length != 0)
                {
                    if(!string.IsNullOrEmpty(s.BackgroundImageUrl))
                        ViewState.Remove("BackImageUrl");

                    if(s.BackgroundImagePosition != BackgroundPosition.NotSet)
                        ViewState.Remove("BackImagePos");

                    if(s.BackgroundImageRepeat != BackgroundRepeat.NotSet)
                        ViewState.Remove("BackImageRepeat");

                    if(s.ZIndex != 0)
                        ViewState.Remove("zIndex");

                    if(s.Display != Display.NotSet)
                        ViewState.Remove("Display");

                    if(s.Position != ElementPosition.NotSet)
                        ViewState.Remove("Position");

                    if(!s.Left.IsEmpty)
                        ViewState.Remove("Left");

                    if(!s.Right.IsEmpty)
                        ViewState.Remove("Right");

                    if(!s.Top.IsEmpty)
                        ViewState.Remove("Top");

                    if(!s.Bottom.IsEmpty)
                        ViewState.Remove("Bottom");

                    if(s.Opacity != 1.0f)
                        ViewState.Remove("Opacity");

                    if(s.Float != ElementFloat.NotSet)
                        ViewState.Remove("Float");

                    if(s.ListStyleType != ListStyleType.NotSet)
                        ViewState.Remove("ListStyleType");

                    if(s.ListStylePosition != ListStylePosition.NotSet)
                        ViewState.Remove("ListStylePosition");

                    if(!string.IsNullOrEmpty(ListStyleImage))
                        ViewState.Remove("ListStyleImage");
                }
                else
                {
                    if(!string.IsNullOrEmpty(s.BackgroundImageUrl))
                        BackgroundImageUrl = s.BackgroundImageUrl;

                    if(s.BackgroundImagePosition != BackgroundPosition.NotSet)
                        BackgroundImagePosition = s.BackgroundImagePosition;

                    if(s.BackgroundImageRepeat != BackgroundRepeat.NotSet)
                        BackgroundImageRepeat = s.BackgroundImageRepeat;

                    if(s.ZIndex != 0)
                        ZIndex = s.ZIndex;

                    if(s.Display != Display.NotSet)
                        Display = s.Display;

                    if(s.Position != ElementPosition.NotSet)
                        Position = s.Position;

                    if(!s.Left.IsEmpty)
                        Left = s.Left;

                    if(!s.Right.IsEmpty)
                        Right = s.Right;

                    if(!s.Top.IsEmpty)
                        Top = s.Top;

                    if(!s.Bottom.IsEmpty)
                        Bottom = s.Bottom;

                    if(s.Opacity != 1.0f)
                        Opacity = s.Opacity;

                    if(s.Float != ElementFloat.NotSet)
                        Float = s.Float;

                    if(s.ListStyleType != ListStyleType.NotSet)
                        ListStyleType = s.ListStyleType;

                    if(s.ListStylePosition != ListStylePosition.NotSet)
                        ListStylePosition = s.ListStylePosition;

                    if(!string.IsNullOrEmpty(s.ListStyleImage))
                        ListStyleImage = s.ListStyleImage;
                }
            }
        }
Beispiel #5
0
        ///
        protected override void OnPreRender(EventArgs e)
        {
            if(!ItemStyle.IsEmpty)
                Page.Header.StyleSheet.RegisterStyle(ItemStyle, this);
            if(!OpenStyle.IsEmpty)
                Page.Header.StyleSheet.RegisterStyle(OpenStyle, this);
            if(!HoverStyle.IsEmpty)
                Page.Header.StyleSheet.RegisterStyle(HoverStyle, this);
            if(!TopItemStyle.IsEmpty)
                Page.Header.StyleSheet.RegisterStyle(TopItemStyle, this);
            if(!TopHoverStyle.IsEmpty)
                Page.Header.StyleSheet.RegisterStyle(TopHoverStyle, this);
            if(!DisabledStyle.IsEmpty)
                Page.Header.StyleSheet.RegisterStyle(DisabledStyle, this);

            Items.OnPreRender();

            AdvStyle style = new AdvStyle();
            style.ListStyleType = ListStyleType.None;
            Page.Header.StyleSheet.CreateStyleRule(style, this, string.Format("#{0}, #{0} ul", ClientID));

            base.OnPreRender(e);
        }
Beispiel #6
0
        ///
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            if (!UsejQueryStyle && TabStyle != TabStyle.jQuery)
            {
                if (_activeTabStyle != null && !_activeTabStyle.IsEmpty)
                    Page.Header.StyleSheet.RegisterStyle(ActiveTabStyle, this);
                if (_activeTabStyle != null && !_inactiveTabStyle.IsEmpty)
                    Page.Header.StyleSheet.RegisterStyle(InactiveTabStyle, this);

                if (!string.IsNullOrEmpty(ActiveTabStyle.BackImage))
                {
                    _leftGfxAct = new TabGfx(Page.Server.MapPath(ActiveTabStyle.BackImage), ActiveTabStyle.ImageLeftSize, false);
                    _rightGfxAct = new TabGfx(Page.Server.MapPath(ActiveTabStyle.BackImage), ActiveTabStyle.ImageRightSize, true);
                    _midGfxAct = new TabGfx(Page.Server.MapPath(ActiveTabStyle.BackImage), 1, false);

                    _leftGfxInact = new TabGfx(Page.Server.MapPath(InactiveTabStyle.BackImage), InactiveTabStyle.ImageLeftSize, false);
                    _rightGfxInact = new TabGfx(Page.Server.MapPath(InactiveTabStyle.BackImage), InactiveTabStyle.ImageRightSize, true);
                    _midGfxInact = new TabGfx(Page.Server.MapPath(InactiveTabStyle.BackImage), 1, false);
                }

                AdvStyle style = new AdvStyle();
                style.ListStyleType = ListStyleType.None;
                style.PaddingLeft = new Unit("0");
                Page.Header.StyleSheet.CreateStyleRule(style, this, string.Format("#{0}_tabbar", ClientID));
                style = new AdvStyle();
                style.Float = ElementFloat.Left;
                Page.Header.StyleSheet.CreateStyleRule(style, this, string.Format("#{0}_tabbar li", ClientID));

            }

            if (TabStyle == TabStyle.ClientSide)
            {
                Script.AddResourceScript(Page, "jquery.tabctrl.js");

                List<string> opts = new List<string>();

                if (UsejQueryStyle)
                {
                    opts.Add("activeClass:\"ui-state-default ui-corner-top ui-tabs-selected ui-state-active\"");
                    opts.Add("inactiveClass:\"ui-state-default ui-corner-top\"");
                }
                else
                {
                    if (!string.IsNullOrEmpty(ActiveTabStyle.BackImage))
                    {
                        opts.Add("useImages:true");
                        opts.Add(string.Format("left:{{active:\"{0}\",inactive:\"{1}\"}}", _leftGfxAct.FullPath, _leftGfxInact.FullPath));
                        opts.Add(string.Format("middle:{{active:\"{0}\",inactive:\"{1}\"}}", _midGfxAct.FullPath, _midGfxInact.FullPath));
                        opts.Add(string.Format("right:{{active:\"{0}\",inactive:\"{1}\"}}", _rightGfxAct.FullPath, _rightGfxInact.FullPath));
                    }

                    opts.Add("activeClass:\"" + ActiveTabStyle.RenderClass + "\"");
                    opts.Add("inactiveClass:\"" + InactiveTabStyle.RenderClass + "\"");
                }

                Script.AddStartupScript(this, ClientID, "ls_tabctrl", opts);
                ScriptManager.RegisterHiddenField(Page, ClientID + "_actIdx", ActivePageIndex.ToString());
            }
            else if (TabStyle == TabStyle.jQuery)
            {
                Script.AddResourceScript(Page, "jquery.ui.tabs.js");

                List<string> opts = new List<string>();

                if (!Enabled)
                    opts.Add("disabled:true");
                if (Collapsible)
                    opts.Add("collapsible:true");
                if (SortOrder.IndexOf(ActivePageIndex) != 0)
                    opts.Add(string.Format("selected:{0}", SortOrder.IndexOf(ActivePageIndex)));

                opts.Add(string.Format("select:function(event,ui) {{ $(\"#{0}_actIdx\").val($(ui.tab).attr(\"oa\")); }}", ClientID));

                Script.AddStartupScript(this, ClientID, "tabs", opts);
                ScriptManager.RegisterHiddenField(Page, ClientID + "_actIdx", ActivePageIndex.ToString());
            }

            if (Sortable)
            {
                Script.AddResourceScript(Page, "jquery.ui.sortable.js");
                StringBuilder sb = new StringBuilder();
                sb.Append("axis:\"x\",delay:300,containment:\"parent\",stop:function(event,ui){");
                sb.Append("var hid=$(\"#\"+$(this).attr(\"id\").replace(\"tabbar\",\"order\"));");
                sb.Append("var ord=\"\";");
                sb.Append("$(this).find(\"a\").each(function(){ord+=$(this).attr(\"oa\")+\";\";});");
                sb.Append("ord=ord.slice(0,-1);");
                sb.Append("hid.val(ord);");
                sb.Append("}");
                Script.AddStartupScript(this, ClientID + "_sort", string.Format("$(\"#{0}_tabbar\").sortable({{{1}}});", ClientID, sb.ToString()));
                sb.Clear();
                sb.Append(string.Join(";", SortOrder));
                ScriptManager.RegisterHiddenField(Page, ClientID + "_order", sb.ToString());
            }

            foreach (TabPage page in Pages)
                page.PreRender();
        }
Beispiel #7
0
        /// <summary>
        /// Fills this style with the values from another
        /// </summary>
        /// <param name="s">The style to copy from</param>
        public virtual void CopyFrom(AdvStyle s)
        {
            if(s != null & !s.IsEmpty)
            {
                base.CopyFrom(s);
                if(s.RegisteredCssClass.Length != 0)
                {
                    if(!s.PaddingTop.IsEmpty)
                        ViewState.Remove(STR_PADTOP);

                    if(!s.PaddingBottom.IsEmpty)
                        ViewState.Remove(STR_PADBOT);

                    if(!s.PaddingLeft.IsEmpty)
                        ViewState.Remove(STR_PADLEFT);

                    if(!s.PaddingRight.IsEmpty)
                        ViewState.Remove(STR_PADRIGHT);
                }
                else
                {
                    if(!s.PaddingTop.IsEmpty)
                        PaddingTop = s.PaddingTop;

                    if(!s.PaddingBottom.IsEmpty)
                        PaddingTop = s.PaddingBottom;

                    if(!s.PaddingLeft.IsEmpty)
                        PaddingTop = s.PaddingLeft;

                    if(!s.PaddingRight.IsEmpty)
                        PaddingTop = s.PaddingRight;
                }
            }
        }