예제 #1
0
        //=========== DRAWING ============
        #region Drawing

        /** <summary> Updates the object view. </summary> */
        private void UpdateImages()
        {
            if (objectData == null)
            {
                this.objectView.Image = null;
                return;
            }

            Graphics g = Graphics.FromImage(objectImage);

            g.Clear(Color.Transparent);
            bool error = false;

            if (objectData.Invalid)
            {
                g.DrawImage(Resources.InvalidError, new Point(
                                this.objectView.Width / 2 - Resources.InvalidError.Width / 2,
                                this.objectView.Height / 2 - Resources.InvalidError.Height / 2
                                )
                            );
            }
            else if (dialogView)
            {
                for (int x = 0; x < 190; x++)
                {
                    for (int y = 0; y < 254; y++)
                    {
                        if (x >= 40 && x < 40 + 112 && y >= 72 && y < 72 + 112)
                        {
                            objectPaletteImage.Pixels[x, y] = 149;
                        }
                    }
                }

                error = !objectData.DrawDialog(objectPaletteImage, new Point(40, 72), new Size(112, 112), drawSettings);

                for (int x = 0; x < 190; x++)
                {
                    for (int y = 0; y < 254; y++)
                    {
                        if (x >= 40 && x < 40 + 112 && y >= 72 && y < 72 + 112)
                        {
                        }
                        else if ((x == 39 && y >= 71 && y < 71 + 114) || (y == 71 && x >= 39 && x < 39 + 114))
                        {
                            objectPaletteImage.Pixels[x, y] = 146;
                        }
                        else if ((x == 39 + 113 && y >= 72 && y < 71 + 114) || (y == 71 + 113 && x >= 40 && x < 39 + 114))
                        {
                            objectPaletteImage.Pixels[x, y] = 150;
                        }
                        else
                        {
                            objectPaletteImage.Pixels[x, y] = 148;
                        }
                    }
                }
                if (!error)
                {
                    objectPaletteImage.Draw(g, Point.Empty, objectData.GetPalette(drawSettings));
                }
            }
            if (error)
            {
                g.Clear(Color.Transparent);
                g.DrawImage(Resources.MissingImagesError, new Point(
                                this.objectView.Width / 2 - Resources.MissingImagesError.Width / 2,
                                this.objectView.Height / 2 - Resources.MissingImagesError.Height / 2
                                )
                            );
            }

            this.objectView.Image = objectImage;


            g = Graphics.FromImage(this.iconImage);

            PaletteImage icon2 = this.sceneryGroup.GraphicsData.GetPaletteImage(1);

            icon2.Draw(g, (46 - icon2.Width) / 2, (46 - icon2.Height) / 2, Palette.SceneryGroupPalette);
            g.Dispose();

            this.iconView.Image = this.iconImage;
        }