示例#1
0
            //****************************************************************************************************************
            //**                                                  Protected                                                 **
            //****************************************************************************************************************

            //****************************************************************************************************************
            //**                                                   Private                                                  **
            //****************************************************************************************************************

            /// <summary>
            /// Renvoi la police associée à <paramref name="fontName"/> (ou null si elle n'existe pas)
            /// </summary>
            /// <param name="fontName">nom de la police à retourner</param>
            /// <returns>La police associée à <paramref name="fontName"/> (ou null si elle n'existe pas)</returns>
            private Font InstanceGetFont(FontsEnum fontName)
            {
                if (fonts.ContainsKey(fontName))
                {
                    return(fonts[fontName]);
                }
                else
                {
                    return(null);
                }
            }
示例#2
0
 /// <summary>
 /// Copie les polices d'une autre police
 /// </summary>
 /// <param name="name">nom de la police à créer</param>
 /// <param name="copiedFont">police à copier</param>
 private static void CopyFont(string name, FontsEnum copiedFont)
 {
     foreach (LanguagesEnum lang in Enum.GetValues(typeof(LanguagesEnum)))
     {
         if (System.IO.Directory.Exists("Assets/Resources/Lang/Fonts/" + lang.ToString()))
         {
             if (System.IO.File.Exists("Assets/Resources/Lang/Fonts/" + lang.ToString() + "/" + copiedFont.ToString() + ".ttf"))
             {
                 System.IO.File.Copy("Assets/Resources/Lang/Fonts/" + lang.ToString() + "/" + copiedFont.ToString() + ".ttf", "Assets/Resources/Lang/Fonts/" + lang.ToString() + "/" + name + ".ttf");
             }
             if (System.IO.File.Exists("Assets/Resources/Lang/Fonts/" + lang.ToString() + "/" + copiedFont.ToString() + ".dfont"))
             {
                 System.IO.File.Copy("Assets/Resources/Lang/Fonts/" + lang.ToString() + "/" + copiedFont.ToString() + ".dfont", "Assets/Resources/Lang/Fonts/" + lang.ToString() + "/" + name + ".dfont");
             }
             if (System.IO.File.Exists("Assets/Resources/Lang/Fonts/" + lang.ToString() + "/" + copiedFont.ToString() + ".otf"))
             {
                 System.IO.File.Copy("Assets/Resources/Lang/Fonts/" + lang.ToString() + "/" + copiedFont.ToString() + ".otf", "Assets/Resources/Lang/Fonts/" + lang.ToString() + "/" + name + ".otf");
             }
         }
     }
     AssetDatabase.Refresh();
 }
示例#3
0
            /// <summary>
            /// Affiche la liste des polices (avec possibilité de suppression)
            /// </summary>
            public static void LanguageListFont()
            {
                GUILayout.BeginVertical();
                {
                    GUILayout.Label(LangWindowOption.EditorInEnglish ? "Fonts list:" : "Liste de toutes les polices :");
                    GUILayout.Space(8);

                    //Scrollview de toutes les langues
                    fontScrollPosition = GUILayout.BeginScrollView(fontScrollPosition);
                    {
                        GUILayout.BeginVertical();
                        {
                            GUILayout.Label("", GUI.skin.horizontalSlider);
                            foreach (FontsEnum font in Enum.GetValues(typeof(FontsEnum)))
                            {
                                GUILayout.BeginHorizontal();
                                {
                                    //UI de suppression de langue
                                    if (deletingFont && deletingFontValue == font)
                                    {
                                        GUILayout.Label(LangWindowOption.EditorInEnglish ? "Are you sure you want to delete " + font.ToString() + "?" : "Êtes-vous sûr de vouloir supprimer " + font.ToString() + " ?");
                                        GUILayout.Space(10);
                                        Color oldUIColor = GUI.backgroundColor;
                                        GUI.backgroundColor = Color.green;
                                        if (GUILayout.Button(LangWindowOption.EditorInEnglish ? "Yes" : "Oui"))
                                        {
                                            RemoveFont(font.ToString());
                                            deletingFont = false;
                                        }
                                        GUI.backgroundColor = oldUIColor;
                                        GUILayout.Space(10);
                                        GUI.backgroundColor = Color.red;
                                        if (GUILayout.Button(LangWindowOption.EditorInEnglish ? "No" : "Non"))
                                        {
                                            deletingFont = false;
                                        }
                                        GUI.backgroundColor = oldUIColor;
                                        GUILayout.FlexibleSpace();
                                    }
                                    //UI normale
                                    else
                                    {
                                        GUILayout.Label(font.ToString());
                                        GUILayout.FlexibleSpace();
                                        if (GUILayout.Button(LangWindowOption.EditorInEnglish ? "Delete" : "Supprimer"))
                                        {
                                            deletingFont      = true;
                                            deletingFontValue = font;
                                        }
                                    }
                                }
                                GUILayout.EndHorizontal();
                                GUILayout.Label("", GUI.skin.horizontalSlider);
                            }
                        }
                        GUILayout.EndVertical();
                    }
                    GUILayout.EndScrollView();
                    GUILayout.Space(8);

                    //Bouton d'ajout de langue
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.FlexibleSpace();
                        if (GUILayout.Button(LangWindowOption.EditorInEnglish ? "Add new font" : "Ajouter une nouvelle police"))
                        {
                            newFontName      = "";
                            newFontCopyFonts = false;
                            addingNewFont    = true;
                        }
                    }
                    GUILayout.EndHorizontal();
                    GUILayout.Space(8);
                    GUILayout.FlexibleSpace();
                }
                GUILayout.EndVertical();
            }
