예제 #1
0
        public void TestIfContainsConsonant()
        {
            var consonant = "abcdef";
            var con       = new Consonant(consonant);

            Assert.IsTrue(con.ContainsConsonant());
        }
예제 #2
0
        public void TestIfIsConsonant()
        {
            var consonant = "b";
            var con       = new Consonant(consonant);

            Assert.IsTrue(con.IsConsonant());
        }
예제 #3
0
        public void TestIfIsSetOfConsonant()
        {
            var consonant = "bcdf";
            var con       = new Consonant(consonant);

            Assert.IsTrue(con.IsSetOfConsonants());
        }
예제 #4
0
        public void TestIfIsSetOfConsonantIsInvalid()
        {
            var consonant = "abcdf";
            var con       = new Consonant(consonant);

            Assert.IsFalse(con.IsSetOfConsonants());
        }
예제 #5
0
        public Diacritic(Consonant phone, int diacriticImpact = 0)
        {
            this.Palatalization = phone.Palatalization;

            this.Context   = phone.Context;
            this.Example   = phone.Example;
            this.Length    = phone.Length;
            this.Nasality  = phone.Nasality;
            this.Phonation = phone.Phonation;
            this.Speaker   = phone.Speaker;
            this.Symbol    = phone.Symbol;

            this.DiacriticImpact = diacriticImpact;
        }
예제 #6
0
        public void GotAudioData(object sender, AudioDataEventArgs e)
        {
            if (!this.Enabled)
                return;

            var info = AudioAnalyzer.AnalyzeFrame(e.Data);
            if (info.Consonant != curConsonant && info.Consonant == Consonant.None || curConsonant == Consonant.None)
            {
                //Console.WriteLine(info.Consonant.ToString() + " - " + info.LoudestFreq.ToString());
                if (ConsonantChanged != null)
                    ConsonantChanged(this, new ConsonantChangedEventArgs(curConsonant, info.Consonant));
                curConsonant = info.Consonant;
            }
        }
예제 #7
0
파일: Hangul.cs 프로젝트: steamb23/Naramal
        /// <summary>
        /// <see cref="Hangul"/> 구조체의 인스턴스를 초기화합니다.
        /// </summary>
        /// <param name="character"><see cref="Hangul"/> 구조체로 변환될 한글 문자입니다.</param>
        public Hangul(char character)
        {
            if (CheckHangulSyllable(character))
            {
                int unicodeValue = character;
                unicodeValue -= 0xac00;

                var remainder = unicodeValue % (VowelCount * FinalConsonantCount);

                Consonant      = (Consonant)(unicodeValue / (VowelCount * FinalConsonantCount));
                Vowel          = (Vowel)(remainder / FinalConsonantCount);
                FinalConsonant = (FinalConsonant)(remainder % FinalConsonantCount);
            }
            else
            {
                Consonant      = Consonant.Failed;
                Vowel          = Vowel.Failed;
                FinalConsonant = FinalConsonant.Failed;
            }
        }
