Example #1
0
        public WinningScreen()
        {
            Stage = SummerizedStage.Score;

            RestartButton = WindowFactory.CreateButton("Restart");
            NextButton    = WindowFactory.CreateButton("Next");

            RestartButton.Position = new Vector2()
            {
                X = GetControlXPosition(NextButton, 1, 2),
                Y = Position.Y + Height * 0.75f,
            };

            NextButton.Position = new Vector2()
            {
                X = GetControlXPosition(NextButton, 2, 2),
                Y = Position.Y + Height * 0.75f,
            };

            WinningText = new Label(FontLoader.Load("HeaderFont"), "You Win!", GlobalData.Theme["Blue"]);
            ScoreText   = new Label(FontLoader.Load("HeaderFont"), "", GlobalData.Theme["LightMagenta"]);

            Star1 = WindowFactory.CreateStar();
            Star2 = WindowFactory.CreateStar();
            Star3 = WindowFactory.CreateStar();

            Star2.Position = new Vector2()
            {
                X = Position.X + Width / 2 - Star1.Width / 2,
                Y = Position.Y + Height * 0.30f,
            };

            Star1.Position = new Vector2()
            {
                X = Position.X + Width / 2 - Star1.Width / 2 - Star1.Width * 1.25f,
                Y = Star2.Position.Y + 20,
            };

            Star3.Position = new Vector2()
            {
                X = Position.X + Width / 2 - Star1.Width / 2 + Star1.Width * 1.25f,
                Y = Star2.Position.Y + 20,
            };

            addStar1 = new DelayedAction(Star1.Shine, 0.5f);
            addStar2 = new DelayedAction(Star2.Shine, 1.0f);
            addStar3 = new DelayedAction(Star3.Shine, 1.5f);
        }
Example #2
0
        public override void LoadContent(GraphicsDevice gd, ContentManager cm)
        {
            //Initialization for basicEffect
            basicEffect = new BasicEffect(gd);
            basicEffect.VertexColorEnabled = true;
            basicEffect.LightingEnabled    = false;

            spriteBatch = new SpriteBatch(gd);
            string fontFilePath = Path.Combine(cm.RootDirectory, "Fonts/font.fnt");

            fontFile     = FontLoader.Load(fontFilePath);
            fontTexture  = cm.Load <Texture2D>("Fonts/font_0.png");
            fontRenderer = new FontRenderer(fontFile, fontTexture);
            logo         = cm.Load <Texture2D>("LOGO.png");
            bgTexture    = cm.Load <Texture2D>("bg.png");
        }
Example #3
0
        public void LoadCustomFontsTest()
        {
            var loader = new FontLoader();

            Instance.RegisterFontCollectionLoader(loader);
            try
            {
                using var pDir  = new SafeCoTaskMemString(fontDir);
                using var pColl = ComReleaserFactory.Create(Instance.CreateCustomFontCollection(loader, pDir, pDir.Size));
                EnumFonts(pColl.Item);
            }
            finally
            {
                Instance.UnregisterFontCollectionLoader(loader);
            }
        }
Example #4
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            var fontPath = @"C:\Windows\Fonts\Calibri.ttf";

            var font = FontLoader.FromFile(fontPath);

            Console.WriteLine(font.Version);

            Console.WriteLine(font.GetPixelWidthOfString("Abcdefg", 12));

            GenerateIrakurPdf();

            Console.ReadLine();
        }
        /// <summary>
        /// Translates a font string to a font
        /// </summary>
        /// <param name="fontString">The font string to translate</param>
        /// <returns>The font, otherwise null on error</returns>
        public static Font TranslateFontString(string fontString)
        {
            var   arraySplit = fontString.Split(new char[] { ';' });
            float fFontSize;

            if (6 != arraySplit.Length || !ParseUtil.ParseFloat(arraySplit[1], out fFontSize))
            {
                return(null);
            }
            return(FontLoader.GetFont(
                       arraySplit[0],
                       fFontSize,
                       (arraySplit[2].Equals("1") ? FontStyle.Bold : FontStyle.Regular) |
                       (arraySplit[3].Equals("1") ? FontStyle.Underline : FontStyle.Regular) |
                       (arraySplit[4].Equals("1") ? FontStyle.Italic : FontStyle.Regular) |
                       (arraySplit[5].Equals("1") ? FontStyle.Strikeout : FontStyle.Regular)));
        }
Example #6
0
        public static Texture[] AddFont(FontInfo font)
        {
            if (sheetsLoaded)
            {
                throw new Exception($"Unable to add font (name: {font.FontName}). Sheets are already loaded.");
            }

            var data     = FontLoader.LoadCharacters(font);
            var textures = new Texture[data.Length];

            for (int i = 0; i < data.Length; i++)
            {
                textures[i] = addTexture(data[i], font.FontName, font.CharSizes[i].X, font.CharSizes[i].Y);
            }

            return(textures);
        }
