コード例 #1
0
ファイル: RewardChooser.cs プロジェクト: radtek/ZeldaOracle
        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();
        }
コード例 #2
0
        private void OnDrawItem(object sender, DrawItemEventArgs e)
        {
            ListBox   listBox = sender as ListBox;
            Brush     brush   = new SolidBrush(e.ForeColor);
            Rectangle bounds  = new Rectangle(e.Bounds.X + 20, e.Bounds.Y + 3, e.Bounds.Width, e.Bounds.Height);

            e.DrawBackground();

            // Draw the label.
            e.Graphics.DrawString(listBox.Items[e.Index].ToString(), e.Font, brush, bounds, StringFormat.GenericDefault);

            // Draw the sprite.
            if (PropertyGrid.PropertyObject is TileDataInstance)
            {
                TileDataInstance tile = (TileDataInstance)PropertyGrid.PropertyObject;
                EditorGraphics.DrawSprite(e.Graphics, tile.SpriteList[e.Index],
                                          tile.Room.Zone.ImageVariantID, (Point2I)(e.Bounds.Location) +
                                          new Point2I(2, 2), new Point2I(16, 16));
            }

            brush.Dispose();
        }