/// <summary>
        /// Outputs some navigation links to the page.
        /// </summary>
        /// <param name="controlCollection">the pages' contols</param>
        /// <param name="path">The path of the current image directory being browsed</param>
        /// <param name="url">The URL to use in the links</param>
        public static void RendenderLinkPath(System.Web.UI.ControlCollection controlCollection, string path, System.Web.UI.Control ctrl, ImageBrowserConfig cfg)
        {
            HyperLink h = null;
            Literal   l = null;

            if (path != null && path.Length > 0)
            {
                path = path.Replace(@"\", "/");
            }
            else
            {
                h             = new HyperLink();
                h.NavigateUrl = "";
                h.Text        = cfg.RootName;
                h.Attributes.Add("class", "LinkButton");
                controlCollection.Add(h);
                return;
            }

            string[] paths = path.Split('/');

            paths[0] = cfg.RootName;

            for (int i = 1; i <= paths.Length; i++)
            {
                if (i < paths.Length)
                {
                    h             = new HyperLink();
                    h.NavigateUrl = ctrl.Page.GetPostBackClientHyperlink(ctrl, "directory;" + string.Join("/", paths, 0, i).Replace(cfg.RootName, ""));
                    h.Text        = paths[i - 1];
                    h.Attributes.Add("class", "LinkButton");
                    controlCollection.Add(h);

                    l      = new Literal();
                    l.Text = " &raquo; \n";
                    controlCollection.Add(l);
                }
                else
                {
                    h             = new HyperLink();
                    h.NavigateUrl = "";
                    h.Text        = paths[i - 1];
                    h.Attributes.Add("class", "LinkButton");
                    controlCollection.Add(h);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Outputs some navigation links to the page.
        /// </summary>
        /// <param name="controlCollection">the pages' contols</param>
        /// <param name="path">The path of the current image directory being browsed</param>
        /// <param name="url">The URL to use in the links</param>
        public static void RendenderLinkPath(System.Web.UI.ControlCollection controlCollection, string path, string url)
        {
            HyperLink h = new HyperLink();

            h.NavigateUrl = "/";
            h.Text        = "Home";
            h.Attributes.Add("class", "topNav");
            controlCollection.Add(h);

            Literal l = new Literal();

            l.Text = " &raquo; \n";
            controlCollection.Add(l);

            if (path != null && path.Length > 0)
            {
                path = path.Replace(@"\", "/");
            }
            else
            {
                Literal label = new Literal();
                label.Text = "My Pictures";
                controlCollection.Add(label);
                return;
            }

            string[] paths = path.Split('/');

            paths[0] = "My Pictures";

            for (int i = 1; i <= paths.Length; i++)
            {
                if (i < paths.Length)
                {
                    h             = new HyperLink();
                    h.NavigateUrl = url + string.Join("/", paths, 0, i).Replace("My Pictures", "/pics");
                    h.Text        = paths[i - 1];
                    h.Attributes.Add("class", "topNav");
                    controlCollection.Add(h);

                    l      = new Literal();
                    l.Text = " &raquo; \n";
                    controlCollection.Add(l);
                }
                else
                {
                    Literal label = new Literal();
                    label.Text = paths[i - 1];
                    controlCollection.Add(label);
                }
            }
        }
Beispiel #3
0
        public System.Web.UI.Control RenderPage(GameState GameStatus, IPage Source, bool debugInfo)
        {
            System.Web.UI.Control Body;

            if (debugInfo)
            {
                return(RenderDebugInfo(GameStatus, Source));
            }

            System.Web.UI.HtmlControls.HtmlForm director = new System.Web.UI.HtmlControls.HtmlForm()
            {
                Action = "."
            };
            director.EnableViewState = false;
            director.ViewStateMode   = System.Web.UI.ViewStateMode.Disabled;
            director.Style["border"] = "1px solid black";
            Body = director;

            if (Source.Background != null)
            {
                Body.Controls.Add(ImageFromObject(Source.Background, "", false));
            }
            else
            {
                if (null != GameStatus &&
                    null != GameStatus.Player &&
                    null != GameStatus.Player.Avatar &&
                    null != GameStatus.Player.Avatar.Picture)
                {
                    System.Web.UI.HtmlControls.HtmlTable DisplayTable =
                        new System.Web.UI.HtmlControls.HtmlTable();
                    DisplayTable.Rows.Add(new System.Web.UI.HtmlControls.HtmlTableRow()
                    {
                        Cells =
                        {
                            new System.Web.UI.HtmlControls.HtmlTableCell()
                            {
                                Controls =
                                {
                                    ImageFromObject(
                                        GameStatus.Player.Avatar.Picture,
                                        "Player_Avatar_Picture",
                                        false
                                        )
                                }
                            },
                            new System.Web.UI.HtmlControls.HtmlTableCell()
                            {
                                Controls =
                                {
                                    RenderNutrientBlock(GameStatus.Player.Nutrients,
                                                        "Status", false
                                                        )
                                }
                            },
                            new System.Web.UI.HtmlControls.HtmlTableCell()
                            {
                                Controls =
                                {
                                    RenderNutrientBlock(GameStatus.CurrentDelta,
                                                        "Current", false
                                                        )
                                }
                            },
                            new System.Web.UI.HtmlControls.HtmlTableCell()
                            {
                                Controls =
                                {
                                    RenderNutrientBlock(GameStatus.DailyDelta,
                                                        "Change Today", true
                                                        )
                                }
                            }
                        }
                    });
                    DisplayTable.Rows.Add(new System.Web.UI.HtmlControls.HtmlTableRow()
                    {
                        Cells =
                        {
                            new System.Web.UI.HtmlControls.HtmlTableCell()
                            {
                                Controls =
                                {
                                    new System.Web.UI.WebControls.Label()
                                    {
                                        Text = "<br/>Energy: "
                                               + GameStatus.Player.Energy.ToString()
                                    },
                                    new System.Web.UI.WebControls.Label()
                                    {
                                        Text = "<br/>Focus: "
                                               + GameStatus.Player.Focus.ToString()
                                    },
                                    new System.Web.UI.WebControls.Label()
                                    {
                                        Text = "<br/>Hunger: "
                                               + GameStatus.Player.Hunger.ToString()
                                    },
                                    new System.Web.UI.WebControls.Label()
                                    {
                                        Text = "<br/>kCal/target: "
                                               + GameStatus.Player.Calories.ToString()
                                               + " / "
                                               + GameStatus.Player.TargetCalories.ToString()
                                    },
                                }
                            }
                        }
                    });
                    Body.Controls.Add(DisplayTable);
                }
            }
            if (Source.Title != null)
            {
                Body.Controls.Add(new System.Web.UI.HtmlControls.HtmlGenericControl("h3")
                {
                    InnerHtml = Source.Title
                });
            }
            if (Source.Message != null)
            {
                System.Web.UI.WebControls.Panel MessagePanel = new System.Web.UI.WebControls.Panel();
                MessagePanel.Controls.Add(new System.Web.UI.WebControls.Label()
                {
                    Text = Source.Message
                });
                Body.Controls.Add(MessagePanel);
            }

            System.Web.UI.ControlCollection form = Body.Controls;

            ControlLookup["CurrentPage"] = new System.Web.UI.HtmlControls.HtmlInputHidden()
            {
                ID            = "stg_curpage",
                Value         = Source.MainType.ToString(),
                ViewStateMode = System.Web.UI.ViewStateMode.Disabled
            };
            form.Add(ControlLookup["CurrentPage"]);

            /* Special Handling for Character Creation */
            if (Source.MainType == GameState.PageType.Char_Creation)
            {
                form.Add(CharCreateControls(Source));
            }

            if (null != Source.PrimaryOptions)
            {
                form.Add(RenderOptions(Source.PrimaryOptions, true));
            }
            if (null != Source.AppliedOptions)
            {
                form.Add(RenderOptions(Source.AppliedOptions, false));
            }

            return(Body);
        }