Example #7
0
 protected void LoadFonts()
 {
     _employee.Font       = FontLoader.GetFontNormal();
     _vacationType.Font   = FontLoader.GetFontNormal();
     _approver.Font       = FontLoader.GetFontNormal();
     _duration.Font       = FontLoader.GetFontNormal();
     _vacationStatus.Font = FontLoader.GetFontNormal();
     _vacationError.Font  = FontLoader.GetFontNormal();
     _vacationPickImageFromGallery.Font = FontLoader.GetFontNormal();
     _vacationPickImageFromCamera.Font  = FontLoader.GetFontNormal();
     _labelEmployee.Font       = FontLoader.GetFontBold();
     _labelVacationType.Font   = FontLoader.GetFontBold();
     _labelApprover.Font       = FontLoader.GetFontBold();
     _labelDuration.Font       = FontLoader.GetFontBold();
     _labelVacationStatus.Font = FontLoader.GetFontBold();
     _labelAttachments.Font    = FontLoader.GetFontBold();
 }
Example #8
0
        public BmFont(string fontTexture, ContentManager content)
        {
            //_content = content;
            _fontTexture = content.Load <Texture2D>(fontTexture);

            string   fontFilePath = $"Content\\{fontTexture}.fnt";
            FontFile fontFile     = FontLoader.Load(fontFilePath);

            _fontFile = fontFile;

            _characterMap = new Dictionary <char, FontChar>();

            foreach (FontChar fontCharacter in fontFile.Chars)
            {
                var c = (char)fontCharacter.ID;
                _characterMap.Add(c, fontCharacter);
            }
        }
Example #9
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            /* 1 game 1 font */
            var fontFilePath = Path.Combine(Content.RootDirectory, @"fonts\segoe32.fnt");
            var fontFile     = FontLoader.Load(fontFilePath);
            var fontTexture  = Content.Load <Texture2D>(@"fonts\segoe32_0.png");

            fontRenderer = new FontRenderer(fontFile, fontTexture);

            LoadingScreen loading = new LoadingScreen(Content);

            ScreenManager.Instance.SetLoadingScreen(loading);


            ScreenManager.Instance.SetScreen(new MenuScreen());
            //ScreenManager.Instance.SetScreen(new LevelCreator(0));
        }
Example #10
0
    // Use this for initialization
    void Start()
    {
        //bgToDelete = transform.GetChild(0).gameObject;

        if (FontToUse.Equals(""))
        {
            FontToUse = "Fonts/7x5";
        }

        fontLoader          = new FontLoader();
        fontLoader.FontName = FontToUse;

        ledUnits = new List <List <LedUnit> > ();
        fontLoader.SetSize(NumberUnitHeight);

        float startX = -1 * ((NumberUnitWidth + Spaces * (NumberUnitWidth - 1)) / 2 - 0.5f);
        float startY = (NumberUnitHeight + Spaces * (NumberUnitHeight - 1)) / 2 - 0.5f;

        for (int j = 0; j < NumberUnitWidth; j++)
        {
            List <LedUnit> lList = new List <LedUnit>();
            for (int i = 0; i < (int)NumberUnitHeight; i++)
            {
                GameObject ledUnit = Instantiate(PrefabUnit);
                ledUnit.transform.SetParent(this.transform);
                ledUnit.transform.localPosition = new Vector3(startX + j * Spaces + j, startY - i * Spaces - i, 0);
                ledUnit.transform.localScale    = new Vector3(1, 1, 1);
                lList.Add(ledUnit.GetComponent <LedUnit>());
            }
            ledUnits.Add(lList);
        }

        background = Instantiate(PrefabBackground);
        //background.GetComponent<Collider>().enabled = false;
        background.transform.SetParent(this.transform);
        background.transform.localPosition = new Vector3(0, 0, 0.5f);
        background.transform.localScale    = new Vector3(NumberUnitWidth + Spaces * (NumberUnitWidth - 1) + 1, NumberUnitHeight + Spaces * (NumberUnitHeight - 1) + 1, 1);
        background.transform.localRotation = Quaternion.Euler(new Vector3(0, 0, 0));

        GenerateLetterList();

        actTime = RefreshTime;
    }
