コード例 #1
0
        /// <summary>
        /// draw item name if exist
        /// </summary>
        /// <param name="theItem"></param>
        /// <param name="myGraphic"></param>
        private static void DrawDisplayName(JToken theItem, Graphics myGraphic)
        {
            JToken displayName = theItem["DisplayName"];

            if (displayName != null)
            {
                JToken key          = displayName["key"];
                JToken sourceString = displayName["source_string"];
                if (key != null && sourceString != null)
                {
                    //myGraphic.DrawRectangle(new Pen(new SolidBrush(Color.Red)), new Rectangle(5, 385, 512, 59));

                    Size  rectSize  = string.Equals(Settings.Default.rarityDesign, "Flat") ? new Rectangle(5, 405, 512, 55).Size : new Rectangle(5, 395, 512, 49).Size;
                    Point textPoint = string.Equals(Settings.Default.rarityDesign, "Flat") ? new Point(522, 405) : new Point(522 / 2, 395);
                    if (string.Equals(Settings.Default.rarityDesign, "Minimalist"))
                    {
                        rectSize  = string.Equals(Settings.Default.rarityDesign, "Flat") ? new Rectangle(5, 395, 512, 55).Size : string.Equals(Settings.Default.IconLanguage, "Russian") ? new Rectangle(5, 385, 512, 69).Size : new Rectangle(5, 385, 512, 59).Size;
                        textPoint = string.Equals(Settings.Default.rarityDesign, "Flat") ? new Point(522, 405) : string.Equals(Settings.Default.IconLanguage, "Russian") ? new Point(522 / 2, 400) : new Point(522 / 2, 408);
                    }
                    else if (Settings.Default.IconLanguage == "Russian")
                    {
                        rectSize  = string.Equals(Settings.Default.rarityDesign, "Flat") ? new Rectangle(5, 395, 512, 55).Size : new Rectangle(5, 385, 512, 59).Size;
                        textPoint = string.Equals(Settings.Default.rarityDesign, "Flat") ? new Point(522, 405) : new Point(522 / 2, 390);
                    }

                    string text = SearchResource.getTextByKey(key.Value <string>(), sourceString.Value <string>());

                    float size = 35;
                    if (string.Equals(Settings.Default.rarityDesign, "Minimalist"))
                    {
                        size = string.Equals(Settings.Default.IconLanguage, "Russian") ? 55 : 45;
                    }
                    else if (string.Equals(Settings.Default.IconLanguage, "Russian"))
                    {
                        size = 45;
                    }

                    Font goodFont = FontUtilities.FindFont(
                        myGraphic,
                        Settings.Default.IconLanguage == "Russian" || string.Equals(Settings.Default.rarityDesign, "Minimalist") ? text.ToUpper() : text,
                        rectSize,
                        new Font(Settings.Default.IconLanguage == "Japanese" ? FontUtilities.pfc.Families[2] : Settings.Default.IconLanguage == "Russian" || Settings.Default.IconLanguage == "Chinese (S)" ? FontUtilities.pfc.Families[1] : FontUtilities.pfc.Families[0], size)
                        );

                    myGraphic.DrawString(
                        Settings.Default.IconLanguage == "Russian" || string.Equals(Settings.Default.rarityDesign, "Minimalist") ? text.ToUpper() : text,
                        goodFont,
                        new SolidBrush(Color.White),
                        textPoint,
                        string.Equals(Settings.Default.rarityDesign, "Flat") ? FontUtilities.rightString : FontUtilities.centeredString
                        );
                }
            }
        }
コード例 #2
0
ファイル: BundleDesign.cs プロジェクト: MyNameIsDark01/FModel
        private static void drawCompletionText(Bitmap myBitmap, string count)
        {
            string all = "Complete ALL CHALLENGES to earn the reward item";
            string any = "Complete ANY " + count + " CHALLENGES to earn the reward item";

            if (!Settings.Default.IconLanguage.Equals("English"))
            {
                all = SearchResource.getTextByKey("CompletionRewardFormat_All", "Complete ALL CHALLENGES to earn the reward item", "AthenaChallengeDetailsEntry");
                any = SearchResource.getTextByKey("CompletionRewardFormat", "Complete ANY " + count + " CHALLENGES to earn the reward item", "AthenaChallengeDetailsEntry");

                //because HtmlAgilityPack fail to detect the end of the tag when it's </>
                if (all.Contains("</>"))
                {
                    all = all.Replace("</>", "</text>");
                }
                if (any.Contains("</>"))
                {
                    any = any.Replace("</>", "</text>");
                }

                HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
                doc.LoadHtml(all);
                if (doc.DocumentNode.InnerText.Contains(" {0}")) //avoid white space
                {
                    if (all.Contains("</text>"))
                    {
                        all = doc.DocumentNode.InnerText.Replace(doc.DocumentNode.SelectSingleNode("text").InnerText, doc.DocumentNode.SelectSingleNode("text").InnerText.ToUpper());
                        all = all.Replace(" {0}", string.Empty);
                    }
                    else
                    {
                        all = doc.DocumentNode.InnerText.Replace(" {0}", string.Empty);
                    }
                }
                else
                {
                    if (all.Contains("</text>"))
                    {
                        all = doc.DocumentNode.InnerText.Replace(doc.DocumentNode.SelectSingleNode("text").InnerText, doc.DocumentNode.SelectSingleNode("text").InnerText.ToUpper());
                        all = all.Replace("{0}", string.Empty);
                    }
                    else
                    {
                        all = doc.DocumentNode.InnerText.Replace("{0}", string.Empty);
                    }
                }

                doc = new HtmlAgilityPack.HtmlDocument();
                doc.LoadHtml(any);
                if (doc.DocumentNode.InnerText.Contains("{QuestNumber}")) //russian
                {
                    if (any.Contains("</text>"))
                    {
                        any = doc.DocumentNode.InnerText.Replace(doc.DocumentNode.SelectSingleNode("text").InnerText, doc.DocumentNode.SelectSingleNode("text").InnerText.ToUpper());
                        any = any.Replace("{QuestNumber}", count);
                    }
                    else
                    {
                        any = doc.DocumentNode.InnerText.Replace("{QuestNumber}", count);
                    }
                }
                else
                {
                    if (any.Contains("</text>"))
                    {
                        any = doc.DocumentNode.InnerText.Replace(doc.DocumentNode.SelectSingleNode("text").InnerText, doc.DocumentNode.SelectSingleNode("text").InnerText.ToUpper());
                        any = string.Format(any, count);
                    }
                    else
                    {
                        any = string.Format(doc.DocumentNode.InnerText, count);
                    }
                }

                if (all.Contains("  "))
                {
                    all = all.Replace("  ", " ");
                }                                                         //double space in Spanish (LA)               i.e. with QuestBundle_PirateParty
                if (any.Contains("  "))
                {
                    any = any.Replace("  ", " ");
                }
            }

            drawQuestBackground(myBitmap, false);
            Font goodFont = FontUtilities.FindFont(toDrawOn, count == "-1" ? all : any, new Rectangle(57, theY + 7, myBitmap.Width - 227, 45).Size, new Font(Settings.Default.IconLanguage == "Japanese" ? FontUtilities.pfc.Families[2] : FontUtilities.pfc.Families[1], 30)); //size in "new Font()" is never check

            toDrawOn.DrawString(count == "-1" ? all : any, goodFont, new SolidBrush(Color.White), new Point(55, theY + 15));
        }