İçeriğe geç
ShiftDelete.Net
Haber ara/ SDN'ye SorGiriş
Haber Akışı SDNTV İnceleme Forum Yapay Zeka Akıllı Telefon Elektrikli Otomobil Oyun ShiftDelete.Net Global Teknoloji Haberleri Mobil Otomobil Donanım Savunma Bilim Sosyal Medya İnternet Giyilebilir Teknoloji Rehber Ürünler Sinema Dizi Akıllı Ev Motosiklet Mikromobilite Kripto Para Sağlık Teknolojileri Son dakika Yazarlar
  1. Ana sayfa
  2. SDN Forum
  3. Programlama
  4. Programlama Dilleri
Programlama Dilleri

C# Saat Uygulaması

Konu bilgisi

19cevap
17 bingörüntüleme
26.07.2012açıldı
06.05.2013son cevap

#1
Merhaba Arkadaşlar
Bir Saat Yapmak İstiyorum Fakat Form Çalıştırdkdan Sonra Normal Bir Saat Gibi Zaman İlerleyecek
Bunu Nasıl Yapabilirim ?
Cevaplar
#2
hangi dilde yapacaksın hangi programda biraz daha detaylı bilgi verirsen yardımcı olacak birileri çıkacaktır
#3
GassipGirl dedi: ↑
hangi dilde yapacaksın hangi programda biraz daha detaylı bilgi verirsen yardımcı olacak birileri çıkacaktır
Okuman yok herhalde başlığı okuyabilirsen bütün sorularına cevap bulacaksın.
OnurSorhan Konuyu açan
#4
GassipGirl dedi: ↑
hangi dilde yapacaksın hangi programda biraz daha detaylı bilgi verirsen yardımcı olacak birileri çıkacaktır
Başlığı Görmedniz Sanırım "
#5
Janmark dedi: ↑
Okuman yok herhalde başlığı okuyabilirsen bütün sorularına cevap bulacaksın.
haklısınız oruç işte naparsın :)okumam yok sadece yazabiliyorum :)
OnurSorhan dedi: ↑
Başlığı Görmedniz Sanırım "
valla görmedim:)
OnurSorhan Konuyu açan
#6
Daha Detaylı Bilgi Verim Ben En İyisi Belki O Zaman Daha Kolay Olabilir :)

private void Form1_Load(object sender, EventArgs e)       
  {         
    timer1.Enabled = true;             
  }        
  private void timer1_Tick(object sender, EventArgs e)       
  {      
       label1.Text = DateTime.Now.Hour.ToString();       
      label2.Text = DateTime.Now.Minute.ToString();   
          label3.Text = DateTime.Now.Second.ToString();     
     }


Böyle Bir kod yapısı kurdum fakat böyle saat sadece formu kapatıp açdığım zaman güncelleniyor benim istediğim form açıkken saat normal çalışsın .s
#7
OnurSorhan dedi: ↑
Daha Detaylı Bilgi Verim Ben En İyisi Belki O Zaman Daha Kolay Olabilir :)

private void Form1_Load(object sender, EventArgs e)       
  {         
    timer1.Enabled = true;             
  }        
  private void timer1_Tick(object sender, EventArgs e)       
  {      
       label1.Text = DateTime.Now.Hour.ToString();       
      label2.Text = DateTime.Now.Minute.ToString();   
          label3.Text = DateTime.Now.Second.ToString();     
     }


Böyle Bir kod yapısı kurdum fakat böyle saat sadece formu kapatıp açdığım zaman güncelleniyor benim istediğim form açıkken saat normal çalışsın .s
Öncelikle Öyle bir kod yapısı kurmamışsın frmtr'den almışsın :) ve kodlarda sorun yok çalışıyor :)
OnurSorhan Konuyu açan
#8
frmtr'yi İlk Defa Sizden Duyuyorum Desem :D

Ben bir alarm Proğramı Yapıyorum

Bakın Bunlarda Kodlarım Benim Yapmak İstediğimi Anlamadınız Hala Çalışmıyor Demiyorum Ben Sürekli Saniyenin Dakikanın Değişmesinden Bahsetmiştim Ben

Bunlarda Kodlarım Frmtr ne ya haha :D
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Collections.Generic;
using System.Text;
using System.Media;