Example #11
0
        private void InintControl()
        {
            _employee                     = FindViewById <TextView>(Resource.Id.ItemEmployee);
            _vacationType                 = FindViewById <TextView>(Resource.Id.ItemType);
            _approver                     = FindViewById <TextView>(Resource.Id.ItemApprover);
            _vacationStartDateBtn         = FindViewById <Button>(Resource.Id.ItemStartDateBtn);
            _vacationEndDateBtn           = FindViewById <Button>(Resource.Id.ItemEndDateBtn);
            _duration                     = FindViewById <TextView>(Resource.Id.ItemDuration);
            _vacationStatus               = FindViewById <TextView>(Resource.Id.ItemStatus);
            _vacationError                = FindViewById <TextView>(Resource.Id.ItemError);
            _vacationImageView            = FindViewById <ImageView>(Resource.Id.ItemImageView);
            _vacationPickImageFromGallery = FindViewById <Button>(Resource.Id.ItemPickImageFromGallery);
            _vacationPickImageFromCamera  = FindViewById <Button>(Resource.Id.ItemPickImageFromCamera);
            _labelEmployee                = FindViewById <TextView>(Resource.Id.LabelEmployee);
            _lavelVacationType            = FindViewById <TextView>(Resource.Id.LabelType);
            _labelApprover                = FindViewById <TextView>(Resource.Id.LabelApprover);
            _labelDuration                = FindViewById <TextView>(Resource.Id.LabelDuration);
            _labelVacationStatus          = FindViewById <TextView>(Resource.Id.LabelStatus);
            _labelAttachments             = FindViewById <TextView>(Resource.Id.LabelAttachment);

            _employee.Typeface                     = FontLoader.GetFontNormal(this);
            _vacationType.Typeface                 = FontLoader.GetFontNormal(this);
            _approver.Typeface                     = FontLoader.GetFontNormal(this);
            _vacationStartDateBtn.Typeface         = FontLoader.GetFontNormal(this);
            _vacationEndDateBtn.Typeface           = FontLoader.GetFontNormal(this);
            _duration.Typeface                     = FontLoader.GetFontNormal(this);
            _vacationStatus.Typeface               = FontLoader.GetFontNormal(this);
            _vacationError.Typeface                = FontLoader.GetFontNormal(this);
            _vacationPickImageFromGallery.Typeface = FontLoader.GetFontNormal(this);
            _vacationPickImageFromCamera.Typeface  = FontLoader.GetFontNormal(this);
            _labelEmployee.Typeface                = FontLoader.GetFontBold(this);
            _lavelVacationType.Typeface            = FontLoader.GetFontBold(this);
            _labelApprover.Typeface                = FontLoader.GetFontBold(this);
            _labelDuration.Typeface                = FontLoader.GetFontBold(this);
            _labelVacationStatus.Typeface          = FontLoader.GetFontBold(this);
            _labelAttachments.Typeface             = FontLoader.GetFontBold(this);

            _vacationStartDateBtn.Click         += delegate { ShowDialog(from); };
            _vacationEndDateBtn.Click           += delegate { ShowDialog(to); };
            _vacationPickImageFromGallery.Click += onVacationPickImageFromGalleryClick;
            _vacationImageView.Click            += onVacationPickImageFromGalleryClick;
            _vacationPickImageFromCamera.Click  += onVacationPickImageFromCameraClick;
        }
Example #12
0
        public Frm_Login()
        {
            InitializeComponent();

            // Animator settings
            Animator.AnimationType    = AnimatorNS.AnimationType.Transparent;
            Animator.Interval         = 8;
            Animator.MaxAnimationTime = 1000;
            Animator.TimeStep         = 0.02F;

            XR_Button_Login.Enabled      = false;
            XR_TextBox_User.TextChanged += ValidateInput;
            XR_TextBox_Pass.TextChanged += ValidateInput;

            /* IMPORTANT, OTHERWISE THE CUSTOM FONT WILL NOT LOAD
            ** ---------
            ** Because we're not installing the custom font on the system, debugging the software
            ** without specifying the XRails_TitleLabel font property on the form that is using it
            ** will cause the label to revert to the default system font
            **
            ** The form designer may show the TitleLabel font as "Microsoft Sans Serif", don't
            ** panic! The custom font only loads during the debugging process and after running
            ** the compiled software
            */
            var customFont = FontLoader.SetFont(22, FontStyle.Regular, GraphicsUnit.Point, 1);

            XR_TitleLabel_Welcome.Font = customFont;
            XR_TitleLabel_LoginTo.Font = customFont;

            // Set the form opacity to 0% and enable the timer that will
            // increase it when the software is launched.
            Opacity = 0;

            tmrFadeIn = new Timer
            {
                Interval = 1,
                Enabled  = true,
            };

            // Add a dynamic handler to the .Tick event
            tmrFadeIn.Tick += FadeIn_Tick;
        }
Example #13
0
        public LoadGameScreen(OnScreenChanged screenChanged) : base(screenChanged)
        {
            UserInterfaceLoader uiLoader   = UserInterfaceLoader.GetInstance();
            FontLoader          fontLoader = FontLoader.GetInstance();

            var TileSize = GameConstants.TILE_SIZE;

            fileSelected = -1;
            Texture2D blankButtonSprite   = uiLoader.Get("select");
            Texture2D confirmButtonSprite = uiLoader.Get("confirm");
            Texture2D backButtonSprite    = uiLoader.Get("back");

            backButton = new StaticEntity("Back Button", new Vector2(TileSize * 2, GameConstants.WINDOW_HEIGHT - TileSize), backButtonSprite);

            fileButtons      = new List <StaticEntity>();
            levelData        = new List <String>();
            weapon1ItemBoxes = new List <ItemBox>();
            weapon2ItemBoxes = new List <ItemBox>();
            shield1ItemBoxes = new List <ItemBox>();
            charm1ItemBoxes  = new List <ItemBox>();
            for (int i = 0; i < GameConstants.NUMBER_OF_SAVES; i++)
            {
                fileButtons.Add(new StaticEntity("Button " + i.ToString(), new Vector2(TileSize * 2, TileSize * 3 + i * TileSize * 2), blankButtonSprite));
                levelData.Add("");
                weapon1ItemBoxes.Add(new ItemBox("Weapon1 File " + i.ToString(), new Vector2(TileSize * 7, TileSize * 3 + i * TileSize * 2)));
                weapon2ItemBoxes.Add(new ItemBox("Weapon2 File " + i.ToString(), new Vector2(TileSize * 8, TileSize * 3 + i * TileSize * 2)));
                shield1ItemBoxes.Add(new ItemBox("Shield1 File " + i.ToString(), new Vector2(TileSize * 9, TileSize * 3 + i * TileSize * 2)));
                charm1ItemBoxes.Add(new ItemBox("Charm1 File " + i.ToString(), new Vector2(TileSize * 10, TileSize * 3 + i * TileSize * 2)));
            }
            confirmButton = new StaticEntity("Confirm Button", new Vector2(TileSize * 5, GameConstants.WINDOW_HEIGHT - TileSize), confirmButtonSprite);

            font   = fontLoader.Get("font");
            font20 = fontLoader.Get("font20");

            actionBarBackground = uiLoader.Get("blankBackground");
            background          = new StaticEntity("Background", new Vector2(GameConstants.WINDOW_WIDTH / 2, GameConstants.WINDOW_HEIGHT / 2), actionBarBackground);

            for (int i = 0; i < GameConstants.NUMBER_OF_SAVES; i++)
            {
                CheckGameData(i, levelData, weapon1ItemBoxes, weapon2ItemBoxes, shield1ItemBoxes, charm1ItemBoxes);
            }
        }
Example #14
0
        public void FontLoader_FindCorrectPartialMatchesInFileResources_FindsTheRightNumber()
        {
            var appAssembly       = Substitute.For <IApplicationAssembly>();
            var fontsAssembly     = Substitute.For <IFontsAssembly>();
            var filesystem        = Substitute.For <IFileSystem>();
            var messenger         = Substitute.For <IFrameworkMessenger>();
            var properties        = Substitute.For <IStartupPropertiesCache>();
            var subFontGenerator  = Substitute.For <ISubFontGenerator>();
            var gpuSurfaceManager = Substitute.For <IGpuSurfaceManager>();

            filesystem.GetFilesInDirectory(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <SearchOption>()).Returns(new string[]
            {
                "partial/testi/iqueend0.fnt",
                "no/match/here",
                "partial/test/uniqueend1.fnt",
                "partial/test/uniqueend2.fnt",
                "no/match/here",
                "no/match/here",
                "partial/test/uniqueend3",
                "partial/test/uniqueend4.fnt",
                "no/match/here",
                "no/match/here",
            });

            properties.User.Returns(new StartupConfig
            {
                FontFolder = "partial"
            });

            IFontLoader loader = new FontLoader(
                appAssembly,
                fontsAssembly,
                messenger,
                gpuSurfaceManager,
                properties,
                subFontGenerator,
                filesystem);

            var result = loader.FindDotFntFileNamePartialMatchesFromFileResource("test");

            Assert.Equal(4, result.Count);
        }
