コード例 #1
0
ファイル: TextFontLoader.cs プロジェクト: gmoller/Archmaester
        public override FontFile Handle(string line, FontFile fontFile)
        {
            Dictionary <string, string> dict = CreateDictionary(line, "page");

            var fontPage = new FontPage
            {
                ID   = Convert.ToInt32(dict["id"]),
                File = dict["file"]
            };

            fontFile.Pages.Add(fontPage);

            return(fontFile);
        }
コード例 #2
0
        public PreviewItemViewModel(PreviewViewModel parent, int index, FontPage page)
        {
            this.parent                  = parent;
            this.page                    = page;
            this.Index                   = index;
            this.ClickCommand            = new DelegateCommand(this.Click, this.CanClick);
            this.parent.PropertyChanged += Parent_PropertyChanged;
            var query = page.Glyphs.OrderBy(item => item.ID);

            foreach (var item in query)
            {
                this.glyphList.Add(new GlyphItemViewModel(item));
            }
            this.RefreshImage();
        }
コード例 #3
0
        public PropertiesForm()
        {
            InitializeComponent();

            GraphicsProperties properties = XGraphicsLab.properties;

            Size       pageSize = this.tpgGeneral.Size;
            TabControl tabControl;
            TabPage    tabPage;

            // General
            GeneralPage generalPage = new GeneralPage();

            generalPage.UpdateDrawing    += new UpdateDrawing(OnUpdateDrawing);
            generalPage.GeneralProperties = properties.General;
            this.tpgGeneral.Controls.Add(generalPage);
            UITools.SetTabPageColor(this.tpgGeneral);

            // Pens
            PenPage penPage;

            tabControl      = new TabControl();
            tabControl.Size = pageSize;

            tabPage = new TabPage();
            UITools.SetTabPageColor(tabPage);
            tabPage.Text           = "Pen1";
            penPage                = new PenPage();
            penPage.UpdateDrawing += new UpdateDrawing(OnUpdateDrawing);
            penPage.PenProperty    = properties.Pen1;
            tabPage.Controls.Add(penPage);
            tabControl.Controls.Add(tabPage);

            tabPage = new TabPage();
            UITools.SetTabPageColor(tabPage);
            tabPage.Text           = "Pen2";
            penPage                = new PenPage();
            penPage.UpdateDrawing += new UpdateDrawing(OnUpdateDrawing);
            penPage.PenProperty    = properties.Pen2;
            tabPage.Controls.Add(penPage);
            tabControl.Controls.Add(tabPage);

            tabPage = new TabPage();
            UITools.SetTabPageColor(tabPage);
            tabPage.Text           = "Pen3";
            penPage                = new PenPage();
            penPage.UpdateDrawing += new UpdateDrawing(OnUpdateDrawing);
            penPage.PenProperty    = properties.Pen3;
            tabPage.Controls.Add(penPage);
            tabControl.Controls.Add(tabPage);

            this.tpgPens.Controls.Add(tabControl);
            UITools.SetTabPageColor(this.tpgPens);

            // Brushes
            BrushPage brushPage;

            tabControl      = new TabControl();
            tabControl.Size = pageSize;

            tabPage = new TabPage();
            UITools.SetTabPageColor(tabPage);
            tabPage.Text             = "Brush1";
            brushPage                = new BrushPage();
            brushPage.UpdateDrawing += new UpdateDrawing(OnUpdateDrawing);
            brushPage.BrushProperty  = properties.Brush1;
            tabPage.Controls.Add(brushPage);
            tabControl.Controls.Add(tabPage);

            tabPage = new TabPage();
            UITools.SetTabPageColor(tabPage);
            tabPage.Text             = "Brush2";
            brushPage                = new BrushPage();
            brushPage.UpdateDrawing += new UpdateDrawing(OnUpdateDrawing);
            brushPage.BrushProperty  = properties.Brush2;
            tabPage.Controls.Add(brushPage);
            tabControl.Controls.Add(tabPage);

            tabPage = new TabPage();
            UITools.SetTabPageColor(tabPage);
            tabPage.Text             = "Brush3";
            brushPage                = new BrushPage();
            brushPage.UpdateDrawing += new UpdateDrawing(OnUpdateDrawing);
            brushPage.BrushProperty  = properties.Brush3;
            tabPage.Controls.Add(brushPage);
            tabControl.Controls.Add(tabPage);

            this.tpgBrushes.Controls.Add(tabControl);
            UITools.SetTabPageColor(this.tpgBrushes);

            // Fonts
            FontPage fonthPage;

            tabControl      = new TabControl();
            tabControl.Size = pageSize;

            tabPage = new TabPage();
            UITools.SetTabPageColor(tabPage);
            tabPage.Text             = "Font1";
            fonthPage                = new FontPage();
            fonthPage.UpdateDrawing += new UpdateDrawing(OnUpdateDrawing);
            fonthPage.FontProperty   = properties.Font1;
            tabPage.Controls.Add(fonthPage);
            tabControl.Controls.Add(tabPage);

            tabPage = new TabPage();
            UITools.SetTabPageColor(tabPage);
            tabPage.Text             = "Font2";
            fonthPage                = new FontPage();
            fonthPage.UpdateDrawing += new UpdateDrawing(OnUpdateDrawing);
            fonthPage.FontProperty   = properties.Font2;
            tabPage.Controls.Add(fonthPage);
            tabControl.Controls.Add(tabPage);

            this.tpgFonts.Controls.Add(tabControl);
            UITools.SetTabPageColor(this.tpgFonts);

            // Path
            //GeneralPage generalPage = new GeneralPage();
            //generalPage.UpdateDrawing +=  new UpdateDrawing(OnUpdateDrawing);
            //generalPage.GeneralProperties = properties.General;
            //this.tpgGeneral.Controls.Add(generalPage);
            UITools.SetTabPageColor(this.tpgPath);
        }
コード例 #4
0
ファイル: SpriteFontLoader.cs プロジェクト: jlu19/Tile_Puzzle
    public static FontData LoadFontFromXmlFile(TextAsset fontLayout)
    {
        FontData font = new FontData();
        XmlDocument document = new XmlDocument();
        document.LoadXml(fontLayout.text);
        XmlNode root = document.DocumentElement;

        // load the basic attributes
        XmlNode secton = root.SelectSingleNode("info");
        font.Info.Face = ParseString(secton, "face");
        font.Info.Size = ParseInt(secton, "size");
        font.Info.Bold = ParseBool(secton, "bold");
        font.Info.Italic = ParseBool(secton, "italic");
        font.Info.Unicode = ParseBool(secton, "unicode");
        font.Info.StretchHeight = ParseInt(secton, "stretchH");
        font.Info.Charset = ParseString(secton, "charset");
        font.Info.Smooth = ParseBool(secton, "smooth");
        font.Info.SuperSampling = ParseInt(secton, "aa");
        font.Info.Padding = ParseRect(secton, "padding");
        font.Info.Spacing = ParseVector2(secton, "spacing");
        font.Info.Outline = ParseInt(secton, "outline");

        // common attributes
        secton = root.SelectSingleNode("common");
        font.Common.LineHeight = ParseInt(secton, "lineHeight");
        font.Common.Base = ParseInt(secton, "base");
        font.Common.ScaleW = ParseInt(secton, "scaleW");
        font.Common.ScaleH = ParseInt(secton, "scaleH");
        font.Common.Pages = ParseInt(secton, "pages");
        font.Common.Packed = ParseBool(secton, "packed");
        font.Common.AlphaChannel = ParseInt(secton, "alphaChnl");
        font.Common.RedChannel = ParseInt(secton, "redChnl");
        font.Common.GreenChannel = ParseInt(secton, "greenChnl");
        font.Common.BlueChannel = ParseInt(secton, "blueChnl");

        // load texture information
        font.Pages.Clear();
        foreach (XmlNode node in root.SelectNodes("pages/page"))
        {
            FontPage page = new FontPage();
            page.Id = ParseInt(node, "id");
            page.File = ParseString(node, "file");
            font.Pages.Add(page);
        }

        // load character information
        font.Chars.Clear();
        foreach (XmlNode node in root.SelectNodes("chars/char"))
        {
            FontChar ch = new FontChar();
            ch.Id = ParseInt(node, "id");
            ch.X = ParseInt(node, "x");
            ch.Y = ParseInt(node, "y");
            ch.Width = ParseInt(node, "width");
            ch.Height = ParseInt(node, "height");
            ch.XOffset = ParseInt(node, "xoffset");
            ch.YOffset = ParseInt(node, "yoffset");
            ch.XAdvance = ParseInt(node, "xadvance");
            ch.Page = ParseInt(node, "page");
            ch.Channel = ParseInt(node, "chnl");
            ch.Description = string.Format("Char: [{0}]; Code: [{1}]", (char)ch.Id, ch.Id);
            font.Chars.Add(ch);
        }

        // loading kerning information
        font.Kernings.Clear();
        foreach (XmlNode node in root.SelectNodes("kernings/kerning"))
        {
            FontKerning key = new FontKerning();
            key.First = ParseInt(node, "first");
            key.Second = ParseInt(node, "second");
            key.Amount = ParseInt(node, "amount");
            key.Description = string.Format("[{0}] [{1}] Amout: [{2}]", (char)key.First, (char)key.Second, key.Amount);
            font.Kernings.Add(key);
        }
        return font;
    }
