Esempio n. 1
0
        public override void Draw(Graphics g)
        {
            if (nid > 0)
            {
                Image            img       = null;
                HsActionCallback preAction = null;
                HsActionCallback action    = null;
                if (type == PictureRegionCellType.Item)
                {
                    img    = HItemBook.GetHItemImage(nid);
                    action = () =>
                    {
                        var itemConfig = ConfigData.GetHItemConfig(nid);
                        var pen        = new Pen(Color.FromName(HSTypes.I2RareColor(itemConfig.Rare)), 2);
                        g.DrawRectangle(pen, X, Y, Width, Height);
                        pen.Dispose();
                    };
                }
                else if (type == PictureRegionCellType.Gismo)
                {
                    img = DungeonBook.GetGismoImage(nid);
                }
                else if (type == PictureRegionCellType.People)
                {
                    img       = HSIcons.GetImage("Samurai", nid);
                    preAction = () =>
                    {
                        var peopleConfig = ConfigData.GetSamuraiConfig(nid);
                        var brush        = new SolidBrush(Color.FromName(HSTypes.I2QualityColorD(peopleConfig.Quality)));
                        g.FillRectangle(brush, X + 3, Y + 3, Width - 6, Height - 6);
                        brush.Dispose();
                    };
                }
                else if (type == PictureRegionCellType.SceneQuest)
                {
                    img = SceneQuestBook.GetSceneQuestImageScene(nid);
                }
                else if (type == PictureRegionCellType.DungeonItem)
                {
                    img = DungeonBook.GetDungeonItemImage(nid);
                }

                if (preAction != null)
                {
                    preAction();
                }
                if (img != null)
                {
                    if (Scale == 1)
                    {
                        if (Enabled)
                        {
                            g.DrawImage(img, X, Y, Width, Height);
                        }
                        else
                        {
                            g.DrawImage(img, new Rectangle(X, Y, Width, Height), 0, 0, img.Width, img.Height, GraphicsUnit.Pixel, HSImageAttributes.ToGray);
                        }
                    }
                    else
                    {
                        int realWidth  = (int)(Width * Scale);
                        int realHeight = (int)(Height * Scale);
                        g.DrawImage(img, X + (Width - realWidth) / 2, Y + (Height - realHeight) / 2, realWidth, realHeight);
                    }
                }
                if (action != null)
                {
                    action();
                }
            }

            foreach (IRegionDecorator decorator in decorators)
            {
                decorator.Draw(g, X, Y, Width, Height);
            }
        }