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 Anolog_Saat
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Timer t = new Timer();
int WIDTH = 300, HEIGHT = 300, Saniye = 130, Yelkovan = 105, Akrep = 75;
int cx, cy;
Bitmap bmp;
int Movee=0;
int Mouse_X;
int Mouse_Y;
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
Movee = 1;
Mouse_X = e.X;
Mouse_Y = e.Y;
}
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
if (Movee == 1)
{
this.SetDesktopLocation(MousePosition.X - Mouse_X, MousePosition.Y - Mouse_Y);
}
}
private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
{
Movee = 0;
}
Graphics g;
private void Form1_Load(object sender, EventArgs e)
{
this.TransparencyKey = System.Drawing.SystemColors.ControlLightLight;
this.pictureBox1.BackColor = System.Drawing.Color.Transparent;
this.BackColor = System.Drawing.SystemColors.ControlLightLight;
bmp = new Bitmap(WIDTH + 1, HEIGHT + 1);
cx = WIDTH / 2;
cy = HEIGHT / 2;
t.Interval = 1000;
t.Tick += new EventHandler(this.t_Tick);
t.Start();
}
private void t_Tick(object sender, EventArgs e)
{
g = Graphics.FromImage(bmp);
int ss = DateTime.Now.Second;
int mm = DateTime.Now.Minute;
int hh = DateTime.Now.Hour;
int[] SnDkSKoord = new int[2];
g.Clear(SystemColors.ControlLightLight);
g.DrawEllipse(new Pen(Color.Black, 4f), 0, 0, WIDTH, HEIGHT);
g.FillEllipse(new SolidBrush(Color.Azure),new Rectangle(0,0,WIDTH,HEIGHT));
g.DrawImage(Properties.Resources.trcoderooter, new Rectangle(cx-80, cy - 140, 160, 160));
g.DrawString("12", new Font("Arial", 15), Brushes.Black, new PointF(140, 3));
g.DrawString("1", new Font("Arial", 15), Brushes.Black, new PointF(218, 22));
g.DrawString("2", new Font("Arial", 15), Brushes.Black, new PointF(263, 70));
g.DrawString("3", new Font("Arial", 15), Brushes.Black, new PointF(285, 140));
g.DrawString("4", new Font("Arial", 15), Brushes.Black, new PointF(263, 212));
g.DrawString("5", new Font("Arial", 15), Brushes.Black, new PointF(218, 259));
g.DrawString("6", new Font("Arial", 15), Brushes.Black, new PointF(142, 279));
g.DrawString("7", new Font("Arial", 15), Brushes.Black, new PointF(70, 259));
g.DrawString("8", new Font("Arial", 15), Brushes.Black, new PointF(22, 212));
g.DrawString("9", new Font("Arial", 15), Brushes.Black, new PointF(1, 140));
g.DrawString("10", new Font("Arial", 15), Brushes.Black, new PointF(22, 70));
g.DrawString("11", new Font("Arial", 15), Brushes.Black, new PointF(70, 22));
g.DrawString(hh + ":" + mm + ":" + ss, new Font("Arial", 13,FontStyle.Bold), Brushes.DarkGreen, new PointF(cx-35, cy+40));
g.DrawString(DateTime.Now.ToShortDateString(), new Font("Arial", 12, FontStyle.Bold), Brushes.DarkGreen, new PointF(cx - 42, cy + 65));
SnDkSKoord = SnDkKoord(ss, Saniye);
g.DrawLine(new Pen(Color.Red, 2f), new Point(cx, cy), new Point(SnDkSKoord[0], SnDkSKoord[1]));
SnDkSKoord = SnDkKoord(mm, Yelkovan);
g.DrawLine(new Pen(Color.Black, 5f), new Point(cx, cy), new Point(SnDkSKoord[0], SnDkSKoord[1]));
SnDkSKoord = SaatKoord(hh % 12, mm, Akrep);
g.DrawLine(new Pen(Color.Gray, 6f), new Point(cx, cy), new Point(SnDkSKoord[0], SnDkSKoord[1]));
pictureBox1.Image = bmp;
g.Dispose();
}
private int[] SnDkKoord(int val, int hlen)
{
int[] coord = new int[2];
val *= 6;
if (val >= 0 && val <= 180)
{
coord[0] = cx + (int)(hlen * Math.Sin(Math.PI * val / 180));
coord[1] = cy - (int)(hlen * Math.Cos(Math.PI * val / 180));
}
else
{
coord[0] = cx - (int)(hlen * -Math.Sin(Math.PI * val / 180));
coord[1] = cy - (int)(hlen * Math.Cos(Math.PI * val / 180));
}
return coord;
}
private int[] SaatKoord(int hval, int mval, int hlen)
{
int[] coord = new int[2];
int val = (int)((hval * 30) + (mval * 0.5));
if (val >= 0 && val <= 180)
{
coord[0] = cx + (int)(hlen * Math.Sin(Math.PI * val / 180));
coord[1] = cy - (int)(hlen * Math.Cos(Math.PI * val / 180));
}
else
{
coord[0] = cx - (int)(hlen * -Math.Sin(Math.PI * val / 180));
coord[1] = cy - (int)(hlen * Math.Cos(Math.PI * val / 180));
}
return coord;
}
}
}
C# ile çok fonksiyonlu hesap makinesi yapımı kodları....
TRCodeRooTeR 8443 1 2019-12-22 05:12:22C# ile yazılmış Bankamatik Otomasyonu program kodları...
TRCodeRooTeR 6990 1 2020-11-16 10:17:29