コード例 #1
0
ファイル: CataPageSection.cs プロジェクト: YorickBM/NonFlash
        public Row(ContentManager content, int rowNum, Vector2i position, Vector2i size, CatalogusPage page)
        {
            images         = new List <Image>();
            fonts          = new List <Font>();
            this.page      = page;
            timer          = new Timer(200);
            timer.Elapsed += Timer_Elapsed;
            rowN           = rowNum;
            hidden         = true;

            pageName = new Font(content, "Fonts/Catalogus/PageTitle", page.caption, new Color(109, 109, 109));
            area     = new Rectangle(0, 0, 177, 21);
            try
            {
                if (File.Exists(@"Content/catalogue/icons/icon_" + icon.ToString() + ".xnb"))
                {
                    this.icon = new Image(content, "catalogue/icons/icon_" + icon.ToString(), Vector2.Zero);
                }
                else
                {
                    this.icon = new Image(content, "catalogue/icons/icon_1", Vector2.Zero);
                }
            }
            catch (Exception ex)
            {
                this.icon = GameScreenManager.Instance.catalogusnotFoundIcon.Clone() as Image;
            }
        }
コード例 #2
0
ファイル: CataPageSection.cs プロジェクト: YorickBM/NonFlash
        public CataPageSection(ContentManager content, CatalogusPage page, Vector2i position, Vector2i size, out int bodySize, IEnumerable <CatalogusPage> subPages)
        {
            images  = new List <Image>();
            fonts   = new List <Font>();
            bodyT   = new List <Image>();
            headerT = new List <Image>();
            bodyF   = new List <Font>();
            headerF = new List <Font>();
            rows    = new List <Row>();

            this.size          = size;
            this.localPosition = position;
            this.page          = page;
            delay          = new Timer(200);
            delay.Elapsed += Delay_Elapsed;

            try
            {
                #region Section Body

                rowNum = 0;
                Logger.Debug("Generating Body for:", page.caption);
                foreach (CatalogusPage subPage in subPages)
                {
                    try
                    {
                        Row row = new Row(content, rowNum++, position, size, subPage);
                        row.hidden = subPage.isCollapsed;
                        bodyF.AddRange(row.GetFonts());
                        bodyT.AddRange(row.GetImages());
                        rows.Add(row);
                    }
                    catch (Exception ex)
                    {
                        Logger.Error("Following page could not be displayed:", subPage.caption, "(" + subPage.pageId + ")");
                        Logger.Error(ex);
                    }
                }

                #endregion

                #region Section Header
                Logger.Debug("Generating header for:", page.caption);

                Font title = new Font(content, "Fonts/Catalogus/PageTitle", page.caption, new Color(109, 109, 109)); //125, 216, 246
                title.SetPosition(position + new Vector2i(23, size.Y / 2 - title.measureString().Y / 2));
                headerF.Add(title);

                collapsed            = new Image(content, "Menu/Catalogus/Section/openClose", new Vector2i(10, 10));
                collapsed.SourceRect = new Rectangle((int)0 + (int)collapsed.Size.X, (int)0, (int)collapsed.Size.X, (int)collapsed.Size.Y);
                collapsed.SetPosition(position + new Vector2i(6, size.Y / 2 - collapsed.dimensions.Y / 2) + new Vector2i(title.measureString().X, 0));

                open = new Image(content, "Menu/Catalogus/Section/openClose", new Vector2i(10, 10));
                open.SetPosition(position + new Vector2i(6, size.Y / 2 - open.dimensions.Y / 2) + new Vector2i(title.measureString().X, 0));

                if (subPages.Count() > 0)
                {
                    if (!page.isCollapsed)
                    {
                        headerT.Add(open);
                    }
                    else
                    {
                        headerT.Add(collapsed);
                    }
                    hasSubPages = true;
                }
                else
                {
                    hasSubPages = false;
                }

                try
                {
                    if (File.Exists(@"Content/catalogue/icons/icon_" + page.iconId.ToString() + ".xnb"))
                    {
                        icon = new Image(content, "catalogue/icons/icon_" + page.iconId.ToString(), Vector2.Zero);
                    }
                    else
                    {
                        icon = new Image(content, "catalogue/icons/icon_1", Vector2.Zero);
                    }
                }
                catch (Exception ex)
                {
                    icon = GameScreenManager.Instance.catalogusnotFoundIcon.Clone() as Image;
                }
                icon.SetPosition(position + new Vector2i(6, size.Y / 2 - icon.dimensions.Y / 2));
                headerT.Add(icon);

                #endregion
            } catch (Exception ex)
            {
                Logger.Error("Error on creating catalogus page section:", page.caption);
            }

            bodySize = rowNum * 20;
            BodySize = bodySize;
        }