Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Практика_4._1
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void pictureBox1_Click(object sender, EventArgs e)
- {
- getFile.Filter = "Файлы jpeg|*.jpg|Файлы png|*.png|Файлы bmp|*.bmp";
- getFile.ShowDialog();
- if(File.Exists(getFile.FileName))
- mainImage.Load(getFile.FileName);
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
- {
- if ((e.KeyChar >= '0') && (e.KeyChar <= '9'))
- return;
- if (Char.IsControl(e.KeyChar))
- {
- if (e.KeyChar == (char)Keys.Enter)
- mainImage.Focus();
- return;
- }
- e.Handled = true;
- }
- private void size_SelectedIndexChanged(object sender, EventArgs e)
- {
- setPrice();
- }
- private double countPrice()
- {
- double price;
- double coefficient = 0;
- switch (size.SelectedIndex)
- {
- case 0: coefficient = 1; break;
- case 1: coefficient = 1.1; break;
- case 2: coefficient = 1.3; break;
- case 3: coefficient = 1.4; break;
- case 4: coefficient = 1.5; break;
- case 5: coefficient = 1.6; break;
- case 6: coefficient = 1.7; break;
- case 7: coefficient = 1.8; break;
- case 8: coefficient = 1.9; break;
- }
- if (count.TextLength > 0)
- price = Convert.ToDouble(count.Text) * coefficient;
- else
- price = 0;
- if (glossy.Checked)
- price *= 1.5;
- else if (metallic.Checked)
- price *= 2;
- return price;
- }
- private void setPrice()
- {
- if (File.Exists(getFile.FileName))
- price.Text = (countPrice()).ToString() + " грн";
- else MessageBox.Show("Изображение не задано.");
- }
- private void count_TextChanged(object sender, EventArgs e)
- {
- setPrice();
- }
- private void matt_MouseClick(object sender, MouseEventArgs e)
- {
- setPrice();
- }
- private void glossy_Click(object sender, EventArgs e)
- {
- setPrice();
- }
- private void metallic_Click(object sender, EventArgs e)
- {
- setPrice();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment