Пример #1
0
 public void AddIntoContainer(PlayerItem item)
 {
     try
     {
         ItemsEnum  itemType = AnalyzeBaseRecord(item.baserecord);
         RarityEnum rarity   = RarityEnumHelpers.StringToRarityEnum(item.Rarity);
         containedItemTypes.Add(itemType);
         containedRarities.Add(rarity);
         if (!ItemsDict.ContainsKey(itemType))
         {
             ItemsDict.Add(itemType, new Dictionary <RarityEnum, List <PlayerItem> >());
         }
         if (!ItemsDict[itemType].ContainsKey(rarity))
         {
             ItemsDict[itemType].Add(rarity, new List <PlayerItem>()
             {
                 item
             });
         }
         else
         {
             ItemsDict[itemType][rarity].Add(item);
         }
     }
     catch (Exception ex)
     {
         log.Error("Error while adding item to dict:", ex);
     }
 }
Пример #2
0
        private static void GenerateCssStyle(HtmlTextWriter writer)
        {
            string purple = System.Configuration.ConfigurationManager.AppSettings["ColorPurpleItems"];

            if (String.IsNullOrWhiteSpace(purple))
            {
                purple = RarityEnumHelpers.RarityToTextColorString(RarityEnum.Purple);
            }
            string green = System.Configuration.ConfigurationManager.AppSettings["ColorGreenItems"];

            if (String.IsNullOrWhiteSpace(green))
            {
                green = RarityEnumHelpers.RarityToTextColorString(RarityEnum.Green);
            }
            string blue = System.Configuration.ConfigurationManager.AppSettings["ColorBlueItems"];

            if (String.IsNullOrWhiteSpace(blue))
            {
                blue = RarityEnumHelpers.RarityToTextColorString(RarityEnum.Blue);
            }
            string white = System.Configuration.ConfigurationManager.AppSettings["ColorWhiteItems"];

            if (String.IsNullOrWhiteSpace(white))
            {
                white = RarityEnumHelpers.RarityToTextColorString(RarityEnum.White);
            }
            string backgroundColor = System.Configuration.ConfigurationManager.AppSettings["ColorBackground"];

            if (String.IsNullOrWhiteSpace(backgroundColor))
            {
                backgroundColor = "#ccc";
            }

            int itemLineHeight = 17;

            Int32.TryParse(System.Configuration.ConfigurationManager.AppSettings["ItemLineHeight"], out itemLineHeight);
            int hoverSpace = 5;

            Int32.TryParse(System.Configuration.ConfigurationManager.AppSettings["HoverSpace"], out hoverSpace);
            int itemTypeColumnWidth = 300;

            Int32.TryParse(System.Configuration.ConfigurationManager.AppSettings["ItemTypeColumnWidth"], out itemTypeColumnWidth);

            writer.WriteLine($".grimIAPrinterResultHtml {{ background-color: {backgroundColor}; }}");
            writer.WriteLine(".grimIAPrinterResultBody { margin: 0px; }");
            writer.WriteLine($".grimIAPrinterResult {{ font-family: monospace; background-color: {backgroundColor}; }}");
            writer.WriteLine(".grimIAPrinterResult h4 { margin-block-start: 0px; }");
            writer.WriteLine(".grimIAPrinterResult .rarity { margin:10px; }");
            writer.WriteLine(".grimIAPrinterResult .itemList { padding-inline-start: 0px; list-style: none; }");
            writer.WriteLine($".grimIAPrinterResult .itemType {{ display: inline-block; vertical-align: top; margin-left: 10px; margin-bottom: 30px; width: {itemTypeColumnWidth}px; }}");
            writer.WriteLine($".grimIAPrinterResult .itemType li {{ height: {itemLineHeight}px; }}");
            writer.WriteLine(".grimIAPrinterResult .itemLink { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; display: block; }");
            writer.WriteLine($".grimIAPrinterResult .itemLink:hover {{ overflow: visible; white-space: normal; width: auto; position: absolute; display: inline; min-width: {itemTypeColumnWidth}px; padding-right: {hoverSpace}px; background-color: {backgroundColor}; }}");
            writer.WriteLine($".grimIAPrinterResult .itemLink:hover+li {{ margin-top: {itemLineHeight}px; }}");
            writer.WriteLine($".grimIAPrinterResult .rarityPurple {{ color: {purple}; }}");
            writer.WriteLine($".grimIAPrinterResult .rarityGreen {{ color: {green}; }}");
            writer.WriteLine($".grimIAPrinterResult .rarityBlue {{ color: {blue}; }}");
            writer.Write($".grimIAPrinterResult .rarityWhite {{ color: {white}; }}");             //last css entry no new line to avoid ugly empty line in style
        }
Пример #3
0
        private static string FormatResultForum(ItemContainer container)
        {
            StringBuilder result    = new StringBuilder();
            string        textColor = "";

            foreach (var rarity in container.GetContainedRarities().OrderBy(e => e))
            {
                textColor = RarityEnumHelpers.RarityToTextColorString(rarity);
                bool rarityFirst = true;
                foreach (var itemType in container.GetContainedItemTypes().OrderBy(e => e))
                {
                    bool itemTypeFirst = true;
                    foreach (var item in container.Get(itemType, rarity).GroupBy(e => e.Name).OrderBy(e => e.Key))
                    {
                        if (rarityFirst)
                        {
                            result.AppendLine($"[SIZE=\"3\"]{ColorStringForum($"{rarity.ToString()}:", textColor)}[/SIZE]");
                            result.AppendLine();
                            rarityFirst = false;
                        }
                        if (itemTypeFirst)
                        {
                            result.AppendLine(ColorStringForum($"{itemType.ToString()}:", textColor));
                            itemTypeFirst = false;
                            result.AppendLine("[SPOILER2]");
                        }
                        result.Append($"[URL=\"{BuildGrimToolsItemUrl(item.Key)}\"]{ColorStringForum(item.Key, textColor)}[/URL]");
                        if (item.Count() > 1)
                        {
                            result.Append($" x{item.Count()}");
                        }
                        result.AppendLine();
                    }
                    if (!itemTypeFirst)
                    {
                        result.AppendLine("[/SPOILER2]");
                        result.AppendLine();
                    }
                }
                if (!rarityFirst)
                {
                    result.AppendLine();
                }
            }
            return(result.ToString());
        }