StevanovicMilan

Vežba 08, Zadatak 1

Dec 1st, 2017
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.09 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.IO;
  11.  
  12. namespace Vezba_08_2017
  13. {
  14.     public partial class Form1 : Form
  15.     {
  16.         public Form1()
  17.         {
  18.             InitializeComponent();
  19.         }
  20.  
  21.         private void fontToolStripMenuItem_Click(object sender, EventArgs e)
  22.         {
  23.             FontDialog fontDialog = new FontDialog();
  24.             if(fontDialog.ShowDialog() == DialogResult.OK)
  25.             {
  26.                 textBox1.Font = fontDialog.Font;
  27.             }
  28.         }
  29.  
  30.         private void colorToolStripMenuItem_Click(object sender, EventArgs e)
  31.         {
  32.             ColorDialog colorDialog = new ColorDialog();
  33.             if(colorDialog.ShowDialog() == DialogResult.OK)
  34.             {
  35.                 textBox1.ForeColor = colorDialog.Color;
  36.             }
  37.         }
  38.  
  39.         private void addToolStripMenuItem_Click(object sender, EventArgs e)
  40.         {
  41.             AddForm add = new AddForm();
  42.             if(add.ShowDialog() == DialogResult.OK)
  43.             {
  44.                 Osoba o = add.PodaciOOsobi;
  45.                 textBox1.Text += string.Format("{0} {1} rodjen {2} u {3}", o.Ime, o.Prezime, o.DatumRodjenja.ToShortDateString(), o.MestoRodjenja);
  46.             }
  47.         }
  48.  
  49.         private void folderToolStripMenuItem_Click(object sender, EventArgs e)
  50.         {
  51.             FolderBrowserDialog folderDialog = new FolderBrowserDialog();
  52.             folderDialog.ShowDialog();
  53.         }
  54.  
  55.         private void openToolStripMenuItem_Click(object sender, EventArgs e)
  56.         {
  57.             OpenFileDialog openDialog = new OpenFileDialog();
  58.             openDialog.Filter = "Tekstualne datoteke (*.txt)|*.txt|Sve datoteke (*.*)|*.*";
  59.             if (openDialog.ShowDialog() == DialogResult.OK)
  60.             {
  61.                 textBox1.Text = File.ReadAllText(openDialog.FileName);
  62.             }
  63.         }
  64.  
  65.         private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
  66.         {
  67.             SaveFileDialog saveDialog = new SaveFileDialog();
  68.             saveDialog.Filter = "Tekstualne datoteke (*.txt)|*.txt|Sve datoteke (*.*)|*.*";
  69.             if (saveDialog.ShowDialog() == DialogResult.OK)
  70.             {
  71.                 File.WriteAllText(saveDialog.FileName, textBox1.Text);
  72.             }
  73.         }
  74.  
  75.         private void pageSetupToolStripMenuItem_Click(object sender, EventArgs e)
  76.         {
  77.             PageSetupDialog pageDialog = new PageSetupDialog();
  78.             pageDialog.ShowDialog();
  79.         }
  80.  
  81.         private void printToolStripMenuItem_Click(object sender, EventArgs e)
  82.         {
  83.             PrintDialog printDialog = new PrintDialog();
  84.             printDialog.ShowDialog();
  85.  
  86.         }
  87.  
  88.         private void exitToolStripMenuItem_Click(object sender, EventArgs e)
  89.         {
  90.             Close();
  91.         }
  92.  
  93.         private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
  94.         {
  95.             AboutForm about = new AboutForm();
  96.             about.ShowDialog();
  97.         }
  98.     }
  99. }
  100.  
  101.  
  102.  
  103.  
  104.  
  105. using System;
  106. using System.Collections.Generic;
  107. using System.Linq;
  108. using System.Text;
  109. using System.Threading.Tasks;
  110.  
  111. namespace Vezba_08_2017
  112. {
  113.     public class Osoba
  114.     {
  115.         public string Ime { get; set; }
  116.         public string Prezime { get; set; }
  117.         public string MestoRodjenja { get; set; }
  118.         public DateTime DatumRodjenja { get; set; }
  119.  
  120.     }
  121. }
  122.  
  123.  
  124.  
  125.  
  126.  
  127. using System;
  128. using System.Collections.Generic;
  129. using System.ComponentModel;
  130. using System.Data;
  131. using System.Drawing;
  132. using System.Linq;
  133. using System.Text;
  134. using System.Threading.Tasks;
  135. using System.Windows.Forms;
  136.  
  137. namespace Vezba_08_2017
  138. {
  139.     public partial class AboutForm : Form
  140.     {
  141.         public AboutForm()
  142.         {
  143.             InitializeComponent();
  144.         }
  145.  
  146.         private void button1_Click(object sender, EventArgs e)
  147.         {
  148.             DialogResult = DialogResult.OK;
  149.             Close();
  150.         }
  151.     }
  152. }
  153.  
  154.  
  155.  
  156.  
  157.  
  158. using System;
  159. using System.Collections.Generic;
  160. using System.ComponentModel;
  161. using System.Data;
  162. using System.Drawing;
  163. using System.Linq;
  164. using System.Text;
  165. using System.Threading.Tasks;
  166. using System.Windows.Forms;
  167.  
  168. namespace Vezba_08_2017
  169. {
  170.     public partial class AddForm : Form
  171.     {
  172.         public Osoba PodaciOOsobi { get; private set; }
  173.         public AddForm()
  174.         {
  175.             InitializeComponent();
  176.         }
  177.  
  178.         private void button1_Click(object sender, EventArgs e)
  179.         {
  180.             PodaciOOsobi = new Osoba();
  181.             PodaciOOsobi.Ime = textBox1.Text;
  182.             PodaciOOsobi.Prezime = textBox2.Text;
  183.             PodaciOOsobi.MestoRodjenja = textBox3.Text;
  184.             PodaciOOsobi.DatumRodjenja = dateTimePicker1.Value;
  185.  
  186.             DialogResult = DialogResult.OK;
  187.             Close();
  188.         }
  189.  
  190.         private void button2_Click(object sender, EventArgs e)
  191.         {
  192.             DialogResult = DialogResult.Cancel;
  193.             Close();
  194.         }
  195.     }
  196. }
Advertisement
Add Comment
Please, Sign In to add comment