Example #1
0
        /// <summary>
        /// Callback for highlighting a new item.
        /// Updates the text box on the main form.
        /// </summary>
        /// <param name="sender">sender object</param>
        /// <param name="e">SackPanelEventArgs data</param>
        private void NewItemHighlightedCallback(object sender, SackPanelEventArgs e)
        {
            Item           item      = e.Item;
            SackCollection sack      = e.Sack;
            SackPanel      sackPanel = (SackPanel)sender;

            if (item == null)
            {
                // Only do something if this sack is the "owner" of the current item highlighted.
                if (sack == this.lastSackHighlighted)
                {
                    this.itemText.Text = string.Empty;

                    // hide the tooltip
                    this.tooltipText = null;
                    this.tooltip.ChangeText(this.tooltipText);
                }
            }
            else
            {
                string text  = ItemProvider.ToFriendlyName(item);
                Color  color = ItemGfxHelper.GetColorTag(item, text);
                text = Item.ClipColorTag(text);
                this.itemText.ForeColor = color;
                this.itemText.Text      = text;

                string attributes = ItemHtmlHelper.GetAttributes(item, true);                 // true means hide uninteresting attributes
                string setitems   = ItemHtmlHelper.GetItemSetString(item);
                string reqs       = ItemHtmlHelper.GetRequirements(item);

                // combine the 2
                if (reqs.Length < 1)
                {
                    this.tooltipText = attributes;
                }
                else if (setitems.Length < 1)
                {
                    string reqTitle = HtmlHelper.MakeSafeForHtml("?Requirements?");
                    reqTitle = string.Format(CultureInfo.InvariantCulture, "<font size=+2 color={0}>{1}</font><br>", HtmlHelper.HtmlColor(ItemGfxHelper.GetColor(ItemStyle.Potion)), reqTitle);
                    string separator = string.Format(CultureInfo.InvariantCulture, "<hr color={0}><br>", HtmlHelper.HtmlColor(ItemGfxHelper.GetColor(ItemStyle.Broken)));
                    this.tooltipText = string.Concat(attributes, separator, reqs);
                }
                else
                {
                    string reqTitle = HtmlHelper.MakeSafeForHtml("?Requirements?");
                    reqTitle = string.Format(CultureInfo.InvariantCulture, "<font size=+2 color={0}>{1}</font><br>", HtmlHelper.HtmlColor(ItemGfxHelper.GetColor(ItemStyle.Potion)), reqTitle);
                    string separator1 = string.Format(CultureInfo.InvariantCulture, "<hr color={0}>", HtmlHelper.HtmlColor(ItemGfxHelper.GetColor(ItemStyle.Broken)));
                    string separator2 = string.Format(CultureInfo.InvariantCulture, "<hr color={0}><br>", HtmlHelper.HtmlColor(ItemGfxHelper.GetColor(ItemStyle.Broken)));
                    this.tooltipText = string.Concat(attributes, separator1, setitems, separator2, reqs);
                }

                // show tooltip
                this.tooltipText = string.Concat(HtmlHelper.TooltipBodyTag(Database.DB.Scale), this.tooltipText);
                this.tooltip.ChangeText(this.tooltipText);
            }

            this.lastSackHighlighted      = sack;
            this.lastSackPanelHighlighted = sackPanel;
        }
Example #2
0
        /// <summary>
        /// Returns a string containing the tool tip text for the highlighted result.
        /// </summary>
        /// <param name="selectedResult">Currently selected Result</param>
        /// <returns>String containing the tool tip for the Result.</returns>
        private string GetToolTip(Result selectedResult)
        {
            if (selectedResult == null || selectedResult.Item == null)
            {
                // hide the tooltip
                this.tooltipText = null;
                ////this.tooltip.ChangeText(this.tooltipText);
            }
            else
            {
                string attributes = ItemHtmlHelper.GetAttributes(selectedResult.Item, true);                 // true means hide uninteresting attributes
                string setitems   = ItemHtmlHelper.GetItemSetString(selectedResult.Item);
                string reqs       = ItemHtmlHelper.GetRequirements(selectedResult.Item);

                // combine the 2
                if (reqs.Length < 1)
                {
                    this.tooltipText = attributes;
                }
                else if (setitems.Length < 1)
                {
                    string reqTitle = HtmlHelper.MakeSafeForHtml("?Requirements?");
                    reqTitle = string.Format(CultureInfo.InvariantCulture, "<font size=+2 color={0}>{1}</font><br>", HtmlHelper.HtmlColor(ItemGfxHelper.GetColor(ItemStyle.Potion)), reqTitle);
                    string separator = string.Format(CultureInfo.InvariantCulture, "<hr color={0}><br>", HtmlHelper.HtmlColor(ItemGfxHelper.GetColor(ItemStyle.Broken)));
                    this.tooltipText = string.Concat(attributes, separator, reqs);
                }
                else
                {
                    string reqTitle = HtmlHelper.MakeSafeForHtml("?Requirements?");
                    reqTitle = string.Format(CultureInfo.InvariantCulture, "<font size=+2 color={0}>{1}</font><br>", HtmlHelper.HtmlColor(ItemGfxHelper.GetColor(ItemStyle.Potion)), reqTitle);
                    string separator1 = string.Format(CultureInfo.InvariantCulture, "<hr color={0}>", HtmlHelper.HtmlColor(ItemGfxHelper.GetColor(ItemStyle.Broken)));
                    string separator2 = string.Format(CultureInfo.InvariantCulture, "<hr color={0}><br>", HtmlHelper.HtmlColor(ItemGfxHelper.GetColor(ItemStyle.Broken)));
                    this.tooltipText = string.Concat(attributes, separator1, setitems, separator2, reqs);
                }

                // show tooltip
                this.tooltipText = string.Concat(HtmlHelper.TooltipBodyTag(Database.DB.Scale), this.tooltipText);
                ////this.tooltip.ChangeText(this.tooltipText);
            }

            return(this.tooltipText);
        }
Example #3
0
 public bool Apply(Item item)
 {
     return(ItemHtmlHelper.GetAttributes(item, true).ToUpperInvariant().Contains(attribute.ToUpperInvariant()));
 }