Timer based animation for font : Font « GUI Windows Form « C# / C Sharp

C# / C Sharp
1. 2D Graphics
2. Collections Data Structure
3. Components
4. Database ADO.net
5. Development Class
6. Event
7. File Stream
8. GUI Windows Form
9. Language Basics
10. Network
11. Office
12. Regular Expressions
13. Services Event
14. Thread
15. Web Services
16. Windows
17. XML
Microsoft Office Word 2007 Tutorial
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
C# / C Sharp » GUI Windows Form » FontScreenshots 
Timer based animation for font
Timer based animation for font


  using System;
  using System.Drawing;
  using System.Drawing.Text;
  using System.Collections;
  using System.ComponentModel;
  using System.Windows.Forms;
  using System.Data;


  public class FontForm : System.Windows.Forms.Form
  {
    private Timer timer;
    private int swellValue;
    private string fontFace = "WingDings";

    public FontForm()
    {
      InitializeComponent();
      timer = new Timer();

      Text = "Font App";
      Width = 425;
      Height = 150;
      BackColor = Color.Honeydew;
      CenterToScreen();
      timer.Enabled = true;
      timer.Interval = 100;
      timer.Tick += new EventHandler(FontForm_OnTimer);
    }
    private void InitializeComponent()
    {
      this.AutoScaleBaseSize = new System.Drawing.Size(513);
      this.ClientSize = new System.Drawing.Size(292253);
      this.Text = "Form1";
      this.Resize += new System.EventHandler(this.FontForm_Resize);
      this.Paint += new System.Windows.Forms.PaintEventHandler(this.FontForm_Paint);

    }
    static void Main() 
    {
      Application.Run(new FontForm());
    }

    private void FontForm_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
    {
      Graphics g = e.Graphics;
      Font theFont = new Font(fontFace, 12 + swellValue);

      string message = "www.java2s.com";  
  
      float windowCenter = this.DisplayRectangle.Width / 2;             
      SizeF stringSize = e.Graphics.MeasureString(message, theFont);
      float startPos = windowCenter - (stringSize.Width / 2);

      g.DrawString(message, theFont, 
        new SolidBrush(Color.Blue), startPos, 10);
    }

    private void FontForm_Resize(object sender, System.EventArgs e)
    {
      Rectangle myRect = new Rectangle(0100
        ClientRectangle.Width, ClientRectangle.Height)
      Invalidate(myRect);
    }

    private void FontForm_OnTimer(object sender, EventArgs e)
    {
      swellValue += 5;
      if(swellValue >= 50)
        swellValue = 0;

      Invalidate(new Rectangle(00, ClientRectangle.Width, 100));
    }
  }

           
       
Related examples in the same category
1. System Fonts: Icon Title FontSystem Fonts: Icon Title Font
2. Load all system installed fontsLoad all system installed fonts
3. Get all system installed fontGet all system installed font
4. Font listFont list
w_w___w___._j___a___v__a__2___s___.___c_o__m__ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.