Yaratish uchun ham foydalaniladi. So‘nggi yillarda kompyuter va uning dasturiy ta‘minotiga bo‘lgan talab va qiziqishlar ortib bormoqda. Bu esa o‘z navbatida dasturchidan katta izlanish va mahoratni talab qiladi


Download 295.63 Kb.
bet14/15
Sana08.01.2022
Hajmi295.63 Kb.
#237053
1   ...   7   8   9   10   11   12   13   14   15
Bog'liq
kurs ishi

Плюс, 2009. – 672 с., ил.
8. Фленов М. Е. Библия C#. – 2-е изд. Перераб. И доп.- СПб.: БХВ
Петербург. 2011. – 560 с.: ил. + CD-ROM.
9. Уотсон, Карл и, Нейгел, Кристиан, Педерсен, Якоб Хаммер, Рид,
Джон Д., Скиннер, Морган, Уайт, Эрик. Visual С# 2008: базовый курс. : Пер.
с англ. - М. : ООО "И.Д. Вильяме", 2009. - 1216 с.: ил. — Парал. тит. англ.
10. Дейтел Х. C# Наиболее полное руководство. Пер. с англ. / Дейтел Х.,
Дейтел П., Листфилд Дж., Нието Т., Йегер Ш., Златкина М. – СПб.: БХВ
Петербург, 2006. – 1056 с.: ил.
11. www.ziyonet.uz

ILOVA

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 Analog_Clock

{

public partial class Form1 : Form



{

Timer t = new Timer();

int WIDTH = 300, HEIGTH = 300, secHAND = 140, minHAND = 110, hrHAND = 80;

//center


int cx, cy;

Bitmap bmp;

Graphics g;

public Form1()

{

InitializeComponent();



}

private void Form1_Load(object sender, EventArgs e)

{

//create bitmap



bmp = new Bitmap(WIDTH + 1, HEIGTH + 1);

// center

cx = WIDTH / 2;

cy = HEIGTH / 2;

//Backcolor

this.BackColor = Color.White;

//timer

t.Interval = 1000; //in milliseconds

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[] handCoord = new int[2];

g.Clear(Color.White);

g.DrawEllipse(new Pen(Color.Black, 1f), 0, 0, WIDTH, HEIGTH);

g.DrawString("12", new Font("Arial", 12), Brushes.Black, new PointF(140, 2));

g.DrawString("3", new Font("Arial", 12), Brushes.Black, new PointF(286, 140));

g.DrawString("6", new Font("Arial", 12), Brushes.Black, new PointF(142, 282));

g.DrawString("9", new Font("Arial", 12), Brushes.Black, new PointF(0, 140));

handCoord = msCoord(ss, secHAND);

g.DrawLine(new Pen(Color.Red, 1f), new Point(cx, cy), new Point(handCoord[0], handCoord[1]));



handCoord = msCoord(mm, minHAND);

g.DrawLine(new Pen(Color.Black, 2f), new Point(cx, cy), new Point(handCoord[0], handCoord[1]));

handCoord = hrCoord(hh % 12, mm, hrHAND);

g.DrawLine(new Pen(Color.Blue, 3f), new Point(cx, cy), new Point(handCoord[0], handCoord[1]));

g.Dispose();

pictureBox1.Image = bmp;

this.Text = "Analog Clock " + hh + ":" + mm + ":" + ss;

}

// coordinates min and sec

private int[] msCoord(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.Sin(Math.PI * val / 180));

}

return coord;

}

private int[] hrCoord(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.Sin(Math.PI * val / 180));

}

return coord;

}


Download 295.63 Kb.

Do'stlaringiz bilan baham:
1   ...   7   8   9   10   11   12   13   14   15




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling