• 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# Ekran Koruyucu Yapmak - C Sharp Ekran Koruyucu Yapmak

Üyelik Tarihi
7 Ocak 2015
Konular
4,091
Mesajlar
4,274
MFC Puanı
40
Kod:
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_Ekran_Koruyucu_Grafik
{
    public partial class Ekran_Koruyucu_Grafik : Form
    {
        public Ekran_Koruyucu_Grafik()
        {
            // Ekran koruyucu için gerekli özellikleri ve ayarları atama

            InitializeComponent();

            InitializeMyComponent();
        }

        private **** Form1_Load(object sender, EventArgs e)
        {
            // Ekran koruyucu yu başlat, ekran koruyucu bir timer

            // nesnesi kullanarak yapabiliriz. Her Tick olayında ekrana

            // yeni bir yazı yazdıracağım

            timer1.Enabled = true;

            // Ekran koruyucu nun yazı yazma hızını bu değişkeni

            //değiştirerek ayalayabiliriz

            timer1.Interval = 100;
        }

        // Ekran koruyucu timer olayı Tick oldugunde yapılacak olan işlemler

        private **** IsmıYaz()
        {
            Graphics g; //ekran yazı yazmak içim grafik nesnesi kullanacağım

            g = this.CreateGraphics();

            Random rdm = new Random();

            //random nesnesini kullanarak ekranda rasgele neresi gelirse oraya

            //istediğim yazı metnini yazdıracağım. yaziMEtni değişkenini değiştirerek

            //istenilen yazı yazdırılabilir.

            string yaziMetni="C Sharp Uygulamalar";

            //Bir hata oluştuğunda ekran koruyucu nun hata vermemesi için try catch kullan



            try
            {
                //grafik nesnesini kullanarak ekran koruyucu ya rasgele fatih köksal yazma 


                g.DrawString(yaziMetni, new Font(FontFamily.Families[rdm.Next(100)], 30,
        FontStyle.Bold), new SolidBrush(Color.FromArgb(rdm.Next(255),
        rdm.Next(255), rdm.Next(255))), rdm.Next(1000), rdm.Next(2000));
            }
            catch
            { 
                //Eğer hatayı öğrenmek için mesaj verilebilir
            }
        }

        private **** timer1_Tick(object sender, EventArgs e)
        {
            //her timer olayında ekran koruyucu yaziMetni değişkenindeki yazıyı yazacak
            IsmıYaz();
        }

        private **** Form1_KeyPress(object sender, KeyPressEventArgs e)
        {
            //eğer escape(esc) tuşuna basılmışsa ekran koruyucu programını kapat

            if (e.KeyChar == (char)Keys.Escape)
                this.Close();
        }

        private **** InitializeMyComponent()
        {
            this.components = new System.ComponentModel.Container();

            this.timer1 = new System.Windows.Forms.Timer(this.components);

            this.SuspendLayout();


            // 
            // Ekran koruyucu timer1 olayı
            // 
            this.timer1.Tick += new System.EventHandler(this.timer1_Tick);


            // 
            // Ekran koruyucu Form1 özellikleri
            // 
            this.Name = "Ekran-Koruyucu";
            this.ShowInTaskbar = false;
            this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
            this.ResumeLayout(false);
            this.Text = "Ekran Koruyucu";
            this.TopMost = true;
            this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
            this.Load += new System.EventHandler(this.Form1_Load);


            // Ekran koruyucu programında escape (esc) tuşu ile çıkabilmek için
            // Ekran koruyucu keyprees event olayını kullanma
            this.KeyPress += new System.Windows.Forms.
                KeyPressEventHandler(this.Form1_KeyPress);
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
            this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
            this.ClientSize = new System.Drawing.Size(292, 266);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;

        }

    }
}
 
Üst