Exemple #1
0
        //Checker Process
        private void Checker_Click(object sender, EventArgs e)
        {
            try
            {
                //Clear Shapes
                View_Shape.Refresh();
                List <Braille> Data = Braille.Understanding(Text_Input.Text);
                List <int>     Op   = Braille.Operations(Data);

                int[] Operations = Op.ToArray();
                int   X          = 5;
                int   Y          = 5;

                //Check Item Position
                foreach (var item in Operations)
                {
                    char[] value = item.ToString().ToCharArray();
                    if (X >= 820)
                    {
                        X = 5;
                        Y = 50;
                    }
                    Generate_Shapes(value, X, Y);
                    X += 35;
                }

                //Check If There're Any Operation
                if (Operations.Length == 0)
                {
                    MessageBox.Show("Characters Not Found", "Wait", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }

                Data.Clear();
                Op.Clear();
            }
            catch (Exception E)
            {
                MessageBox.Show(E.Message);
            }
        }
Exemple #2
0
        //Language Understanding
        public static List <Braille> Understanding(string Text)
        {
            //Prepare Data Structure
            Braille        B               = new Braille();
            List <Braille> Content         = new List <Braille>();
            List <char[]>  Total_Character = new List <char[]>();

            //Split Total Text Into Words
            string[] Words = Text.Split(' ');

            //Count Words
            foreach (var item in Words)
            {
                Total_Character.Add(item.ToCharArray());
            }

            //Check Each Single Word
            for (int i = 0; i < Total_Character.Count; i++)
            {
                char[] Letters          = Total_Character[i];
                int    Number_Of_Uppers = 0;
                bool   Upper_Case       = false;
                int    N_Uppers         = 0;
                int    Zero_Time        = 0;

                //Search If All Uppers ()
                foreach (var item in Letters)
                {
                    if (item.ToString() == item.ToString().ToUpper())
                    {
                        N_Uppers += 1;
                    }
                }

                //If All Upper
                if (N_Uppers == Letters.Length)
                {
                    Upper_Case = true;
                }

                //Search For Availablity
                foreach (var letter in Letters)
                {
                    foreach (var Character in Characters_Set)
                    {
                        string  Up    = Character.character.ToString().ToUpper();
                        Braille Upper = new Braille('U', "6");

                        //Case Character Not Declared Or Not Found []
                        Braille Not_Found = new Braille('N', "123456");

                        //Basic Case For Digit
                        if (Char.IsDigit(Character.character) && letter == Character.character)
                        {
                            Braille Digit = new Braille('U', "2456");
                            Content.Add(Digit);
                            Content.Add(Character);
                            break;
                        }

                        //Basic Case For Each Letter
                        if (letter == Character.character)
                        {
                            if (letter == '*')
                            {
                                Content.Add(Character);
                            }
                            Content.Add(Character);
                            break;
                        }

                        //Case All Upper
                        if (letter.ToString() == Character.character.ToString().ToUpper() && Upper_Case == true && N_Uppers > 1)
                        {
                            if (Zero_Time == 0)
                            {
                                Content.Insert(Content.Count, Upper);
                                Content.Insert(Content.Count, Upper);
                                Content.Add(Character);
                                Zero_Time += 1;
                                break;
                            }
                            else
                            {
                                Content.Add(Character);
                                break;
                            }
                        }

                        //Case For Basic Upper
                        if (letter.ToString() == Character.character.ToString().ToUpper() && Upper_Case == false)
                        {
                            Content.Add(Upper);
                            Content.Add(Character);
                            Number_Of_Uppers += 1;
                            break;
                        }

                        //Case For Basic Upper If It's Only One Letter
                        if (letter.ToString() == Character.character.ToString().ToUpper() && Upper_Case == true && N_Uppers == 1)
                        {
                            Content.Add(Upper);
                            Content.Add(Character);
                            Number_Of_Uppers += 1;
                            break;
                        }
                    }
                }
            }
            return(Content);
        }