using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Dolgozat
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            numberbasebutton.Content = "--->";
        }

        public static bool basicstate = true;

        private void numberbasebutton_Click(object sender, RoutedEventArgs e)
        {
            //bool value for rotating the arrow
            // by default arrow points to right
            


            romanic_number.IsEnabled = !romanic_number.IsEnabled;
            arabic_number.IsEnabled= !arabic_number.IsEnabled;

            basicstate = !basicstate;
            if (basicstate)
            {
                numberbasebutton.Content = "--->";
                
            } else
            {
                numberbasebutton.Content = "<---";
            }
            romanic_number.Text = "";
            arabic_number.Text = "";

        }

        private void convertbutton_Click(object sender, RoutedEventArgs e)
        {
            if (romanic_number.IsEnabled) { 
                string romNum = romanic_number.Text;
                int arabicValue = ConvertToArabic(romNum);
                if (arabicValue != 0)
                {
                    arabic_number.Text = arabicValue.ToString();
                }
                else
                {
                    arabic_number.Text = "Hiba!";
                }
            }
            else
            {
                int arNum = 0;
                bool isanumber = Int32.TryParse(arabic_number.Text, out arNum);
                if (isanumber)
                {
                   romanic_number.Text = ConvertToRomanic(arNum);
                }
                
            }

        }

        public static string ConvertToRomanic(int arNum)
        {
            switch (arNum)
            {
                case 1:
                    return "I";
                case 2:
                    return "II";
                case 3:
                    return "III";
                case 4:
                    return "IV";
                case 5:
                    return "V";
                case 6:
                    return "VI";
                case 7:
                    return "VII";
                case 8:
                    return "VIII";
                case 9:
                    return "IX";
                case 10:
                    return "X";
                default:
                    return "Hiba!";
            }
        } 

        public static int ConvertToArabic(string romNum)
        {
            romNum = romNum.ToUpper();
            switch (romNum)
            {
                case "I":
                    return 1;
                case "II":
                    return 2;
                case "III":
                    return 3;
                case "IV":
                    return 4;
                case "V":
                    return 5;
                case "VI":
                    return 6;
                case "VII":
                    return 7;
                case "VIII":
                    return 8;
                case "IX":
                    return 9;
                case "X":
                    return 10;
                default:
                    return 0;
            }
        }
    }
}