示例#4
0
            /// <summary>
            /// affiche l'interface d'ajour de police
            /// </summary>
            public static void LanguageAddNewFont()
            {
                GUILayout.BeginVertical();
                {
                    GUILayout.Label(LangWindowOption.EditorInEnglish ? "Adding new font:" : "Ajout de police :");

                    //Infos pour la création
                    GUILayout.Space(5);
                    //nom de la langue
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Space(5);
                        GUILayout.Label("", GUI.skin.horizontalSliderThumb);
                        GUILayout.Space(5);
                        GUILayout.Label(LangWindowOption.EditorInEnglish ? "Name:" : "Nom :");
                        GUILayout.FlexibleSpace();
                    }
                    GUILayout.EndHorizontal();
                    bool nameError = false;
                    foreach (FontsEnum val in Enum.GetValues(typeof(FontsEnum)))
                    {
                        if (val.ToString().Equals(newFontName))
                        {
                            nameError = true;
                            break;
                        }
                    }
                    Color oldGuiBackgroundColor = GUI.backgroundColor;
                    if (nameError)
                    {
                        GUI.backgroundColor = Color.red;
                    }
                    newFontName = EditorGUILayout.TextArea(newFontName);
                    if (nameError)
                    {
                        GUI.backgroundColor = oldGuiBackgroundColor;
                    }
                    GUILayout.Space(5);

                    //Copier les polices?
                    newFontCopyFonts = GUILayout.Toggle(newFontCopyFonts, newFontCopyFonts ? LangWindowOption.EditorInEnglish ? " Copy from:" : " Copier :" : LangWindowOption.EditorInEnglish ? " Copy another font" : " Copier une autre police");
                    if (newFontCopyFonts)
                    {
                        GUILayout.BeginHorizontal();
                        {
                            GUILayout.Space(10);
                            GUILayout.Label("", GUI.skin.horizontalSliderThumb);
                            GUILayout.Space(5);
                            newFontCopiedFonts = (FontsEnum)EditorGUILayout.EnumPopup(newFontCopiedFonts);
                            GUILayout.FlexibleSpace();
                            GUILayout.Space(5);
                        }
                        GUILayout.EndHorizontal();
                    }
                    GUILayout.Space(5);

                    //Boutons ajouter et annuler
                    GUILayout.BeginHorizontal();
                    {
                        if (nameError || newFontName == "")
                        {
                            GUI.enabled = false;
                        }
                        if (GUILayout.Button(LangWindowOption.EditorInEnglish ? "Add" : "Ajouter"))
                        {
                            if (newFontCopyFonts)
                            {
                                CopyFont(newFontName, newFontCopiedFonts);
                            }
                            AddFont(newFontName);
                            addingNewFont = false;
                        }
                        if (nameError || newFontName == "")
                        {
                            GUI.enabled = true;
                        }
                        GUILayout.Space(10);
                        oldGuiBackgroundColor = GUI.backgroundColor;
                        GUI.backgroundColor   = Color.red;
                        if (GUILayout.Button(LangWindowOption.EditorInEnglish ? "Cancel" : "Annuler"))
                        {
                            addingNewFont = false;
                        }
                        GUI.backgroundColor = oldGuiBackgroundColor;
                        GUILayout.FlexibleSpace();
                    }
                    GUILayout.EndHorizontal();
                }
                GUILayout.EndVertical();
            }
        public static void GenerateAndSendData(ViewModel.SenderAndRecieverFivePersonsSingleChoice model, string contenttext, BackgroundImageEnum background, Mp3Enum song, FontsEnum font)
        {
            var stringpath = ITextSharpPdfCreator.GeneratefileForCustomers.GeneratePdfFileForCustomer(ReturnPathString.ReturnUniqueFileName(), model.sender.firstname, model.sender.lastname, contenttext, background, song, font);

            SmtpMailService.SendCustomerMail.SendMailToCustomer(model.Recipient1.Email, stringpath, song);
            SmtpMailService.SendCustomerMail.SendMailToCustomer(model.Recipient2.Email, stringpath, song);
            SmtpMailService.SendCustomerMail.SendMailToCustomer(model.Recipient3.Email, stringpath, song);
            SmtpMailService.SendCustomerMail.SendMailToCustomer(model.Recipient4.Email, stringpath, song);
            SmtpMailService.SendCustomerMail.SendMailToCustomer(model.Recipient5.Email, stringpath, song);
        }
 public static void GenerateAndSendData(ViewModel.SenderAndRecieversOnePersonSingleChoice model, string contenttext, BackgroundImageEnum background, Mp3Enum song, FontsEnum font)
 {
     var stringpath = ITextSharpPdfCreator.GeneratefileForCustomers.GeneratePdfFileForCustomer(ReturnPathString.ReturnUniqueFileName(), model.sender.firstname, model.sender.lastname, contenttext, background, song, font);
     //<summary>
     // commented out, to test pdf generation without sending file
     //<summary>
     //SmtpMailService.SendCustomerMail.SendMailToCustomer(model.Recipient1.Email,stringpath);
 }
        public void GenerateAndSendGeneralChoice(ViewModel.SenderAndRecieverFivePersonsSingleChoice model, string contenttext, BackgroundImageEnum background, Mp3Enum song, FontsEnum font)
        {
            var item2 = new GenerateAndSendDataQuintupleDelegate(GeneralFunctions.GeneratePdfAndSendToRecipients.GenerateAndSendData);

            item.QuintupleGeneralChoiceEvent += item2;
            item.QuintupleGeneralChoiceEvent(model, contenttext, background, song, font);
            item.QuintupleGeneralChoiceEvent -= item2;
        }
