Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 LV4_1
- {
- public partial class Form1 : Form
- {
- //Kolekcija (Queue - FIFO) (Stack - LIFO)
- Queue<Osoba> osobaCollection = new Queue<Osoba>();
- //Deklariramo listu
- List<string> imeList = new List<string>();
- //Deklariramo niz
- string[] imeArray = { "Maja", "Marko", "Ivan", "Iva", "Andrija" };
- public Form1()
- {
- InitializeComponent();
- }
- private void btnPrint_Click(object sender, EventArgs e)
- {
- if (rbCollection.Checked)
- {
- richTextBox1.Clear();
- richTextBox1.Text = "Ime \t Prezime \t Godina rodjenja\n";
- foreach (Osoba os in osobaCollection)
- {
- richTextBox1.Text += String.Format("{0} \t {1} \t {2}\n", os.Ime, os.Prezime, os.GodinaRodjenja); ;
- }
- richTextBox1.Text += "\n";
- richTextBox1.Text += "* Obrnuti redoslijed *\n";
- richTextBox1.Text += "**********************\n";
- foreach (Osoba os in osobaCollection.Reverse())
- {
- richTextBox1.Text += String.Format("{0} \t {1} \t {2}\n", os.Ime, os.Prezime, os.GodinaRodjenja); ;
- }
- lblNoItems.Text = osobaCollection.Count.ToString();
- }
- else if (rbList.Checked)
- {
- //Ispis
- richTextBox1.Clear();
- foreach (string ime in imeList)
- {
- richTextBox1.Text += ime + "\n";
- }
- richTextBox1.Text += "\n";
- richTextBox1.Text += "* Sortirano *\n";
- richTextBox1.Text += "*************\n";
- imeList.Sort();
- foreach (string ime in imeList)
- {
- richTextBox1.Text += ime + "\n";
- }
- lblNoItems.Text = imeList.Count.ToString();
- }
- else if (rbArray.Checked)
- {
- //Ispis
- richTextBox1.Clear();
- for (int i = 0; i <= 4; i++)
- {
- richTextBox1.Text += imeArray[i] + "\n";
- }
- richTextBox1.Text += "\n";
- richTextBox1.Text += "* Sortirano *\n";
- richTextBox1.Text += "*************\n";
- Array.Sort(imeArray);
- foreach (string ime in imeArray)
- {
- richTextBox1.Text += ime + "\n";
- }
- lblNoItems.Text = imeArray.Length.ToString();
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- if (rbCollection.Checked)
- {
- //Unos
- Osoba os = new Osoba(txtIme.Text, txtPrezime.Text, Convert.ToInt32(txtGodinaRodjenja.Text));
- osobaCollection.Enqueue(os);
- }
- else if (rbList.Checked)
- {
- //Unos
- imeList.Add(txtIme.Text);
- }
- }
- private void btnOpen_Click(object sender, EventArgs e)
- {
- if (openFileDialog1.ShowDialog()==DialogResult.OK){
- this.Text=openFileDialog1.FileName;
- System.IO.StreamReader sr = new System.IO.StreamReader(openFileDialog1.FileName);
- richTextBox2.Text=sr.ReadToEnd();
- sr.Close();
- }
- }
- private void btnFont_Click(object sender, EventArgs e)
- {
- if (fontDialog1.ShowDialog() == DialogResult.OK)
- {
- richTextBox2.Font = fontDialog1.Font;
- }
- }
- private void btnColor_Click(object sender, EventArgs e)
- {
- if (colorDialog1.ShowDialog() == DialogResult.OK)
- {
- richTextBox2.ForeColor = colorDialog1.Color;
- }
- }
- private void btnMultiply_Click(object sender, EventArgs e)
- {
- int a, b, rez;
- try
- {
- a = Convert.ToInt32(rbA.Text);
- b = Convert.ToInt32(rbB.Text);
- rez = a * b;
- rbResult.Text = rez.ToString();
- }
- catch(Exception)
- {
- MessageBox.Show("Morate unijeti cijeli broj");
- //MessageBox.Show("Morate unijeti cijeli broj","Upozorenje", --> primjer za uredit taj messagebox
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement