• Web sitemizin içeriğine ve tüm hizmetlerimize erişim sağlamak için Web sitemize kayıt olmalı ya da giriş yapmalısınız. Web sitemize üye olmak tamamen ücretsizdir.
  • Sohbetokey.com ile canlı okey oynamaya ne dersin? Hem sohbet et, hem mobil okey oyna!
  • Soru mu? Sorun mu? ''Bir Sorum Var?'' sistemimiz aktiftir. Paylaşın beraber çözüm üretelim.

C Sharp Uygulamalar Dijital Saat Yapımı ve Gösterimi 2

Üyelik Tarihi
7 Ocak 2015
Konular
4,091
Mesajlar
4,274
MFC Puanı
40
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace C_Sharp_Form_Dijital_Saat
{
public partial class Form_Dijital_Saat : Form
{
//her saniye dijital saati güncellemek için timer nesnesi ile
//bir dijital saat yapalım
Timer timer = new Timer();
//saati grafik nesnesi olarak yazabilmek için graphics nesnesinden
//bir örnek oluşturalım
Graphics g;

public Form_Dijital_Saat()
{
InitializeMyComponent();
this.ClientSize = new System.Drawing.Size(239, 83);
SaatUygulamasınıBaslat();
}

//form yüklenirken saati başlatalım ve
//saat grafiği her 1 saniyede bir güncellensin
private **** SaatUygulamasınıBaslat()
{
timer.Enabled = true;
timer.Interval = 1000; // bir saniye denk gelen süre
timer.Tick += new EventHandler(timer_Tick); //saniye olayını oluşturma
timer_Tick(this, null);
}

private **** timer_Tick(object sender, EventArgs e)
{
//saat,dakika ve saniyeyi sistem saatinde çek
string saat = DateTime.Now.Hour.ToString();
string dakika = DateTime.Now.Minute.ToString();
string saniye = DateTime.Now.Second.ToString();
if (saat.Length == 1) saat = "0" + saat;
if (dakika.Length == 1) dakika = "0" + dakika;
if (saniye.Length == 1) saniye = "0" + saniye;

Random random = new Random();

//açılan formda grafik alanı yarat

g = this.CreateGraphics();
g.Clear(Color.BlueViolet);
g.Clear(Color.Blue);
g.Clear(Color.Red);
g.Clear(Color.Gray);
g.Clear(Color.DarkOrange);
g.Clear(Color.Brown);

//bir hata oldugunda problem olmaması için try catch bloğu kullan
try
{
//grafik nesnesini kullanarak ekrana değişik renkler dijital saati yazdır
g.DrawString(saat + ":" + dakika + ":" + saniye, new Font(FontFamily.Families[12], 30, FontStyle.Bold), new SolidBrush(Color.FromArgb(255, 255,255)), 20, 5);

}
catch
{
}

}

#region Windows Form Designer generated code

///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.

private **** InitializeMyComponent()
{
this.SuspendLayout();
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(239, 83);
this.ControlBox = true;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "Form1";
this.Text = "Digital Saat";
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion
}
}
 
Üst