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

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Design Patterns
8.Development Class
9.Event
10.File Stream
11.Generics
12.GUI Windows Form
13.Language Basics
14.LINQ
15.Network
16.Office
17.Reflection
18.Regular Expressions
19.Security
20.Services Event
21.Thread
22.Web Services
23.Windows
24.Windows Presentation Foundation
25.XML
26.XML LINQ
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source
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.java2java.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.All font properties
2.new Font("Times New Roman", 10, FontStyle.Italic)
3.new Font(strFont, fSize)
4.new Font(fontRegular, FontStyle.Italic);
5.Text on Baseline
6.Font: SizeInPoints
7.Font with different size
8.Font: GetHeight
9.System Fonts: Icon Title FontSystem Fonts: Icon Title Font
10.Load all system installed fontsLoad all system installed fonts
11.Get all system installed fontGet all system installed font
12.Font listFont list
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.