You are on page 1of 25

Zadatak 1

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace zadadatak1
{
public partial class frmGlavna : Form
{
int ukupno = 0;
int uspesno = 0;
int promasaj = 0;

public void PomeriDugme()
{
int visina = this.ClientSize.Height;
int sirina = this.ClientSize.Width;
Random v = new Random();


btnUhvati.Top = v.Next(0,visina-
btnUhvati.ClientSize.Height);
btnUhvati.Left = v.Next(0,sirina-
btnUhvati.ClientSize.Width);

}

public frmGlavna()
{
InitializeComponent();
}

private void frmGlavna_Load(object sender, EventArgs e)
{

}

private void btnUhvati_MouseHover(object sender,
EventArgs e)
{
PomeriDugme();
}

private void btnUhvati_Click(object sender, EventArgs e)
{
uspesno++;
ukupno = promasaj + uspesno;
this.Text = uspesno + " od " + ukupno;

Random v = new Random();
Color boja = Color.FromArgb(v.Next(256),
v.Next(256), v.Next(256));
this.BackColor = boja;
}

private void frmGlavna_Click(object sender, EventArgs e)
{
promasaj++;
ukupno = promasaj + uspesno;
this.Text = uspesno + " od " + ukupno;
}
}
}


2 zadatak 3 grupa


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Blok_ponedeljak
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}



private void label1_Click(object sender, EventArgs e)
{

}

private void Form1_Load(object sender, EventArgs e)
{
pictureBox1.Image = null;
pictureBox2.Image = null;
pictureBox3.Image = null;
pictureBox4.Image = null;
}

private void pictureBox1_MouseEnter(object sender,
EventArgs e)
{
pictureBox1.Image = Properties.Resources.patrik;


}

private void pictureBox1_MouseLeave(object sender,
EventArgs e)
{
pictureBox1.Image = null;

}

private void pictureBox3_Click(object sender, EventArgs
e)
{
pictureBox3.Image = null;
}

private void pictureBox3_MouseEnter(object sender,
EventArgs e)
{
pictureBox3.Image = Properties.Resources.sandy;
}

private void pictureBox3_MouseLeave(object sender,
EventArgs e)
{
pictureBox3.Image = null;
}

private void pictureBox2_Click(object sender, EventArgs
e)
{
pictureBox2.Image = null;
}

private void pictureBox2_MouseEnter(object sender,
EventArgs e)
{
pictureBox2.Image = Properties.Resources.spongebob1;
}

private void pictureBox2_MouseLeave(object sender,
EventArgs e)
{
pictureBox2.Image = null;
}

private void pictureBox4_Click(object sender, EventArgs
e)
{
pictureBox4.Image = null;
}

private void pictureBox4_MouseEnter(object sender,
EventArgs e)
{
pictureBox4.Image = Properties.Resources.squidward;
}

private void pictureBox4_MouseLeave(object sender,
EventArgs e)
{
pictureBox4.Image = null;
}

private void label1_MouseEnter(object sender, EventArgs
e)
{
//pictureBox1.Visible = true;
}

private void label1_MouseLeave(object sender, EventArgs
e)
{
// pictureBox1.Visible = false;
}


}
}

Zakljucak, bolje je preko picture boxa, nego preko visibla



Zadatak 3



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace zadatik3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void btnResi_Click(object sender, EventArgs e)
{
try
{

double a =
Convert.ToDouble(tbxLinearniclan.Text);
double b =
Convert.ToDouble(tbxSlobodniclan.Text);
if (a == 0 && b == 0) label4.Text = "Jednacina
ima beskonacno resenja";
else if (a == 0 && b != 0) label4.Text =
"Jednacina nema resenja";
else if (a != 0)
{
double x = -b / a;
label4.Text = "Jednacina ima jedno resenje
x=" + x;
}

}
catch
{
MessageBox.Show("Niste uneli odgovarajuci
broj");
}



}

private void Form1_Load(object sender, EventArgs e)
{

}
}
}

Slobodni zadatak prf

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
//slobodno crtanje

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int xp, yp;
bool crtanje;
private void pictureBox1_MouseDown(object sender,
MouseEventArgs e)
{
xp = e.X;
yp = e.Y;
crtanje = true;

}

private void pictureBox1_MouseMove(object sender,
MouseEventArgs e)
{
if (crtanje)
{
int xk = e.X;
int yk = e.Y;

Graphics g = pictureBox1.CreateGraphics();
Pen olovka = new Pen(Color.Red, 5);
g.DrawLine(olovka, xp, yp, xk, yk);
g.Dispose();
olovka.Dispose();
xp = xk;
yp = yk;
}

}



private void pictureBox1_MouseUp(object sender,
MouseEventArgs e)
{
crtanje = false;
}
}
}


