예제 #1
0
        private void listBox1_DrawItem(object sender, DrawItemEventArgs e)
        {
            e.DrawBackground();

            string name = (string)listBox1.Items[e.Index];

            if (rewardManager.HasReward(name))
            {
                Reward reward = rewardManager.GetReward(name);
                ZeldaOracle.Common.Graphics.Sprite sprite = null;

                Point2I position = (Point2I)e.Bounds.Location + new Point2I(2, 2);

                if (reward != null && reward.Animation != null)
                {
                    sprite = reward.Animation.Frames[0].Sprite;
                }
                if (sprite != null)
                {
                    EditorGraphics.DrawSprite(e.Graphics, sprite, position);
                }
            }

            int       x        = e.Bounds.Left + 20;
            int       y        = e.Bounds.Top;
            int       width    = e.Bounds.Right - x;
            int       height   = e.Bounds.Bottom - y;
            Rectangle textRect = new Rectangle(x, y, width, height);

            if (name == "")
            {
                name = "(none)";
            }

            Point2I      textPosition = (Point2I)e.Bounds.Location + new Point2I(24, 0);
            StringFormat stringFormat = new StringFormat();

            stringFormat.Alignment     = StringAlignment.Near;
            stringFormat.LineAlignment = StringAlignment.Center;
            e.Graphics.DrawString(name, textBox1.Font, new SolidBrush(System.Drawing.Color.Black), textRect, stringFormat);

            // Draw the focus rectangle if appropriate.
            e.DrawFocusRectangle();
        }