namespace Alarm
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
internal System.Windows.Forms.Button button2;
internal System.Windows.Forms.Button button1;
internal System.Windows.Forms.Label Label3;
internal System.Windows.Forms.TextBox textBox3;
internal System.Windows.Forms.TextBox textBox2;
internal System.Windows.Forms.Timer timer2;
internal System.Windows.Forms.Label Label2;
internal System.Windows.Forms.TextBox textBox1;
internal System.Windows.Forms.Timer timer1;
internal System.Windows.Forms.Label Label1;
private Timer timer3;
private Label label4;
private Label label5;
private Label label6;
private System.ComponentModel.IContainer components;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.button2 = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.Label3 = new System.Windows.Forms.Label();
this.textBox3 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.timer2 = new System.Windows.Forms.Timer(this.components);
this.Label2 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.Label1 = new System.Windows.Forms.Label();
this.timer3 = new System.Windows.Forms.Timer(this.components);
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// button2
//
this.button2.Image = ((System.Drawing.Image)(resources.GetObject("button2.Image")));
this.button2.ImageAlign = System.Drawing.ContentAlignment.TopCenter;
this.button2.Location = new System.Drawing.Point(421, 12);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(72, 56);
this.button2.TabIndex = 26;
this.button2.Text = "Alarmı Kapat";
this.button2.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button1
//
this.button1.Image = ((System.Drawing.Image)(resources.GetObject("button1.Image")));
this.button1.ImageAlign = System.Drawing.ContentAlignment.TopCenter;
this.button1.Location = new System.Drawing.Point(335, 12);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(80, 56);
this.button1.TabIndex = 25;
this.button1.Text = "Alarmı Aç";
this.button1.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Label3
//
this.Label3.Location = new System.Drawing.Point(8, 59);
this.Label3.Name = "Label3";
this.Label3.Size = new System.Drawing.Size(72, 23);
this.Label3.TabIndex = 23;
this.Label3.Text = "Alarm Metni";
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(86, 55);
this.textBox3.Multiline = true;
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(192, 83);
this.textBox3.TabIndex = 24;
this.textBox3.Text = "Uyarı Mesajını Lütfen Buraya Yazınız";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(132, 29);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(100, 20);
this.textBox2.TabIndex = 22;
//
// timer2
//
this.timer2.Tick += new System.EventHandler(this.timer2_Tick);
//
// Label2
//
this.Label2.Location = new System.Drawing.Point(8, 32);
this.Label2.Name = "Label2";
this.Label2.Size = new System.Drawing.Size(100, 23);
this.Label2.TabIndex = 21;
this.Label2.Text = "Alarm Saati";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(132, 4);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 20);
this.textBox1.TabIndex = 20;
//
// timer1
//
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// Label1
//
this.Label1.Location = new System.Drawing.Point(8, 7);
this.Label1.Name = "Label1";
this.Label1.Size = new System.Drawing.Size(88, 16);
this.Label1.TabIndex = 19;
this.Label1.Text = "Alarm Tarihi";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(374, 107);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(35, 13);
this.label4.TabIndex = 27;
this.label4.Text = "label4";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(387, 107);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(35, 13);
this.label5.TabIndex = 28;
this.label5.Text = "label5";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(405, 107);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(35, 13);
this.label6.TabIndex = 29;
this.label6.Text = "label6";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(505, 151);
this.Controls.Add(this.label6);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.Label3);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.Label2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.Label1);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
this.PerformLayout();

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void Form1_Load(object sender, System.EventArgs e)
{
{
timer3.Enabled = true;
}

label4.Text = DateTime.Now.Hour.ToString();
label5.Text = ":" + DateTime.Now.Minute.ToString();
label6.Text = ":" + DateTime.Now.Second.ToString();

//tarih ve saati Text kutularında göster
textBox1.Text = DateTime.Now.ToShortDateString();
textBox2.Text = DateTime.Now.ToLongTimeString();
//Başlangıçta alarm kapalı
timer2.Enabled = false;
timer1.Enabled = false;
//her 100 ms'de bir yanıp sönmeyi sağla
timer2.Interval = 100;
//her 1000 ms'de bir alarmı kontrol etsin
timer1.Interval = 1000;
Text = "Alarm Kapalı";
}

private void timer1_Tick(object sender, System.EventArgs e)
{
//alarm zamanı geldiyse
if (textBox1.Text == DateTime.Now.ToShortDateString() && textBox2.Text == DateTime.Now.ToLongTimeString())
{
//timer2yi aktif yap (yanıp sönmeyi sağlayacak)
timer2.Enabled = true;
//Alarm metnini bildir
MessageBox.Show(textBox3.Text);

}
}

private void timer2_Tick(object sender, System.EventArgs e)
{
//Yazı ve zemin rengini değiştirerek
//Yanıp sönmesini sağla
Color c;
c=textBox3.BackColor;
textBox3.BackColor=textBox3.ForeColor ;
textBox3.ForeColor=c;
}

private void button1_Click(object sender, System.EventArgs e)
{

//Alarmı aktif yap
timer1.Enabled = true;
this.Text = "Alarm Açık";

}

private void button2_Click(object sender, System.EventArgs e)
{

//alarmı kapat
timer2.Enabled = false;
timer1.Enabled = false;
this.Text = "Alarm Kapalı";

}

private void timer3_Tick(object sender, EventArgs e)
{
label4.Text = DateTime.Now.Hour.ToString();
label5.Text = DateTime.Now.Minute.ToString();
label6.Text = DateTime.Now.Second.ToString();

}
}
}
#9
OnurSorhan dedi: ↑
frmtr'yi İlk Defa Sizden Duyuyorum Desem :D

Ben bir alarm Proğramı Yapıyorum

Bakın Bunlarda Kodlarım Benim Yapmak İstediğimi Anlamadınız Hala Çalışmıyor Demiyorum Ben Sürekli Saniyenin Dakikanın Değişmesinden Bahsetmiştim Ben

Bunlarda Kodlarım Frmtr ne ya haha :D
Öyle diyorsan öyledir :)
#11
timer ın intervalini 1000 yaparsan istediğin olucaktır.
#13
Şu anlık sadece Hesap makinesi yapabilecek seviyedeyim :)) Ama bu saat işide iyiymiş :)
OnurSorhan Konuyu açan
#14
Bilgiler İçin Teşekkür Ederim Herkese :)
Şu Kodlar İşimi Gördü :)


 
      private void Form3_Load(object sender, EventArgs e)        
 {          
   Timer t = new Timer(); // timer nesnesi oluşturduk         
    t.Enabled = true; // timerı enable ettik    
         t.Interval = 1000; // Her Bir Saniye'de Tick Eventi Gerçekleşsin İstedik      
       t.Tick += new EventHandler(t_Tick); // Tickleme İçin Event Oluşturduk       
      label1.Text = ""; // Form İlk Load Olduğunda Label'da Yazı Olmasın      
   }         
 void t_Tick(object sender, EventArgs e)        
 {           
  label1.Text = DateTime.Now.ToLongTimeString(); // HER Tickleme Anında Label1.Text'e atama yapıyoruz   
      } 



#15
sanırım söylemek istediğin sadece 1 kere saati otomatik alıcaksın sonra saati saniye saniye sen işleticeksin değil mi?

bunun için form loada timer ın içinde yaptıklarını kopyala daha sonrada altına bir satırda timer1.Enabled=true; ekle

label1 saat : label2 dakika : label3 saniye olsun..

timer1 intervallini 1000 yap.
timer1 in içine

int saniye = int16.Parse(label3.Text);
saniye= saniye +1;
label3.Text= saniye.ToString();
if(int16.Parse(label3.Text)==60)
{
label3.Text="0";
int dakika = int16.Parse(label2.Text);
dakika = dakika+1;
label2.Text=dakika.ToString();
if(int16.Parse(label2.Text)==60)
{
label2.Text="0";
int saat = int16.Parse(label1.Text);
saat = saat+1;
label1.Text=saat.ToString();
if(int16.Parse(label1.Text)==24)
{
label1.Text="";
}
}
}

şuan staj yerimdeyim kodu çalıştırıp deneme imkanım yok kafamdan yazdım herşeyi ufak tefek hatalar çıkabilir
#16
1- Tick Event'i icinde

DateTime.Now.Second
DateTime.Now.Minute
DateTime.Now.Hour

Ile saniye / dakika / saat alabilirsiniz. Saat sonucta. Sistem zaten saat bilgisini yonetiyor. Ayrica donusumlere filan gerek yok.

2- Timer Tick ayrica ozel bir Event'tir. System.Windows.Forms.Timer icin ozel olarak tasarlanmistir, GUI ile ayni thread icerisinde calisir ama kendi icerisinde alt thread olusturur.

Icice gecen iki Thread nedeniyle, GUI mesgulken CALISMAZ. Mouse hareketi, cok kisa sureyle GUI'yi mesgul ettigi icin CALISIYORMUS GIBI GORUNUR fakat GUI'yi 10 sn. mesgul edecek bir ise baslarsaniz saatin saymadigini gorursunuz. Is bittikten sonra saymaya devam eder.

Bunu dikkate alarak Timer kullanin.
Misafir
#17
İyi geceler arkadaslar ACİLLL bana C# ta button click oldugunda hamle sayısını 1 arttırıyor ve en sonunda uygulamadakı butun buttonların ıcındekı renkler random olarak geldıgınde bıtıcek ve bıttıgınde messageBox vericek ! ! ! yardımci olabılrsenz sevınırımm :)
Misafir
#18
bana dijital saat ile alarm progrtamı lazım yardımcı olabilirmisiniz c# form'da
#19
SDN Okuru dedi: ↑
bana dijital saat ile alarm progrtamı lazım yardımcı olabilirmisiniz c# form'da
kardeşim okuman yok mu? yukarıya baksana...
Misafir
#20
gncler ben c# form da label nesnesine yazılan yazının rengini her 300 milisaniyede degişmesini istiyorum ödevim bu yardım ederseniz svinirim

Cevabını yaz

Cevap yazmak için giriş yap ya da üye ol. Eski forum kullanıcı adın ve parolanla girebilirsin.

Reklam