Example #15
0
        public void CreateFontFaceTest()
        {
            var ldr   = new FontLoader();
            var pList = Directory.EnumerateFiles(fontDir).Take(1).Select(f => Instance.CreateFontFileReference(f)).ToArray();

            try
            {
                pList[0].Analyze(out var sup, out var ft, out var fc, out var fcn);
                TestContext.WriteLine($"Supported={sup}; FileType={ft}; FaceType={fc}; FaceCnt={fcn}");
                var pFF = ComReleaserFactory.Create(Instance.CreateFontFace(fc, (uint)pList.Length, pList, 0, DWRITE_FONT_SIMULATIONS.DWRITE_FONT_SIMULATIONS_NONE));
                Assert.That(pFF.Item.GetType(), Is.EqualTo(fc));
                var ff    = new IDWriteFontFile[pList.Length];
                var fflen = (uint)ff.Length;
                Assert.That(() => pFF.Item.GetFiles(ref fflen, ff), Throws.Nothing);
                ff.WriteValues();
                TestContext.WriteLine($"Index in font files: {pFF.Item.GetIndex()}");
                TestContext.WriteLine($"Simulations: {pFF.Item.GetSimulations()}");
                Assert.That(pFF.Item.IsSymbolFont(), Is.False);
                Assert.That(() => { pFF.Item.GetMetrics(out var faceMetrics); faceMetrics.WriteValues(); }, Throws.Nothing);
                var glCnt = (int)pFF.Item.GetGlyphCount();
                Assert.That(glCnt, Is.GreaterThan(0));
                glCnt = Math.Min(3, glCnt);
                var glm   = new DWRITE_GLYPH_METRICS[glCnt];
                var glidx = Enumerable.Range(0, glCnt).Select(i => (ushort)i).ToArray();
                Assert.That(() => pFF.Item.GetDesignGlyphMetrics(glidx, (uint)glCnt, glm), Throws.Nothing);
                glm.WriteValues();
                Assert.That(() =>
                {
                    var tag = DWRITE_FONT_FEATURE_TAG.DWRITE_FONT_FEATURE_TAG_DEFAULT;
                    pFF.Item.TryGetFontTable((uint)tag, out var tableData, out var tableSize, out var tableCtx, out var tableExists);
                    TestContext.WriteLine($"Table: {tag} = Sz:{tableSize}, {tableExists}");
                    pFF.Item.ReleaseFontTable(tableCtx);
                }, Throws.Nothing);
                var rParams = Instance.CreateRenderingParams();
                pFF.Item.GetRecommendedRenderingMode(9f, 72f, DWRITE_MEASURING_MODE.DWRITE_MEASURING_MODE_NATURAL, rParams).WriteValues();
                var hMon = User32.MonitorFromPoint(System.Drawing.Point.Empty, User32.MonitorFlags.MONITOR_DEFAULTTOPRIMARY);
                rParams = Instance.CreateMonitorRenderingParams(hMon);
                pFF.Item.GetRecommendedRenderingMode(9f, 72f, DWRITE_MEASURING_MODE.DWRITE_MEASURING_MODE_NATURAL, rParams).WriteValues();
                rParams = Instance.CreateCustomRenderingParams(2.2f, 1f, 1f, DWRITE_PIXEL_GEOMETRY.DWRITE_PIXEL_GEOMETRY_BGR, DWRITE_RENDERING_MODE.DWRITE_RENDERING_MODE_ALIASED);
                pFF.Item.GetRecommendedRenderingMode(9f, 72f, DWRITE_MEASURING_MODE.DWRITE_MEASURING_MODE_NATURAL, rParams).WriteValues();
                pFF.Item.GetGdiCompatibleMetrics(9f, 72f).WriteValues();
                Assert.That(() => pFF.Item.GetGdiCompatibleGlyphMetrics(9f, 72f, default, true, glidx, (uint)glCnt, glm), Throws.Nothing);
Example #16
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            _SpriteBatch = new SpriteBatch(GraphicsDevice);

            // Load the textures of the main scene
            _Background    = this.Content.Load <Texture2D>("background");
            _ReadyCover    = this.Content.Load <Texture2D>("ready");
            _GameoverCover = this.Content.Load <Texture2D>("gameover");

            // Load the score font
            _ScoreFontFile     = FontLoader.Load(Path.Combine(this.Content.RootDirectory, "score_font.fnt"));
            _ScoreFontTexture  = this.Content.Load <Texture2D>("score_font_0");
            _ScoreFontRenderer = new FontRenderer(_ScoreFontFile, _ScoreFontTexture);

            // Load the tips font
            _TipsFontFile     = FontLoader.Load(Path.Combine(this.Content.RootDirectory, "tips_font.fnt"));
            _TipsFontTexture  = this.Content.Load <Texture2D>("tips_font_0");
            _TipsFontRenderer = new FontRenderer(_TipsFontFile, _TipsFontTexture);
        }
Example #17
0
        public void FontLoader_FindCorrectPartialMatchesInFontsEmbeddedResources_FindsTheRightNumber()
        {
            var appAssembly       = Substitute.For <IApplicationAssembly>();
            var fontsAssembly     = Substitute.For <IFontsAssembly>();
            var filesystem        = Substitute.For <IFileSystem>();
            var messenger         = Substitute.For <IFrameworkMessenger>();
            var properties        = Substitute.For <IStartupPropertiesCache>();
            var subFontGenerator  = Substitute.For <ISubFontGenerator>();
            var gpuSurfaceManager = Substitute.For <IGpuSurfaceManager>();



            IFontLoader loader = new FontLoader(
                appAssembly,
                fontsAssembly,
                messenger,
                gpuSurfaceManager,
                properties,
                subFontGenerator,
                filesystem);

            fontsAssembly.GetManifestResourceNames().Returns(new List <string>
            {
                "partial.test.uniqueend0.fnt",
                "no.match.here",
                "partial.test.uniqueend1.fnt",
                "partial.test.uniqueend2.fnt",
                "no.match.here",
                "no.match.here",
                "partial.test.uniqueend3",
                "partial.test.uniqueend4.fnt",
                "no.match.here",
                "no.match.here",
            });

            appAssembly.Name.Returns("partial");

            var result = loader.FindDotFntFileNamePartialMatchesFromEmbeddedResource(true, "test");

            Assert.Equal(4, result.Count);
        }
Example #18
0
        public void FontLoader_GenerateFontFromDescriptionInfoFailsOnNullDescription_ReturnsNull()
        {
            var appAssembly       = Substitute.For <IApplicationAssembly>();
            var fontsAssembly     = Substitute.For <IFontsAssembly>();
            var filesystem        = Substitute.For <IFileSystem>();
            var messenger         = Substitute.For <IFrameworkMessenger>();
            var properties        = Substitute.For <IStartupPropertiesCache>();
            var gpuSurfaceManager = Substitute.For <IGpuSurfaceManager>();
            var subFontGenerator  = Substitute.For <ISubFontGenerator>();

            IFontLoader loader = new FontLoader(
                appAssembly,
                fontsAssembly,
                messenger,
                gpuSurfaceManager,
                properties,
                subFontGenerator,
                filesystem);

            Assert.Null(loader.GenerateFontFromDescriptionInfo(null));
        }
Example #19
0
        public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
        {
            UITableViewCell cell      = tableView.DequeueReusableCell(cellIdentifier);
            var             cellStyle = UITableViewCellStyle.Value1;

            if (cell == null)
            {
                cell = new UITableViewCell(cellStyle, cellIdentifier);
            }
            cell.TextLabel.Text = tableItems[indexPath.Row].VacationType;
            if (cellStyle == UITableViewCellStyle.Subtitle ||
                cellStyle == UITableViewCellStyle.Value1 ||
                cellStyle == UITableViewCellStyle.Value2)
            {
                cell.DetailTextLabel.Text = tableItems[indexPath.Row].Date;
                if (tableItems[indexPath.Row].Status.Equals(VacationStatus.Approved.ToString()))
                {
                    cell.DetailTextLabel.TextColor = UIColor.Green;
                }
                else
                {
                    if (tableItems[indexPath.Row].Status.Equals(VacationStatus.Rejected.ToString()))
                    {
                        cell.DetailTextLabel.TextColor = UIColor.Red;
                    }
                    else
                    {
                        cell.DetailTextLabel.TextColor = UIColor.Gray;
                    }
                }
            }
            if (cellStyle != UITableViewCellStyle.Value2)
            {
                cell.ImageView.Image = UIImage.FromFile("Images/person.png");
            }
            cell.Accessory            = UITableViewCellAccessory.DisclosureIndicator;
            cell.DetailTextLabel.Font = FontLoader.GetFontSmall();
            cell.TextLabel.Font       = FontLoader.GetFontBold();
            return(cell);
        }
Example #20
0
        public WinAllScreen()
        {
            Title.Text = "Congratulation!";

            WinAllText    = new Label(FontLoader.Load("HeaderFont"), "You have passed all levels!", GlobalData.Theme["Silver"]);
            HighScoreText = new Label(FontLoader.Load("HeaderFont"), "High Score: " + GlobalData.Session.CurrentScore.ToString("N0"), GlobalData.Theme["Yellow"]);

            TextBox    = WindowFactory.CreateTextbox();
            SaveButton = WindowFactory.CreateButton("Back to menu");

            TextBox.Position = new Vector2()
            {
                X = GetControlXPosition(TextBox, 1, 1),
                Y = this.Position.Y + 210f,
            };

            SaveButton.Position = new Vector2()
            {
                X = GetControlXPosition(SaveButton, 1, 1),
                Y = this.Position.Y + 300f,
            };
        }
Example #21
0
        public PopupWonView(Context context, IAttributeSet attrs) : base(context, attrs)
        {
            LayoutInflater.From(context).Inflate(Resource.Layout.popup_won_view, this, true);
            mTime       = (TextView)FindViewById(Resource.Id.time_bar_text);
            mScore      = (TextView)FindViewById(Resource.Id.score_bar_text);
            mStar1      = (ImageView)FindViewById(Resource.Id.star_1);
            mStar2      = (ImageView)FindViewById(Resource.Id.star_2);
            mStar3      = (ImageView)FindViewById(Resource.Id.star_3);
            mBackButton = (ImageView)FindViewById(Resource.Id.button_back);
            mNextButton = (ImageView)FindViewById(Resource.Id.button_next);
            FontLoader.SetTypeface(new TextView[] { mTime, mScore }, FontLoader.Font.GROBOLD);
            SetBackgroundResource(Resource.Drawable.level_complete);
            mHandler           = new Handler();
            mBackButton.Click += (sender, e) =>
            {
                Shared.EventBus.Notify(new BackGameEvent());
            };

            mNextButton.Click += (sender, e) =>
            {
                Shared.EventBus.Notify(new NextGameEvent());
            };
        }
Example #22
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="contentManager"></param>
        private void LoadContent(ContentManager contentManager)
        {
            var definitionPath = string.Format("{0}_{1}.fnt", Name, Style);

            using (var contents = File.OpenRead(Path.Combine(contentManager.RootDirectory, definitionPath)))
                _definition = FontLoader.Load(contents);

            if (_textures != null)
            {
                for (int i = 0; i < _textures.Length; i++)
                {
                    _textures[i].Dispose();
                }
            }

            // We need to support multiple texture pages for more than plain ASCII text.
            _textures = new Texture2D[_definition.Pages.Count];
            for (int i = 0; i < _definition.Pages.Count; i++)
            {
                var texturePath = string.Format("{0}_{1}_{2}.png", Name, Style, i);
                _textures[i] = contentManager.Load <Texture2D>(texturePath);
            }
        }
 public void SetCustomFont(string assetPath)
 {
     try
     {
         if (!string.IsNullOrEmpty(assetPath))
         {
             Typeface face = FontLoader.GetFont(Context.Assets, assetPath);
             if (face != null)
             {
                 TypefaceStyle style = TypefaceStyle.Normal;
                 if (this.Typeface != null) //Takes care of android:textStyle=""
                 {
                     style = Typeface.Style;
                 }
                 this.SetTypeface(face, style);
             }
         }
     }
     catch (Exception ex)
     {
         Stencil.Native.Core.Container.Track.LogWarning(ex.Message, "AutoCompleteTextView");
     }
 }
Example #24
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            ViewGroup view = (ViewGroup)inflater.Inflate(Resource.Layout.game_fragment, container, false);

            view.SetClipChildren(false);
            ((ViewGroup)view.FindViewById(Resource.Id.game_board)).SetClipChildren(false);
            mTime      = (TextView)view.FindViewById(Resource.Id.time_bar_text);
            mTimeImage = (ImageView)view.FindViewById(Resource.Id.time_bar_image);
            FontLoader.SetTypeface(new TextView[] { mTime }, FontLoader.Font.GROBOLD);
            mBoardView = BoardView.fromXml(Android.App.Application.Context, view);
            FrameLayout frameLayout = (FrameLayout)view.FindViewById(Resource.Id.game_container);

            frameLayout.AddView(mBoardView);
            frameLayout.SetClipChildren(false);

            // build board
            BuildBoard();
            Shared.EventBus.listen(nameof(FlipDownCardsEvent), this);
            Shared.EventBus.listen(nameof(HidePairCardsEvent), this);
            Shared.EventBus.listen(nameof(GameWonEvent), this);

            return(view);
        }
