Ejemplo n.º 1
0
        /// <summary>
        /// Draws the item.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="e">The <see cref="System.Windows.Forms.DrawItemEventArgs"/> instance containing the event data.</param>
        /// <param name="itemIsDropped">if set to <c>true</c> item is dropped.</param>
        private void DrawItem(KillLogItem item, DrawItemEventArgs e, bool itemIsDropped = false)
        {
            Graphics g = e.Graphics;

            // Draw background
            g.FillRectangle(itemIsDropped ? Brushes.Green : Brushes.LightGray, e.Bounds);

            int itemQty = itemIsDropped ? item.QtyDropped : item.QtyDestroyed;
            int inContainerPad = item.IsInContainer ? PadLeft * 2 : 0;

            // Texts size measure
            Size itemTextSize = TextRenderer.MeasureText(g, item.Name, m_fittingFont, Size.Empty, Format);
            Size itemQtyTextSize = TextRenderer.MeasureText(g, itemQty.ToNumericString(0), m_fittingFont);

            Rectangle itemTextRect = new Rectangle(e.Bounds.Left + inContainerPad + PadLeft * 2 + ItemImageSize,
                e.Bounds.Top + (e.Bounds.Height - itemTextSize.Height) / 2,
                itemTextSize.Width + PadRight, itemTextSize.Height);
            Rectangle itemQtyTextRect = new Rectangle(e.Bounds.Right - itemQtyTextSize.Width - PadRight,
                e.Bounds.Top + (e.Bounds.Height - itemTextSize.Height) / 2,
                itemQtyTextSize.Width + PadRight, itemQtyTextSize.Height);

            // Draw texts
            TextRenderer.DrawText(g, item.Name, m_fittingFont, itemTextRect, Color.Black);
            TextRenderer.DrawText(g, itemQty.ToNumericString(0), m_fittingFont, itemQtyTextRect, Color.Black);

            // Draw the image
            if (Settings.UI.SafeForWork)
                return;

            g.DrawImage(item.ItemImage, new Rectangle(e.Bounds.Left + inContainerPad + PadLeft * 2,
                e.Bounds.Top + (e.Bounds.Height - ItemImageSize) / 2,
                ItemImageSize, ItemImageSize));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds the item.
        /// </summary>
        /// <param name="item">The item.</param>
        private void AddItem(KillLogItem item)
        {
            bool eventHandlerAdded = false;

            // Add if the item was destroyed
            if (item.QtyDestroyed > 0)
            {
                FittingContentListBox.Items.Add(item);
                item.KillLogItemImageUpdated += item_KillLogItemImageUpdated;
                eventHandlerAdded = true;
            }

            // Re-add if the item was also dropped
            if (item.QtyDropped <= 0)
                return;

            FittingContentListBox.Items.Add(item);
            if (!eventHandlerAdded)
                item.KillLogItemImageUpdated += item_KillLogItemImageUpdated;
        }