예제 #1
0
 public static void CreateFontFile( FontEd font )
 {
     using( StreamWriter writer = new StreamWriter( File.Create( font.FilePath ) ) )
     {
         writer.Write( font.Text );
         writer.Close( );
     }
 }
        public NewFontWindow( )
        {
            InitializeComponent( );

            _txtFontName.LostFocus += new EventHandler( _txtFontName_LostFocus );
            _txtFontName.GotFocus += new EventHandler( _txtFontName_GotFocus );

            _font = new FontEd( );
        }
 public FontAssetItem( FontEd font )
     : base()
 {
     InitializeComponent( );
     _image.Image = global::LunarDevKit.Properties.Resources.FontIcon;
     _font = font;
     _font.Parent = this;
     this.LabelName = font.Name;
 }
        private void cancelButton_Click( object sender, EventArgs e )
        {
            _font = null;

            this.Close( );
        }
        private void AddFont( FontEd font, bool showFontWindow )
        {
            FontAssetItem fontItem = new FontAssetItem( font );
            _SetAssetItemProperties( fontItem );
            fontItem.AssetClicked += new AssetItemEventHandler( FontAssetClicked );
            fontItem.AssetDoubleClicked += new AssetItemEventHandler( FontAssetDoubleClicked );

            _fontsTabPanel.Controls.Add( fontItem );
            _fontItems.Add( font.Name, fontItem );

            font.FontAdded = true;

            if( showFontWindow )
                fontItem.SpriteFontWindow.Show( );
        }
        public void AddNewFont( )
        {
            string fontName = "";
            Helper.InputBox( Global.EditorTxt.NewFontMsg, Global.EditorTxt.FontTypeNewName, ref fontName );

            while( _fontItems.ContainsKey( fontName ) )
            {
                if( MessageBox.Show( Global.EditorTxt.FontWithSameNameExistsError + "\n" + Global.EditorTxt.ChooseNewNameMsg, "", MessageBoxButtons.YesNo, MessageBoxIcon.Question ) == DialogResult.Yes )
                    Helper.InputBox( Global.EditorTxt.NewFontMsg, Global.EditorTxt.FontTypeNewName, ref fontName );
                else
                    return;
            }

            FontEd font = new FontEd( );
            font.Name = fontName;
            font.Text = GetFontGeneratedCode( fontName );
            font.FilePath = Path.Combine( GetAssetFolder( AssetType.Font ), font.Name + Consts.Files.FONT_EXTENSION );
            if( font.Save( ) )
            {

                AddFont( font, true );

                Global.MainWindow.OnAssetAdded( );
                Global.DisplayMessage( Global.EditorTxt.CreateFontSuccess, 1f );
            }
            else
                Global.DisplayMessage( Global.EditorTxt.CreateFontFailed, 1f );
        }
        private void AddFont( FontEd sprite )
        {
            try
            {

            }
            catch( Exception e )
            {
                ErrorReport.Throw( e );
            }
        }
 public SpriteFontWindow( FontEd font )
 {
     InitializeComponent( );
     this.Owner = Global.MainWindow;
     _font = font;
 }
예제 #9
0
        public static FontEd LoadFontFile( string filePath )
        {
            if( !File.Exists( filePath ) )
            {
                MessageBox.Show( Path.GetFileName( filePath ) + Global.EditorTxt.FileNotFound, "", MessageBoxButtons.OK, MessageBoxIcon.Warning );
                return null;
            }

            FontEd font = new FontEd( );
            font.Name = Path.GetFileNameWithoutExtension( filePath );

            if( Path.GetExtension( filePath ) == ".spritefont" )
            {
                using( StreamReader reader = new StreamReader( File.OpenRead( filePath ) ) )
                {
                    font.Text = reader.ReadToEnd( );
                    reader.Close( );
                }

                Global.MainWindow.AddFontToLoad( filePath );
            }
            else
            {
                MessageBox.Show( "Invalid extension for a sprite font file!", "", MessageBoxButtons.OK, MessageBoxIcon.Warning );
                return null;
            }

            font.FilePath = filePath;
            return font;
        }
        protected override void DisposeResources( )
        {
            if( _font != null )
            {
                _font.SpriteFont = null;
                _font = null;
            }

            if( _spriteFontWindow != null )
                _spriteFontWindow.Dispose( );

            if( AssetThumbnail != null )
                AssetThumbnail.Dispose( );

            base.DisposeResources( );
        }