Example #25
0
 public void SetCustomFont(string assetPath)
 {
     try
     {
         if (!string.IsNullOrEmpty(assetPath))
         {
             Typeface face = FontLoader.GetFont(_context.Assets, assetPath);
             if (face != null)
             {
                 TypefaceStyle style = TypefaceStyle.Normal;
                 if (this.Typeface != null) //Takes care of android:textStyle=""
                 {
                     style = Typeface.Style;
                 }
                 this.SetTypeface(face, style);
             }
         }
     }
     catch (System.Exception ex)
     {
         Container.Track.LogWarning(ex.Message, "TextDrawable");
     }
 }
Example #26
0
        /// <summary>
        /// 加载字体资源
        /// </summary>
        /// <param name="url"></param>
        /// <param name="callback"></param>
        private void LoadFont(string url, LoadAssetModel loadModel, System.Action <Font> callback)
        {
            FontLoader.LoadFontAsset(url, loadModel, (loader) =>
            {
                ResourcesLoadTraceMgr.Instance.RecordTraceResourceInfor(loader);
                #region  加载成功后的处理逻辑
                if (loader == null || (loader.IsCompleted && loader.IsError))
                {
                    Debug.LogError("LoadFont   Fail,Not Exit At Path= " + url);
                    if (callback != null)
                    {
                        callback.Invoke(null);
                    }
                    return;
                }  //加载资源出错

                if (callback != null)
                {
                    callback.Invoke(loader.ResultObj as Font);
                }
                #endregion
            });
        }
 public ButtonStyle(Color textColorNormal = default, Color textColorHover = default, Color textColorPressed = default, Color backgroundColorNormal = default, Color backgroundColorHover = default, Color backgroundColorPressed = default, Color borderColorNormal = default, Color borderColorHover = default, Color borderColorPressed = default, float borderSizeNormal = -1f, float borderSizeHover = -1f, float borderSizePressed = -1f, float textSizeNormal = -1f, float textSizeHover = -1f, float textSizePressed = -1f, StringFormat textAlignmentNormal = null, StringFormat textAlignmentHover = null, StringFormat textAlignmentPressed = null, FontLoader fontLoaderInstance = null) : this()
 {
     this.textColorNormal        = textColorNormal == default ? Default.textColorNormal : textColorNormal;
     this.textColorHover         = textColorHover == default ? Default.textColorHover : textColorHover;
     this.textColorPressed       = textColorPressed == default ? Default.textColorPressed : textColorPressed;
     this.backgroundColorNormal  = backgroundColorNormal == default ? Default.backgroundColorNormal : backgroundColorNormal;
     this.backgroundColorHover   = backgroundColorHover == default ? Default.backgroundColorHover : backgroundColorHover;
     this.backgroundColorPressed = backgroundColorPressed == default ? Default.backgroundColorPressed : backgroundColorPressed;
     this.borderColorNormal      = borderColorNormal == default ? Default.borderColorNormal : borderColorNormal;
     this.borderColorHover       = borderColorHover == default ? Default.borderColorHover : borderColorHover;
     this.borderColorPressed     = borderColorPressed == default ? Default.borderColorPressed : borderColorPressed;
     this.borderSizeNormal       = borderSizeNormal == -1f ? Default.borderSizeNormal : borderSizeNormal;
     this.borderSizeHover        = borderSizeHover == -1f ? Default.borderSizeHover : borderSizeHover;
     this.borderSizePressed      = borderSizePressed == -1f ? Default.borderSizePressed : borderSizePressed;
     this.textSizeNormal         = textSizeNormal == -1f ? Default.textSizeNormal : textSizeNormal;
     this.textSizeHover          = textSizeHover == -1f ? Default.textSizeHover : textSizeHover;
     this.textSizePressed        = textSizePressed == -1f ? Default.textSizePressed : textSizePressed;
     this.textAlignmentNormal    = textAlignmentNormal ?? Default.textAlignmentNormal;
     this.textAlignmentHover     = textAlignmentHover ?? Default.textAlignmentHover;
     this.textAlignmentPressed   = textAlignmentPressed ?? Default.textAlignmentPressed;
     this.fontLoaderInstance     = fontLoaderInstance ?? Default.fontLoaderInstance;
     Normal();
 }
Example #28
0
        public void FontLoader_GenerateFontFromDescriptionInfo_CallsGeneratorEnoughTimes()
        {
            var appAssembly   = Substitute.For <IApplicationAssembly>();
            var fontsAssembly = Substitute.For <IFontsAssembly>();
            var filesystem    = Substitute.For <IFileSystem>();

            var messenger         = Substitute.For <IFrameworkMessenger>();
            var properties        = Substitute.For <IStartupPropertiesCache>();
            var gpuSurfaceManager = Substitute.For <IGpuSurfaceManager>();

            var subFontGeneratorMock = Substitute.For <ISubFontGenerator>();

            subFontGeneratorMock.Generate(Arg.Any <CandidateSubFontDesc>()).Returns(new SubFont(0, 0, new Dictionary <char, FontCharacter>(), new ITexture[3], false, null));

            IFontLoader loader = new FontLoader(
                appAssembly,
                fontsAssembly,
                messenger,
                gpuSurfaceManager,
                properties,
                subFontGeneratorMock,
                filesystem);

            var result = loader.GenerateFontFromDescriptionInfo(new CandidateFontDesc
            {
                CandidateSubFonts = new List <CandidateSubFontDesc>
                {
                    new CandidateSubFontDesc(),
                    new CandidateSubFontDesc(),
                    new CandidateSubFontDesc()
                }
            });

            subFontGeneratorMock.Received(3).Generate(Arg.Any <CandidateSubFontDesc>());

            Assert.NotNull(result);
        }
Example #29
0
        static void Main()
        {
            using (FontLoader font = new FontLoader("font/VL-Gothic-Regular.ttf"))
                using (FontLoader debugFont = new FontLoader("font/88 Zen.ttf"))
                {
                    TextOptions textOptions = new TextOptions(font.Family, 12, 17)
                    {
                        ShadowIndex  = 1,
                        DrawShadow   = true,
                        Antialiasing = true
                    };
                    textOptions.SetSolidBrushes(Color.White, Color.Black, Color.OrangeRed);

                    TextOptions debugTextOptions = new TextOptions(debugFont.Family, 8, 8)
                    {
                        ShadowIndex = 1,
                        DrawShadow  = true,
                    };
                    debugTextOptions.SetSolidBrushes(Color.White, Color.Black);

                    WindowOptions options = new WindowOptions()
                    {
                        Title            = "Sample",
                        TargetSize       = new Size(320, 240),
                        WindowSize       = new Size(640, 480),
                        DebugTextOptions = debugTextOptions,
                        TextOptions      = textOptions
                    };

                    using (SitrineWindow window = new SitrineWindow(options))
                    {
                        window.AddStoryboard(new SampleStory(window));
                        window.Run(30.0, 60.0);
                    }
                }
        }
Example #30
0
 public FontFile LoadFontFile(string assetName)
 {
     //return Plato.ModHelper.Content.Load<FontFile>(assetName);//
     return(FontLoader.Parse(File.ReadAllText(Path.Combine(Plato.ModHelper.DirectoryPath, assetName))));
 }
Example #31
0
 /// <summary>
 /// FontLoaderとその使用するナンバーを指定設定する。
 /// 
 /// ナンバーは、FontLoaderで定義ファイルを読み込んだときに、
 /// 定義ファイルに書かれている先頭から0,1,2,…とナンバリングされている。
 /// </summary>
 /// <param name="loader_"></param>
 /// <param name="no_"></param>
 /// <remarks>
 /// 以降、GetTextureでは、このフォントが読み込まれる。
 /// </remarks>
 public void SetLoader(FontLoader loader,int fontNo)
 {
     this.loader = loader;
     this.fontNo	= fontNo;
 }