// This file is part of VB-to-VCS, and is therefore licensed under the GNU GPLv3 public license.
// Copyright (C) 2016  Ganden Schaffner and James Fletcher

﻿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 DivModGanden
{
    public partial class frmDivModA : Form
    {
        public frmDivMod frmDivMod;

        public frmDivModA()
        {
            InitializeComponent();
        }

        private void btnCalc_Click(object sender, EventArgs e)
        {
            int value1, value2;
            if (Int32.TryParse(txtValue1.Text, out value1) && Int32.TryParse(txtValue2.Text, out value2))
            {
                if (value1 % value2 == 0)
                    lblOut.Text = "The first is evenly divisible by the second";
                else
                    lblOut.Text = "The first is not evenly divisible by the second";
            }
            else
                lblOut.Text = "Invalid input. Should be integers";

        }

        private void btnBack_Click(object sender, EventArgs e)
        {
            frmDivMod.Show();
            this.Hide();
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            frmDivMod.Close();
        }

        protected override void OnFormClosing(FormClosingEventArgs e)
        {
            // Overrides the original 'X' button click to make it simulate pressing btnExit instead (to close frmSplashScreen)
            base.OnFormClosing(e);

            btnExit.PerformClick();
        }

        private void TextBox_GotFocus(object sender, EventArgs e)
        {
            (sender as TextBox).SelectAll();
        }
    }
}
