C # ile Bildirim Sistemi

Doğukan Taydaş

Moderatör
Moderatör
Premium Üye
Geliştirici
Yardımsever Üye
Mesaj
736
Çözümler
55
Beğeni
1.544
Puan
1.179
Ticaret Puanı
0
:mmt-hakkinda:
Değerli forum üyeleri ve değerli forum ziyaretcileri Merhabalar,
bugün sizlere C # ile Bildirim sistemi göstereceğim. Bildirim sistemini Gameforge Client çalışmlarım için hazırladım.
Visual Studio 2019 sürümüyle proje hazırlanmıştır.

Form1.cs:
Genişlet Daralt Kopyala
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CustomAlertBoxDemo
{
    public partial class Bildiri : Form
    {
        public Bildiri()
        {
            InitializeComponent();
        }

        public void Alert(string msg, Alert.enmType type)
        {
            Alert frm = new Alert();
            frm.showAlert(msg,type);
        }
        private void Başarılı_Click(object sender, EventArgs e)
        {
            this.Alert("Başarılı", CustomAlertBoxDemo.Alert.enmType.Başarılı);
        }

        private void Uyarı_Click(object sender, EventArgs e)
        {
            this.Alert("Uyarı", CustomAlertBoxDemo.Alert.enmType.Uyarı);
        }

        private void Hata_Click(object sender, EventArgs e)
        {
            this.Alert("Hata", CustomAlertBoxDemo.Alert.enmType.Hata);
        }

        private void Bilgi_Click(object sender, EventArgs e)
        {
            this.Alert("Bilgi", CustomAlertBoxDemo.Alert.enmType.Bilgi);
        }
    }
}

Form1.Designer.cs:
Genişlet Daralt Kopyala
namespace CustomAlertBoxDemo
{
    partial class Bildiri
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (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()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Bildiri));
            this.Başarılı = new System.Windows.Forms.Button();
            this.Uyarı = new System.Windows.Forms.Button();
            this.Hata = new System.Windows.Forms.Button();
            this.Bilgi = new System.Windows.Forms.Button();
            this.SuspendLayout();
            //
            // Başarılı
            //
            this.Başarılı.BackColor = System.Drawing.Color.SeaGreen;
            this.Başarılı.FlatAppearance.BorderSize = 0;
            this.Başarılı.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
            this.Başarılı.ForeColor = System.Drawing.Color.White;
            this.Başarılı.Location = new System.Drawing.Point(12, 12);
            this.Başarılı.Name = "Başarılı";
            this.Başarılı.Size = new System.Drawing.Size(204, 58);
            this.Başarılı.TabIndex = 0;
            this.Başarılı.Text = "Başarılı";
            this.Başarılı.UseVisualStyleBackColor = false;
            this.Başarılı.Click += new System.EventHandler(this.Başarılı_Click);
            //
            // Uyarı
            //
            this.Uyarı.BackColor = System.Drawing.Color.DarkOrange;
            this.Uyarı.FlatAppearance.BorderSize = 0;
            this.Uyarı.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
            this.Uyarı.ForeColor = System.Drawing.Color.White;
            this.Uyarı.Location = new System.Drawing.Point(12, 140);
            this.Uyarı.Name = "Uyarı";
            this.Uyarı.Size = new System.Drawing.Size(204, 58);
            this.Uyarı.TabIndex = 0;
            this.Uyarı.Text = "Uyarı";
            this.Uyarı.UseVisualStyleBackColor = false;
            this.Uyarı.Click += new System.EventHandler(this.Uyarı_Click);
            //
            // Hata
            //
            this.Hata.BackColor = System.Drawing.Color.DarkRed;
            this.Hata.FlatAppearance.BorderSize = 0;
            this.Hata.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
            this.Hata.ForeColor = System.Drawing.Color.White;
            this.Hata.Location = new System.Drawing.Point(12, 204);
            this.Hata.Name = "Hata";
            this.Hata.Size = new System.Drawing.Size(204, 58);
            this.Hata.TabIndex = 0;
            this.Hata.Text = "Hata";
            this.Hata.UseVisualStyleBackColor = false;
            this.Hata.Click += new System.EventHandler(this.Hata_Click);
            //
            // Bilgi
            //
            this.Bilgi.BackColor = System.Drawing.Color.RoyalBlue;
            this.Bilgi.FlatAppearance.BorderSize = 0;
            this.Bilgi.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
            this.Bilgi.ForeColor = System.Drawing.Color.White;
            this.Bilgi.Location = new System.Drawing.Point(12, 76);
            this.Bilgi.Name = "Bilgi";
            this.Bilgi.Size = new System.Drawing.Size(204, 58);
            this.Bilgi.TabIndex = 0;
            this.Bilgi.Text = "Bilgi";
            this.Bilgi.UseVisualStyleBackColor = false;
            this.Bilgi.Click += new System.EventHandler(this.Bilgi_Click);
            //
            // Bildiri
            //
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
            this.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
            this.ClientSize = new System.Drawing.Size(230, 271);
            this.Controls.Add(this.Bilgi);
            this.Controls.Add(this.Hata);
            this.Controls.Add(this.Uyarı);
            this.Controls.Add(this.Başarılı);
            this.Font = new System.Drawing.Font("Century Gothic", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.MaximizeBox = false;
            this.Name = "Bildiri";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "Bildiri Sistemi";
            this.ResumeLayout(false);

        }

        #endregion

        private System.Windows.Forms.Button Başarılı;
        private System.Windows.Forms.Button Uyarı;
        private System.Windows.Forms.Button Hata;
        private System.Windows.Forms.Button Bilgi;
    }
}

Form_Alert.cs:
Genişlet Daralt Kopyala
using CustomAlertBoxDemo.Properties;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CustomAlertBoxDemo
{
    public partial class Alert : Form
    {
        public Alert()
        {
            InitializeComponent();
        }

        public enum enmAction
        {
            wait,
            start,
            close
        }

        public enum enmType
        {
            Başarılı,
            Uyarı,
            Hata,
            Bilgi
        }
        private Alert.enmAction action;

        private int x, y;

        private void timer1_Tick(object sender, EventArgs e)
        {
            switch(this.action)
            {
                case enmAction.wait:
                    timer1.Interval = 5000;
                    action = enmAction.close;
                    break;
                case Alert.enmAction.start:
                    this.timer1.Interval = 1;
                    this.Opacity += 0.1;
                    if (this.x < this.Location.X)
                    {
                        this.Left--;
                    }
                    else
                    {
                        if (this.Opacity == 1.0)
                        {
                            action = Alert.enmAction.wait;
                        }
                    }
                    break;
                case enmAction.close:
                    timer1.Interval = 1;
                    this.Opacity -= 0.1;

                    this.Left -= 3;
                    if (base.Opacity == 0.0)
                    {
                        base.Close();
                    }
                    break;
            }
        }

        private void Kapat_Click(object sender, EventArgs e)
        {
            timer1.Interval = 1;
            action = enmAction.close;
        }

        public void showAlert(string Yazdır, enmType type)
        {
            this.Opacity = 0.0;
            this.StartPosition = FormStartPosition.Manual;
            string fname;

            for (int i = 1; ; i++)
            {
                fname = "alert" + i.ToString();
                Alert frm = (Alert)Application.OpenForms[fname];

                if (frm == null)
                {
                    this.Name = fname;
                    this.x = Screen.PrimaryScreen.WorkingArea.Width - this.Width + 10;
                    this.y = Screen.PrimaryScreen.WorkingArea.Height - this.Height * i - 3 * i;
                    this.Location = new Point(this.x, this.y);
                    break;

                }
            }
            this.x = Screen.PrimaryScreen.WorkingArea.Width - base.Width - 5;

            switch(type)
            {
                case enmType.Başarılı:
                    this.Resim.Image = Resources.success;
                    this.BackColor = Color.SeaGreen;
                    break;
                case enmType.Hata:
                    this.Resim.Image = Resources.error;
                    this.BackColor = Color.DarkRed;
                    break;
                case enmType.Bilgi:
                    this.Resim.Image = Resources.info;
                    this.BackColor = Color.RoyalBlue;
                    break;
                case enmType.Uyarı:
                    this.Resim.Image = Resources.warning;
                    this.BackColor = Color.DarkOrange;
                    break;
            }


            this.Mesaj.Text = Yazdır;

            this.Show();
            this.action = enmAction.start;
            this.timer1.Start();
        }
    }
}

Form_Alert.Designer.cs:
Genişlet Daralt Kopyala
namespace CustomAlertBoxDemo
{
    partial class Alert
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (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();
            this.Mesaj = new System.Windows.Forms.Label();
            this.Resim = new System.Windows.Forms.PictureBox();
            this.timer1 = new System.Windows.Forms.Timer(this.components);
            this.Kapat = new System.Windows.Forms.PictureBox();
            ((System.ComponentModel.ISupportInitialize)(this.Resim)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.Kapat)).BeginInit();
            this.SuspendLayout();
            //
            // Mesaj
            //
            this.Mesaj.AutoSize = true;
            this.Mesaj.ForeColor = System.Drawing.Color.White;
            this.Mesaj.Location = new System.Drawing.Point(79, 17);
            this.Mesaj.Name = "Mesaj";
            this.Mesaj.Size = new System.Drawing.Size(89, 21);
            this.Mesaj.TabIndex = 0;
            this.Mesaj.Text = "Mesaj test";
            //
            // Resim
            //
            this.Resim.Image = global::CustomAlertBoxDemo.Properties.Resources.success;
            this.Resim.Location = new System.Drawing.Point(12, 8);
            this.Resim.Name = "Resim";
            this.Resim.Size = new System.Drawing.Size(49, 39);
            this.Resim.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
            this.Resim.TabIndex = 2;
            this.Resim.TabStop = false;
            //
            // timer1
            //
            this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
            //
            // Kapat
            //
            this.Kapat.Image = global::CustomAlertBoxDemo.Properties.Resources.icons8_cancel_25px;
            this.Kapat.Location = new System.Drawing.Point(299, 17);
            this.Kapat.Name = "Kapat";
            this.Kapat.Size = new System.Drawing.Size(26, 26);
            this.Kapat.TabIndex = 3;
            this.Kapat.TabStop = false;
            this.Kapat.Click += new System.EventHandler(this.Kapat_Click);
            //
            // Alert
            //
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
            this.BackColor = System.Drawing.SystemColors.Highlight;
            this.ClientSize = new System.Drawing.Size(347, 55);
            this.Controls.Add(this.Kapat);
            this.Controls.Add(this.Resim);
            this.Controls.Add(this.Mesaj);
            this.Font = new System.Drawing.Font("Century Gothic", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            this.Name = "Alert";
            ((System.ComponentModel.ISupportInitialize)(this.Resim)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.Kapat)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.Label Mesaj;
        private System.Windows.Forms.PictureBox Resim;
        internal System.Windows.Forms.Timer timer1;
        private System.Windows.Forms.PictureBox Kapat;
    }
}

:mmt-resimler:

bandicam 2021-12-21 21-36-15-076.webp


bandicam 2021-12-21 21-37-11-893.webp


bandicam 2021-12-21 21-35-26-132.webp


 

Dosya Eklentileri

Geri
Üst