﻿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 JaydenSmithCase
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

        private static string convertCase(string input)
        {
            try
            {
                char[] delimiters = { '\t', ',', '.', '/', '\"', '-', ' ', '\n' };
                
                string[] words = input.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);

                string returnValue = "";

                char[] inputCharactersToReplace = input.ToCharArray();
                bool[] isIndexADelimiter = new bool[inputCharactersToReplace.Length];
                for (int i = 0; i < inputCharactersToReplace.Length; i++)
                {
                    for (int j = 0; j < delimiters.Length; j++)
                    {
                        string currentCharacter = inputCharactersToReplace[i].ToString();
                        string currentDelimiter = delimiters[j].ToString();
                        if (currentCharacter.IndexOf(currentDelimiter) > -1)
                        {
                            isIndexADelimiter[i] = true;
                        }
                    }
                }

                int numWordsConverted = 0;
                for (int i = 0; i < inputCharactersToReplace.Length; i++ )
                {
                    if (isIndexADelimiter[i])
                    {
                        //Simply increment to the next character
                    }
                    else
                    {
                        string replacedChar = (inputCharactersToReplace[i].ToString().ToUpperInvariant());
                        inputCharactersToReplace[i] = (char.Parse(replacedChar));
                        i += words[numWordsConverted].Length - 1;
                        numWordsConverted++;
                    }
                }
                returnValue = new string(inputCharactersToReplace);

                return returnValue;
                 
            }
            catch (Exception e) { return e.Message; }
        }

        private void btnConvert_Click(object sender, EventArgs e)
        {
            txtInput.Text = convertCase(txtInput.Text);
        }

        private void txtInput_TextChanged(object sender, EventArgs e)
        {

        }
    }
}