コード例 #5
0
ファイル: SpriteFontLoader.cs プロジェクト: jlu19/Tile_Puzzle
 public static FontData LoadFontFromTextFile(TextAsset fontLayout)
 {
     FontData font = new FontData();
     string[] lines = fontLayout.text.Split('\n');
     font.Pages.Clear();
     font.Chars.Clear();
     font.Kernings.Clear();
     foreach (string line in lines)
     {
         Dictionary<string, string> table = ParseLine(line);
         if (table.Count == 0)
         {
             continue;
         }
         switch (table["section"])
         {
             case "info":
                 font.Info.Face = ParseString(table, "face");
                 font.Info.Size = ParseInt(table, "size");
                 font.Info.Bold = ParseBool(table, "bold");
                 font.Info.Italic = ParseBool(table, "italic");
                 font.Info.Charset = ParseString(table, "charset");
                 font.Info.Unicode = ParseBool(table, "unicode");
                 font.Info.StretchHeight = ParseInt(table, "stretchH");
                 font.Info.Smooth = ParseBool(table, "smooth");
                 font.Info.SuperSampling = ParseInt(table, "aa");
                 font.Info.Padding = ParseRect(table, "padding");
                 font.Info.Spacing = ParseVector2(table, "spacing");
                 font.Info.Outline = ParseInt(table, "outline");
                 break;
             case "common":
                 font.Common.LineHeight = ParseInt(table, "lineHeight");
                 font.Common.Base = ParseInt(table, "base");
                 font.Common.ScaleW = ParseInt(table, "scaleW");
                 font.Common.ScaleH = ParseInt(table, "scaleW");
                 font.Common.Pages = ParseInt(table, "pages");
                 font.Common.Packed = ParseBool(table, "packed");
                 font.Common.AlphaChannel = ParseInt(table, "alphaChnl");
                 font.Common.RedChannel = ParseInt(table, "redChnl");
                 font.Common.GreenChannel = ParseInt(table, "greenChnl");
                 font.Common.BlueChannel = ParseInt(table, "blueChnl");
                 break;
             case "page":
                 FontPage page = new FontPage();
                 page.Id = ParseInt(table, "id");
                 page.File = ParseString(table, "file");
                 font.Pages.Add(page);
                 break;
             case "char":
                 FontChar ch = new FontChar();
                 ch.Id = ParseInt(table, "id");
                 ch.X = ParseInt(table, "x");
                 ch.Y = ParseInt(table, "y");
                 ch.Width = ParseInt(table, "width");
                 ch.Height = ParseInt(table, "height");
                 ch.XOffset = ParseInt(table, "xoffset");
                 ch.YOffset = ParseInt(table, "yoffset");
                 ch.XAdvance = ParseInt(table, "xadvance");
                 ch.Page = ParseInt(table, "page");
                 ch.Channel = ParseInt(table, "chnl");
                 ch.Description = string.Format("Char: [{0}]; Code: [{1}]", (char)ch.Id, ch.Id);
                 font.Chars.Add(ch);
                 break;
             case "kerning":
                 FontKerning key = new FontKerning();
                 key.First = ParseInt(table, "first");
                 key.Second = ParseInt(table, "second");
                 key.Amount = ParseInt(table, "amount");
                 key.Description = string.Format("[{0}] [{1}] Amout: [{2}]", (char)key.First, (char)key.Second, key.Amount);
                 font.Kernings.Add(key);
                 break;
         }
     }
     return font;
 }