4 zadatak


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
//slobodno crtanje

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

int xp, yp;
bool crtanje;
int debljina;
Color boja;


private void pictureBox1_MouseDown(object sender,
MouseEventArgs e)
{
xp = e.X;
yp = e.Y;
crtanje = true;

}

private void pictureBox1_MouseMove(object sender,
MouseEventArgs e)
{
if (crtanje)
{
int xk = e.X;
int yk = e.Y;

Graphics g = pictureBox1.CreateGraphics();
Pen olovka = new Pen(boja, debljina);
g.DrawLine(olovka, xp, yp, xk, yk);
g.Dispose();
olovka.Dispose();
xp = xk;
yp = yk;
}

}



private void pictureBox1_MouseUp(object sender,
MouseEventArgs e)
{
crtanje = false;
}

private void comboBox1_SelectedIndexChanged(object
sender, EventArgs e)
{
if (Convert.ToString(comboBox1.SelectedItem) ==
"crvena")
boja = Color.Red;
else
if (Convert.ToString(comboBox1.SelectedItem) ==
"narandzasta")
boja = Color.Orange;
else
if (Convert.ToString(comboBox1.SelectedItem)
== "zuta")
boja = Color.Yellow;
else
if
(Convert.ToString(comboBox1.SelectedItem) == "zelena")
boja = Color.GreenYellow;
else
if
(Convert.ToString(comboBox1.SelectedItem) == "plava")
boja = Color.Blue;
else
if
(Convert.ToString(comboBox1.SelectedItem) == "ljubicasta")
boja = Color.Purple;


}

private void comboBox2_SelectedIndexChanged(object
sender, EventArgs e)
{
debljina = Convert.ToInt32(comboBox2.SelectedItem);
}
}
}

5 zadatak ++++ gore dole :D

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Zadatak5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
radioButton1.Checked = true;
}

bool crtanje = false;
int pomerajX = 5;
int pomerajY = 0;

int x = 0;
int y = 150;


private void button1_Click(object sender, EventArgs e)
{
crtanje = true;
timer1.Enabled = true;
}

private void Form1_Paint(object sender, PaintEventArgs
e)
{


}

private void timer1_Tick(object sender, EventArgs e)
{
this.Refresh();

Graphics g = this.CreateGraphics();
SolidBrush cetka = new SolidBrush(Color.Red);

if (crtanje == true)
g.FillEllipse(cetka, x+pomerajX, y+pomerajY,
50, 50);

if (radioButton1.Checked == true)
{
x += pomerajX;

if (x > this.ClientSize.Width - 50)
{
pomerajX = -pomerajX;
}
if (x < 0)
{
pomerajX = -pomerajX;
}
g.Dispose();
cetka.Dispose();
}
if (radioButton2.Checked == true)
{
y += pomerajY;

if (y > this.ClientSize.Height - 50)
{
pomerajY = -pomerajY;
}
if (y < 0)
{
pomerajY = -pomerajY;
}
g.Dispose();
cetka.Dispose();
}
}




private void Form1_Resize(object sender, EventArgs e)
{
this.Refresh();
}

private void btnStani_Click(object sender, EventArgs e)
{
timer1.Enabled = false;
}

private void radioButton2_CheckedChanged(object sender,
EventArgs e)
{
pomerajY = 5;
pomerajX = 0;

}

private void radioButton1_CheckedChanged(object sender,
EventArgs e)
{
pomerajX = 5;
pomerajY = 0;
}
}
}



9.uradjen
7.u svesku

8.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace zadataK8
{
public partial class Form1 : Form
{
int br = 0;

public Form1()
{
InitializeComponent();
}

private void textBox1_TextChanged(object sender, EventArgs e)
{

}

private void Form1_Load(object sender, EventArgs e)
{

}

private void btnUnesi_Click(object sender, EventArgs e)
{

try
{
int visina = Convert.ToInt32(tbxVisina.Text);
lbxSpisak.Items.Add(visina);

if (visina > 195)
{
br ++;
label2.Text = "Procentat kosarkasa visih od 195 >> " +br;
}
tbxVisina.Clear();
tbxVisina.Focus();

}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
tbxVisina.Clear();
tbxVisina.Focus();
}
}

private void btnIzbrisi_Click(object sender, EventArgs e)
{
if ((int)lbxSpisak.SelectedItem > 195)
{
br--;
lbxSpisak.Items.Remove(lbxSpisak.SelectedItem);
label2.Text = "Procentat kosarkasa visih od 195 >> " + br;
}
else
lbxSpisak.Items.Remove(lbxSpisak.SelectedItem);
}
}
}

7. zadatak


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DJMakyiKubanac;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}


