Ministerul Educaiei a Republicii Moldova
Universitatea Tehnic din Moldova
Facultatea Calculatoare, Informatic i Microelectronic
Raport
La disciplina: Programarea n Windows
Lucrrile de laborator nr.1-7 n C#
A efectuat: studentul gr. TI-151 Toma Ana
A verificat: Scrob Sergiu
Chiinu 2017
Scopul lucrrii: Aplicarea cunotiinelor acumulate din laboratoarele 1-7 n C#
Listingul programului:
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 WindowsFormsApplication3
{
public partial class Form1 : Form
{
Pen px = new Pen(Color.FromArgb(255, 255, 0, 0), 3);
Pen p = new Pen(Color.FromArgb(255, 255, 0, 0), 3);
Pen p2 = new Pen(Color.FromArgb(255, 0, 0, 0), 4);
Pen p3 = new Pen(Color.FromArgb(255, 0, 0, 0), 4);
int x11 = 480, y11 = 60, x12 = 480 , y12 = 80, x13 = 480, y13 = 95;
//bool chw = true, chr = false, chb = false;
int xs1 = 480, ys1 = 60, xs2 = 480, ys2 = 80, xs3 = 480, ys3 = 95;
bool on = true;
int cx = 480, cy = 130;
bool press = false;
int dx = 0, dy = 0;
Brush b1 = new SolidBrush(Color.Green);
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (press)
{
using (Graphics graphics = CreateGraphics())
{
graphics.FillEllipse(b1, e.X, e.Y, 10, 10);
}
}
}
private void button2_Click(object sender, EventArgs e)
{
this.Refresh();
}
private void Form1_MouseUp(object sender, MouseEventArgs e)
{
press = false;
}
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
press = true;
}
private void leftToolStripMenuItem_Click(object sender, EventArgs e)
{
dx -= 5;
}
private void rightToolStripMenuItem_Click(object sender, EventArgs e)
{
dx += 5;
}
private void downToolStripMenuItem_Click(object sender, EventArgs e)
{
dy += 5;
}
private void upToolStripMenuItem_Click(object sender, EventArgs e)
{
dy -= 5;
if (330 + dy < 300)
dy += 5;
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
px = new Pen(Color.FromArgb(255, 0, 0, 255), 3);
b1 = new SolidBrush(Color.Yellow);
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
px = new Pen(Color.FromArgb(255, 255, 0, 0), 3);
b1 = new SolidBrush(Color.Red);
private void button1_Click(object sender, EventArgs e)
{
on = !on;
if (on == false)
button1.Text = "Start";
else
button1.Text = "Stop";
}
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.Text = "Laboratorul 8Toma Ana";
this.DoubleBuffered = true;
this.Paint += new PaintEventHandler(Form1_Paint);
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
e.Graphics.DrawImage(Properties.Resources.ceas, 380, 30);
e.Graphics.DrawLine(p2, 480, 130, x12, y12);
e.Graphics.DrawLine(p3, 480, 130, x13, y13);
e.Graphics.DrawLine(p3, 0, 300, 600, 300);
e.Graphics.DrawBezier(px, 500 + dx, 370 + dy, 340 + dx,
280 + dy, 420 + dx, 380 + dy, 350 + dx, 580 + dy);
private void timer1_Tick(object sender, EventArgs e)
{
if (on == false)
{
this.Invalidate(new Rectangle(0, 300, 600, 600));
this.Invalidate(new Rectangle(350, 0, 600, 300));
this.Invalidate(new Rectangle(0, 0, 100, 300));
return;
}
double u1 = ((6 * DateTime.Now.Second) * 3.14159265 / 180);
double u2 = ((6 * DateTime.Now.Minute) * 3.14159265 / 180);
double u3 = ((30 * DateTime.Now.Hour + 0.5 * DateTime.Now.Minute) * 3.14159265 /
180);
x11 = (int)(xs1 * Math.Cos(u1) - ys1 * Math.Sin(u1) + cx - cx * Math.Cos(u1) + cy *
Math.Sin(u1));
y11 = (int)(xs1 * Math.Sin(u1) + ys1 * Math.Cos(u1) + cy - cx * Math.Sin(u1) - cy *
Math.Cos(u1));
x12 = (int)(xs2 * Math.Cos(u2) - ys2 * Math.Sin(u2) + cx - cx * Math.Cos(u2) + cy *
Math.Sin(u2));
y12 = (int)(xs2 * Math.Sin(u2) + ys2 * Math.Cos(u2) + cy - cx * Math.Sin(u2) - cy *
Math.Cos(u2));
x13 = (int)(xs3 * Math.Cos(u3) - ys3 * Math.Sin(u3) + cx - cx * Math.Cos(u3) + cy *
Math.Sin(u3));
y13 = (int)(xs3 * Math.Sin(u3) + ys3 * Math.Cos(u3) + cy - cx * Math.Sin(u3) - cy *
Math.Cos(u3));
this.Invalidate(new Rectangle(0, 300, 600, 600));
this.Invalidate(new Rectangle(350, 0, 600, 300));
this.Invalidate(new Rectangle(0, 0 , 100, 300));
}
}
}
Concluzie:
Am fcut cunotiin cu limbajul C#.Am aplicat cunotiinele acumulate din laboratoarele 1-7 n
C#,folosind Visual Studio.Au fost utilizate diferite instrumente din Toolbox.Am invatat sintaxa
unui nou limbaj de programare ,care nu l-am folosit pina acum.Am creat un ceas cu ajutorul
Cu ajutorul primitivelor GDI,la fel am desenat curba Bezier cu care am facut cunostinta la
lucrarea numarul 3 de laborator.In aceasta lucrare de laborator am facut cunostinta cu
platforma .net care usureaza cu mult munca noastra,astfel am creat butoane radio pe care le
folosesc pentru a schimba culoarea curbei Bezier.