示例#8
0
        public void AddAbsoluteTextForReport(string text, int x, int y, int alignement, float _fontSize, FontsEnum _font)
        {
            pcb.BeginText();
            this.fontSize = _fontSize;
            pcb.SetFontAndSize(bf, fontSize);
            string FONT_PATH = "";

            if (_font == FontsEnum.Arial)
            {
                FONT_PATH = @"C:\Windows\Fonts\Arial.ttf";
            }
            else if (_font == FontsEnum.ArialB)
            {
                FONT_PATH = @"C:\Windows\Fonts\ArialBD.ttf";
            }
            else if (_font == FontsEnum.ArialBI)
            {
                FONT_PATH = @"C:\Windows\Fonts\ArialBI.ttf";
            }
            else if (_font == FontsEnum.ArialI)
            {
                FONT_PATH = @"C:\Windows\Fonts\ArialI.ttf";
            }
            else if (_font == FontsEnum.TimesNewRoman)
            {
                FONT_PATH = @"C:\Windows\Fonts\Times.ttf";
            }
            else if (_font == FontsEnum.TimesNewRomanB)
            {
                FONT_PATH = @"C:\Windows\Fonts\TimesBD.ttf";
            }
            else if (_font == FontsEnum.TimesNewRomanBI)
            {
                FONT_PATH = @"C:\Windows\Fonts\TimesBI.ttf";
            }
            else if (_font == FontsEnum.TimesNewRomanI)
            {
                FONT_PATH = @"C:\Windows\Fonts\TimesI.ttf";
            }
            BaseFont base_font = BaseFont.CreateFont(FONT_PATH, "Cp1251", true);

            pcb.SetFontAndSize(base_font, _fontSize);
            pcb.ShowTextAligned(alignement, text, x, y, 0);
            pcb.EndText();
        }
        public static string GeneratePdfFileForCustomer(string filename, string firstname, string lastname, string contenttext, BackgroundImageEnum backgroundimage, Mp3Enum song, FontsEnum font, string addition = "empty")
        {
            filename = filename + ".pdf";
            Document  doc = new Document(iTextSharp.text.PageSize.A4, 0f, 0f, 0f, 0f);
            PdfWriter wri = PdfWriter.GetInstance(doc, new FileStream(filename, FileMode.Create));

            //string backgroundfilepath;
            //if (backgroundimage == BackgroundImageEnum.Background1)
            //{
            //    string backgroundfile = "christmas-background1.jpg";
            //    FileInfo f = new FileInfo(backgroundfile);
            //    backgroundfilepath = f.FullName;
            //}
            //if (backgroundimage == BackgroundImageEnum.Background2)
            //{
            //    string backgroundfile = "Christmas-background2.jpg";
            //    FileInfo f = new FileInfo(backgroundfile);
            //    backgroundfilepath = f.FullName;
            //}
            //if (backgroundimage == BackgroundImageEnum.Background3)
            //{
            //    string backgroundfile = "christmas-background3.jpg";
            //    FileInfo f = new FileInfo(backgroundfile);
            //    backgroundfilepath = f.FullName;
            //}
            doc.Open();
            //string storestring1 = "Dear Sir/Ma'am @ thank you heartilly for de purchase at Sjonnie's liquor store @ we will keep you up to date with the latest news";
            //string addnewlines1 = storestring1.Replace("@", Environment.NewLine);
            string storestring1 = "From: @";

            storestring1 = storestring1 + "@" + firstname + " " + lastname + "@";
            storestring1 = storestring1 + "@" + contenttext;
            string backgroundfile;

            if (backgroundimage == BackgroundImageEnum.Background1)
            {
                backgroundfile = "christmas-background1.jpg";
            }
            if (backgroundimage == BackgroundImageEnum.Background2)
            {
                backgroundfile = "Christmas-background2.jpg";
            }
            else
            {
                backgroundfile = "christmas-background3.jpg";
            }

            FileInfo f = new FileInfo(backgroundfile);
            var      backgroundfilepath = f.FullName;

            iTextSharp.text.Image jpg = iTextSharp.text.Image.GetInstance(backgroundfilepath);
            jpg.SetAbsolutePosition(0, 0);
            jpg.ScaleAbsolute(iTextSharp.text.PageSize.A4.Width, iTextSharp.text.PageSize.A4.Height);
            jpg.Alignment = iTextSharp.text.Image.UNDERLYING;
            string addnewlines1 = storestring1.Replace("@", Environment.NewLine);
            //Paragraph paragraph = new Paragraph(addnewlines1);
            Paragraph paragraph = new Paragraph();

            if (font == FontsEnum.Courier)
            {
                paragraph = new Paragraph(addnewlines1, new Font(Font.FontFamily.COURIER, 40));
            }
            if (font == FontsEnum.Helvetica)
            {
                paragraph = new Paragraph(addnewlines1, new Font(Font.FontFamily.HELVETICA, 40));
            }
            if (font == FontsEnum.TimesNewRoman)
            {
                paragraph = new Paragraph(addnewlines1, new Font(Font.FontFamily.TIMES_ROMAN, 40));
            }
            //paragraph.Alignment = Element.ALIGN_CENTER;
            paragraph.Alignment  = Element.ALIGN_CENTER;
            paragraph.PaddingTop = Element.ALIGN_MIDDLE;
            //ColumnText.ShowTextAligned(wri.DirectContent, Element.ALIGN_CENTER, new Phrase("test",), (PageSize.A4.Width/2),(PageSize.A4.Height/2), 0f);
            ColumnText column = new ColumnText(wri.DirectContent);

            column.SetSimpleColumn(new Rectangle((PageSize.A4.Width / 2) - 300, 0, PageSize.A4.Width, ((int)Math.Floor(PageSize.A4.Height / 1.5))));
            column.AddElement(paragraph);
            column.Go();
            //paragraph.IndentationRight = 100;
            //paragraph.IndentationLeft = 100;
            //if (font == FontsEnum.Arial)
            //{
            //    paragraph.Font = FontFactory.GetFont("Arial");
            //}
            //else
            //{
            //    paragraph.Font = FontFactory.GetFont("Times New Roman");
            //}
            doc.Add(jpg);
            //doc.Add(paragraph);
            doc.Close();
            var pathpdffile = Path.GetFullPath(filename);

            return(pathpdffile);
        }
示例#10
0
 private Font LoadFont(FontsEnum font, LanguagesEnum lang)
 {
     return(Resources.Load <Font>("Lang/Fonts/" + lang.ToString() + "/" + font.ToString()));
 }
示例#11
0
            //****************************************************************************************************************
            //**                                                   Public                                                   **
            //****************************************************************************************************************

            //****************************************************************************************************************
            //**                                                  Protected                                                 **
            //****************************************************************************************************************

            //****************************************************************************************************************
            //**                                                   Private                                                  **
            //****************************************************************************************************************

            #endregion Virtual/Override

            #region Others

            //****************************************************************************************************************
            //**                                                   Public                                                   **
            //****************************************************************************************************************

            /// <summary>
            /// Renvoi la police associée à <paramref name="fontName"/> (ou null si elle n'existe pas)
            /// </summary>
            /// <param name="fontName">nom de la police à retourner</param>
            /// <returns>La police associée à <paramref name="fontName"/> (ou null si elle n'existe pas)</returns>
            public static Font GetFont(FontsEnum fontName)
            {
                return(Instance.InstanceGetFont(fontName));
            }