SlideShare a Scribd company logo
Kurdistan Region-Iraq
Cihan University-Duhok
Department of computer
3rd
Year
ComputerGraphics
Analog Clock
Prepare by :
Omid Mustefa
Supervised :
Dr.Salim
INTRODUCTION
This project is about how to
create an Analog clock
application for windows by
using computer graphics C#
language .
Source Code
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 clock
{
public partial class Form1 : Form
{
Point[,] hands_coord = new Point[3, 2]
{
{new Point(0,0),new Point (0,120)},
{new Point (0,0),new Point (0,140)},
{new Point (0,0),new Point (0,140)}
};
DateTime cur;
DateTime prev;
Boolean change;
Graphics g;
public Form1()
{
InitializeComponent();
}
private void RotatePoint(Point[] pt,
int iRotate, int iangle)
{
Point ptTemp = new Point(0, 0);
for (int i = 0; i < iRotate; i++)
{
ptTemp.X = (int)(pt[i].X *
Math.Cos(2 * Math.PI * iangle / 360) - pt[i].Y
* Math.Sin(2 * Math.PI * iangle / 360));
ptTemp.Y = (int)(pt[i].Y *
Math.Cos(2 * Math.PI * iangle / 360) + pt[i].X
* Math.Sin(2 * Math.PI * iangle / 360));
pt[i] = ptTemp;
}
}
private void Form1_Load(object sender,
EventArgs e)
{
}
private void Form1_Paint(object sender,
PaintEventArgs e)
{
e.Graphics.TranslateTransform(this.Size.Width /
2, this.Size.Height / 2);
e.Graphics.RotateTransform(150);
DrawClock(e.Graphics);
DrawHands(e.Graphics, prev, true,
Color.FromArgb(250, 0, 0, 0));
}
private void DrawClock(Graphics e)
{
Point[] pt = new Point[2];
for (int iangle = 0; iangle < 360;
iangle += 6)
{
pt[0].X = 0;
pt[0].Y = 150;
RotatePoint(pt, 1, iangle);
pt[1].X = pt[1].Y = (iangle % 5 ==
0 ? 10 : 5);
pt[0].X -= pt[1].X / 2;
pt[0].Y -= pt[1].Y / 2;
Pen p = new
Pen(Color.FromArgb(255, 0, 0, 0));
e.DrawEllipse(p, pt[0].X, pt[0].Y,
pt[1].X, pt[1].Y);
e.FillEllipse(new
SolidBrush(Color.FromArgb(255, 0, 0, 0)), pt[0].X,
pt[0].Y, pt[1].X, pt[1].Y);
}
}
private void DrawHands(Graphics e,
DateTime dt, bool change, Color c)
{
Point[,] temmppt = new Point[3, 2];
int[] iangle = new int[3];
iangle[0] = (int)((dt.Hour * 30) %
360 + dt.Minute / 2);
iangle[1] = (int)(dt.Minute * 6);
iangle[2] = (int)(dt.Second * 6);
temmppt =
(Point[,])hands_coord.Clone();
for (int i = change ? 0 : 2; i < 3;
i++)
{
Point[] tt = { temmppt[i, 0],
temmppt[i, 1] };
RotatePoint(tt, 2, iangle[i]);
Pen p = new Pen(c);
e.DrawLine(p, tt[0], tt[1]);
}
}
private void Form1_Resize(object
sender, EventArgs e)
{
Invalidate(); //position in center
}
private void timer1_Tick(object sender,
EventArgs e)
{
cur = DateTime.Now;
change = cur.Hour != prev.Hour ||
cur.Minute != prev.Minute;
DrawHands (this.CreateGraphics
(),cur ,change ,Color.FromArgb
(255,255,255,255));
DrawHands(this.CreateGraphics(),
cur, true, Color.FromArgb(255,0,0,0));
prev = cur;
Invalidate();
}
private void btnDisplay_Click(object
sender, EventArgs e)
{
Close();
}
}
}
OUTPUT
Ad

More Related Content

What's hot (20)

Write a program to perform translation.
 Write a program to perform translation. Write a program to perform translation.
Write a program to perform translation.
Shobhit Saxena
 
Boundary Fill Algorithm in C
Boundary Fill Algorithm in CBoundary Fill Algorithm in C
Boundary Fill Algorithm in C
Kasun Ranga Wijeweera
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
Ankit Kumar
 
SE Computer, Programming Laboratory(210251) University of Pune
SE Computer, Programming Laboratory(210251) University of PuneSE Computer, Programming Laboratory(210251) University of Pune
SE Computer, Programming Laboratory(210251) University of Pune
Bhavesh Shah
 
Computer Graphics Lab File C Programs
Computer Graphics Lab File C ProgramsComputer Graphics Lab File C Programs
Computer Graphics Lab File C Programs
Kandarp Tiwari
 
Gauss in java
Gauss in javaGauss in java
Gauss in java
baxter89
 
Mat lab lecture part 1
Mat lab lecture part 1Mat lab lecture part 1
Mat lab lecture part 1
OmGulshan
 
Dip 5 mathematical preliminaries
Dip 5 mathematical preliminariesDip 5 mathematical preliminaries
Dip 5 mathematical preliminaries
Manas Mantri
 
Turbo C Graphics and Mouse Programming
Turbo C Graphics and Mouse ProgrammingTurbo C Graphics and Mouse Programming
Turbo C Graphics and Mouse Programming
Huzaifa Butt
 
Answers+of+C+sample+exam.docx
Answers+of+C+sample+exam.docxAnswers+of+C+sample+exam.docx
Answers+of+C+sample+exam.docx
ismailaboshatra
 
Computer graphics
Computer graphics   Computer graphics
Computer graphics
Prianka Padmanaban
 
Write a program to perform translation
Write a program to perform translationWrite a program to perform translation
Write a program to perform translation
Shobhit Saxena
 
HelsinkiOS Jan 2015: Useful iOS Code Snippets
HelsinkiOS Jan 2015: Useful iOS Code SnippetsHelsinkiOS Jan 2015: Useful iOS Code Snippets
HelsinkiOS Jan 2015: Useful iOS Code Snippets
Jouni Miettunen
 
Test
TestTest
Test
Kinni MEW
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
amitsarda3
 
Wap in c to draw a line using DDA algorithm
Wap in c to draw a line using DDA algorithmWap in c to draw a line using DDA algorithm
Wap in c to draw a line using DDA algorithm
Kapil Pandit
 
662305 10
662305 10662305 10
662305 10
Nitigan Nakjuatong
 
computer graphics practicals
computer graphics practicalscomputer graphics practicals
computer graphics practicals
Manoj Chauhan
 
Uts
UtsUts
Uts
kiuntoro
 
DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C Programs
Kandarp Tiwari
 
Write a program to perform translation.
 Write a program to perform translation. Write a program to perform translation.
Write a program to perform translation.
Shobhit Saxena
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
Ankit Kumar
 
SE Computer, Programming Laboratory(210251) University of Pune
SE Computer, Programming Laboratory(210251) University of PuneSE Computer, Programming Laboratory(210251) University of Pune
SE Computer, Programming Laboratory(210251) University of Pune
Bhavesh Shah
 
Computer Graphics Lab File C Programs
Computer Graphics Lab File C ProgramsComputer Graphics Lab File C Programs
Computer Graphics Lab File C Programs
Kandarp Tiwari
 
Gauss in java
Gauss in javaGauss in java
Gauss in java
baxter89
 
Mat lab lecture part 1
Mat lab lecture part 1Mat lab lecture part 1
Mat lab lecture part 1
OmGulshan
 
Dip 5 mathematical preliminaries
Dip 5 mathematical preliminariesDip 5 mathematical preliminaries
Dip 5 mathematical preliminaries
Manas Mantri
 
Turbo C Graphics and Mouse Programming
Turbo C Graphics and Mouse ProgrammingTurbo C Graphics and Mouse Programming
Turbo C Graphics and Mouse Programming
Huzaifa Butt
 
Answers+of+C+sample+exam.docx
Answers+of+C+sample+exam.docxAnswers+of+C+sample+exam.docx
Answers+of+C+sample+exam.docx
ismailaboshatra
 
Write a program to perform translation
Write a program to perform translationWrite a program to perform translation
Write a program to perform translation
Shobhit Saxena
 
HelsinkiOS Jan 2015: Useful iOS Code Snippets
HelsinkiOS Jan 2015: Useful iOS Code SnippetsHelsinkiOS Jan 2015: Useful iOS Code Snippets
HelsinkiOS Jan 2015: Useful iOS Code Snippets
Jouni Miettunen
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
amitsarda3
 
Wap in c to draw a line using DDA algorithm
Wap in c to draw a line using DDA algorithmWap in c to draw a line using DDA algorithm
Wap in c to draw a line using DDA algorithm
Kapil Pandit
 
computer graphics practicals
computer graphics practicalscomputer graphics practicals
computer graphics practicals
Manoj Chauhan
 
DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C Programs
Kandarp Tiwari
 

Similar to analog clock C# (20)

Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
Uma mohan
 
Lab. Programs in C
Lab. Programs in CLab. Programs in C
Lab. Programs in C
Saket Pathak
 
C programs Set 2
C programs Set 2C programs Set 2
C programs Set 2
Koshy Geoji
 
C Programming Example
C Programming ExampleC Programming Example
C Programming Example
PRATHAMESH DESHPANDE
 
Architecture for scalable Angular applications (with introduction and extende...
Architecture for scalable Angular applications (with introduction and extende...Architecture for scalable Angular applications (with introduction and extende...
Architecture for scalable Angular applications (with introduction and extende...
Paweł Żurowski
 
Cluj.py Meetup: Extending Python in C
Cluj.py Meetup: Extending Python in CCluj.py Meetup: Extending Python in C
Cluj.py Meetup: Extending Python in C
Steffen Wenz
 
COMPUTER GRAPHICS LAB MANUAL
COMPUTER GRAPHICS LAB MANUALCOMPUTER GRAPHICS LAB MANUAL
COMPUTER GRAPHICS LAB MANUAL
Vivek Kumar Sinha
 
Rsa Signature: Behind The Scenes
Rsa Signature: Behind The Scenes Rsa Signature: Behind The Scenes
Rsa Signature: Behind The Scenes
acijjournal
 
From clever code to better code
From clever code to better codeFrom clever code to better code
From clever code to better code
Dror Helper
 
ماترێکس به‌ کوردی ئارام
ماترێکس به‌ کوردی ئارامماترێکس به‌ کوردی ئارام
ماترێکس به‌ کوردی ئارام
Aram Jamal
 
Pattern printing-in-c(Jaydip Kikani)
Pattern printing-in-c(Jaydip Kikani)Pattern printing-in-c(Jaydip Kikani)
Pattern printing-in-c(Jaydip Kikani)
Jaydip JK
 
pattern-printing-in-c.pdf
pattern-printing-in-c.pdfpattern-printing-in-c.pdf
pattern-printing-in-c.pdf
RSathyaPriyaCSEKIOT
 
Neuroscience Lab: a tour through the eyes of a pythonista, PyData Barcelona2017
Neuroscience Lab: a tour through the eyes of  a pythonista, PyData Barcelona2017Neuroscience Lab: a tour through the eyes of  a pythonista, PyData Barcelona2017
Neuroscience Lab: a tour through the eyes of a pythonista, PyData Barcelona2017
Javier Martinez Alcantara
 
bfd23fd7-0d89-45c0-8b82-c991b30ed375.pdf
bfd23fd7-0d89-45c0-8b82-c991b30ed375.pdfbfd23fd7-0d89-45c0-8b82-c991b30ed375.pdf
bfd23fd7-0d89-45c0-8b82-c991b30ed375.pdf
shehabhamad_90
 
Primitives
PrimitivesPrimitives
Primitives
Nageswara Rao Gottipati
 
I need to create a page that looks like the picture The pro.pdf
I need to create a page that looks like the picture The pro.pdfI need to create a page that looks like the picture The pro.pdf
I need to create a page that looks like the picture The pro.pdf
adianantsolutions
 
.net progrmming part2
.net progrmming part2.net progrmming part2
.net progrmming part2
Dr.M.Karthika parthasarathy
 
C Programming :- An Example
C Programming :- An Example C Programming :- An Example
C Programming :- An Example
Atit Gaonkar
 
CSE 103 Project Presentation.pptx
CSE 103 Project Presentation.pptxCSE 103 Project Presentation.pptx
CSE 103 Project Presentation.pptx
TasnimSaimaRaita
 
DSC program.pdf
DSC program.pdfDSC program.pdf
DSC program.pdf
Prof. Dr. K. Adisesha
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
Uma mohan
 
Lab. Programs in C
Lab. Programs in CLab. Programs in C
Lab. Programs in C
Saket Pathak
 
C programs Set 2
C programs Set 2C programs Set 2
C programs Set 2
Koshy Geoji
 
Architecture for scalable Angular applications (with introduction and extende...
Architecture for scalable Angular applications (with introduction and extende...Architecture for scalable Angular applications (with introduction and extende...
Architecture for scalable Angular applications (with introduction and extende...
Paweł Żurowski
 
Cluj.py Meetup: Extending Python in C
Cluj.py Meetup: Extending Python in CCluj.py Meetup: Extending Python in C
Cluj.py Meetup: Extending Python in C
Steffen Wenz
 
COMPUTER GRAPHICS LAB MANUAL
COMPUTER GRAPHICS LAB MANUALCOMPUTER GRAPHICS LAB MANUAL
COMPUTER GRAPHICS LAB MANUAL
Vivek Kumar Sinha
 
Rsa Signature: Behind The Scenes
Rsa Signature: Behind The Scenes Rsa Signature: Behind The Scenes
Rsa Signature: Behind The Scenes
acijjournal
 
From clever code to better code
From clever code to better codeFrom clever code to better code
From clever code to better code
Dror Helper
 
ماترێکس به‌ کوردی ئارام
ماترێکس به‌ کوردی ئارامماترێکس به‌ کوردی ئارام
ماترێکس به‌ کوردی ئارام
Aram Jamal
 
Pattern printing-in-c(Jaydip Kikani)
Pattern printing-in-c(Jaydip Kikani)Pattern printing-in-c(Jaydip Kikani)
Pattern printing-in-c(Jaydip Kikani)
Jaydip JK
 
Neuroscience Lab: a tour through the eyes of a pythonista, PyData Barcelona2017
Neuroscience Lab: a tour through the eyes of  a pythonista, PyData Barcelona2017Neuroscience Lab: a tour through the eyes of  a pythonista, PyData Barcelona2017
Neuroscience Lab: a tour through the eyes of a pythonista, PyData Barcelona2017
Javier Martinez Alcantara
 
bfd23fd7-0d89-45c0-8b82-c991b30ed375.pdf
bfd23fd7-0d89-45c0-8b82-c991b30ed375.pdfbfd23fd7-0d89-45c0-8b82-c991b30ed375.pdf
bfd23fd7-0d89-45c0-8b82-c991b30ed375.pdf
shehabhamad_90
 
I need to create a page that looks like the picture The pro.pdf
I need to create a page that looks like the picture The pro.pdfI need to create a page that looks like the picture The pro.pdf
I need to create a page that looks like the picture The pro.pdf
adianantsolutions
 
C Programming :- An Example
C Programming :- An Example C Programming :- An Example
C Programming :- An Example
Atit Gaonkar
 
CSE 103 Project Presentation.pptx
CSE 103 Project Presentation.pptxCSE 103 Project Presentation.pptx
CSE 103 Project Presentation.pptx
TasnimSaimaRaita
 
Ad

More from omeed (15)

understanding of java basics
understanding of java basics understanding of java basics
understanding of java basics
omeed
 
OOP using java (Variable in java)
OOP using java (Variable in java)OOP using java (Variable in java)
OOP using java (Variable in java)
omeed
 
Introduction to oop using java
Introduction  to oop using java Introduction  to oop using java
Introduction to oop using java
omeed
 
Asp.net LinkButton & imageButton controls
Asp.net LinkButton & imageButton controlsAsp.net LinkButton & imageButton controls
Asp.net LinkButton & imageButton controls
omeed
 
Asp.net CheckBoxList control
Asp.net CheckBoxList controlAsp.net CheckBoxList control
Asp.net CheckBoxList control
omeed
 
Asp.net CheckBox control
Asp.net CheckBox controlAsp.net CheckBox control
Asp.net CheckBox control
omeed
 
Asp.net RadiobuttonList control
Asp.net RadiobuttonList controlAsp.net RadiobuttonList control
Asp.net RadiobuttonList control
omeed
 
Asp.net Radiobutton control
Asp.net Radiobutton controlAsp.net Radiobutton control
Asp.net Radiobutton control
omeed
 
Asp.net textbox control
Asp.net textbox controlAsp.net textbox control
Asp.net textbox control
omeed
 
Understanding of Asp.net & page lifecycle
Understanding of Asp.net & page lifecycle Understanding of Asp.net & page lifecycle
Understanding of Asp.net & page lifecycle
omeed
 
Asp.net introduction to web development
Asp.net introduction to web development Asp.net introduction to web development
Asp.net introduction to web development
omeed
 
WEB DEVELOPMENT Using Python programming language
WEB DEVELOPMENT Using Python programming language WEB DEVELOPMENT Using Python programming language
WEB DEVELOPMENT Using Python programming language
omeed
 
Apple’s AI-Powered Personal Assistant Uses DNN - siri
Apple’s AI-Powered Personal Assistant Uses DNN - siri  Apple’s AI-Powered Personal Assistant Uses DNN - siri
Apple’s AI-Powered Personal Assistant Uses DNN - siri
omeed
 
Third and fourth generation programming language
Third and fourth generation programming languageThird and fourth generation programming language
Third and fourth generation programming language
omeed
 
graphic Design
graphic Design graphic Design
graphic Design
omeed
 
understanding of java basics
understanding of java basics understanding of java basics
understanding of java basics
omeed
 
OOP using java (Variable in java)
OOP using java (Variable in java)OOP using java (Variable in java)
OOP using java (Variable in java)
omeed
 
Introduction to oop using java
Introduction  to oop using java Introduction  to oop using java
Introduction to oop using java
omeed
 
Asp.net LinkButton & imageButton controls
Asp.net LinkButton & imageButton controlsAsp.net LinkButton & imageButton controls
Asp.net LinkButton & imageButton controls
omeed
 
Asp.net CheckBoxList control
Asp.net CheckBoxList controlAsp.net CheckBoxList control
Asp.net CheckBoxList control
omeed
 
Asp.net CheckBox control
Asp.net CheckBox controlAsp.net CheckBox control
Asp.net CheckBox control
omeed
 
Asp.net RadiobuttonList control
Asp.net RadiobuttonList controlAsp.net RadiobuttonList control
Asp.net RadiobuttonList control
omeed
 
Asp.net Radiobutton control
Asp.net Radiobutton controlAsp.net Radiobutton control
Asp.net Radiobutton control
omeed
 
Asp.net textbox control
Asp.net textbox controlAsp.net textbox control
Asp.net textbox control
omeed
 
Understanding of Asp.net & page lifecycle
Understanding of Asp.net & page lifecycle Understanding of Asp.net & page lifecycle
Understanding of Asp.net & page lifecycle
omeed
 
Asp.net introduction to web development
Asp.net introduction to web development Asp.net introduction to web development
Asp.net introduction to web development
omeed
 
WEB DEVELOPMENT Using Python programming language
WEB DEVELOPMENT Using Python programming language WEB DEVELOPMENT Using Python programming language
WEB DEVELOPMENT Using Python programming language
omeed
 
Apple’s AI-Powered Personal Assistant Uses DNN - siri
Apple’s AI-Powered Personal Assistant Uses DNN - siri  Apple’s AI-Powered Personal Assistant Uses DNN - siri
Apple’s AI-Powered Personal Assistant Uses DNN - siri
omeed
 
Third and fourth generation programming language
Third and fourth generation programming languageThird and fourth generation programming language
Third and fourth generation programming language
omeed
 
graphic Design
graphic Design graphic Design
graphic Design
omeed
 
Ad

Recently uploaded (20)

Discrete choice experiments: Environmental Improvements to Airthrey Loch Lake...
Discrete choice experiments: Environmental Improvements to Airthrey Loch Lake...Discrete choice experiments: Environmental Improvements to Airthrey Loch Lake...
Discrete choice experiments: Environmental Improvements to Airthrey Loch Lake...
Professional Content Writing's
 
Siver Nanoparticles syntheisis, mechanism, Antibacterial activity.pptx
Siver Nanoparticles syntheisis, mechanism, Antibacterial activity.pptxSiver Nanoparticles syntheisis, mechanism, Antibacterial activity.pptx
Siver Nanoparticles syntheisis, mechanism, Antibacterial activity.pptx
PriyaAntil3
 
CORONARY ARTERY BYPASS GRAFTING (1).pptx
CORONARY ARTERY BYPASS GRAFTING (1).pptxCORONARY ARTERY BYPASS GRAFTING (1).pptx
CORONARY ARTERY BYPASS GRAFTING (1).pptx
DharaniJajula
 
ICAI OpenGov Lab: A Quick Introduction | AI for Open Government
ICAI OpenGov Lab: A Quick Introduction | AI for Open GovernmentICAI OpenGov Lab: A Quick Introduction | AI for Open Government
ICAI OpenGov Lab: A Quick Introduction | AI for Open Government
David Graus
 
Issues in using AI in academic publishing.pdf
Issues in using AI in academic publishing.pdfIssues in using AI in academic publishing.pdf
Issues in using AI in academic publishing.pdf
Angelo Salatino
 
Pharmacologically active constituents.pdf
Pharmacologically active constituents.pdfPharmacologically active constituents.pdf
Pharmacologically active constituents.pdf
Nistarini College, Purulia (W.B) India
 
Anti fungal agents Medicinal Chemistry III
Anti fungal agents Medicinal Chemistry  IIIAnti fungal agents Medicinal Chemistry  III
Anti fungal agents Medicinal Chemistry III
HRUTUJA WAGH
 
A Massive Black Hole 0.8kpc from the Host Nucleus Revealed by the Offset Tida...
A Massive Black Hole 0.8kpc from the Host Nucleus Revealed by the Offset Tida...A Massive Black Hole 0.8kpc from the Host Nucleus Revealed by the Offset Tida...
A Massive Black Hole 0.8kpc from the Host Nucleus Revealed by the Offset Tida...
Sérgio Sacani
 
Euclid: The Story So far, a Departmental Colloquium at Maynooth University
Euclid: The Story So far, a Departmental Colloquium at Maynooth UniversityEuclid: The Story So far, a Departmental Colloquium at Maynooth University
Euclid: The Story So far, a Departmental Colloquium at Maynooth University
Peter Coles
 
The Microbial World. Microbiology , Microbes, infections
The Microbial World. Microbiology , Microbes, infectionsThe Microbial World. Microbiology , Microbes, infections
The Microbial World. Microbiology , Microbes, infections
NABIHANAEEM2
 
Astrobiological implications of the stability andreactivity of peptide nuclei...
Astrobiological implications of the stability andreactivity of peptide nuclei...Astrobiological implications of the stability andreactivity of peptide nuclei...
Astrobiological implications of the stability andreactivity of peptide nuclei...
Sérgio Sacani
 
Secondary metabolite ,Plants and Health Care
Secondary metabolite ,Plants and Health CareSecondary metabolite ,Plants and Health Care
Secondary metabolite ,Plants and Health Care
Nistarini College, Purulia (W.B) India
 
dsDNA-ASF, asfaviridae, virus in virology presentation
dsDNA-ASF, asfaviridae, virus in virology presentationdsDNA-ASF, asfaviridae, virus in virology presentation
dsDNA-ASF, asfaviridae, virus in virology presentation
JessaMaeDacayo
 
Cleaned_Expanded_Metal_Nanoparticles_Presentation.pptx
Cleaned_Expanded_Metal_Nanoparticles_Presentation.pptxCleaned_Expanded_Metal_Nanoparticles_Presentation.pptx
Cleaned_Expanded_Metal_Nanoparticles_Presentation.pptx
zainab98aug
 
Antimalarial drug Medicinal Chemistry III
Antimalarial drug Medicinal Chemistry IIIAntimalarial drug Medicinal Chemistry III
Antimalarial drug Medicinal Chemistry III
HRUTUJA WAGH
 
Funakoshi_ZymoResearch_2024-2025_catalog
Funakoshi_ZymoResearch_2024-2025_catalogFunakoshi_ZymoResearch_2024-2025_catalog
Funakoshi_ZymoResearch_2024-2025_catalog
fu7koshi
 
Preparation of Experimental Animals.pptx
Preparation of Experimental Animals.pptxPreparation of Experimental Animals.pptx
Preparation of Experimental Animals.pptx
klynct
 
Brief Presentation on Garment Washing.pdf
Brief Presentation on Garment Washing.pdfBrief Presentation on Garment Washing.pdf
Brief Presentation on Garment Washing.pdf
BharathKumar556689
 
Sleep_physiology_types_duration_underlying mech.
Sleep_physiology_types_duration_underlying mech.Sleep_physiology_types_duration_underlying mech.
Sleep_physiology_types_duration_underlying mech.
klynct
 
Mycology:Characteristics of Ascomycetes Fungi
Mycology:Characteristics of Ascomycetes FungiMycology:Characteristics of Ascomycetes Fungi
Mycology:Characteristics of Ascomycetes Fungi
SAYANTANMALLICK5
 
Discrete choice experiments: Environmental Improvements to Airthrey Loch Lake...
Discrete choice experiments: Environmental Improvements to Airthrey Loch Lake...Discrete choice experiments: Environmental Improvements to Airthrey Loch Lake...
Discrete choice experiments: Environmental Improvements to Airthrey Loch Lake...
Professional Content Writing's
 
Siver Nanoparticles syntheisis, mechanism, Antibacterial activity.pptx
Siver Nanoparticles syntheisis, mechanism, Antibacterial activity.pptxSiver Nanoparticles syntheisis, mechanism, Antibacterial activity.pptx
Siver Nanoparticles syntheisis, mechanism, Antibacterial activity.pptx
PriyaAntil3
 
CORONARY ARTERY BYPASS GRAFTING (1).pptx
CORONARY ARTERY BYPASS GRAFTING (1).pptxCORONARY ARTERY BYPASS GRAFTING (1).pptx
CORONARY ARTERY BYPASS GRAFTING (1).pptx
DharaniJajula
 
ICAI OpenGov Lab: A Quick Introduction | AI for Open Government
ICAI OpenGov Lab: A Quick Introduction | AI for Open GovernmentICAI OpenGov Lab: A Quick Introduction | AI for Open Government
ICAI OpenGov Lab: A Quick Introduction | AI for Open Government
David Graus
 
Issues in using AI in academic publishing.pdf
Issues in using AI in academic publishing.pdfIssues in using AI in academic publishing.pdf
Issues in using AI in academic publishing.pdf
Angelo Salatino
 
Anti fungal agents Medicinal Chemistry III
Anti fungal agents Medicinal Chemistry  IIIAnti fungal agents Medicinal Chemistry  III
Anti fungal agents Medicinal Chemistry III
HRUTUJA WAGH
 
A Massive Black Hole 0.8kpc from the Host Nucleus Revealed by the Offset Tida...
A Massive Black Hole 0.8kpc from the Host Nucleus Revealed by the Offset Tida...A Massive Black Hole 0.8kpc from the Host Nucleus Revealed by the Offset Tida...
A Massive Black Hole 0.8kpc from the Host Nucleus Revealed by the Offset Tida...
Sérgio Sacani
 
Euclid: The Story So far, a Departmental Colloquium at Maynooth University
Euclid: The Story So far, a Departmental Colloquium at Maynooth UniversityEuclid: The Story So far, a Departmental Colloquium at Maynooth University
Euclid: The Story So far, a Departmental Colloquium at Maynooth University
Peter Coles
 
The Microbial World. Microbiology , Microbes, infections
The Microbial World. Microbiology , Microbes, infectionsThe Microbial World. Microbiology , Microbes, infections
The Microbial World. Microbiology , Microbes, infections
NABIHANAEEM2
 
Astrobiological implications of the stability andreactivity of peptide nuclei...
Astrobiological implications of the stability andreactivity of peptide nuclei...Astrobiological implications of the stability andreactivity of peptide nuclei...
Astrobiological implications of the stability andreactivity of peptide nuclei...
Sérgio Sacani
 
dsDNA-ASF, asfaviridae, virus in virology presentation
dsDNA-ASF, asfaviridae, virus in virology presentationdsDNA-ASF, asfaviridae, virus in virology presentation
dsDNA-ASF, asfaviridae, virus in virology presentation
JessaMaeDacayo
 
Cleaned_Expanded_Metal_Nanoparticles_Presentation.pptx
Cleaned_Expanded_Metal_Nanoparticles_Presentation.pptxCleaned_Expanded_Metal_Nanoparticles_Presentation.pptx
Cleaned_Expanded_Metal_Nanoparticles_Presentation.pptx
zainab98aug
 
Antimalarial drug Medicinal Chemistry III
Antimalarial drug Medicinal Chemistry IIIAntimalarial drug Medicinal Chemistry III
Antimalarial drug Medicinal Chemistry III
HRUTUJA WAGH
 
Funakoshi_ZymoResearch_2024-2025_catalog
Funakoshi_ZymoResearch_2024-2025_catalogFunakoshi_ZymoResearch_2024-2025_catalog
Funakoshi_ZymoResearch_2024-2025_catalog
fu7koshi
 
Preparation of Experimental Animals.pptx
Preparation of Experimental Animals.pptxPreparation of Experimental Animals.pptx
Preparation of Experimental Animals.pptx
klynct
 
Brief Presentation on Garment Washing.pdf
Brief Presentation on Garment Washing.pdfBrief Presentation on Garment Washing.pdf
Brief Presentation on Garment Washing.pdf
BharathKumar556689
 
Sleep_physiology_types_duration_underlying mech.
Sleep_physiology_types_duration_underlying mech.Sleep_physiology_types_duration_underlying mech.
Sleep_physiology_types_duration_underlying mech.
klynct
 
Mycology:Characteristics of Ascomycetes Fungi
Mycology:Characteristics of Ascomycetes FungiMycology:Characteristics of Ascomycetes Fungi
Mycology:Characteristics of Ascomycetes Fungi
SAYANTANMALLICK5
 

analog clock C#

  • 1. Kurdistan Region-Iraq Cihan University-Duhok Department of computer 3rd Year ComputerGraphics Analog Clock Prepare by : Omid Mustefa Supervised : Dr.Salim
  • 2. INTRODUCTION This project is about how to create an Analog clock application for windows by using computer graphics C# language .
  • 3. Source Code 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 clock { public partial class Form1 : Form { Point[,] hands_coord = new Point[3, 2] { {new Point(0,0),new Point (0,120)}, {new Point (0,0),new Point (0,140)}, {new Point (0,0),new Point (0,140)} }; DateTime cur; DateTime prev; Boolean change; Graphics g;
  • 4. public Form1() { InitializeComponent(); } private void RotatePoint(Point[] pt, int iRotate, int iangle) { Point ptTemp = new Point(0, 0); for (int i = 0; i < iRotate; i++) { ptTemp.X = (int)(pt[i].X * Math.Cos(2 * Math.PI * iangle / 360) - pt[i].Y * Math.Sin(2 * Math.PI * iangle / 360)); ptTemp.Y = (int)(pt[i].Y * Math.Cos(2 * Math.PI * iangle / 360) + pt[i].X * Math.Sin(2 * Math.PI * iangle / 360)); pt[i] = ptTemp; } } private void Form1_Load(object sender, EventArgs e) { }
  • 5. private void Form1_Paint(object sender, PaintEventArgs e) { e.Graphics.TranslateTransform(this.Size.Width / 2, this.Size.Height / 2); e.Graphics.RotateTransform(150); DrawClock(e.Graphics); DrawHands(e.Graphics, prev, true, Color.FromArgb(250, 0, 0, 0)); } private void DrawClock(Graphics e) { Point[] pt = new Point[2]; for (int iangle = 0; iangle < 360; iangle += 6) { pt[0].X = 0; pt[0].Y = 150; RotatePoint(pt, 1, iangle); pt[1].X = pt[1].Y = (iangle % 5 == 0 ? 10 : 5); pt[0].X -= pt[1].X / 2; pt[0].Y -= pt[1].Y / 2; Pen p = new Pen(Color.FromArgb(255, 0, 0, 0)); e.DrawEllipse(p, pt[0].X, pt[0].Y, pt[1].X, pt[1].Y); e.FillEllipse(new SolidBrush(Color.FromArgb(255, 0, 0, 0)), pt[0].X, pt[0].Y, pt[1].X, pt[1].Y); } }
  • 6. private void DrawHands(Graphics e, DateTime dt, bool change, Color c) { Point[,] temmppt = new Point[3, 2]; int[] iangle = new int[3]; iangle[0] = (int)((dt.Hour * 30) % 360 + dt.Minute / 2); iangle[1] = (int)(dt.Minute * 6); iangle[2] = (int)(dt.Second * 6); temmppt = (Point[,])hands_coord.Clone(); for (int i = change ? 0 : 2; i < 3; i++) { Point[] tt = { temmppt[i, 0], temmppt[i, 1] }; RotatePoint(tt, 2, iangle[i]); Pen p = new Pen(c); e.DrawLine(p, tt[0], tt[1]); } } private void Form1_Resize(object sender, EventArgs e) { Invalidate(); //position in center }
  • 7. private void timer1_Tick(object sender, EventArgs e) { cur = DateTime.Now; change = cur.Hour != prev.Hour || cur.Minute != prev.Minute; DrawHands (this.CreateGraphics (),cur ,change ,Color.FromArgb (255,255,255,255)); DrawHands(this.CreateGraphics(), cur, true, Color.FromArgb(255,0,0,0)); prev = cur; Invalidate(); } private void btnDisplay_Click(object sender, EventArgs e) { Close(); } } }
  翻译: