Esempio n. 1
0
        public override void RenderData(TableCell container, string data)
        {
            if (container == null)
            {
                throw new ArgumentNullException("container");
            }

            string buttonText = string.IsNullOrEmpty(data) ? Text : data;

            if (string.IsNullOrEmpty(buttonText))
            {
                buttonText = string.Empty;
            }

            if (ButtonType == GridViewColumnButtonType.Link)
            {
                if (!string.IsNullOrEmpty(buttonText))
                {
                    HyperLink link = new HyperLink();
                    link.Text        = buttonText;
                    link.NavigateUrl = "javascript:void(0)";
                    container.Controls.Add(link);
                    link.ApplyStyle(ControlStyle);
                }
            }
            else if (ButtonType == GridViewColumnButtonType.Image)
            {
                Image img = new Image();
                img.AlternateText = buttonText;

                if (!string.IsNullOrEmpty(ImageUrl))
                {
                    img.ImageUrl = Owner.ResolveClientUrl(ImageUrl);
                }

                container.Controls.Add(img);
                img.ApplyStyle(ControlStyle);
            }
            else
            {
                Button button = new Button();
                button.Text = buttonText;
                container.Controls.Add(button);
                button.ApplyStyle(ControlStyle);
            }

            container.ApplyStyle(ItemStyle);
        }
        public override void RenderData(TableCell container, string data)
        {
            if (container == null)
            {
                throw new ArgumentNullException("container");
            }

            string buttonText = string.IsNullOrEmpty(Text) ? data : Text;

            HyperLink link = new HyperLink();

            link.Text        = buttonText;
            link.NavigateUrl = "javascript:void(0)";
            container.Controls.Add(link);
            link.ApplyStyle(ControlStyle);

            container.ApplyStyle(ItemStyle);
        }
Esempio n. 3
0
        protected override void Render(HtmlTextWriter writer)
        {
            for (int i = 0; i < Items.Count; i++)
            {
                HyperLink control = RepeateControl;

                // Присвоение ссылке стилей контрола HyperLinkList.
                control.ApplyStyle(this.ControlStyle);

                // Items - элементы которые добавлены в список через дизайнер или через код.
                control.NavigateUrl = Items[i].Value;
                control.Text        = Items[i].Text;

                // Вывод ссылки в HtmlTextWriter
                control.RenderControl(writer);

                writer.Write("<br />");
            }
        }
Esempio n. 4
0
        private Control CreateButton(string text, string imageUrl)
        {
            Control button;

            if (ButtonType == GridViewColumnButtonType.Link)
            {
                HyperLink link = new HyperLink();
                link.Text        = text;
                link.NavigateUrl = "javascript:void(0)";
                link.ApplyStyle(ControlStyle);

                button = link;
            }
            else if (ButtonType == GridViewColumnButtonType.Image)
            {
                ImageButton imageButton = new ImageButton();

                imageButton.AlternateText = text;

                if (!string.IsNullOrEmpty(imageUrl))
                {
                    imageButton.ImageUrl = Owner.ResolveClientUrl(imageUrl);
                }

                imageButton.ApplyStyle(ControlStyle);

                button = imageButton;
            }
            else
            {
                Button regularButton = new Button();
                regularButton.Text = text;
                regularButton.ApplyStyle(ControlStyle);

                button = regularButton;
            }

            return(button);
        }
Esempio n. 5
0
        protected override void CreateChildControls()
        {
            this.Controls.Clear();

            if (this.DesignMode)
            {
                return;
            }
            //=====================================================================================
            // LAYOUT
            //=====================================================================================
            IEnumerable dataSource = null;

            Link[]   links       = null;
            string[] columnNames = null;
            string   title       = String.Empty;

            switch (this.State)
            {
            case ForumState.ViewBoard:
                Board board = ForumManager.GetBoard(this.BoardID);
                if (board != null)
                {
                    title      = board.Name;
                    dataSource = ForumManager.GetForums(this.BoardID);
                    links      = new Link[]
                    {
                        new Link {
                            Text = board.Name, Url = String.Format("{0}?b={1}", this.ForumRootUrl, board.ID)
                        }
                    };
                    columnNames = new string[] { "Forums", "Topics", "Replies", "Last Post" };
                }
                break;

            case ForumState.ViewForum:
            case ForumState.AddTopic:
                Forum forum = ForumManager.GetForum(this.ForumID);
                if (forum != null)
                {
                    title      = forum.Title;
                    dataSource = ForumManager.GetTopics(this.ForumID, this.StartIndex, 10);
                    links      = new Link[]
                    {
                        new Link {
                            Text = forum.Board.Name, Url = String.Format("{0}?b={1}", this.ForumRootUrl, forum.Board.ID)
                        },
                        new Link {
                            Text = forum.Title, Url = String.Format("{0}?f={1}", this.ForumRootUrl, forum.ID)
                        }
                    };
                    columnNames = new string[] { "Topics", "Authors", "Replies", "Views", "Last Post" };
                }
                break;

            case ForumState.ViewTopic:
            case ForumState.AddReply:
                Topic topic = ForumManager.GetTopic(this.TopicID);
                if (topic != null)
                {
                    ForumManager.UpdateTopicViewCount(this.TopicID);
                    title = topic.Title;
                    List <Post> replies = ForumManager.GetReplies(this.TopicID, this.StartIndex, 10).Cast <Post>().ToList();
                    replies.Insert(0, topic as Post);
                    dataSource = replies;
                    links      = new Link[]
                    {
                        new Link {
                            Text = topic.Forum.Board.Name, Url = String.Format("{0}?b={1}", this.ForumRootUrl, topic.Forum.Board.ID)
                        },
                        new Link {
                            Text = topic.Forum.Title, Url = String.Format("{0}?f={1}", this.ForumRootUrl, topic.Forum.ID)
                        },
                        new Link {
                            Text = topic.Title, Url = String.Format("{0}?t={1}", this.ForumRootUrl, topic.ID)
                        }
                    };
                    columnNames = new string[] { "Author", "Message" };
                }
                break;

            case ForumState.AllBoards:
                // AllBoards
                title       = "Lionsguard Community";
                dataSource  = ForumManager.GetBoards();
                links       = null;
                columnNames = new string[] { "Boards" };
                break;
            }

            if (dataSource == null)
            {
                try
                {
                    this.Page.Response.Redirect(this.ForumRootUrl);
                }
                catch (System.Threading.ThreadAbortException) { }
            }


            this.Page.Title = title;

            //-------------------------------------------------------------------------------------
            // Breacrumbs
            //-------------------------------------------------------------------------------------
            this.CreateBreadCrumbsControls(links);

            //-------------------------------------------------------------------------------------
            // Header
            //-------------------------------------------------------------------------------------
            this.Controls.Add(new LiteralControl(String.Format("<h1>{0}</h1>", title)));

            //-------------------------------------------------------------------------------------
            // RSS
            //-------------------------------------------------------------------------------------
            if (!String.IsNullOrEmpty(this.RssHandlerUrl))
            {
                HyperLink rssLink = new HyperLink();
                rssLink.ApplyStyle(this.RssLinkStyle);
                rssLink.NavigateUrl = this.RssHandlerUrl;
                if (!String.IsNullOrEmpty(this.RssIconUrl))
                {
                    rssLink.ImageUrl = this.RssIconUrl;
                }
                this.Controls.Add(rssLink);
            }

            //-------------------------------------------------------------------------------------
            // Alerts
            //-------------------------------------------------------------------------------------
            if (!String.IsNullOrEmpty(this.AlertMessage))
            {
                Panel pnlAlerts = new Panel();
                switch (this.AlertType)
                {
                case ForumAlertType.Success:
                    pnlAlerts.ApplyStyle(this.AlertStyleSuccess);
                    break;

                case ForumAlertType.Error:
                    pnlAlerts.ApplyStyle(this.AlertStyleError);
                    break;
                }
                pnlAlerts.Controls.Add(new LiteralControl(this.AlertMessage));
                this.Controls.Add(pnlAlerts);
            }

            //-------------------------------------------------------------------------------------
            // CONTENT
            //-------------------------------------------------------------------------------------
            this.CreateContentControls(dataSource, columnNames);

            // TODO: Send PM Link, RSS Link, Delicious, Kick

            //-------------------------------------------------------------------------------------
            // Stats/Legend
            //=====================================================================================
        }
Esempio n. 6
0
        protected virtual void InitializeItem(SiteMapNodeItem item)
        {
            switch (item.ItemType)
            {
            case SiteMapNodeItemType.Root:
                if (RootNodeTemplate != null)
                {
                    item.ApplyStyle(NodeStyle);
                    item.ApplyStyle(RootNodeStyle);
                    RootNodeTemplate.InstantiateIn(item);
                }
                else if (NodeTemplate != null)
                {
                    item.ApplyStyle(NodeStyle);
                    item.ApplyStyle(RootNodeStyle);
                    NodeTemplate.InstantiateIn(item);
                }
                else
                {
                    WebControl c = CreateHyperLink(item);
                    c.ApplyStyle(NodeStyle);
                    c.ApplyStyle(RootNodeStyle);
                    item.Controls.Add(c);
                }
                break;

            case SiteMapNodeItemType.Current:
                if (CurrentNodeTemplate != null)
                {
                    item.ApplyStyle(NodeStyle);
                    item.ApplyStyle(CurrentNodeStyle);
                    CurrentNodeTemplate.InstantiateIn(item);
                }
                else if (NodeTemplate != null)
                {
                    item.ApplyStyle(NodeStyle);
                    item.ApplyStyle(CurrentNodeStyle);
                    NodeTemplate.InstantiateIn(item);
                }
                else if (RenderCurrentNodeAsLink)
                {
                    HyperLink c = CreateHyperLink(item);
                    c.ApplyStyle(NodeStyle);
                    c.ApplyStyle(CurrentNodeStyle);
                    item.Controls.Add(c);
                }
                else
                {
                    Literal c = CreateLiteral(item);
                    item.ApplyStyle(NodeStyle);
                    item.ApplyStyle(CurrentNodeStyle);
                    item.Controls.Add(c);
                }
                break;

            case SiteMapNodeItemType.Parent:
                if (NodeTemplate != null)
                {
                    item.ApplyStyle(NodeStyle);
                    NodeTemplate.InstantiateIn(item);
                }
                else
                {
                    WebControl c = CreateHyperLink(item);
                    c.ApplyStyle(NodeStyle);
                    item.Controls.Add(c);
                }
                break;

            case SiteMapNodeItemType.PathSeparator:
                if (PathSeparatorTemplate != null)
                {
                    item.ApplyStyle(PathSeparatorStyle);
                    PathSeparatorTemplate.InstantiateIn(item);
                }
                else
                {
                    Literal h = new Literal();
                    h.Text = PathSeparator;
                    item.ApplyStyle(PathSeparatorStyle);
                    item.Controls.Add(h);
                }
                break;
            }
        }