예제 #8
0
        public void  AddConsonantSubscripPage(Consonant khc, PdfDocument pdf, Document document, string sIndex)
        {
            const String FONT      = @"C:\Windows\Fonts\STKAITI.TTF";
            PdfFont      fontKaiti = PdfFontFactory.CreateFont(FONT, PdfEncodings.IDENTITY_H, PdfFontFactory.EmbeddingStrategy.FORCE_EMBEDDED, true);

            //GENERAR IMAGENES CONSONANTES
            SaveBitmapfromFontChar(khc.Character, "Kaiti", FontStyle.Regular, sIndex, false, Brushes.Black, "Black");
            SaveBitmapfromFontChar(khc.SubscriptCharacter, "Kaiti", FontStyle.Regular, sIndex, true, Brushes.Black, "Black");
            SaveBitmapfromFontChar(khc.Character, "Kaiti", FontStyle.Regular, sIndex, false, Brushes.Black, "Gray");
            SaveBitmapfromFontChar(khc.SubscriptCharacter, "Kaiti", FontStyle.Regular, sIndex, true, Brushes.Black, "Gray");


            PdfCanvas pdfCanvas = new PdfCanvas(pdf.AddNewPage());

            Canvas canvas = new Canvas(pdfCanvas, pdf, document.GetPageEffectiveArea(pdf.GetDefaultPageSize()));


            //Layer 1
            PdfLayer pdflayer1 = new PdfLayer("Layer 1", pdf);

            pdflayer1.SetOn(true);
            pdfCanvas.BeginLayer(pdflayer1);

            ///Template IMG
            string template = @"D:\KH\Template\ConsonantTemplate.png";

            ImageData data = ImageDataFactory.Create(template);

            iText.Layout.Element.Image img = new iText.Layout.Element.Image(ImageDataFactory.Create(template))
                                             .ScaleToFit(PageSize.A4.GetWidth(), PageSize.A4.GetHeight())
                                             .SetFixedPosition(0, 0);
            canvas.Add(img);
            pdfCanvas.EndLayer();

            //Layer 2 CARACTER GRANDE
            PdfLayer pdflayer2 = new PdfLayer("Layer 2", pdf);

            pdflayer2.SetOn(true);
            pdfCanvas.BeginLayer(pdflayer2);

            int LeftMarginMiZige = 114 * 72 / 300 - 20;
            int UpMarginMiZige   = 114 * 72 / 300 - 5;

            int CaracterSize = 200;

            //Este es el path con el que se ha grabado la imagen previamente
            string path = @"D:\KH\KhmerWorkbook\Chars\" + khc.Character.ToString() + "_Black.png";

            string SubscriptCharacterpath = @"D:\KH\KhmerWorkbook\Chars\" + khc.SubscriptCharacter.ToString() + "_Black.png";


            //COLOCAR CONSONANTE
            iText.Layout.Element.Image MainCaracter = new iText.Layout.Element.Image(ImageDataFactory.Create(path))
                                                      .SetFixedPosition(LeftMarginMiZige, PageSize.A4.GetHeight() - CaracterSize - UpMarginMiZige)
                                                      .ScaleAbsolute(CaracterSize, CaracterSize)
                                                      .SetTextAlignment(TextAlignment.CENTER);
            canvas.Add(MainCaracter);

            //COLOCAR FORMA DE SUBSCRIPT AQUI
            int ScriptSize = 200;



            iText.Layout.Element.Image SubscriptCaracter = new iText.Layout.Element.Image(ImageDataFactory.Create(SubscriptCharacterpath))
                                                           .SetFixedPosition(1000 * 72 / 300 - 20, PageSize.A4.GetHeight() - CaracterSize - UpMarginMiZige)
                                                           .ScaleAbsolute(ScriptSize, ScriptSize)
                                                           .SetTextAlignment(TextAlignment.CENTER);
            canvas.Add(SubscriptCaracter);
            pdfCanvas.EndLayer();

            //Layer 4 CARACTER PEQUEÑOS FOR
            PdfLayer pdflayer4 = new PdfLayer("Layer 4", pdf);

            pdflayer4.SetOn(true);
            pdfCanvas.BeginLayer(pdflayer4);

            int MiniCaracterSize = 30;
            int MaxColumns       = 16; //Se elimina una columna al ver los resultados del margen del primer Workbook TianziGe enviado por Amazon
            int MaxRows          = 17;

            float width              = 30.6F;
            float height             = 30.7F;
            int   UpMarginMiZigeMini = 22;

            float left   = 0;
            float bottom = 0;

            iText.Layout.Element.Image MiniCaracter = new iText.Layout.Element.Image(ImageDataFactory.Create(path));
            MiniCaracter.ScaleAbsolute(MiniCaracterSize, MiniCaracterSize);
            MiniCaracter.SetTextAlignment(TextAlignment.CENTER);

            for (int col = 0; col < MaxColumns; col++)

            {
                for (int row = 0; row < MaxRows; row++)
                {
                    //No se imprimen donde esta en caracter grande situado
                    if (!(row < 6))
                    {
                        left   = 35 + col * width;
                        bottom = PageSize.A4.GetHeight() - MiniCaracterSize - 2 - UpMarginMiZigeMini - row * height;
                        MiniCaracter.SetFixedPosition(left, bottom);
                        canvas.Add(MiniCaracter);
                    }
                }
            }
            pdfCanvas.EndLayer();

            //INFORMACION CARACTER

            document.SetFont(fontKaiti);

            var   dimensionsColumns = new float[] { 1, 1, 1, 1, 1, 1 };
            Table table             = new Table(UnitValue.CreatePercentArray(dimensionsColumns));

            table.UseAllAvailableWidth();

            PdfLayer pdflayerInfo = new PdfLayer("pdflayerInfo", pdf);

            pdflayerInfo.SetOn(true);
            pdfCanvas.BeginLayer(pdflayerInfo);
            int repeticion = 0;

            List <Paragraph> pGlobals = new List <Paragraph>();

            foreach (Word_HSK word in includedWords)
            {
                //Add row to table
                if (word.Character.Contains(khc.Character))
                {
                    repeticion++;

                    Paragraph pGlobal = new Paragraph(word.Character + "\t (" + word.Pinyin + ") , " + word.Type + " , " + word.Description).SetFont(fontKaiti).SetFontSize(10);

                    pGlobals.Add(pGlobal);
                }
            }


            if (repeticion > Maxrepeticion)
            {
                Maxrepeticion = repeticion;
                repeticion    = 0;
                int checkLevel = Level;
            }

            int rowspan = 1;
            int colspan;


            int PalabrasPorFila = 0;

            if (pGlobals.Count <= 4)
            {
                colspan         = 6;
                PalabrasPorFila = 1;
            }
            else if ((pGlobals.Count > 4) && (pGlobals.Count <= 8))
            {
                colspan         = 3;
                PalabrasPorFila = 2;
            }
            else
            {
                colspan         = 2;
                PalabrasPorFila = 3;
            }


            //En blanco antes del numero de pagina

            double Count        = pGlobals.Count;
            double doubleplarba = PalabrasPorFila;
            int    NumeroFilas  = (int)Math.Ceiling(Count / PalabrasPorFila);


            int nwhite = 4 - NumeroFilas;

            int Height  = 14;
            int Columns = 6;                          //Se utiliza para graduar al colspan anterior
            //Celdas en blanco hasta el final del documento
            int FilasBlancasAntesdepalabras = 33 + 4; //Al añadir dos filas mas a la plantilla

            for (int x = 0; x < FilasBlancasAntesdepalabras * Columns; x++)
            {
                Cell cellWhite = new Cell();  // Creating a cell
                cellWhite.SetHeight(Height).Add(new Paragraph(" "));
                table.AddCell(cellWhite);     // Adding cell to the table
            }

            foreach (Paragraph p in pGlobals)
            {
                Cell cellGlobal = new Cell(rowspan, colspan);
                cellGlobal.SetHeight(Height).Add(p);
                table.AddCell(cellGlobal);
            }

            RemoveBorder(table);
            canvas.Add(table);


            Table tableNumberPage = new Table(UnitValue.CreatePercentArray(new float[] { 100 }));

            tableNumberPage.UseAllAvailableWidth();

            for (int x = 0; x < nwhite; x++)
            {
                Cell cellWhite = new Cell();        // Creating a cell
                cellWhite.SetHeight(Height).Add(new Paragraph(" ").SetHeight(Height));
                tableNumberPage.AddCell(cellWhite); // Adding cell to the table
            }

            Cell cellNumberPage = new Cell();   // Creating a cell

            cellNumberPage.SetHeight(Height).Add(new Paragraph(sIndex).SetFontSize(10).SetTextAlignment(TextAlignment.CENTER).SetFont(fontKaiti));
            tableNumberPage.AddCell(cellNumberPage);      // Adding cell to the table

            RemoveBorder(tableNumberPage);
            canvas.Add(tableNumberPage);
            pdfCanvas.EndLayer();
        }
예제 #9
0
 public ConsonantChangedEventArgs(Consonant oldConsonant, Consonant newConsonant)
 {
     OldConsonant = oldConsonant;
     NewConsonant = newConsonant;
 }
예제 #10
0
파일: Hangul.cs 프로젝트: steamb23/Naramal
 /// <summary>
 /// <see cref="Hangul"/> 구조체의 인스턴스를 초기화합니다.
 /// </summary>
 /// <param name="consonant">설정할 자음입니다.</param>
 /// <param name="vowel">설정할 모음입니다.</param>
 /// <param name="finalConsonant">설정할 받침입니다. 기본값은 <see cref="FinalConsonant.None"/>입니다.</param>
 public Hangul(Consonant consonant, Vowel vowel, FinalConsonant finalConsonant = FinalConsonant.None)
 {
     this.Consonant      = consonant;
     this.Vowel          = vowel;
     this.FinalConsonant = finalConsonant;
 }
예제 #11
0
파일: Hangul.cs 프로젝트: steamb23/Naramal
 /// <summary>
 /// 한글의 자음, 모음, 받침을 한 문자로 조합합니다.
 /// </summary>
 /// <param name="consonant"></param>
 /// <param name="vowel"></param>
 /// <param name="finalConsonant"></param>
 /// <returns></returns>
 public static char Merge(Consonant consonant, Vowel vowel, FinalConsonant finalConsonant = FinalConsonant.None) => (char)Merge((int)consonant, (int)vowel, (int)finalConsonant);
예제 #12
0
 public void Constructor_WrongSymbol_Exception(char input)
 {
     var letter = new Consonant(input);
 }