private void btnUspeh_Click(object sender, EventArgs e)
{

Ucenik Ujeeee = new Ucenik();

Ujeeee.ImeUcenika = tbxIme.Text;
Ujeeee.PrezimeUcenika = tbxPrezime.Text;


if (checkBox1.Checked)
{
Ujeeee.BrNegOcena = true;
}
else
{
Ujeeee.BrNegOcena = false;
Ujeeee.Prosek = Convert.ToDouble(tbxProsek.Text);
}

lblUspeh.Text = Ujeeee.Prikaz();

tbxIme.Clear();
tbxPrezime.Clear();
tbxProsek.Clear();
tbxIme.Focus();
}

private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (checkBox1.Checked)
{
tbxProsek.Enabled = false;
}
else
{
tbxProsek.Enabled = true;
}
}
}
}

Klasa :
using System;
using System.Collections.Generic;


namespace DJMakyiKubanac
{
public class Ucenik
{
private string imeUcenika;
private string prezimeUcenika;
private bool brNegOcena;
private double prosek;

public string ImeUcenika
{
get { return imeUcenika; }
set { imeUcenika = value; }
}
public string PrezimeUcenika
{
get { return prezimeUcenika; }
set { prezimeUcenika = value; }
}
public bool BrNegOcena
{
get { return brNegOcena; }
set { brNegOcena = value; }
}
public double Prosek
{
get { return prosek; }
set { prosek = value; }
}

public string Prikaz()
{
string s="";

if(brNegOcena==true)
{
s = String.Format("Ucenik: " + imeUcenika + " " +
prezimeUcenika + " je nedovoljan.");
}
else
{
if (this.prosek >= 1.5 && this.prosek < 2.5)
{
s = String.Format("Ucenik: " + imeUcenika + " " +
prezimeUcenika + " je dovoljan.");
}
if (this.prosek >= 2.5 && this.prosek < 3.5)
{
s = String.Format("Ucenik: " + imeUcenika + " " +
prezimeUcenika + " je dobar.");
}
if (this.prosek >= 3.5 && this.prosek < 4.5)
{
s = String.Format("Ucenik: " + imeUcenika + " " +
prezimeUcenika + " je vrlodobar.");
}
if (this.prosek >= 4.5 && this.prosek < 5)
{
s = String.Format("Ucenik: " + imeUcenika + " " +
prezimeUcenika + " je odlican.");
}
}
return s;


}
}
}


9. zadatak


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ZAD9
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int xp, yp;
bool crtanje;
Color boja;
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
xp = e.X;
yp = e.Y;
crtanje = true;
Random r = new Random();
boja = Color.FromArgb(r.Next(256), r.Next(256), r.Next(256));
}
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
if (crtanje)
{
int xk = e.X;
int yk = e.Y;

Graphics g = pictureBox1.CreateGraphics();
Pen olovka = new Pen(boja, 5);

g.DrawLine(olovka, xp, yp, xk, yk);
g.Dispose();
olovka.Dispose();
xp = xk;
yp = yk;
}
}

private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
{
crtanje = false;
}





}
}
Zadatak 10


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Zadatak_10
{
public partial class frmGlavna : Form
{
public frmGlavna()
{
InitializeComponent();
}

int a, b, brPokusaja = 0, brTacnihOdgovora = 0;

private void btnPostaviPitanje_Click(object sender, EventArgs e)
{
Random r = new Random();
a = r.Next(1, 10);
b = r.Next(1, 10);
tbxOdgovor.Clear();

label1.Text = a + "x" + b;
tbxOdgovor.Focus();

timer1.Enabled = true;

}

private void tbxOdgovor_TextChanged(object sender, EventArgs e)
{

}

private void timer1_Tick(object sender, EventArgs e)
{
brPokusaja++;
int odgovor = Convert.ToInt32(tbxOdgovor.Text);

if (a*b == odgovor)
{
brTacnihOdgovora++;
label1.Text = "TACNO!";
}
else
{
label1.Text = "NETACNO!";
}

this.Text = "Tacni odgovori " + brTacnihOdgovora + " od " +
brPokusaja + " pokusaja";
timer1.Enabled = false;
}
}
}
Zadatak 13


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace zadatak13
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}



private void button1_Click(object sender, EventArgs e)
{
try
{

int br = Convert.ToInt32(textBox1.Text);
int binbr, pom;
string rezultat = string.Empty;
while (br > 0)
{

pom =br%2;
br /= 2;
rezultat = pom.ToString() + rezultat;

}
label2.Text = String.Format("Broj je: {0}",rezultat);
}

catch
{
MessageBox.Show("Niste uneli broj"); textBox1.Focus();
textBox1.SelectAll();
}
}

private void btnIskoci_Click(object sender, EventArgs e)
{
this.Close();
}
}
}

You might also like